Java 类sun.awt.image.ImageCache 实例源码

项目:OpenJSharp    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:jdk8u-jdk    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:openjdk-jdk10    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:openjdk9    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:jdk8u_jdk    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:lookaside_java-1.8.0-openjdk    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:infobip-open-jdk-8    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
项目:jdk8u-dev-jdk    文件:AquaPainter.java   
/**
 * Paints a native control, which identified by its size and a set of
 * additional arguments using a cached image.
 *
 * @param  g Graphics to draw the control
 * @param  control the reference to the native control
 * @param  controlState the state of the native control
 * @param  bounds the rectangle where the native part should be drawn.
 *         Note: the focus can/will be drawn outside of this bounds.
 */
static void paintFromSingleCachedImage(final Graphics2D g,
                                       final JRSUIControl control,
                                       final JRSUIState controlState,
                                       final Rectangle bounds) {
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;
    }

    int focus = 0;
    if (controlState.is(JRSUIConstants.Focused.YES)) {
        focus = JRSUIConstants.FOCUS_SIZE;
    }

    final int imgX = bounds.x - focus;
    final int imgY = bounds.y - focus;
    final int imgW = bounds.width + (focus << 1);
    final int imgH = bounds.height + (focus << 1);
    final GraphicsConfiguration config = g.getDeviceConfiguration();
    final ImageCache cache = ImageCache.getInstance();
    final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
                                                bounds, controlState);
    Image img = cache.getImage(key);
    if (img == null) {
        img = new MultiResolutionCachedImage(imgW, imgH,
                (rvWidth, rvHeight) -> createImage(imgX, imgY,
                 rvWidth, rvHeight, bounds, control, controlState));

        if (!controlState.is(JRSUIConstants.Animating.YES)) {
            cache.setImage(key, img);
        }
    }

    g.drawImage(img, imgX, imgY, imgW, imgH, null);
}