本文整理匯總了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();
}
示例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);
}
}
}