sun.awt.image.MultiResolutionCachedImage Java Examples

The following examples show how to use sun.awt.image.MultiResolutionCachedImage. 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: CImage.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #2
Source File: CImage.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #3
Source File: CImage.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #4
Source File: CImage.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #5
Source File: CImage.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #6
Source File: AquaUtils.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #7
Source File: AquaImageFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #8
Source File: AquaUtils.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #9
Source File: AquaImageFactory.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #10
Source File: AquaUtils.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #11
Source File: AquaImageFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #12
Source File: CImage.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    Dimension2D size = nativeGetNSImageSize(ptr);
    final int baseWidth = (int)size.getWidth();
    final int baseHeight = (int)size.getHeight();

    Dimension2D[] sizes = nativeGetNSImageRepresentationSizes(ptr, size.getWidth(), size.getHeight());

    // The image may be represented in the only size which differs from the base one.
    // For instance, the app's dock icon is represented in a Retina-scaled size on Retina.
    // Check if a single represenation has a bigger size and in that case use it as the dest size.
    if (sizes != null && sizes.length == 1 &&
        (sizes[0].getWidth() > baseWidth && sizes[0].getHeight() > baseHeight))
    {
        size = sizes[0];
    }
    final int dstWidth  = (int)size.getWidth();
    final int dstHeight = (int)size.getHeight();


    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(baseWidth, baseHeight, (width, height)
                    -> toImage(dstWidth, dstHeight))
            : new MultiResolutionCachedImage(baseWidth, baseHeight, sizes, (width, height)
                    -> toImage(width, height));
}
 
Example #13
Source File: CImage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #14
Source File: AquaImageFactory.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #15
Source File: AquaUtils.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #16
Source File: AquaImageFactory.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #17
Source File: AquaUtils.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #18
Source File: AquaImageFactory.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #19
Source File: AquaUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #20
Source File: AquaUtils.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #21
Source File: AquaImageFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #22
Source File: CImage.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #23
Source File: AquaUtils.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #24
Source File: AquaImageFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #25
Source File: AquaUtils.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static Image generateLightenedImage(final Image image, final int percent) {
    final GrayFilter filter = new GrayFilter(true, percent);
    return (image instanceof MultiResolutionCachedImage)
            ? ((MultiResolutionCachedImage) image).map(
                    rv -> generateLightenedImage(rv, filter))
            : generateLightenedImage(image, filter);
}
 
Example #26
Source File: AquaImageFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #27
Source File: CImage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
Example #28
Source File: AquaUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static Image map(Image image, ImageFilter filter) {
    if (image instanceof MultiResolutionImage) {
        return MultiResolutionCachedImage
                .map((MultiResolutionImage) image,
                     (img) -> generateFilteredImage(img, filter));
    }
    return generateFilteredImage(image, filter);
}
 
Example #29
Source File: AquaImageFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static IconUIResource getAppIconCompositedOn(final Image background) {

        if (background instanceof MultiResolutionCachedImage) {
            int width = background.getWidth(null);
            Image mrIconImage = ((MultiResolutionCachedImage) background).map(
                    rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
            return new IconUIResource(new ImageIcon(mrIconImage));
        }

        BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
        return new IconUIResource(new ImageIcon(iconImage));
    }
 
Example #30
Source File: CImage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}