sun.awt.ConstrainableGraphics Java Examples
The following examples show how to use
sun.awt.ConstrainableGraphics.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmptyClipRenderingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Run the test: cycle through all the rectangles, use one as clip and * another as the area to render to. * Set the clip in the same way Swing does it when repainting: * first constrain the graphics to the damaged area, and repaint everything */ void runTest(Graphics2D destGraphics) { destGraphics.setColor(Color.black); destGraphics.fillRect(0, 0, IMG_W, IMG_H); destGraphics.setColor(Color.red); for (Rectangle clip : rects) { Graphics2D g2d = (Graphics2D)destGraphics.create(); g2d.setColor(Color.red); // mimic what swing does in BufferStrategyPaintManager if (g2d instanceof ConstrainableGraphics) { ((ConstrainableGraphics)g2d).constrain(clip.x, clip.y, clip.width, clip.height); } g2d.setClip(clip); for (Rectangle renderRegion : rects) { if (renderRegion != clip) { // from CellRendererPane's paintComponent Graphics2D rG = (Graphics2D) g2d.create(renderRegion.x, renderRegion.y, renderRegion.width, renderRegion.height); rG.fillRect(0,0, renderRegion.width, renderRegion.height); } } } }