11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.awt.Color;
25 import java.awt.Graphics;
26 import java.awt.Image;
27 import java.awt.Toolkit;
28 import java.awt.image.BufferedImage;
29 import java.awt.image.ImageObserver;
30 import static java.awt.image.ImageObserver.ALLBITS;
31 import java.io.File;
32 import javax.imageio.ImageIO;
33 import sun.awt.OSInfo;
34 import sun.awt.SunToolkit;
35 import sun.awt.image.MultiResolutionToolkitImage;
36
37 /**
38 * @test
39 * @bug 8040291
40 * @author Alexander Scherbatiy
41 * @summary [macosx] Http-Images are not fully loaded when using ImageIcon
42 * @modules java.desktop/sun.awt
43 * java.desktop/sun.awt.image
44 * @run main MultiResolutionToolkitImageTest
45 */
46 public class MultiResolutionToolkitImageTest {
47
48 private static final int IMAGE_WIDTH = 300;
49 private static final int IMAGE_HEIGHT = 200;
50 private static final Color COLOR_1X = Color.GREEN;
138 Exception e = new Exception();
139
140 for (StackTraceElement elem : e.getStackTrace()) {
141 if (elem.getClassName().endsWith("MultiResolutionToolkitImage")) {
142 return true;
143 }
144 }
145 return false;
146 }
147
148 static class IdleImageObserver implements ImageObserver {
149
150 @Override
151 public boolean imageUpdate(Image img, int infoflags, int x, int y,
152 int width, int height) {
153 return false;
154 }
155 }
156
157 static Image getResolutionVariant(Image image) {
158 return ((MultiResolutionToolkitImage) image).getResolutionVariant();
159 }
160 }
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.awt.Color;
25 import java.awt.Graphics;
26 import java.awt.Image;
27 import java.awt.Toolkit;
28 import java.awt.image.BufferedImage;
29 import java.awt.image.ImageObserver;
30 import static java.awt.image.ImageObserver.ALLBITS;
31 import java.awt.image.MultiResolutionImage;
32 import java.io.File;
33 import javax.imageio.ImageIO;
34 import sun.awt.OSInfo;
35 import sun.awt.SunToolkit;
36 import sun.awt.image.MultiResolutionToolkitImage;
37
38 /**
39 * @test
40 * @bug 8040291
41 * @author Alexander Scherbatiy
42 * @summary [macosx] Http-Images are not fully loaded when using ImageIcon
43 * @modules java.desktop/sun.awt
44 * java.desktop/sun.awt.image
45 * @run main MultiResolutionToolkitImageTest
46 */
47 public class MultiResolutionToolkitImageTest {
48
49 private static final int IMAGE_WIDTH = 300;
50 private static final int IMAGE_HEIGHT = 200;
51 private static final Color COLOR_1X = Color.GREEN;
139 Exception e = new Exception();
140
141 for (StackTraceElement elem : e.getStackTrace()) {
142 if (elem.getClassName().endsWith("MultiResolutionToolkitImage")) {
143 return true;
144 }
145 }
146 return false;
147 }
148
149 static class IdleImageObserver implements ImageObserver {
150
151 @Override
152 public boolean imageUpdate(Image img, int infoflags, int x, int y,
153 int width, int height) {
154 return false;
155 }
156 }
157
158 static Image getResolutionVariant(Image image) {
159 return ((MultiResolutionImage) image).getResolutionVariants().get(1);
160 }
161 }
|