Refine search
protected void paintFocus(Graphics g, Rectangle t, Dimension d) { g.setColor(AbstractLookAndFeel.getFocusColor()); BasicGraphicsUtils.drawDashedRect(g, t.x - 3, t.y - 1, t.width + 6, t.height + 2); BasicGraphicsUtils.drawDashedRect(g, t.x - 2, t.y, t.width + 4, t.height); }
g.setColor(hazAlfa(fila)); g.fillPolygon(carp); g.setColor(darkShadow.darker()); g.drawPolygon(carp); 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);
public Dimension getPreferredSize(JComponent c) { AbstractButton b = (AbstractButton) c; return BasicGraphicsUtils.getPreferredButtonSize(b, b.getIconTextGap()); }
g.setColor(lbl.getBackground()); g.fillRect(0, 0, lbl.getWidth(), lbl.getHeight()); g.setColor(lbl.getForeground()); Icon icon = (lbl.isEnabled()) ? lbl.getIcon() : lbl.getDisabledIcon(); g.setColor(changedForeground); BasicGraphicsUtils.drawStringUnderlineCharAt(g, clippedText, mnemonicIndex, textX, textY); } else {
viewRect.height -= (i.bottom + viewRect.y); g.setColor(disabledForeground); BasicGraphicsUtils.drawString( g, acceleratorText, g.setColor(b.getBackground().brighter()); BasicGraphicsUtils.drawString( g, acceleratorText, acceleratorRect.y + fmAccel.getAscent()); g.setColor(b.getBackground().darker()); BasicGraphicsUtils.drawString( g, acceleratorText, g.setColor(acceleratorForeground); BasicGraphicsUtils.drawString( g, acceleratorText,
@Override public void paint(Graphics g, JComponent c) { g.setFont(FlamingoUtilities.getFont(commandButton, "Ribbon.font", "Button.font", "Panel.font")); this.layoutInfo = this.layoutManager.getLayoutInfo(this.commandButton, paintPopupActionIcon(g, layoutInfo.popupActionRect); FontMetrics fm = g.getFontMetrics(); g.setColor(getForegroundColor(isTextPaintedEnabled)); BasicGraphicsUtils.drawString(g, mainTextLayoutInfo.text, -1, mainTextLayoutInfo.textRect.x, mainTextLayoutInfo.textRect.y + fm.getAscent()); for (CommandButtonLayoutManager.TextLayoutInfo extraTextLayoutInfo : layoutInfo.extraTextLayoutInfoList) { if (extraTextLayoutInfo.text != null) { BasicGraphicsUtils.drawString(g, extraTextLayoutInfo.text, -1, extraTextLayoutInfo.textRect.x, extraTextLayoutInfo.textRect.y + fm.getAscent());
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color color = UIManager.getColor("Tree.selectionBorderColor"); if (color != null) { lineColor = color; } if (isDashed()) { if (treeBackground != c.getBackground()) { treeBackground = c.getBackground(); focusColor = new Color(~treeBackground.getRGB()); } Color old = g.getColor(); g.setColor(focusColor); BasicGraphicsUtils.drawDashedRect(g, x, y, width, height); g.setColor(old); } else { super.paintBorder(c, g, x, y, width, height); } }
g.setColor( bkColor ); if( currentIcon != null && getText() != null ) g.fillRect( offset, 0, getWidth() - 1 - offset, getHeight() - 1 ); g.setColor( _tree.isEnabled() ? EditorUtilities.TEXT_HIGHLIGHT_TEXT : EditorUtilities.CONTROL_LIGHT ); BasicGraphicsUtils.drawDashedRect( g, offset, 0, getWidth() - 1 - offset, getHeight() - 1 ); g.setColor( _tree.isEnabled() ? EditorUtilities.TEXT_HIGHLIGHT_TEXT : EditorUtilities.CONTROL_LIGHT ); BasicGraphicsUtils.drawDashedRect( g, 0, 0, getWidth() - 1, getHeight() - 1 );
FontMetrics fm= g.getFontMetrics(); int mnemIndex= menuItem.getDisplayedMnemonicIndex(); g.setColor(UIManager.getColor("MenuItem.disabledForeground")); BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, g.setColor(menuItem.getBackground().brighter()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, textRect.y + fm.getAscent()); g.setColor(menuItem.getBackground().darker()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, text, g.setColor(selectionForeground); // Uses protected field. BasicGraphicsUtils.drawStringUnderlineCharAt( g, text,
g.setFont(font); g.setColor(tabPane.getForegroundAt(tabIndex)); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, g.setColor(tabPane.getBackgroundAt(tabIndex).brighter()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, textRect.y + metrics.getAscent()); g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title,
private void paintFocus(Graphics g, int x, int y, int w, int h) { Color bsColor = getBorderSelectionColor(); if (bsColor != null && (selected || !drawDashedFocusIndicator)) { g.setColor(bsColor); g.drawRect(x, y, w - 1, h - 1); } if (drawDashedFocusIndicator) { Color color; if (selected) { color = getBackgroundSelectionColor(); } else { color = getBackgroundNonSelectionColor(); if (color == null) { color = getBackground(); } } if (treeBGColor != color) { treeBGColor = color; focusBGColor = new Color(~color.getRGB()); } g.setColor(focusBGColor); BasicGraphicsUtils.drawDashedRect(g, x, y, w, h); } }
@Override protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); FontMetrics fm = g.getFontMetrics(); /* Draw the Text */ if (model.isEnabled()) { /** * * paint the text normally */ g.setColor(b.getForeground()); drawString(g, text, model.getMnemonic(), textRect.x, textRect.y + fm.getAscent()); } else { /** * * paint the text disabled ** */ // g.setColor(getDisabledTextColor()); g.setColor(b.getForeground().brighter()); drawString(g, text, model.getMnemonic(), textRect.x, textRect.y + fm.getAscent()); } }
g.setColor(l.getForeground()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemonicIndex, textX, textY); g.setColor(UIManager.getColor("Label.disabledShadow")); BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(UIManager.getColor("Label.disabledForeground")); BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemonicIndex, textX, textY);
/** * 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); }
protected void paintText(Graphics g) { FontMetrics fm = g.getFontMetrics(); String toPaint = this.commandButton.getText(); // compute the insets int fullInsets = this.commandButton.getInsets().left; int pw = this.getPreferredSize(this.commandButton).width; int mw = this.getMinimumSize(this.commandButton).width; int w = this.commandButton.getWidth(); int h = this.commandButton.getHeight(); int insets = fullInsets - (pw - w) * (fullInsets - 2) / (pw - mw); // and the text rectangle Rectangle textRect = new Rectangle(insets, 1 + (h - fm.getHeight()) / 2, w - 2 * insets, fm.getHeight()); // show the first characters that fit into the available text rectangle while (true) { if (toPaint.length() == 0) break; int strWidth = fm.stringWidth(toPaint); if (strWidth <= textRect.width) break; toPaint = toPaint.substring(0, toPaint.length() - 1); } BasicGraphicsUtils.drawString(g, toPaint, -1, textRect.x, textRect.y + fm.getAscent()); }
Shape contour = getOutline(this); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); BasicGraphicsUtils.drawString(g2d, titleToShow, -1, startX + 5, yOffset); } else { BasicGraphicsUtils.drawString(g2d, titleToShow, -1, startX + width - 5 - fm.stringWidth(titleToShow),
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints);
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); } }
/** * Draws one of the lines on a multiline label/button. * * @param g the Graphics context of the component. * @param fm the font metrics. * @param rect the rectangle that the text needs to be painted in. * @param text the text that needs to be drawn. * @param hAlign the horizontal alignment. * @param y the y position of the text. * @param mnemonic the mnemonic. * * @return the x starting position of the text */ public static int drawLine( Graphics g, FontMetrics fm, Rectangle rect, String text, int hAlign, int y, int mnemonic) { int x = rect.x; if ( text != null) { int width = SwingUtilities.computeStringWidth( fm, text); if ( hAlign == SwingConstants.CENTER) { x = rect.x + ((rect.width - width) / 2); } else if ( hAlign == SwingConstants.RIGHT) { x = rect.x + (rect.width - width); } BasicGraphicsUtils.drawString( g, text, mnemonic, x, y); } return x; }
g.setFont(f); FontMetrics fm = g.getFontMetrics(); g.setColor (UIManager.getColor("RadioButton.mandatoryBackground")); g.setColor(selectedColor); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); g.setColor(unselectedColor); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); g.setColor(b.getForeground()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); g.setColor(getDisabledTextColor()); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());