java.awt.image.VolatileImage#getHeight()源码实例Demo

下面列出了java.awt.image.VolatileImage#getHeight() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码2 项目: dragonwell8_jdk   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码3 项目: TencentKona-8   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码4 项目: jdk8u60   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码5 项目: JDKSourceCode1.8   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码6 项目: openjdk-jdk8u   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码7 项目: openjdk-jdk8u-backup   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码8 项目: Bytecoder   文件: RepaintManager.java
/**
 * Return a volatile offscreen buffer that should be used as a
 * double buffer with the specified component <code>c</code>.
 * The image returned will be an instance of VolatileImage, or null
 * if a VolatileImage object could not be instantiated.
 * This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
 * This happens when the maximum double buffer size has been set for this
 * repaint manager.
 *
 * @param c the component
 * @param proposedWidth the width of the buffer
 * @param proposedHeight the height of the buffer
 *
 * @return the volatile image
 * @see java.awt.image.VolatileImage
 * @since 1.4
 */
public Image getVolatileOffscreenBuffer(Component c,
                                        int proposedWidth,int proposedHeight) {
    RepaintManager delegate = getDelegate(c);
    if (delegate != null) {
        return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                    proposedHeight);
    }

    // If the window is non-opaque, it's double-buffered at peer's level
    Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
    if (!w.isOpaque()) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
            return null;
        }
    }

    GraphicsConfiguration config = c.getGraphicsConfiguration();
    if (config == null) {
        config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                        getDefaultScreenDevice().getDefaultConfiguration();
    }
    Dimension maxSize = getDoubleBufferMaximumSize();
    int width = proposedWidth < 1 ? 1 :
        (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
    int height = proposedHeight < 1 ? 1 :
        (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
    VolatileImage image = volatileMap.get(config);
    if (image == null || image.getWidth() < width ||
                         image.getHeight() < height) {
        if (image != null) {
            image.flush();
        }
        image = config.createCompatibleVolatileImage(width, height,
                                                     volatileBufferType);
        volatileMap.put(config, image);
    }
    return image;
}
 
源代码9 项目: openjdk-jdk9   文件: RepaintManager.java
/**
 * Return a volatile offscreen buffer that should be used as a
 * double buffer with the specified component <code>c</code>.
 * The image returned will be an instance of VolatileImage, or null
 * if a VolatileImage object could not be instantiated.
 * This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
 * This happens when the maximum double buffer size has been set for this
 * repaint manager.
 *
 * @param c the component
 * @param proposedWidth the width of the buffer
 * @param proposedHeight the height of the buffer
 *
 * @return the volatile image
 * @see java.awt.image.VolatileImage
 * @since 1.4
 */
public Image getVolatileOffscreenBuffer(Component c,
                                        int proposedWidth,int proposedHeight) {
    RepaintManager delegate = getDelegate(c);
    if (delegate != null) {
        return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                    proposedHeight);
    }

    // If the window is non-opaque, it's double-buffered at peer's level
    Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
    if (!w.isOpaque()) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
            return null;
        }
    }

    GraphicsConfiguration config = c.getGraphicsConfiguration();
    if (config == null) {
        config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                        getDefaultScreenDevice().getDefaultConfiguration();
    }
    Dimension maxSize = getDoubleBufferMaximumSize();
    int width = proposedWidth < 1 ? 1 :
        (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
    int height = proposedHeight < 1 ? 1 :
        (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
    VolatileImage image = volatileMap.get(config);
    if (image == null || image.getWidth() < width ||
                         image.getHeight() < height) {
        if (image != null) {
            image.flush();
        }
        image = config.createCompatibleVolatileImage(width, height,
                                                     volatileBufferType);
        volatileMap.put(config, image);
    }
    return image;
}
 
源代码10 项目: jdk8u-jdk   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码11 项目: Java8CN   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码12 项目: hottub   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码13 项目: Pixelitor   文件: SimpleCachedPainter.java
@Override
public void paint(Graphics2D g, Object o, int width, int height) {
    GraphicsConfiguration gc = g.getDeviceConfiguration();
    if (cache == null) { // called for the first time or was invalidated
        createAndUseCachedImage(g, gc, width, height);
        return;
    }

    VolatileImage vi = cache.get();
    if (vi == null) { // soft reference collected
        createAndUseCachedImage(g, gc, width, height);
        return;
    }

    if (vi.getWidth() != width || vi.getHeight() != height) { // size changed
        vi.flush();
        createAndUseCachedImage(g, gc, width, height);
        return;
    }
    // at this point we have a cached image with the right size

    int safetyCounter = 0; // to be 100% sure that this is not an infinite loop
    do {
        int valCode = vi.validate(gc); // check before rendering
        if (valCode == VolatileImage.IMAGE_OK) {
            // simplest case, just use the image
            g.drawImage(vi, 0, 0, null);
        } else if (valCode == VolatileImage.IMAGE_RESTORED) {
            // memory loss, but the the image object can be reused
            renderAndUseCachedImage(vi, g, width, height);
        } else if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) {
            // surface incompatibility: the image has to be recreated
            vi.flush();
            vi = createAndUseCachedImage(g, gc, width, height);
        }
    } while (vi.contentsLost() && safetyCounter++ < 3); // check after rendering
}
 
