本文整理汇总了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);
}
}
}