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


Java Graphics2D.getBackground方法代碼示例

本文整理匯總了Java中java.awt.Graphics2D.getBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics2D.getBackground方法的具體用法?Java Graphics2D.getBackground怎麽用?Java Graphics2D.getBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Graphics2D的用法示例。


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

示例1: gInfo

import java.awt.Graphics2D; //導入方法依賴的package包/類
public gInfo(Graphics2D g)
{
	transform = g.getTransform();
	paint = g.getPaint();
	stroke = g.getStroke();
	font = g.getFont();
	composite = g.getComposite();
	bgrnd = g.getBackground();
	shape = g.getClip();
	hints = g.getRenderingHints();
}
 
開發者ID:Chroniaro,項目名稱:What-Happened-to-Station-7,代碼行數:12,代碼來源:TStack.java

示例2: paint

import java.awt.Graphics2D; //導入方法依賴的package包/類
@Override
public void paint(Graphics2D g, Shape alloc, Rectangle clipBounds) {
    Rectangle2D.Double allocBounds = ViewUtils.shape2Bounds(alloc);
    if (allocBounds.intersects(clipBounds)) {
        Font origFont = g.getFont();
        Color origColor = g.getColor();
        Color origBkColor = g.getBackground();
        Shape origClip = g.getClip();
        try {
            // Leave component font
            
            g.setBackground(getBackgroundColor());

            int xInt = (int) allocBounds.getX();
            int yInt = (int) allocBounds.getY();
            int endXInt = (int) (allocBounds.getX() + allocBounds.getWidth() - 1);
            int endYInt = (int) (allocBounds.getY() + allocBounds.getHeight() - 1);
            g.setColor(getBorderColor());
            g.drawRect(xInt, yInt, endXInt - xInt, endYInt - yInt);
            
            g.setColor(getForegroundColor());
            g.clearRect(xInt + 1, yInt + 1, endXInt - xInt - 1, endYInt - yInt - 1);
            g.clip(alloc);
            TextLayout textLayout = getTextLayout();
            if (textLayout != null) {
                EditorView.Parent parent = (EditorView.Parent) getParent();
                float ascent = parent.getViewRenderContext().getDefaultAscent();
                String desc = fold.getDescription(); // For empty desc a single-space text layout is returned
                float x = (float) (allocBounds.getX() + EXTRA_MARGIN_WIDTH);
                float y = (float) allocBounds.getY();
                if (desc.length() > 0) {
                    
                    textLayout.draw(g, x, y + ascent);
                }
            }
        } finally {
            g.setClip(origClip);
            g.setBackground(origBkColor);
            g.setColor(origColor);
            g.setFont(origFont);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:FoldView.java


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