當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicGraphicsUtils類代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.BasicGraphicsUtils的典型用法代碼示例。如果您正苦於以下問題:Java BasicGraphicsUtils類的具體用法?Java BasicGraphicsUtils怎麽用?Java BasicGraphicsUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BasicGraphicsUtils類屬於javax.swing.plaf.basic包,在下文中一共展示了BasicGraphicsUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDrawEmptyString

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例2: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title,
	Rectangle textRect, boolean 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(isSelected ? Color.white : Color.black);
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
		else
		{ // tab disabled
			g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
			g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:FlatterTabbedPaneUI.java

示例3: paintFocus

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:DefaultTreeCellRenderer.java

示例4: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:XCheckboxPeer.java

示例5: testStringWidth

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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!");
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例6: testStringClip

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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) + "...");
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:bug8132119.java

示例7: checkNullArgumentsDrawString

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例8: checkNullArgumentsDrawStringUnderlineCharAt

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例9: checkNullArgumentsGetClippedString

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:bug8132119.java

示例10: checkNullArgumentsGetStringWidth

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:bug8132119.java

示例11: paintFocus

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
}
 
開發者ID:mstritt,項目名稱:orbit-image-analysis,代碼行數:23,代碼來源:BasicLinkButtonUI.java

示例12: paintFocus

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:17,代碼來源:RepaintableTreeCellRenderer.java

示例13: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
	}
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:27,代碼來源:FilledButtonUI.java

示例14: paintFocus

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
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);
    }
}
 
開發者ID:JCheckboxTree,項目名稱:JCheckboxTree,代碼行數:17,代碼來源:CustomDefaultTreeCellRenderer.java

示例15: paintBorder

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入依賴的package包/類
@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);
    }

}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:24,代碼來源:TreeCellContext.java


注:本文中的javax.swing.plaf.basic.BasicGraphicsUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。