sun.awt.image.ImageCache Java Examples

The following examples show how to use sun.awt.image.ImageCache. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AquaPainter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: AquaPainter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: AquaPainter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: AquaPainter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: AquaPainter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: AquaPainter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: AquaPainter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: AquaPainter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: AquaPainter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: AquaPainter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #11
Source File: AquaPainter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}