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!");
}
}
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;
}
}
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);
}
}
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;
}
}
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;
}
}
Aggregations