Search in sources :

Example 1 with MultiResolutionImage

use of java.awt.image.MultiResolutionImage in project jdk8u_jdk by JetBrains.

the class BaseMultiResolutionImageTest method testRVSizes.

static void testRVSizes() {
    int imageSize = getSize(1);
    double[][] sizeArray = { { -imageSize, imageSize }, { 2 * imageSize, -2 * imageSize }, { Double.POSITIVE_INFINITY, imageSize }, { Double.POSITIVE_INFINITY, -imageSize }, { imageSize, Double.NEGATIVE_INFINITY }, { -imageSize, Double.NEGATIVE_INFINITY }, { Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY }, { Double.NaN, imageSize }, { imageSize, Double.NaN }, { Double.NaN, Double.NaN }, { Double.POSITIVE_INFINITY, Double.NaN } };
    for (double[] sizes : sizeArray) {
        try {
            MultiResolutionImage mrImage = new BaseMultiResolutionImage(0, createRVImage(0), createRVImage(1));
            mrImage.getResolutionVariant(sizes[0], sizes[1]);
        } catch (IllegalArgumentException ignored) {
            continue;
        }
        throw new RuntimeException("IllegalArgumentException is not thrown!");
    }
}
Also used : BaseMultiResolutionImage(java.awt.image.BaseMultiResolutionImage) MultiResolutionImage(java.awt.image.MultiResolutionImage) BaseMultiResolutionImage(java.awt.image.BaseMultiResolutionImage)

Example 2 with MultiResolutionImage

use of java.awt.image.MultiResolutionImage in project jdk8u_jdk by JetBrains.

the class NSImageToMultiResolutionImageTest method main.

public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        return;
    }
    String icon = "NSImage://NSApplicationIcon";
    final Image image = Toolkit.getDefaultToolkit().getImage(icon);
    if (!(image instanceof MultiResolutionImage)) {
        throw new RuntimeException("Icon does not have resolution variants!");
    }
    MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;
    int width = 0;
    int height = 0;
    for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
        int rvWidth = resolutionVariant.getWidth(null);
        int rvHeight = resolutionVariant.getHeight(null);
        if (rvWidth < width || rvHeight < height) {
            throw new RuntimeException("Resolution variants are not sorted!");
        }
        width = rvWidth;
        height = rvHeight;
    }
}
Also used : MultiResolutionImage(java.awt.image.MultiResolutionImage) Image(java.awt.Image) MultiResolutionImage(java.awt.image.MultiResolutionImage)

Example 3 with MultiResolutionImage

use of java.awt.image.MultiResolutionImage in project jdk8u_jdk by JetBrains.

the class MultiResolutionDisabledImageTest method main.

public static void main(String[] args) throws Exception {
    Image baseMRImage = new BaseMultiResolutionImage(createImage(1), createImage(2));
    testMRDisabledImage(baseMRImage);
    saveImages();
    Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X);
    if (toolkitMRImage instanceof MultiResolutionImage) {
        testMRDisabledImage(toolkitMRImage);
    }
}
Also used : BaseMultiResolutionImage(java.awt.image.BaseMultiResolutionImage) MultiResolutionImage(java.awt.image.MultiResolutionImage) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BaseMultiResolutionImage(java.awt.image.BaseMultiResolutionImage) MultiResolutionImage(java.awt.image.MultiResolutionImage) BaseMultiResolutionImage(java.awt.image.BaseMultiResolutionImage)

Example 4 with MultiResolutionImage

use of java.awt.image.MultiResolutionImage in project jdk8u_jdk by JetBrains.

the class PostEventQueue method getImageWithResolutionVariant.

protected Image getImageWithResolutionVariant(URL url, URL resolutionVariantURL) {
    synchronized (urlImgCache) {
        Image image = getImageFromHash(this, url);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantURL);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        String key = url.toString();
        urlImgCache.put(key, image);
        return image;
    }
}
Also used : MultiResolutionImage(java.awt.image.MultiResolutionImage) MultiResolutionImage(java.awt.image.MultiResolutionImage)

Example 5 with MultiResolutionImage

use of java.awt.image.MultiResolutionImage in project jdk8u_jdk by JetBrains.

the class PostEventQueue method getImageWithResolutionVariant.

protected Image getImageWithResolutionVariant(String fileName, String resolutionVariantName) {
    synchronized (fileImgCache) {
        Image image = getImageFromHash(this, fileName);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        fileImgCache.put(fileName, image);
        return image;
    }
}
Also used : MultiResolutionImage(java.awt.image.MultiResolutionImage) MultiResolutionImage(java.awt.image.MultiResolutionImage)

Aggregations

MultiResolutionImage (java.awt.image.MultiResolutionImage)10 Image (java.awt.Image)7 BufferedImage (java.awt.image.BufferedImage)6 MediaTracker (java.awt.MediaTracker)2 AffineTransform (java.awt.geom.AffineTransform)2 BaseMultiResolutionImage (java.awt.image.BaseMultiResolutionImage)2 RenderedImage (java.awt.image.RenderedImage)2 VolatileImage (java.awt.image.VolatileImage)2 RenderableImage (java.awt.image.renderable.RenderableImage)2 JPanel (javax.swing.JPanel)2 MultiResolutionToolkitImage (sun.awt.image.MultiResolutionToolkitImage)2 ToolkitImage (sun.awt.image.ToolkitImage)2 GradientPaint (java.awt.GradientPaint)1 Graphics2D (java.awt.Graphics2D)1 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 TexturePaint (java.awt.TexturePaint)1 ImageObserver (java.awt.image.ImageObserver)1