Java 类javax.swing.plaf.basic.BasicGraphicsUtils 实例源码

项目:OpenJSharp    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:OpenJSharp    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:jdk8u-jdk    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:jdk8u-jdk    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:openjdk-jdk10    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:openjdk-jdk10    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:openjdk-jdk10    文件:bug8132119.java   
private static void testStringWidth() {

        String str = "12345678910\u036F";
        JComponent comp = createComponent(str);
        Font font = comp.getFont();
        FontMetrics fontMetrics = comp.getFontMetrics(font);
        float stringWidth = BasicGraphicsUtils.getStringWidth(comp, fontMetrics, str);

        if (stringWidth == fontMetrics.stringWidth(str)) {
            throw new RuntimeException("Numeric shaper is not used!");
        }

        if (stringWidth != getLayoutWidth(str, font, NUMERIC_SHAPER)) {
            throw new RuntimeException("Wrong text width!");
        }
    }
项目:openjdk-jdk10    文件:bug8132119.java   
private static void testStringClip() {

        String str = "1234567890";
        JComponent comp = createComponent(str);
        FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());

        int width = (int) BasicGraphicsUtils.getStringWidth(comp, fontMetrics, str);

        String clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, width);
        checkClippedString(str, clip, str);

        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, width + 1);
        checkClippedString(str, clip, str);

        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, -1);
        checkClippedString(str, clip, "...");

        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, 0);
        checkClippedString(str, clip, "...");

        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics,
                str, width - width / str.length());
        int endIndex = str.length() - 3;
        checkClippedString(str, clip, str.substring(0, endIndex) + "...");
    }
项目:openjdk-jdk10    文件:bug8132119.java   
private static void testDrawEmptyString() {
    JLabel label = new JLabel();
    BufferedImage buffImage = createBufferedImage(50, 50);
    Graphics2D g2 = buffImage.createGraphics();
    g2.setColor(DRAW_COLOR);
    BasicGraphicsUtils.drawString(null, g2, null, 0, 0);
    BasicGraphicsUtils.drawString(label, g2, null, 0, 0);
    BasicGraphicsUtils.drawString(null, g2, "", 0, 0);
    BasicGraphicsUtils.drawString(label, g2, "", 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, null, 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, null, 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, "", 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, "", 3, 0, 0);
    g2.dispose();
    checkImageIsEmpty(buffImage);
}
项目:openjdk-jdk10    文件:bug8132119.java   
private static void checkNullArgumentsDrawString(JComponent comp, Graphics2D g,
        String text) {

    float x = 50;
    float y = 50;
    BasicGraphicsUtils.drawString(null, g, text, x, y);
    BasicGraphicsUtils.drawString(comp, g, null, x, y);

    try {
        BasicGraphicsUtils.drawString(comp, null, text, x, y);
    } catch (NullPointerException e) {
        return;
    }

    throw new RuntimeException("NPE is not thrown");
}
项目:openjdk-jdk10    文件:bug8132119.java   
private static void checkNullArgumentsDrawStringUnderlineCharAt(
        JComponent comp, Graphics2D g, String text) {

    int x = 50;
    int y = 50;
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g, text, 1, x, y);
    BasicGraphicsUtils.drawStringUnderlineCharAt(comp, g, null, 1, x, y);

    try {
        BasicGraphicsUtils.drawStringUnderlineCharAt(comp, null, text, 1, x, y);
    } catch (NullPointerException e) {
        return;
    }

    throw new RuntimeException("NPE is not thrown");
}
项目:openjdk-jdk10    文件:bug8132119.java   
private static void checkNullArgumentsGetClippedString(
        JComponent comp, String text) {

    FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());

    BasicGraphicsUtils.getClippedString(null, fontMetrics, text, 1);
    String result = BasicGraphicsUtils.getClippedString(comp, fontMetrics, null, 1);
    if (!"".equals(result)) {
        throw new RuntimeException("Empty string is not returned!");
    }

    try {
        BasicGraphicsUtils.getClippedString(comp, null, text, 1);
    } catch (NullPointerException e) {
        return;
    }

    throw new RuntimeException("NPE is not thrown");
}
项目:openjdk-jdk10    文件:bug8132119.java   
private static void checkNullArgumentsGetStringWidth(JComponent comp,
        String text) {

    FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
    BasicGraphicsUtils.getStringWidth(null, fontMetrics, text);
    float result = BasicGraphicsUtils.getStringWidth(comp, fontMetrics, null);

    if (result != 0) {
        throw new RuntimeException("The string length is not 0");
    }

    try {
        BasicGraphicsUtils.getStringWidth(comp, null, text);
    } catch (NullPointerException e) {
        return;
    }

    throw new RuntimeException("NPE is not thrown");
}
项目:openjdk9    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:openjdk9    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:Java8CN    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:orbit-image-analysis    文件:BasicLinkButtonUI.java   
protected void paintFocus(
  Graphics g,
  AbstractButton b,
  Rectangle viewRect,
  Rectangle textRect,
  Rectangle iconRect) {
  if (b.getParent() instanceof JToolBar) {
    // Windows doesn't draw the focus rect for buttons in a toolbar.
    return;
  }

  // focus painted same color as text
  int width = b.getWidth();
  int height = b.getHeight();
  g.setColor(getFocusColor());
  BasicGraphicsUtils.drawDashedRect(
    g,
    dashedRectGapX,
    dashedRectGapY,
    width - dashedRectGapWidth,
    height - dashedRectGapHeight);
}
项目:DigitalMediaServer    文件:RepaintableTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:pumpernickel    文件:FilledButtonUI.java   
public void paintText(Graphics2D g,ButtonInfo info) {
    ButtonModel model = info.button.getModel();
    FontMetrics fm = info.button.getFontMetrics(info.button.getFont());
    int mnemonicIndex = info.button.getDisplayedMnemonicIndex();
    String text = info.button.getText();
    int textShiftOffset = 0;


    g.setComposite(AlphaComposite.SrcOver);
    /* Draw the Text */
    if(isEnabled(info.button)) {
        /*** paint the text normally */
        g.setColor(info.button.getForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x + textShiftOffset,
                info.textRect.y + fm.getAscent() + textShiftOffset);
    } else {
        /*** paint the text disabled ***/
        g.setColor(info.button.getBackground().brighter());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x, info.textRect.y + fm.getAscent());
        g.setColor(info.button.getBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x - 1, info.textRect.y + fm.getAscent() - 1);
    }
}
项目:jdk8u_jdk    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:jdk8u_jdk    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:JCheckboxTree    文件:CustomDefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator) && drawSolidFocusIndicator) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:swingx    文件:TreeCellContext.java   
@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);
    }

}
项目:swingx    文件:BasicHyperlinkUI.java   
@Override
    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
            Rectangle textRect, Rectangle iconRect) {
        if (b.getParent() instanceof JToolBar) {
            // Windows doesn't draw the focus rect for buttons in a toolbar.
            return;
        }

        // focus painted same color as text
        g.setColor(getFocusColor());
        // paint the focus rect around the union of text rect and icon rect
        // PENDING JW: duplicated to handle insets
        Rectangle iconTextRect = getIconTextRect(b); 
        // PENDING JW: better factor handling of insets - the bare union doesn't respect insets
//        Rectangle iconTextRect = textRect.union(iconRect);
        BasicGraphicsUtils.drawDashedRect(g, iconTextRect.x, iconTextRect.y, 
                iconTextRect.width, iconTextRect.height);
        // pre-#167-swingx: active area too large
//        int width = b.getWidth();
//        int height = b.getHeight();
//        BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
//                width - dashedRectGapWidth, height - dashedRectGapHeight);
    }
