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

下面列出了怎么用javax.swing.plaf.basic.BasicGraphicsUtils的API类实例代码及写法,或者点击链接到github查看源代码。

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);
    }
}
 
源代码2 项目: dragonwell8_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);
    }
}
 
源代码3 项目: dragonwell8_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);
    }
}
 
源代码4 项目: TencentKona-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);
    }
}
 
源代码5 项目: TencentKona-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);
    }
}
 
源代码6 项目: jdk8u60   文件: 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);
    }
}
 
源代码7 项目: jdk8u60   文件: 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);
    }
}
 
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);
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: 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);
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: 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);
    }
}
 
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);
    }
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: 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);
    }
}
 
源代码13 项目: Bytecoder   文件: 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);
    }
}
 
源代码14 项目: openjdk-jdk9   文件: 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);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: 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);
    }
}
 
源代码16 项目: openjdk-jdk9   文件: 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!");
        }
    }
 
源代码17 项目: openjdk-jdk9   文件: 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) + "...");
    }
 
源代码18 项目: openjdk-jdk9   文件: 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);
}
 
源代码19 项目: openjdk-jdk9   文件: 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");
}
 
源代码20 项目: openjdk-jdk9   文件: 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");
}
 
源代码21 项目: openjdk-jdk9   文件: 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");
}
 
源代码22 项目: openjdk-jdk9   文件: 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");
}
 
源代码23 项目: 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);
    }
}
 
源代码24 项目: 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);
    }
}
 
源代码25 项目: 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);
    }
}
 
源代码26 项目: hottub   文件: 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);
    }
}
 
源代码27 项目: hottub   文件: 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);
    }
}
 
源代码28 项目: openjdk-8-source   文件: 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);
    }
}
 
源代码29 项目: openjdk-8-source   文件: 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);
    }
}
 
源代码30 项目: 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);
}
 
 类所在包
 同包方法