protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { ButtonModel model = b.getModel(); FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont()); int mnemIndex; if (JTattooUtilities.getJavaVersion() >= 1.4) { mnemIndex = b.getDisplayedMnemonicIndex(); } else { mnemIndex = JTattooUtilities.findDisplayedMnemonicIndex(b.getText(), model.getMnemonic()); } int offs = 0; if (model.isArmed() && model.isPressed()) { offs = 1; } Graphics2D g2D = (Graphics2D) g; Composite composite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); g2D.setComposite(alpha); Color foreground = b.getForeground(); Color background = b.getBackground(); if (background instanceof ColorUIResource) { if (model.isPressed() && model.isArmed()) { foreground = AbstractLookAndFeel.getTheme().getSelectionForegroundColor(); } else if (model.isRollover()) { foreground = AbstractLookAndFeel.getTheme().getRolloverForegroundColor(); } } if (!model.isEnabled()) { foreground = AbstractLookAndFeel.getTheme().getDisabledForegroundColor(); } if (ColorHelper.getGrayValue(foreground) > 64) { g2D.setColor(Color.black); } else { g2D.setColor(Color.white); } JTattooUtilities.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x + offs + 1, textRect.y + offs + fm.getAscent() + 1); g2D.setComposite(composite); g2D.setColor(foreground); JTattooUtilities.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x + offs, textRect.y + offs + fm.getAscent()); }
public void paintLogo(Component c, Graphics g, int x, int y, int w, int h) { if (hasLogo(c)) { Graphics2D g2D = (Graphics2D) g; Font savedFont = g2D.getFont(); g.setFont(logoFont); FontMetrics fm = JTattooUtilities.getFontMetrics((JComponent) c, g, c.getFont()); String logo = JTattooUtilities.getClippedText( AbstractLookAndFeel.getTheme().getLogoString(), fm, h - 16); AffineTransform savedTransform = g2D.getTransform(); Color fc = getLogoColorHi(); Color bc = getLogoColorLo(); if (JTattooUtilities.isLeftToRight(c)) { g2D.translate(fm.getAscent() + 1, h - shadowSize - 4); g2D.rotate(Math.toRadians(-90)); g2D.setColor(bc); JTattooUtilities.drawString((JComponent) c, g, logo, 0, 1); g2D.setColor(fc); JTattooUtilities.drawString((JComponent) c, g, logo, 1, 0); } else { g2D.translate(w - shadowSize - 4, h - shadowSize - 4); g2D.rotate(Math.toRadians(-90)); g2D.setColor(bc); JTattooUtilities.drawString((JComponent) c, g, logo, 0, 1); g2D.setColor(fc); JTattooUtilities.drawString((JComponent) c, g, logo, 1, 0); } g2D.setTransform(savedTransform); g2D.setFont(savedFont); } }