Пример #1
0
 public void dispose() {
   rootGN = null;
   currImg = null;
   workImg = null;
   renderingHints = null;
   usr2dev = null;
   if (damagedAreas != null) {
     damagedAreas.clear();
   }
   damagedAreas = null;
 }
Пример #2
0
  // long lastFrame = -1;
  public void repaint(RectListManager devRLM) {
    if (devRLM == null) return;

    updateWorkingBuffers();
    if ((rootGN == null) || (workImg == null)) return;

    try {
      // Ensure only one thread works on WorkImg at a time...
      synchronized (workImg) {
        Graphics2D g2d = GraphicsUtil.createGraphics(workImg, renderingHints);

        Rectangle dr;
        dr = new Rectangle(0, 0, offScreenWidth, offScreenHeight);

        if ((isDoubleBuffered) && (currImg != null) && (damagedAreas != null)) {

          damagedAreas.subtract(devRLM, COPY_OVERHEAD, COPY_LINE_OVERHEAD);

          damagedAreas.mergeRects(COPY_OVERHEAD, COPY_LINE_OVERHEAD);

          Iterator iter = damagedAreas.iterator();
          g2d.setComposite(AlphaComposite.Src);
          while (iter.hasNext()) {
            Rectangle r = (Rectangle) iter.next();
            if (!dr.intersects(r)) continue;
            r = dr.intersection(r);
            g2d.setClip(r.x, r.y, r.width, r.height);
            g2d.setComposite(AlphaComposite.Clear);
            g2d.fillRect(r.x, r.y, r.width, r.height);
            g2d.setComposite(AlphaComposite.SrcOver);
            g2d.drawImage(currImg, 0, 0, null);
          }
        }

        Iterator iter = devRLM.iterator();
        while (iter.hasNext()) {
          Rectangle r = (Rectangle) iter.next();
          if (!dr.intersects(r)) continue;
          r = dr.intersection(r);
          g2d.setTransform(IDENTITY);
          g2d.setClip(r.x, r.y, r.width, r.height);
          g2d.setComposite(AlphaComposite.Clear);
          g2d.fillRect(r.x, r.y, r.width, r.height);
          g2d.setComposite(AlphaComposite.SrcOver);
          g2d.transform(usr2dev);
          rootGN.paint(g2d);
        }
        g2d.dispose();
      }
    } catch (Throwable t) {
      t.printStackTrace();
    }
    if (HaltingThread.hasBeenHalted()) return;

    // System.out.println("Dmg: "   + damagedAreas);
    // System.out.println("Areas: " + devRects);

    // Swap the buffers if the rendering completed cleanly.
    if (isDoubleBuffered) {
      BufferedImage tmpImg = workImg;
      workImg = currImg;
      currImg = tmpImg;
      damagedAreas = devRLM;
    }
  }
Пример #3
0
 public void repaint(Shape area) {
   if (area == null) return;
   RectListManager rlm = new RectListManager();
   rlm.add(usr2dev.createTransformedShape(area).getBounds());
   repaint(rlm);
 }