if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) { g.setColor(tabPane.getForegroundAt(tabIndex)); BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); } else { // tab disabled g.setColor(Color.BLACK); BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
/** * Draw text with an emphasized background. * * @param g * the Graphics context to draw with. * @param foreground * the foreground color. * @param emphasis * the emphasis color. * @param s * the text to draw. * @param underlinedIndex * the index to underline. * @param x * the x coordinate to draw at. * @param y * the y coordinate to draw at. */ public void drawEmphasizedText(Graphics g, Color foreground, Color emphasis, String s, int underlinedIndex, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setColor(emphasis); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, s, underlinedIndex, x, y + 1); g2d.setColor(foreground); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, s, underlinedIndex, x, y); }
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints);
/** * Draws the string at the specified location underlining the specified character. * * @param c JComponent that will display the string, may be null * @param g Graphics to draw the text to * @param text String to display * @param x X coordinate to draw the text at * @param y Y coordinate to draw the text at */ public static void drawString(JComponent c, Graphics g, String text, int x, int y) { if (drawStringMethod != null) { try { drawStringMethod.invoke(null, c, g, text, Integer.valueOf(x), Integer.valueOf(y)); return; } catch (IllegalArgumentException e) { // Use the BasicGraphicsUtils as fallback } catch (IllegalAccessException e) { // Use the BasicGraphicsUtils as fallback } catch (InvocationTargetException e) { // Use the BasicGraphicsUtils as fallback } } Graphics2D g2 = (Graphics2D) g; Map<?, ?> oldRenderingHints = installDesktopHints(g2); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, -1, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints); } }
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints);
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, -1, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints);
if (transform != null) g2d.transform(transform); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, mnemonicIndex, textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); g2d.dispose();
if (transform != null) g2d.transform(transform); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, mnemonicIndex, textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); g2d.dispose();
BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, textRect.y + fm.getAscent()); g.setColor(menuItem.getBackground().darker()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, BasicGraphicsUtils.drawStringUnderlineCharAt( g, text,
BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemIndex, textRect.x+1, textRect.y + fm.getAscent() +1); g.setColor(getDisabledTextColor()); BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemIndex, textRect.x, textRect.y + fm.getAscent());
BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemIndex, textRect.x+1, textRect.y + fm.getAscent() +1); g.setColor(getDisabledTextColor()); BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemIndex, textRect.x, textRect.y + fm.getAscent());
BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, textRect.y + metrics.getAscent()); g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title,
public static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y) { Graphics2D g2D = (Graphics2D) g; Object savedRenderingHint = null; if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint()); } if (getJavaVersion() >= 1.6) { try { Class swingUtilities2Class = Class.forName("sun.swing.SwingUtilities2"); Class classParams[] = {JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE}; Method m = swingUtilities2Class.getMethod("drawStringUnderlineCharAt", classParams); Object methodParams[] = {c, g, text, new Integer(underlinedIndex), new Integer(x), new Integer(y)}; m.invoke(null, methodParams); } catch (Exception ex) { BasicGraphicsUtils.drawString(g, text, underlinedIndex, x, y); } } else if (getJavaVersion() >= 1.4) { BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); } else { BasicGraphicsUtils.drawString(g, text, underlinedIndex, x, y); } if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint); } }
private void paintWithForegroundPainterWithoutFilters(Graphics2D g2d) { paintWithoutForegroundPainter(g2d); if (getText() != null && !getText().isEmpty()) { Insets i = getInsets(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = getWidth() - (i.right + viewRect.x); viewRect.height = getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // layout the text and icon String text = SwingUtilities.layoutCompoundLabel( this, g2d.getFontMetrics(), getText(), getIcon(), getVerticalAlignment(), getHorizontalAlignment(), getVerticalTextPosition(), getHorizontalTextPosition(), viewRect, iconRect, textRect, getText() == null ? 0 : getIconTextGap()); if (!isPaintBorderInsets()) { g2d.translate(i.left, i.top); } g2d.setPaint(fgPaint); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, getDisplayedMnemonicIndex(), textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); } }
private void paintWithForegroundPainterWithoutFilters(Graphics2D g2d) { paintWithoutForegroundPainter(g2d); if (getText() != null && !getText().isEmpty()) { Insets i = getInsets(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = getWidth() - (i.right + viewRect.x); viewRect.height = getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // layout the text and icon String text = SwingUtilities.layoutCompoundLabel( this, g2d.getFontMetrics(), getText(), getIcon(), getVerticalAlignment(), getHorizontalAlignment(), getVerticalTextPosition(), getHorizontalTextPosition(), viewRect, iconRect, textRect, getText() == null ? 0 : getIconTextGap()); if (!isPaintBorderInsets()) { g2d.translate(i.left, i.top); } g2d.setPaint(fgPaint); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, getDisplayedMnemonicIndex(), textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); } }
private void paintWithForegroundPainterWithoutFilters(Graphics2D g2d) { paintWithoutForegroundPainter(g2d); if (getText() != null && !getText().isEmpty()) { Insets i = getInsets(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = getWidth() - (i.right + viewRect.x); viewRect.height = getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // layout the text and icon String text = SwingUtilities.layoutCompoundLabel( this, g2d.getFontMetrics(), getText(), getIcon(), getVerticalAlignment(), getHorizontalAlignment(), getVerticalTextPosition(), getHorizontalTextPosition(), viewRect, iconRect, textRect, getText() == null ? 0 : getIconTextGap()); if (!isPaintBorderInsets()) { g2d.translate(i.left, i.top); } g2d.setPaint(fgPaint); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, getDisplayedMnemonicIndex(), textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); } }
private void paintWithForegroundPainterWithoutFilters(Graphics2D g2d) { paintWithoutForegroundPainter(g2d); if (getText() != null && !getText().isEmpty()) { Insets i = getInsets(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = getWidth() - (i.right + viewRect.x); viewRect.height = getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // layout the text and icon String text = SwingUtilities.layoutCompoundLabel( this, g2d.getFontMetrics(), getText(), getIcon(), getVerticalAlignment(), getHorizontalAlignment(), getVerticalTextPosition(), getHorizontalTextPosition(), viewRect, iconRect, textRect, getText() == null ? 0 : getIconTextGap()); if (!isPaintBorderInsets()) { g2d.translate(i.left, i.top); } g2d.setPaint(fgPaint); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, getDisplayedMnemonicIndex(), textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); } }
BasicGraphicsUtils.drawStringUnderlineCharAt(g, clippedText, mnemonicIndex, textX, textY); } else {
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());