protected void paint(AbstractTnGraphics graphics) { NavBottomStatusBarHelper.getInstance().drawBackground(graphics, this, false); if (isDisabled) { return; } int width = this.getWidth(); int height = this.getHeight(); AbstractTnFont fontNumber = UiStyleManager.getInstance().getFont(UiStyleManager.FONT_SPEED_LIMIT_NUMBER); AbstractTnFont fontUnit = UiStyleManager.getInstance().getFont(UiStyleManager.FONT_SPEED_LIMIT); int gap = (height - fontNumber.getHeight() - fontUnit.getHeight()) / 3; int xNumber = (width - fontNumber.stringWidth(speedStr)) / 2; int yNumber = (height - fontNumber.getHeight() - fontUnit.getHeight() - gap) / 2; int xUnit = (width - fontUnit.stringWidth(unitStr)) / 2; int yUnit = yNumber + fontNumber.getHeight() + gap; graphics.setColor(UiStyleManager.getInstance().getColor(UiStyleManager.TEXT_COLOR_WH)); graphics.setFont(fontNumber); graphics.drawString( speedStr, xNumber, yNumber, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); graphics.setFont(fontUnit); graphics.drawString(unitStr, xUnit, yUnit, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); }
protected void paint(AbstractTnGraphics g) { // g.setColor(isFocused ? bgFocusedColor : bgUnFocusedColor); // g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight()); super.paint(g); boolean isTitleAvailable = (title != null && title.length() > 0); boolean isValueAvailable = (value != null && value.length() > 0); int titleY = topGap; AbstractTnFont titleFont = getTitleFont(); if (titleFont == null) { titleFont = g.getFont(); } AbstractTnFont valueFont = getValueFont(); if (valueFont == null) { valueFont = g.getFont(); } if (isTitleAvailable) { if (isValueAvailable) { titleY = topGap; } else { titleY = (this.getPreferredHeight() - titleFont.getHeight()) / 2; } g.setColor(isFocused ? titleFocusedColor : this.titleUnFocuedColor); g.setFont(titleFont); g.drawString( title, this.getLeftPadding(), titleY, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } if (isValueAvailable) { int ValueY; if (isTitleAvailable) { ValueY = titleY + LINE_GAP + titleFont.getHeight(); } else { ValueY = (this.getPreferredHeight() - valueFont.getHeight()) / 2; } g.setColor(isFocused ? valueFocusedColor : this.valueUnFocusedColor); g.setFont(valueFont); if (valueFont.stringWidth(value) < this.getPreferredWidth() - 2 * leftPadding) { g.drawString( value, this.getLeftPadding(), ValueY, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } else { String tempValue = value; while (valueFont.stringWidth(tempValue + "...") > this.getPreferredWidth() - 2 * this.getLeftPadding()) { tempValue = tempValue.substring(0, tempValue.length() - 1); } g.drawString( tempValue + "...", this.getLeftPadding(), ValueY, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } } }
protected void paint(AbstractTnGraphics graphics) { super.paint(graphics); if (badgeImage != null) { int oldBadgeImageWidth = badgeImage.getWidth(); int oldBadgeImageHeight = badgeImage.getHeight(); badgeImage.setWidth(badgeWidth); badgeImage.setHeight(badgeHeight); int left = 0; int y = 0; if ((this.badgePosition & AbstractTnGraphics.RIGHT) != 0) { int rightIconWidht = rightButtonIconFocus == null ? 0 : rightButtonIconFocus.getWidth(); left = this.getWidth() - this.getRightPadding() - rightIconWidht - this.getGap() - badgeWidth; y = (this.getHeight() - badgeHeight) / 2; if (y < this.getTopPadding()) y = this.getTopPadding(); graphics.drawImage(badgeImage, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } else if ((this.badgePosition & AbstractTnGraphics.TOP) != 0) { // left = this.getWidth() - this.getRightPadding() - badgeImage.getWidth(); left = this.getWidth() / 2 + this.getFocusedIcon().getWidth() / 4; int fontHeight = font.getHeight() < boldFont.getHeight() ? boldFont.getHeight() : font.getHeight(); int iconY = topPadding + (this.getHeight() - topPadding - bottomPadding - getFocusedIcon().getHeight() - fontHeight - gap) / 2; int badageTopHeight = badgeHeight / 3; if (iconY < badageTopHeight) { y = iconY; } else { y = iconY - badageTopHeight; } graphics.drawImage(badgeImage, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } else if (this.badgePosition == this.SAME_Y_AS_ICON) { left = this.getFocusedIcon().getWidth() * 5 / 8; y = topPadding; graphics.drawImage(badgeImage, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } left += (badgeWidth - FrogTextHelper.getWidth(this.badge, badgeFont, this.boldFont)) / 2; y += (badgeHeight + 1) / 2; if (isFocused()) { graphics.setColor(badgeFocusedColor); } else { graphics.setColor(badgeBlurColor); } if (!"".equalsIgnoreCase(badge.getText())) { graphics.setFont(badgeFont); graphics.drawString( badge.getText(), left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.FONT_ABSOLUTE_VCENTER); } badgeImage.setWidth(oldBadgeImageWidth); badgeImage.setHeight(oldBadgeImageHeight); } }
/** * Paint the component to screen * * @param graphics (@link AbstractTnGraphics) */ protected void paint(AbstractTnGraphics graphics) { int y = 0; AbstractTnImage buttonIcon; if (isFocused()) { graphics.setColor(focusColor); buttonIcon = iconFocus; } else { graphics.setColor(unfocusColor); buttonIcon = iconUnfocus; } graphics.setFont(font); int left; if (buttonIcon != null) { if ((style & AbstractTnGraphics.LEFT) != 0) { left = leftPadding; y = (this.getHeight() - buttonIcon.getHeight()) / 2; if (y < topPadding) y = topPadding; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); left = leftPadding + buttonIcon.getWidth() + gap; if ((style & AbstractTnGraphics.HCENTER) != 0) { int textTypingWidth = this.getWidth() - leftPadding - buttonIcon.getWidth() - gap - rightPadding; left = buttonIcon.getWidth() + gap + leftPadding + (textTypingWidth - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont)) / 2; if (left < buttonIcon.getWidth() + gap + leftPadding) left = buttonIcon.getWidth() + gap + leftPadding; } y = (this.getHeight() - font.getHeight()) / 2; int scrollWidth = this.getWidth() - buttonIcon.getWidth() - leftPadding - rightPadding - gap; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); } else if ((style & AbstractTnGraphics.RIGHT) != 0) { left = leftPadding; if ((style & AbstractTnGraphics.HCENTER) != 0) { int textTypingWidth = this.getWidth() - leftPadding - buttonIcon.getWidth() - gap - rightPadding; left = leftPadding + (textTypingWidth - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont)) / 2; if (left < leftPadding) left = leftPadding; } y = (this.getHeight() - font.getHeight()) / 2; int scrollWidth = this.getWidth() - buttonIcon.getWidth() - leftPadding - rightPadding - gap; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); y = (this.getHeight() - buttonIcon.getHeight()) / 2; if (y < topPadding) y = topPadding; left = this.getWidth() - rightPadding - buttonIcon.getWidth(); graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); left = this.getWidth() - rightPadding - buttonIcon.getWidth() - gap; } else if ((style & AbstractTnGraphics.TOP) != 0) { left = (this.getWidth() - buttonIcon.getWidth()) / 2; if (this.textLine != null) { int fontHeight = font.getHeight() < boldFont.getHeight() ? boldFont.getHeight() : font.getHeight(); y = topPadding + (this.getHeight() - topPadding - bottomPadding - buttonIcon.getHeight() - fontHeight - gap) / 2; if (y < 0) y = 0; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); left = (this.getWidth() - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont)) / 2; if (left < leftPadding) { left = leftPadding; } y += buttonIcon.getHeight() + gap; int scrollWidth = this.getWidth() - leftPadding - rightPadding; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); } else { y = topPadding + (this.getHeight() - topPadding - bottomPadding - buttonIcon.getHeight()) / 2; if (y < topPadding) y = topPadding; left = (this.getWidth() - buttonIcon.getWidth()) / 2; if (left < leftPadding) left = leftPadding; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } } else if ((style & AbstractTnGraphics.BOTTOM) != 0) { if (this.textLine != null) { left = (this.getWidth() - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont)) / 2; if (left < leftPadding) { left = leftPadding; } y = topPadding; int scrollWidth = this.getWidth() - leftPadding - rightPadding; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); y = topPadding + gap + font.getHeight(); left = (this.getWidth() - buttonIcon.getWidth()) / 2; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } else { y = topPadding + (this.getHeight() - topPadding - bottomPadding - buttonIcon.getHeight()) / 2; if (y < topPadding) y = topPadding; left = (this.getWidth() - buttonIcon.getWidth()) / 2; if (left < leftPadding) left = leftPadding; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); } } else { int leftStart = (getWidth() - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont) - gap - buttonIcon.getWidth()) / 2; if (leftStart < leftPadding) leftStart = leftPadding; left = leftStart; y = topPadding + (this.getHeight() - topPadding - bottomPadding - buttonIcon.getHeight()) / 2; graphics.drawImage(buttonIcon, left, y, AbstractTnGraphics.LEFT | AbstractTnGraphics.TOP); left = left + buttonIcon.getWidth() + gap; y = (this.getHeight() - font.getHeight()) / 2; int scrollWidth = this.getWidth() - leftStart - buttonIcon.getWidth() - gap - rightPadding; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); } } else { y = topPadding + (this.getHeight() - bottomPadding - topPadding - font.getHeight()) / 2; int textTypingWidth = this.getWidth() - leftPadding - rightPadding; left = leftPadding + (textTypingWidth - FrogTextHelper.getWidth(this.textLine, this.font, this.boldFont)) / 2; if (left < leftPadding) left = leftPadding; int scrollWidth = this.getWidth() - leftPadding - rightPadding; graphics.pushClip(left, y, scrollWidth, this.getHeight()); FrogTextHelper.paint( graphics, left - this.scrollX, y, this.textLine, font, boldFont, scrollWidth, !isFocused || !isScrollable); graphics.popClip(); } }