author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57928 | f95327be136a |
permissions | -rw-r--r-- |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
1 |
/* |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
2 |
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
4 |
* |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
8 |
* |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
13 |
* accompanied this code). |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
14 |
* |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
18 |
* |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
21 |
* questions. |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
22 |
*/ |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
23 |
|
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
24 |
package com.sun.swingset3.demos.colorchooser; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
25 |
|
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
26 |
import java.awt.*; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
27 |
import java.awt.event.HierarchyEvent; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
28 |
import java.awt.event.HierarchyListener; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
29 |
import java.awt.geom.GeneralPath; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
30 |
import java.awt.image.BufferedImage; |
57928
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
31 |
import java.lang.reflect.InvocationTargetException; |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
32 |
import java.util.Hashtable; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
33 |
import java.util.Map; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
34 |
import javax.swing.*; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
35 |
|
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
36 |
import static com.sun.swingset3.demos.colorchooser.BezierAnimationPanel.BezierColor.*; |
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
37 |
|
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
38 |
/** |
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
39 |
* BezierAnimationPanel |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
40 |
* |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
41 |
* @author Jim Graham |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
42 |
* @author Jeff Dinkins (removed dynamic setting changes, made swing friendly) |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
43 |
* @version 1.16 11/17/05 |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
44 |
*/ |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
45 |
public class BezierAnimationPanel extends JPanel implements Runnable { |
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
46 |
public static enum BezierColor { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
47 |
BACKGROUND, OUTER, GRADIENT_A, GRADIENT_B |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
48 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
49 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
50 |
private final Map<BezierColor, Color> colors = new Hashtable<BezierColor, Color>(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
51 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
52 |
private GradientPaint gradient = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
53 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
54 |
private static final int NUMPTS = 6; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
55 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
56 |
private final float[] animpts = new float[NUMPTS * 2]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
57 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
58 |
private final float[] deltas = new float[NUMPTS * 2]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
59 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
60 |
private BufferedImage img; |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
61 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
62 |
private Thread anim; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
63 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
64 |
private final Object lock = new Object(); |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
65 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
66 |
/** |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
67 |
* BezierAnimationPanel Constructor |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
68 |
*/ |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
69 |
public BezierAnimationPanel() { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
70 |
setOpaque(true); |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
71 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
72 |
colors.put(BACKGROUND, new Color(0, 0, 153)); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
73 |
colors.put(OUTER, new Color(255, 255, 255)); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
74 |
colors.put(GRADIENT_A, new Color(255, 0, 101)); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
75 |
colors.put(GRADIENT_B, new Color(255, 255, 0)); |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
76 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
77 |
addHierarchyListener(new HierarchyListener() { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
78 |
public void hierarchyChanged(HierarchyEvent e) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
79 |
if (isShowing()) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
80 |
start(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
81 |
} else { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
82 |
stop(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
83 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
84 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
85 |
}); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
86 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
87 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
88 |
public Color getBezierColor(BezierColor bezierColor) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
89 |
return colors.get(bezierColor); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
90 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
91 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
92 |
public void setBezierColor(BezierColor bezierColor, Color value) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
93 |
if (value != null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
94 |
colors.put(bezierColor, value); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
95 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
96 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
97 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
98 |
public void start() { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
99 |
Dimension size = getSize(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
100 |
for (int i = 0; i < animpts.length; i += 2) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
101 |
animpts[i] = (float) (Math.random() * size.width); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
102 |
animpts[i + 1] = (float) (Math.random() * size.height); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
103 |
deltas[i] = (float) (Math.random() * 4.0 + 2.0); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
104 |
deltas[i + 1] = (float) (Math.random() * 4.0 + 2.0); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
105 |
if (animpts[i] > size.width / 6.0f) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
106 |
deltas[i] = -deltas[i]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
107 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
108 |
if (animpts[i + 1] > size.height / 6.0f) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
109 |
deltas[i + 1] = -deltas[i + 1]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
110 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
111 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
112 |
anim = new Thread(this); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
113 |
anim.setPriority(Thread.MIN_PRIORITY); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
114 |
anim.start(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
115 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
116 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
117 |
public synchronized void stop() { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
118 |
anim = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
119 |
notify(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
120 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
121 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
122 |
private static void animate(float[] pts, float[] deltas, int index, int limit) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
123 |
float newpt = pts[index] + deltas[index]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
124 |
if (newpt <= 0) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
125 |
newpt = -newpt; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
126 |
deltas[index] = (float) (Math.random() * 3.0 + 2.0); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
127 |
} else if (newpt >= (float) limit) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
128 |
newpt = 2.0f * limit - newpt; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
129 |
deltas[index] = -(float) (Math.random() * 3.0 + 2.0); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
130 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
131 |
pts[index] = newpt; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
132 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
133 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
134 |
public void run() { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
135 |
Thread me = Thread.currentThread(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
136 |
while (getSize().width <= 0) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
137 |
try { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
138 |
Thread.sleep(500); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
139 |
} catch (InterruptedException e) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
140 |
return; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
141 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
142 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
143 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
144 |
Graphics2D g2d = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
145 |
Graphics2D bufferG2D = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
146 |
BasicStroke solid = new BasicStroke(9.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 9.0f); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
147 |
GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
148 |
int rule = AlphaComposite.SRC_OVER; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
149 |
AlphaComposite opaque = AlphaComposite.SrcOver; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
150 |
AlphaComposite blend = AlphaComposite.getInstance(rule, 0.9f); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
151 |
AlphaComposite set = AlphaComposite.Src; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
152 |
Dimension oldSize = getSize(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
153 |
Shape clippath = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
154 |
while (anim == me) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
155 |
Dimension size = getSize(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
156 |
if (size.width != oldSize.width || size.height != oldSize.height) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
157 |
img = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
158 |
clippath = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
159 |
if (bufferG2D != null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
160 |
bufferG2D.dispose(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
161 |
bufferG2D = null; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
162 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
163 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
164 |
oldSize = size; |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
165 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
166 |
if (img == null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
167 |
img = (BufferedImage) createImage(size.width, size.height); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
168 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
169 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
170 |
if (bufferG2D == null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
171 |
bufferG2D = img.createGraphics(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
172 |
bufferG2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
173 |
bufferG2D.setClip(clippath); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
174 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
175 |
g2d = bufferG2D; |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
176 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
177 |
float[] ctrlpts; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
178 |
for (int i = 0; i < animpts.length; i += 2) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
179 |
animate(animpts, deltas, i, size.width); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
180 |
animate(animpts, deltas, i + 1, size.height); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
181 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
182 |
ctrlpts = animpts; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
183 |
int len = ctrlpts.length; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
184 |
gp.reset(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
185 |
float prevx = ctrlpts[len - 2]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
186 |
float prevy = ctrlpts[len - 1]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
187 |
float curx = ctrlpts[0]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
188 |
float cury = ctrlpts[1]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
189 |
float midx = (curx + prevx) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
190 |
float midy = (cury + prevy) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
191 |
gp.moveTo(midx, midy); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
192 |
for (int i = 2; i <= ctrlpts.length; i += 2) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
193 |
float x1 = (midx + curx) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
194 |
float y1 = (midy + cury) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
195 |
prevx = curx; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
196 |
prevy = cury; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
197 |
if (i < ctrlpts.length) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
198 |
curx = ctrlpts[i]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
199 |
cury = ctrlpts[i + 1]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
200 |
} else { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
201 |
curx = ctrlpts[0]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
202 |
cury = ctrlpts[1]; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
203 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
204 |
midx = (curx + prevx) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
205 |
midy = (cury + prevy) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
206 |
float x2 = (prevx + midx) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
207 |
float y2 = (prevy + midy) / 2.0f; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
208 |
gp.curveTo(x1, y1, x2, y2, midx, midy); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
209 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
210 |
gp.closePath(); |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
211 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
212 |
synchronized (lock) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
213 |
g2d.setComposite(set); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
214 |
g2d.setBackground(getBezierColor(BACKGROUND)); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
215 |
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
216 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
217 |
// g2d.clearRect(bounds.x-5, bounds.y-5, bounds.x + bounds.width |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
218 |
// + 5, bounds.y + bounds.height + 5); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
219 |
g2d.clearRect(0, 0, getWidth(), getHeight()); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
220 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
221 |
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
222 |
g2d.setColor(getBezierColor(OUTER)); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
223 |
g2d.setComposite(opaque); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
224 |
g2d.setStroke(solid); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
225 |
g2d.draw(gp); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
226 |
g2d.setPaint(gradient); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
227 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
228 |
Rectangle bounds = gp.getBounds(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
229 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
230 |
gradient = new GradientPaint(bounds.x, bounds.y, getBezierColor(GRADIENT_A), bounds.x + bounds.width, |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
231 |
bounds.y + bounds.height, getBezierColor(GRADIENT_B), true); |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
232 |
|
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
233 |
g2d.setComposite(blend); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
234 |
g2d.fill(gp); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
235 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
236 |
|
57928
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
237 |
try { |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
238 |
SwingUtilities.invokeAndWait(new Runnable() { |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
239 |
@Override |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
240 |
public void run() { |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
241 |
repaint(); |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
242 |
} |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
243 |
}); |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
244 |
} catch (InvocationTargetException | InterruptedException e) { |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
245 |
e.printStackTrace(); |
f95327be136a
8221312: test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java failed
akolarkunnu
parents:
57526
diff
changeset
|
246 |
} |
57526
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
247 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
248 |
if (g2d != null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
249 |
g2d.dispose(); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
250 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
251 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
252 |
|
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
253 |
public void paint(Graphics g) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
254 |
synchronized (lock) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
255 |
Graphics2D g2d = (Graphics2D) g; |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
256 |
if (img != null) { |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
257 |
g2d.setComposite(AlphaComposite.Src); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
258 |
g2d.drawImage(img, null, 0, 0); |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
259 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
260 |
} |
8538b1f28a71
8228479: Correct the format of ColorChooserDemoTest
akolarkunnu
parents:
53672
diff
changeset
|
261 |
} |
53672
f024302abefd
8217235: Create automated test for SwingSet ColorChooserDemoTest
akolarkunnu
parents:
diff
changeset
|
262 |
} |