源代码14 项目: visualvm   文件: LevelIndicator.java
private Color getColorAt(VolatileImage img, int x, int y) {
    if ((x <= 0) || (y < 0) || (x > img.getWidth()) || (y > img.getHeight())) {
        return null;
    }

    int RGB = img.getSnapshot().getRGB(x - 1, 0);
    int red = (RGB & 0x00ff0000) >> 16;
    int green = (RGB & 0x0000ff00) >> 8;
    int blue = RGB & 0x000000ff;

    // and the Java Color is ...
    return new Color(red, green, blue);
}
 
源代码15 项目: openjdk-8   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码16 项目: jdk8u_jdk   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码17 项目: jdk8u-jdk   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码18 项目: jdk8u-dev-jdk   文件: RepaintManager.java
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
源代码19 项目: RipplePower   文件: LGraphics.java
public LGraphics(VolatileImage awtImage) {
	this.width = awtImage.getWidth();
	this.height = awtImage.getHeight();
	this.g2d = awtImage.createGraphics();
	this.g2d.setClip(0, 0, width, height);
	this.store.save(g2d);
}
 
源代码20 项目: seaglass   文件: AbstractRegionPainter.java
/**
 * Gets the rendered image for this painter at the requested size, either
 * from cache or create a new one
 *
 * @param  config            the graphics configuration.
 * @param  c                 the component to paint.
 * @param  w                 the component width.
 * @param  h                 the component height.
 * @param  extendedCacheKeys extended cache keys.
 *
 * @return the new image.
 */
private VolatileImage getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys) {
    ImageCache imageCache = ImageCache.getInstance();

    // get the buffer for this component
    VolatileImage buffer = (VolatileImage) imageCache.getImage(config, w, h, this, extendedCacheKeys);

    int renderCounter = 0; // to avoid any potential, though unlikely,

    // infinite loop
    do {

        // validate the buffer so we can check for surface loss
        int bufferStatus = VolatileImage.IMAGE_INCOMPATIBLE;

        if (buffer != null) {
            bufferStatus = buffer.validate(config);
        }

        // If the buffer status is incompatible or restored, then we need to
        // re-render to the volatile image
        if (bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE || bufferStatus == VolatileImage.IMAGE_RESTORED) {

            // if the buffer is null (hasn't been created), or isn't the
            // right size, or has lost its contents,
            // then recreate the buffer
            if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h
                    || bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE) {

                // clear any resources related to the old back buffer
                if (buffer != null) {
                    buffer.flush();
                    buffer = null;
                }

                // recreate the buffer
                buffer = config.createCompatibleVolatileImage(w, h, Transparency.TRANSLUCENT);

                // put in cache for future
                imageCache.setImage(buffer, config, w, h, this, extendedCacheKeys);
            }

            // create the graphics context with which to paint to the buffer
            Graphics2D bg = buffer.createGraphics();

            // clear the background before configuring the graphics
            bg.setComposite(AlphaComposite.Clear);
            bg.fillRect(0, 0, w, h);
            bg.setComposite(AlphaComposite.SrcOver);
            configureGraphics(bg);

            // paint the painter into buffer
            paintDirectly(bg, c, w, h, extendedCacheKeys);

            // close buffer graphics
            bg.dispose();
        }
    } while (buffer.contentsLost() && renderCounter++ < 3);

    // check if we failed
    if (renderCounter == 3)
        return null;

    // return image
    return buffer;
}