项目:SmartTokens    文件:UnifiedToolbarButtonUI.java   
@Override
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
    MacFontUtils.enableAntialiasing((Graphics2D) g);
    Graphics2D graphics = (Graphics2D) g.create();

    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    FontMetrics fm = c.getFontMetrics(c.getFont());

    // 1) Draw the emphasis text.
    graphics.setColor(model.isArmed()
            ? MacColorUtils.EMPTY_COLOR
            : EmphasizedLabelUI.DEFAULT_EMPHASIS_COLOR);
    BasicGraphicsUtils.drawStringUnderlineCharAt(graphics, text, -1,
            textRect.x, textRect.y + 1 + fm.getAscent());

    // 2) Draw the text.
    graphics.setColor(model.isEnabled()
            ? EmphasizedLabelUI.DEFAULT_FOCUSED_FONT_COLOR
            : EmphasizedLabelUI.DEFAULT_DISABLED_FONT_COLOR);
    BasicGraphicsUtils.drawStringUnderlineCharAt(graphics, text, -1,
            textRect.x, textRect.y + fm.getAscent());

    graphics.dispose();
}
项目:infobip-open-jdk-8    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:infobip-open-jdk-8    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:jdk8u-dev-jdk    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:jdk8u-dev-jdk    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:aibench-project    文件:TreeCellContext.java   
@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);
    }

}
项目:aibench-project    文件:BasicHyperlinkUI.java   
@Override
    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
            Rectangle textRect, Rectangle iconRect) {
        if (b.getParent() instanceof JToolBar) {
            // Windows doesn't draw the focus rect for buttons in a toolbar.
            return;
        }

        // focus painted same color as text
        g.setColor(getFocusColor());
        // paint the focus rect around the union of text rect and icon rect
        // PENDING JW: duplicated to handle insets
        Rectangle iconTextRect = getIconTextRect(b); 
        // PENDING JW: better factor handling of insets - the bare union doesn't respect insets
//        Rectangle iconTextRect = textRect.union(iconRect);
        BasicGraphicsUtils.drawDashedRect(g, iconTextRect.x, iconTextRect.y, 
                iconTextRect.width, iconTextRect.height);
        // pre-#167-swingx: active area too large
//        int width = b.getWidth();
//        int height = b.getHeight();
//        BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
//                width - dashedRectGapWidth, height - dashedRectGapHeight);
    }
项目:jdk7-jdk    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:jdk7-jdk    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:openjdk-source-code-learn    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:openjdk-source-code-learn    文件:XCheckboxPeer.java   
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
项目:java-swing-tips    文件:MainPanel.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color bsColor = getBorderSelectionColor();
    boolean b = selected || !drawDashedFocusIndicator;
    if (Objects.nonNull(bsColor) && b) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && Objects.nonNull(notColor)) {
        if (!notColor.equals(treeBGColor)) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}
项目:Introspect-Framework    文件:CustomTabbedPaneUI.java   
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
    g.setFont(font);
    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        v.paint(g, textRect);
    } else {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
        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);
        }
    }
}
项目:OLD-OpenJDK8    文件:DefaultTreeCellRenderer.java   
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
    Color       bsColor = getBorderSelectionColor();

    if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
        g.setColor(bsColor);
        g.drawRect(x, y, w - 1, h - 1);
    }
    if (drawDashedFocusIndicator && notColor != null) {
        if (treeBGColor != notColor) {
            treeBGColor = notColor;
            focusBGColor = new Color(~notColor.getRGB());
        }
        g.setColor(focusBGColor);
        BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
    }
}