author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 26601 | 2713482c0fd3 |
permissions | -rw-r--r-- |
26601
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
1 |
/* |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
4 |
* |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
8 |
* |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
13 |
* accompanied this code). |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
14 |
* |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
18 |
* |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
21 |
* questions. |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
22 |
*/ |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
23 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
24 |
import javax.swing.*; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
25 |
import javax.swing.border.EmptyBorder; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
26 |
import java.awt.*; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
27 |
import java.awt.event.*; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
28 |
import java.awt.geom.Area; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
29 |
import java.awt.geom.Rectangle2D; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
30 |
import java.awt.image.BufferedImage; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
31 |
import java.security.SecureRandom; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
32 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
33 |
public abstract class Common { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
34 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
35 |
ExtendedRobot robot; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
36 |
Class<? extends JFrame> windowClass; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
37 |
JFrame background; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
38 |
BufferedImage foreground; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
39 |
Window window; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
40 |
volatile boolean gradientBackgroundEnabled = false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
41 |
volatile int gradientWidth = 255; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
42 |
volatile int gradientHeight = 255; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
43 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
44 |
float opacity = 1.0f; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
45 |
float perPixelTranslucency = 1.0f; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
46 |
static Color BG_COLOR = Color.BLUE; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
47 |
static Color FG_COLOR = Color.RED; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
48 |
static final int delay = 1000; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
49 |
static final SecureRandom random = new SecureRandom(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
50 |
static final int dl = 100; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
51 |
static final Class[] WINDOWS_TO_TEST = { JWindow.class, JFrame.class, JDialog.class }; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
52 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
53 |
volatile int clicked; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
54 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
55 |
public Common(Class windowClass, float opacity, float perPixelTranslucency, boolean gradient) throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
56 |
this.gradientBackgroundEnabled = gradient; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
57 |
this.perPixelTranslucency = perPixelTranslucency; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
58 |
this.opacity = opacity; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
59 |
robot = new ExtendedRobot(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
60 |
this.windowClass = windowClass; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
61 |
EventQueue.invokeAndWait(this::initBackgroundFrame); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
62 |
EventQueue.invokeAndWait(this::initGUI); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
63 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
64 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
65 |
public Common(Class windowClass) throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
66 |
this(windowClass, 1.0f, 1.0f, false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
67 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
68 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
69 |
public Common(Class windowClass, boolean gradient) throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
70 |
this(windowClass, 1.0f, 1.0f, gradient); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
71 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
72 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
73 |
public abstract void doTest() throws Exception; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
74 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
75 |
public void dispose() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
76 |
window.dispose(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
77 |
background.dispose(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
78 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
79 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
80 |
public void applyShape() {}; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
81 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
82 |
public void applyDynamicShape() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
83 |
final Area a = new Area(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
84 |
Dimension size = window.getSize(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
85 |
for (int x = 0; x < 3; x++) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
86 |
for (int y = 0; y < 3; y++) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
87 |
a.add(new Area(new Rectangle2D.Double( |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
88 |
x * size.getWidth() / 17*6, y * size.getHeight() / 17*6, |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
89 |
size.getWidth() / 17*5, size.getHeight() / 17*5))); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
90 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
91 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
92 |
window.setShape(a); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
93 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
94 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
95 |
public BufferedImage getForegroundWindow() throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
96 |
final BufferedImage f[] = new BufferedImage[1]; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
97 |
EventQueue.invokeAndWait( () -> { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
98 |
f[0] = new BufferedImage(window.getWidth(), |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
99 |
window.getHeight(), BufferedImage.TYPE_INT_RGB); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
100 |
window.printAll(f[0].createGraphics()); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
101 |
}); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
102 |
robot.waitForIdle(delay); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
103 |
return f[0]; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
104 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
105 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
106 |
public static boolean checkTranslucencyMode(GraphicsDevice.WindowTranslucency mode) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
107 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
108 |
if (!GraphicsEnvironment |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
109 |
.getLocalGraphicsEnvironment() |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
110 |
.getDefaultScreenDevice() |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
111 |
.isWindowTranslucencySupported(mode)){ |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
112 |
System.out.println(mode+" translucency mode isn't supported"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
113 |
return false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
114 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
115 |
return true; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
116 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
117 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
118 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
119 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
120 |
public void applyAppDragNResizeSupport() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
121 |
MouseAdapter m = new MouseAdapter() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
122 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
123 |
private Point dragOrigin = null; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
124 |
private Dimension origSize = null; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
125 |
private Point origLoc = null; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
126 |
private boolean left = false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
127 |
private boolean top = false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
128 |
private boolean bottom = false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
129 |
private boolean right = false; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
130 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
131 |
public void mousePressed(MouseEvent e) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
132 |
dragOrigin = e.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
133 |
origSize = window.getSize(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
134 |
origLoc = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
135 |
right = (origLoc.x + window.getWidth() - dragOrigin.x) < 5; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
136 |
left = !right && dragOrigin.x - origLoc.x < 5; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
137 |
bottom = (origLoc.y + window.getHeight() - dragOrigin.y) < 5; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
138 |
top = !bottom && dragOrigin.y - origLoc.y < 5; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
139 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
140 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
141 |
public void mouseReleased(MouseEvent e) { resize(e); } |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
142 |
public void mouseDragged(MouseEvent e) { resize(e); } |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
143 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
144 |
void resize(MouseEvent e) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
145 |
Point dragDelta = e.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
146 |
dragDelta.translate(-dragOrigin.x, -dragOrigin.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
147 |
Point newLoc = new Point(origLoc); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
148 |
newLoc.translate(dragDelta.x, dragDelta.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
149 |
Dimension newSize = new Dimension(origSize); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
150 |
if (left || right) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
151 |
newSize.width += right ? dragDelta.x : -dragDelta.x; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
152 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
153 |
if (top || bottom) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
154 |
newSize.height += bottom ? dragDelta.y : -dragDelta.y; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
155 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
156 |
if (right || (top || bottom) && !left) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
157 |
newLoc.x = origLoc.x; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
158 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
159 |
if (bottom || (left || right) && !top) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
160 |
newLoc.y = origLoc.y; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
161 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
162 |
window.setBounds(newLoc.x, newLoc.y, newSize.width, newSize.height); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
163 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
164 |
}; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
165 |
for (Component comp : window.getComponents()) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
166 |
comp.addMouseListener(m); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
167 |
comp.addMouseMotionListener(m); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
168 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
169 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
170 |
window.addMouseListener(m); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
171 |
window.addMouseMotionListener(m); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
172 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
173 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
174 |
public void checkTranslucentShape() throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
175 |
foreground = getForegroundWindow(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
176 |
Point[] points = new Point[4]; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
177 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
178 |
Dimension size = window.getSize(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
179 |
Point location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
180 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
181 |
points[0] = new Point(20, 20); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
182 |
points[1] = new Point(20, size.height-20); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
183 |
points[2] = new Point(size.width-20, 20); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
184 |
points[3] = new Point(size.width-20, size.height-20); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
185 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
186 |
for (Point p : points){ |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
187 |
p.translate(location.x, location.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
188 |
Color actual = robot.getPixelColor(p.x, p.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
189 |
if (actual.equals(BG_COLOR)|| actual.equals(FG_COLOR)) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
190 |
throw new RuntimeException("Error in point "+p+": "+actual+" equals to foreground or background color"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
191 |
else |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
192 |
System.out.println("OK with foreground point "+p); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
193 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
194 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
195 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
196 |
public void checkDynamicShape() throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
197 |
Point[] points = new Point[4]; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
198 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
199 |
Dimension size = window.getSize(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
200 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
201 |
int blockSizeX = (int) (size.getWidth() / 17); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
202 |
int blockSizeY = (int) (size.getHeight() / 17); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
203 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
204 |
// background |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
205 |
points[0] = new Point((int) (blockSizeX * 5.5), (int) (blockSizeY * 5.5)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
206 |
points[1] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
207 |
points[2] = new Point((int) (blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
208 |
points[3] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (blockSizeY * 5.5)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
209 |
checkShape(points, true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
210 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
211 |
// foreground |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
212 |
if (opacity < 1.0f){ |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
213 |
checkTranslucentShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
214 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
215 |
points[0] = new Point(3 * blockSizeX, 3 * blockSizeY); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
216 |
points[1] = new Point(14 * blockSizeX, 14 * blockSizeY); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
217 |
points[2] = new Point(3 * blockSizeX, 14 * blockSizeY); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
218 |
points[3] = new Point(14 * blockSizeX, 3 * blockSizeY); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
219 |
checkShape(points, false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
220 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
221 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
222 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
223 |
public void checkShape(Point[] points, boolean areBackgroundPoints) throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
224 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
225 |
Point location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
226 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
227 |
for (Point p : points) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
228 |
p.translate(location.x, location.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
229 |
Color pixel = robot.getPixelColor(p.x, p.y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
230 |
if (areBackgroundPoints) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
231 |
if (pixel.getRed() != 0 |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
232 |
|| pixel.getGreen() != 0 ) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
233 |
throw new RuntimeException("Background point " + p + |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
234 |
" color " + pixel + |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
235 |
" does not equal to background color " + BG_COLOR); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
236 |
else |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
237 |
System.out.println("OK with background point " + p); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
238 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
239 |
if (pixel.equals(BG_COLOR)) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
240 |
throw new RuntimeException("Foreground point " + p + |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
241 |
" color " + pixel + |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
242 |
" equals to background color " + BG_COLOR); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
243 |
else |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
244 |
System.out.println("OK with foreground point " + p); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
245 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
246 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
247 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
248 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
249 |
public void initBackgroundFrame() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
250 |
background = new JFrame(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
251 |
background.setUndecorated(true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
252 |
background.getContentPane().setBackground(BG_COLOR); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
253 |
background.setSize(500, 500); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
254 |
background.setLocation(dl, dl); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
255 |
background.setVisible(true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
256 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
257 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
258 |
public void initGUI() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
259 |
Container contentPane; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
260 |
if (windowClass.equals(Frame.class)) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
261 |
window = new JFrame(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
262 |
((JFrame) window).setUndecorated(true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
263 |
contentPane = ((JFrame) window).getContentPane(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
264 |
} else if (windowClass.equals(Dialog.class)) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
265 |
window = new JDialog(background); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
266 |
((JDialog) window).setUndecorated(true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
267 |
contentPane = ((JDialog) window).getContentPane(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
268 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
269 |
window = new JWindow(background); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
270 |
contentPane = ((JWindow) window).getContentPane(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
271 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
272 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
273 |
if (perPixelTranslucency < 1.0f) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
274 |
contentPane.setBackground(colorWithOpacity(FG_COLOR, perPixelTranslucency)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
275 |
window.setBackground(colorWithOpacity(FG_COLOR, perPixelTranslucency)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
276 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
277 |
contentPane.setBackground(FG_COLOR); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
278 |
window.setBackground(FG_COLOR); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
279 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
280 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
281 |
window.setLocation(2 * dl, 2 * dl); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
282 |
window.setSize(255, 255); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
283 |
window.setPreferredSize(new Dimension(255, 255)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
284 |
createSwingComponents(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
285 |
if (opacity < 1.0f) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
286 |
window.setOpacity(opacity); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
287 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
288 |
window.addComponentListener(new ComponentAdapter() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
289 |
@Override |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
290 |
public void componentResized(ComponentEvent e) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
291 |
applyShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
292 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
293 |
}); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
294 |
applyShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
295 |
window.setVisible(true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
296 |
applyAppDragNResizeSupport(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
297 |
window.toFront(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
298 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
299 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
300 |
public void createSwingComponents() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
301 |
Container contentPane; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
302 |
if (gradientBackgroundEnabled) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
303 |
JPanel jPanel = new JPanel() { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
304 |
@Override |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
305 |
protected void paintComponent(Graphics g) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
306 |
if (g instanceof Graphics2D) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
307 |
Color background = Color.RED; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
308 |
Paint p = new GradientPaint(0.0f, 0.0f, colorWithOpacity(background, 0), |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
309 |
0.0f, gradientHeight - 3, colorWithOpacity(background, 1), true); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
310 |
Graphics2D g2d = (Graphics2D) g; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
311 |
g2d.setPaint(p); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
312 |
g2d.fillRect(0, 3, gradientWidth, gradientHeight - 3); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
313 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
314 |
super.paintComponent(g); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
315 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
316 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
317 |
}; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
318 |
jPanel.setBorder(new EmptyBorder(15, 5, 5, 5)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
319 |
jPanel.setOpaque(false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
320 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
321 |
contentPane = jPanel; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
322 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
323 |
RootPaneContainer.class.cast(window).setContentPane(contentPane); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
324 |
} else { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
325 |
contentPane = RootPaneContainer.class.cast(window).getContentPane(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
326 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
327 |
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
328 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
329 |
JButton button = new JButton("JButton"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
330 |
window.add(button); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
331 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
332 |
JTextArea textArea = new JTextArea("JTextArea"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
333 |
window.add(textArea); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
334 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
335 |
JCheckBox checkbox = new JCheckBox("JCheckBox"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
336 |
checkbox.setOpaque(false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
337 |
window.add(checkbox); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
338 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
339 |
JComboBox comboBox = new JComboBox(new String[]{"JComboBox", "Some item"}); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
340 |
window.add(comboBox); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
341 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
342 |
JLabel label = new JLabel("JLabel"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
343 |
window.add(label); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
344 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
345 |
JTextField textField = new JTextField("JTextField"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
346 |
window.add(textField); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
347 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
348 |
JPanel panel = new JPanel(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
349 |
panel.setOpaque(false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
350 |
window.add(panel); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
351 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
352 |
JComboBox comboBox2 = new JComboBox(new String[]{"JComboBox2", "Another item"}); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
353 |
window.add(comboBox2); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
354 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
355 |
JRadioButton radioButton = new JRadioButton("JRadioButton"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
356 |
radioButton.setOpaque(false); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
357 |
window.add(radioButton); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
358 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
359 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
360 |
Color colorWithOpacity(Color color, float opacity) { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
361 |
return new Color(color.getColorSpace(), color.getColorComponents(null), opacity); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
362 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
363 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
364 |
public void checkTranslucent() throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
365 |
checkTranslucentShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
366 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
367 |
// Drag |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
368 |
Point location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
369 |
robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
370 |
robot.waitForIdle(delay); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
371 |
checkTranslucentShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
372 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
373 |
// Resize |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
374 |
location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
375 |
robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
376 |
robot.waitForIdle(delay); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
377 |
checkTranslucentShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
378 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
379 |
EventQueue.invokeAndWait(this::dispose); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
380 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
381 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
382 |
public void checkDynamic() throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
383 |
checkDynamicShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
384 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
385 |
// Drag |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
386 |
Point location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
387 |
robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
388 |
robot.waitForIdle(delay); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
389 |
checkDynamicShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
390 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
391 |
// Resize |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
392 |
location = window.getLocationOnScreen(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
393 |
robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
394 |
robot.waitForIdle(delay); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
395 |
checkDynamicShape(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
396 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
397 |
EventQueue.invokeAndWait(this::dispose); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
398 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
399 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
400 |
void checkClick(int x, int y, int flag) throws Exception { |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
401 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
402 |
System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger."); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
403 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
404 |
clicked = 0; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
405 |
robot.mouseMove(x, y); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
406 |
robot.click(); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
407 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
408 |
for (int i = 0; i < 100; i++) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
409 |
if ((clicked & (1 << flag)) == 0) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
410 |
robot.delay(50); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
411 |
else |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
412 |
break; |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
413 |
|
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
414 |
if ((clicked & (1 << flag)) == 0) |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
415 |
throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!"); |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
416 |
} |
2713482c0fd3
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff
changeset
|
417 |
} |