author | rchamyal |
Thu, 24 Mar 2016 14:06:32 +0530 | |
changeset 36907 | c3d8383e3efb |
parent 31448 | 1066345d2a8a |
child 39035 | 84023829c647 |
permissions | -rw-r--r-- |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
1 |
/* |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
30474
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
4 |
* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
8 |
* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
14 |
* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
18 |
* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
21 |
* questions. |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
22 |
*/ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
23 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
24 |
import java.awt.Color; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
25 |
import java.awt.Dialog; |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
26 |
import java.awt.Frame; |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
27 |
import java.awt.Graphics; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
28 |
import java.awt.Graphics2D; |
36907 | 29 |
import java.awt.GraphicsEnvironment; |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
30 |
import java.awt.Panel; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
31 |
import java.awt.Rectangle; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
32 |
import java.awt.Robot; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
33 |
import java.awt.SplashScreen; |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
34 |
import java.awt.TextField; |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
35 |
import java.awt.Window; |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
36 |
import java.awt.event.KeyEvent; |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
37 |
import java.awt.image.BufferedImage; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
38 |
import java.io.File; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
39 |
import javax.imageio.ImageIO; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
40 |
import sun.java2d.SunGraphics2D; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
41 |
|
36907 | 42 |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
43 |
/** |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
44 |
* @test |
36907 | 45 |
* @bug 8043869 8075244 8078082 8145173 |
46 |
* @summary Tests the HiDPI splash screen support for windows and MAC |
|
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
30474
diff
changeset
|
47 |
* @modules java.desktop/sun.java2d |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
48 |
* @run main MultiResolutionSplashTest GENERATE_IMAGES |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
49 |
* @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_SPLASH 0 |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
50 |
* @run main/othervm -splash:splash2 MultiResolutionSplashTest TEST_SPLASH 1 |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
51 |
* @run main/othervm -splash:splash3. MultiResolutionSplashTest TEST_SPLASH 2 |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
52 |
* @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_FOCUS |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
53 |
*/ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
54 |
public class MultiResolutionSplashTest { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
55 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
56 |
private static final int IMAGE_WIDTH = 300; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
57 |
private static final int IMAGE_HEIGHT = 200; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
58 |
|
36907 | 59 |
private static final ImageInfo[] macTests = { |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
60 |
new ImageInfo("splash1.png", "splash1@2x.png", Color.BLUE, Color.GREEN), |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
61 |
new ImageInfo("splash2", "splash2@2x", Color.WHITE, Color.BLACK), |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
62 |
new ImageInfo("splash3.", "splash3@2x.", Color.YELLOW, Color.RED) |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
63 |
}; |
36907 | 64 |
private static final ImageInfo[] windowsTests = { |
65 |
new ImageInfo("splash1.png", "splash1.scale-120.png", Color.BLUE, Color.GREEN), |
|
66 |
new ImageInfo("splash2", "splash2.scale-120", Color.WHITE, Color.BLACK), |
|
67 |
new ImageInfo("splash3.", "splash3.scale-120.", Color.YELLOW, Color.RED) |
|
68 |
}; |
|
69 |
private static ImageInfo[] tests; |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
70 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
71 |
public static void main(String[] args) throws Exception { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
72 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
73 |
String test = args[0]; |
36907 | 74 |
tests = windowsTests; |
75 |
String osName = System.getProperty("os.name"); |
|
76 |
if (osName.contains("OS X")) { |
|
77 |
tests = macTests; |
|
78 |
} |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
79 |
switch (test) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
80 |
case "GENERATE_IMAGES": |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
81 |
generateImages(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
82 |
break; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
83 |
case "TEST_SPLASH": |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
84 |
int index = Integer.parseInt(args[1]); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
85 |
testSplash(tests[index]); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
86 |
break; |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
87 |
case "TEST_FOCUS": |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
88 |
testFocus(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
89 |
break; |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
90 |
default: |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
91 |
throw new RuntimeException("Unknown test: " + test); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
92 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
93 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
94 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
95 |
static void testSplash(ImageInfo test) throws Exception { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
96 |
SplashScreen splashScreen = SplashScreen.getSplashScreen(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
97 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
98 |
if (splashScreen == null) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
99 |
throw new RuntimeException("Splash screen is not shown!"); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
100 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
101 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
102 |
Graphics2D g = splashScreen.createGraphics(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
103 |
Rectangle splashBounds = splashScreen.getBounds(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
104 |
int screenX = (int) splashBounds.getCenterX(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
105 |
int screenY = (int) splashBounds.getCenterY(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
106 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
107 |
Robot robot = new Robot(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
108 |
Color splashScreenColor = robot.getPixelColor(screenX, screenY); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
109 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
110 |
float scaleFactor = getScaleFactor(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
111 |
Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
112 |
|
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
113 |
if (!compare(testColor, splashScreenColor)) { |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
114 |
throw new RuntimeException( |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
115 |
"Image with wrong resolution is used for splash screen!"); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
116 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
117 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
118 |
|
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
119 |
static void testFocus() throws Exception { |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
120 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
121 |
System.out.println("Focus Test!"); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
122 |
Robot robot = new Robot(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
123 |
robot.setAutoDelay(50); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
124 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
125 |
Frame frame = new Frame(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
126 |
frame.setSize(100, 100); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
127 |
String test = "123"; |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
128 |
TextField textField = new TextField(test); |
30474
afc246c255e1
8078082: [TEST_BUG] java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java fails
pchopra
parents:
29736
diff
changeset
|
129 |
textField.selectAll(); |
29736
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
130 |
frame.add(textField); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
131 |
frame.setVisible(true); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
132 |
robot.waitForIdle(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
133 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
134 |
robot.keyPress(KeyEvent.VK_A); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
135 |
robot.keyRelease(KeyEvent.VK_A); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
136 |
robot.keyPress(KeyEvent.VK_B); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
137 |
robot.keyRelease(KeyEvent.VK_B); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
138 |
robot.waitForIdle(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
139 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
140 |
frame.dispose(); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
141 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
142 |
if(!textField.getText().equals("ab")){ |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
143 |
throw new RuntimeException("Focus is lost!"); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
144 |
} |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
145 |
} |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
146 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
147 |
static boolean compare(Color c1, Color c2){ |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
148 |
return compare(c1.getRed(), c2.getRed()) |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
149 |
&& compare(c1.getGreen(), c2.getGreen()) |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
150 |
&& compare(c1.getBlue(), c2.getBlue()); |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
151 |
} |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
152 |
|
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
153 |
static boolean compare(int n, int m){ |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
154 |
return Math.abs(n - m) <= 50; |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
155 |
} |
83a76fe84763
8075244: [macosx] The fix for JDK-8043869 should be reworked
alexsch
parents:
29726
diff
changeset
|
156 |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
157 |
static float getScaleFactor() { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
158 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
159 |
final Dialog dialog = new Dialog((Window) null); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
160 |
dialog.setSize(100, 100); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
161 |
dialog.setModal(true); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
162 |
final float[] scaleFactors = new float[1]; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
163 |
Panel panel = new Panel() { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
164 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
165 |
@Override |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
166 |
public void paint(Graphics g) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
167 |
float scaleFactor = 1; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
168 |
if (g instanceof SunGraphics2D) { |
36907 | 169 |
scaleFactor = (float)GraphicsEnvironment. |
170 |
getLocalGraphicsEnvironment(). |
|
171 |
getDefaultScreenDevice().getDefaultConfiguration(). |
|
172 |
getDefaultTransform().getScaleX(); |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
173 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
174 |
scaleFactors[0] = scaleFactor; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
175 |
dialog.setVisible(false); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
176 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
177 |
}; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
178 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
179 |
dialog.add(panel); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
180 |
dialog.setVisible(true); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
181 |
dialog.dispose(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
182 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
183 |
return scaleFactors[0]; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
184 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
185 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
186 |
static void generateImages() throws Exception { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
187 |
for (ImageInfo test : tests) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
188 |
generateImage(test.name1x, test.color1x, 1); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
189 |
generateImage(test.name2x, test.color2x, 2); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
190 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
191 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
192 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
193 |
static void generateImage(String name, Color color, int scale) throws Exception { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
194 |
File file = new File(name); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
195 |
if (file.exists()) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
196 |
return; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
197 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
198 |
BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT, |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
199 |
BufferedImage.TYPE_INT_RGB); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
200 |
Graphics g = image.getGraphics(); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
201 |
g.setColor(color); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
202 |
g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
203 |
ImageIO.write(image, "png", file); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
204 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
205 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
206 |
static class ImageInfo { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
207 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
208 |
final String name1x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
209 |
final String name2x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
210 |
final Color color1x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
211 |
final Color color2x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
212 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
213 |
public ImageInfo(String name1x, String name2x, Color color1x, Color color2x) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
214 |
this.name1x = name1x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
215 |
this.name2x = name2x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
216 |
this.color1x = color1x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
217 |
this.color2x = color2x; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
218 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
219 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
diff
changeset
|
220 |
} |