protected final void setAccelerationPriority(float priority) {
    accelerationPriority = priority;

    Image image = offscreenImageReference.get();
    if (image != null) image.setAccelerationPriority(accelerationPriority);
  }
  protected final void paintComponent(Graphics g) {
    if (bufferType != BUFFER_NONE) { // Painting to an offscreen image

      // Determine offscreen image state
      int imageState = updateOffscreenImage();

      // Offscreen image has to be recreated
      if (imageState == VolatileImage.IMAGE_INCOMPATIBLE) {
        // Create new offscreen image
        offscreenImage = createOffscreenImage();
        // Return if VolatileImage not supported
        if (offscreenImage == null) return;
        // Set image acceleration
        offscreenImage.setAccelerationPriority(accelerationPriority);
        // Weakly reference new offscreen image
        offscreenImageReference = new WeakReference(offscreenImage);
        // Set IMAGE_RESTORED flag to repaint the offscreen image
        imageState = VolatileImage.IMAGE_RESTORED;

        //                try {
        //                    Graphics2D gr = (Graphics2D)offscreenImage.getGraphics();
        //
        //                    // These commands cause the Graphics2D object to clear to (0,0,0,0).
        //                    gr.setComposite(AlphaComposite.Src);
        //                    gr.setColor(Color.black);
        //                    gr.fillRect(0, 0, getWidth(), getHeight()); // Clears the image.
        //
        ////                    g.drawImage(bimage,null,0,0);
        //                } finally {
        //                    // It's always best to dispose of your Graphics objects.
        //                    g.dispose();
        //                }
      }

      // Offscreen image has to be repainted
      if (imageState == VolatileImage.IMAGE_RESTORED)
        invalidOffscreenArea.setBounds(0, 0, getWidth(), getHeight());

      // Update the offscreen image if needed
      if (isDirty()) {
        Graphics offscreenGraphics = offscreenImage.getGraphics();
        try {
          paintComponent(offscreenGraphics, invalidOffscreenArea);
        } finally {
          offscreenGraphics.dispose();
        }
      }

      // Paint the offscreen image to onscreen graphics
      g.drawImage(offscreenImage, 0, 0, null);
      //                try {
      //
      // javax.imageio.ImageIO.write((java.awt.image.BufferedImage)offscreenImage, "png", new
      // java.io.File("C:\\Temp\\debugimg\\image" + System.currentTimeMillis() + ".png"));
      //                } catch (Exception e) {System.err.println(e);}

    } else { // Painting directly to the provided Graphics

      // Resolve clipping rectangle
      Rectangle clipRect = g.getClipBounds();
      if (clipRect == null) clipRect = new Rectangle(0, 0, getWidth(), getHeight());

      // Paint directly to the Graphics
      paintComponent(g, clipRect);
    }

    invalidOffscreenArea.setBounds(0, 0, 0, 0);
  }
Пример #3
0
 /*     */ public void setAccelerationPriority(float paramFloat) {
   /* 327 */ super.setAccelerationPriority(paramFloat);
   /* 328 */ ImageRepresentation localImageRepresentation = getImageRep();
   /* 329 */ localImageRepresentation.setAccelerationPriority(this.accelerationPriority);
   /*     */ }