Beispiel #1
0
 public PaintJob(Box clip, Color background) {
   bufferCache = Context.instance().bufferedImageCache;
   bufferedImagePool = Context.instance().bufferedImagePool;
   this.clip = clip;
   buffer = bufferedImagePool.acquire(clip.getSize());
   rootGraphics = buffer.createGraphics();
   rootGraphics.setBackground(background);
   rootGraphics.clearRect(0, 0, clip.width, clip.height);
   composite = rootGraphics.getComposite();
 }
Beispiel #2
0
 public BufferedImage buildBufferFor(Panel panel) {
   Dimension dimension = new Dimension(panel.getWidth(), panel.getHeight());
   BufferedImage buffer = bufferedImagePool.acquire(dimension);
   Graphics2D graphics = buffer.createGraphics();
   graphics.setBackground(Colors.TRANSPARENT);
   graphics.clearRect(0, 0, panel.getWidth(), panel.getHeight());
   panel.paintOn(graphics);
   graphics.dispose();
   bufferCache.cache(panel, buffer);
   return buffer;
 }
Beispiel #3
0
 public void paintClipFor(Panel panel, Graphics2D graphics) {
   if (panel.canBeBuffered()) {
     BufferedImage panelBuffer = bufferCache.retrieve(panel);
     if (shouldBuildBufferFor(panel, panelBuffer)) {
       bufferedImagePool.recycle(panelBuffer);
       panelBuffer = buildBufferFor(panel);
     }
     graphics.drawImage(panelBuffer, 0, 0, null);
   } else {
     panel.paintOn(graphics);
   }
 }