本文整理汇总了Java中sun.java2d.SunGraphics2D.constrain方法的典型用法代码示例。如果您正苦于以下问题:Java SunGraphics2D.constrain方法的具体用法?Java SunGraphics2D.constrain怎么用?Java SunGraphics2D.constrain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.java2d.SunGraphics2D
的用法示例。
在下文中一共展示了SunGraphics2D.constrain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import sun.java2d.SunGraphics2D; //导入方法依赖的package包/类
public static void main(final String[] args) {
final GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsConfiguration gc =
ge.getDefaultScreenDevice().getDefaultConfiguration();
final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();
sg2d.constrain(0, 61, 100, 100);
final AffineTransform expected = sg2d.cloneTransform();
sg2d.setTransform(sg2d.getTransform());
final AffineTransform actual = sg2d.cloneTransform();
sg2d.dispose();
vi.flush();
if (!expected.equals(actual)) {
System.out.println("Expected = " + expected);
System.out.println("Actual = " + actual);
throw new RuntimeException("Wrong transform");
}
}
示例2: getDrawGraphics
import sun.java2d.SunGraphics2D; //导入方法依赖的package包/类
/**
* @return the draw graphics
*/
public Graphics getDrawGraphics() {
revalidate();
Image backBuffer = getBackBuffer();
if (backBuffer == null) {
return getGraphics();
}
SunGraphics2D g = (SunGraphics2D)backBuffer.getGraphics();
g.constrain(-insets.left, -insets.top,
backBuffer.getWidth(null) + insets.left,
backBuffer.getHeight(null) + insets.top);
return g;
}
示例3: applyConstrain
import sun.java2d.SunGraphics2D; //导入方法依赖的package包/类
private void applyConstrain(final Graphics g) {
final SunGraphics2D sg2d = (SunGraphics2D) g;
final Rectangle size = localToWindow(getSize());
sg2d.constrain(size.x, size.y, size.width, size.height, getVisibleRegion());
}