Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/BasicStroke/DashStrokeTest.java
41149 views
1
/*
2
* Copyright (c) 2015, 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
* @test
24
* @bug 8075942 8080932
25
* @summary test there is no exception rendering a dashed stroke
26
* @run main DashStrokeTest
27
*/
28
29
import java.awt.BasicStroke;
30
import java.awt.Color;
31
import java.awt.Graphics2D;
32
import java.awt.Stroke;
33
import java.awt.geom.GeneralPath;
34
import java.awt.image.BufferedImage;
35
36
37
public class DashStrokeTest {
38
39
public static void main(String[] args) {
40
41
GeneralPath shape = new GeneralPath();
42
int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
43
double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
44
double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
45
shape.moveTo(xpoints[0], ypoints[0]);
46
for (int i = 1; i < pointTypes.length; i++) {
47
if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
48
shape.quadTo(xpoints[i], ypoints[i],
49
xpoints[i + 1], ypoints[i + 1]);
50
} else {
51
shape.lineTo(xpoints[i], ypoints[i]);
52
}
53
}
54
55
BufferedImage image = new
56
BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
57
Graphics2D g2 = image.createGraphics();
58
59
Color color = new Color(124, 0, 124, 255);
60
g2.setColor(color);
61
Stroke stroke = new BasicStroke(1.0f,
62
BasicStroke.CAP_BUTT,
63
BasicStroke.JOIN_BEVEL,
64
10.0f, new float[] {9, 6}, 0.0f);
65
g2.setStroke(stroke);
66
g2.draw(shape);
67
}
68
}
69
70