author | yan |
Tue, 23 Jun 2015 11:59:27 +0300 | |
changeset 31448 | 1066345d2a8a |
parent 25107 | 9a16a601de25 |
child 46151 | 5fa789776f7d |
permissions | -rw-r--r-- |
25107
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
1 |
/* |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
25107
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25107
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
4 |
* |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
8 |
* |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
14 |
* |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
18 |
* |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
21 |
* questions. |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
22 |
*/ |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
23 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
24 |
import java.awt.Color; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
25 |
import java.awt.Graphics; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
26 |
import java.awt.Image; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
27 |
import java.awt.Toolkit; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
28 |
import java.awt.image.BufferedImage; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
29 |
import java.awt.image.ImageObserver; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
30 |
import static java.awt.image.ImageObserver.ALLBITS; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
31 |
import java.io.File; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
32 |
import javax.imageio.ImageIO; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
33 |
import sun.awt.OSInfo; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
34 |
import sun.awt.SunToolkit; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
35 |
import sun.awt.image.MultiResolutionToolkitImage; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
36 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
37 |
/** |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
38 |
* @test |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
39 |
* @bug 8040291 |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
40 |
* @author Alexander Scherbatiy |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
41 |
* @summary [macosx] Http-Images are not fully loaded when using ImageIcon |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
25107
diff
changeset
|
42 |
* @modules java.desktop/sun.awt |
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
25107
diff
changeset
|
43 |
* java.desktop/sun.awt.image |
25107
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
44 |
* @run main MultiResolutionToolkitImageTest |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
45 |
*/ |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
46 |
public class MultiResolutionToolkitImageTest { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
47 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
48 |
private static final int IMAGE_WIDTH = 300; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
49 |
private static final int IMAGE_HEIGHT = 200; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
50 |
private static final Color COLOR_1X = Color.GREEN; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
51 |
private static final Color COLOR_2X = Color.BLUE; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
52 |
private static final String IMAGE_NAME_1X = "image.png"; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
53 |
private static final String IMAGE_NAME_2X = "image@2x.png"; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
54 |
private static final int WAIT_TIME = 400; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
55 |
private static volatile boolean isImageLoaded = false; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
56 |
private static volatile boolean isRVObserverCalled = false; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
57 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
58 |
public static void main(String[] args) throws Exception { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
59 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
60 |
if (!checkOS()) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
61 |
return; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
62 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
63 |
generateImages(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
64 |
testToolkitMultiResolutionImageLoad(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
65 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
66 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
67 |
static void testToolkitMultiResolutionImageLoad() throws Exception { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
68 |
File imageFile = new File(IMAGE_NAME_1X); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
69 |
String fileName = imageFile.getAbsolutePath(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
70 |
Image image = Toolkit.getDefaultToolkit().getImage(fileName); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
71 |
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
72 |
toolkit.prepareImage(image, -1, -1, new LoadImageObserver()); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
73 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
74 |
final long time = WAIT_TIME + System.currentTimeMillis(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
75 |
while ((!isImageLoaded || !isRVObserverCalled) |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
76 |
&& System.currentTimeMillis() < time) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
77 |
Thread.sleep(50); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
78 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
79 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
80 |
if(!isImageLoaded){ |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
81 |
throw new RuntimeException("Image is not loaded!"); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
82 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
83 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
84 |
if(!isRVObserverCalled){ |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
85 |
throw new RuntimeException("Resolution Variant observer is not called!"); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
86 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
87 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
88 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
89 |
static void generateImages() throws Exception { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
90 |
if (!new File(IMAGE_NAME_1X).exists()) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
91 |
generateImage(1); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
92 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
93 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
94 |
if (!new File(IMAGE_NAME_2X).exists()) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
95 |
generateImage(2); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
96 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
97 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
98 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
99 |
static void generateImage(int scale) throws Exception { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
100 |
BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT, |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
101 |
BufferedImage.TYPE_INT_RGB); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
102 |
Graphics g = image.getGraphics(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
103 |
g.setColor(scale == 1 ? COLOR_1X : COLOR_2X); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
104 |
g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
105 |
File file = new File(scale == 1 ? IMAGE_NAME_1X : IMAGE_NAME_2X); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
106 |
ImageIO.write(image, "png", file); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
107 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
108 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
109 |
static boolean checkOS() { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
110 |
return OSInfo.getOSType() == OSInfo.OSType.MACOSX; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
111 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
112 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
113 |
static class LoadImageObserver implements ImageObserver { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
114 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
115 |
@Override |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
116 |
public boolean imageUpdate(Image img, int infoflags, int x, int y, |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
117 |
int width, int height) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
118 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
119 |
if (isRVObserver()) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
120 |
isRVObserverCalled = true; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
121 |
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
122 |
Image resolutionVariant = getResolutionVariant(img); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
123 |
int rvFlags = toolkit.checkImage(resolutionVariant, width, height, |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
124 |
new IdleImageObserver()); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
125 |
if (rvFlags < infoflags) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
126 |
throw new RuntimeException("Info flags are greater than" |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
127 |
+ " resolution varint info flags"); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
128 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
129 |
} else if ((infoflags & ALLBITS) != 0) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
130 |
isImageLoaded = true; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
131 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
132 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
133 |
return (infoflags & ALLBITS) == 0; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
134 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
135 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
136 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
137 |
static boolean isRVObserver() { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
138 |
Exception e = new Exception(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
139 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
140 |
for (StackTraceElement elem : e.getStackTrace()) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
141 |
if (elem.getClassName().endsWith("MultiResolutionToolkitImage")) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
142 |
return true; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
143 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
144 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
145 |
return false; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
146 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
147 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
148 |
static class IdleImageObserver implements ImageObserver { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
149 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
150 |
@Override |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
151 |
public boolean imageUpdate(Image img, int infoflags, int x, int y, |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
152 |
int width, int height) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
153 |
return false; |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
154 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
155 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
156 |
|
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
157 |
static Image getResolutionVariant(Image image) { |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
158 |
return ((MultiResolutionToolkitImage) image).getResolutionVariant(); |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
159 |
} |
9a16a601de25
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
alexsch
parents:
diff
changeset
|
160 |
} |