Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Headless/HeadlessBasicStroke.java
41149 views
1
/*
2
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.awt.*;
25
26
/*
27
* @test
28
* @summary Check that BasicStroke constructors and get-methods do not
29
* throw exceptions in headless mode
30
* @run main/othervm -Djava.awt.headless=true HeadlessBasicStroke
31
*/
32
33
34
public class HeadlessBasicStroke {
35
public static void main (String[] args) {
36
BasicStroke bs;
37
38
// Constructors without exceptions
39
bs = new BasicStroke(1, BasicStroke.CAP_BUTT,
40
BasicStroke.JOIN_BEVEL, 3, null, -1);
41
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 3,
42
new float[]{(float) 2.0, (float) 3.0}, 0);
43
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 3,
44
new float[]{(float) 2.0, (float) 3.0}, 1);
45
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, (float) 3);
46
47
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 3);
48
49
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, (float) 3);
50
51
bs = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3);
52
53
bs = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 3);
54
55
bs = new BasicStroke(1, BasicStroke.JOIN_ROUND, BasicStroke.CAP_SQUARE, 3);
56
57
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
58
59
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
60
61
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
62
63
bs = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
64
65
bs = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);
66
67
bs = new BasicStroke(1, BasicStroke.JOIN_ROUND, BasicStroke.CAP_SQUARE);
68
69
bs = new BasicStroke((float) 0.1);
70
71
bs = new BasicStroke((float) 0.9);
72
73
bs = new BasicStroke(4);
74
75
bs = new BasicStroke(10);
76
77
bs = new BasicStroke(20);
78
79
bs = new BasicStroke(100);
80
81
bs = new BasicStroke();
82
83
// Constructors with exceptions
84
boolean exceptions = false;
85
try {
86
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2);
87
} catch (IllegalArgumentException e) {
88
exceptions = true;
89
}
90
if (!exceptions)
91
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
92
93
exceptions = false;
94
try {
95
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2);
96
} catch (IllegalArgumentException e) {
97
exceptions = true;
98
}
99
if (!exceptions)
100
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
101
102
exceptions = false;
103
try {
104
bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2);
105
} catch (IllegalArgumentException e) {
106
exceptions = true;
107
}
108
if (!exceptions)
109
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
110
111
exceptions = false;
112
try {
113
bs = new BasicStroke(1, 5678, 92039, 3);
114
} catch (IllegalArgumentException e) {
115
exceptions = true;
116
}
117
if (!exceptions)
118
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
119
120
exceptions = false;
121
try {
122
bs = new BasicStroke(1, 5678, 92039);
123
} catch (IllegalArgumentException e) {
124
exceptions = true;
125
}
126
if (!exceptions)
127
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
128
129
exceptions = false;
130
try {
131
bs = new BasicStroke((float) -0.9);
132
} catch (IllegalArgumentException e) {
133
exceptions = true;
134
}
135
if (!exceptions)
136
throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected");
137
138
// Create stroke shape
139
bs = new BasicStroke(20);
140
bs.createStrokedShape(new Rectangle(10, 10, 10, 10));
141
142
// Get-methods
143
bs = new BasicStroke(100);
144
bs.getLineWidth();
145
bs.getEndCap();
146
bs.getLineJoin();
147
bs.getMiterLimit();
148
bs.getDashArray();
149
bs.getDashPhase();
150
}
151
}
152
153