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 * @run main/othervm -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine DashStrokeTest
28 */
29
30import java.awt.BasicStroke;
31import java.awt.Color;
32import java.awt.Graphics2D;
33import java.awt.Stroke;
34import java.awt.geom.GeneralPath;
35import java.awt.image.BufferedImage;
36
37
38public class DashStrokeTest {
39
40    public static void main(String[] args) {
41
42        GeneralPath shape = new GeneralPath();
43        int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
44        double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
45        double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
46        shape.moveTo(xpoints[0], ypoints[0]);
47        for (int i = 1; i < pointTypes.length; i++) {
48            if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
49                shape.quadTo(xpoints[i], ypoints[i],
50                             xpoints[i + 1], ypoints[i + 1]);
51            } else {
52                shape.lineTo(xpoints[i], ypoints[i]);
53            }
54        }
55
56        BufferedImage image = new
57            BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
58        Graphics2D g2 = image.createGraphics();
59
60        Color color = new Color(124, 0, 124, 255);
61        g2.setColor(color);
62        Stroke stroke = new BasicStroke(1.0f,
63                                        BasicStroke.CAP_BUTT,
64                                        BasicStroke.JOIN_BEVEL,
65                                        10.0f, new float[] {9, 6}, 0.0f);
66        g2.setStroke(stroke);
67        g2.draw(shape);
68    }
69}
70