test/jdk/java/awt/BasicStroke/DashStrokeTest.java
author prr
Tue, 14 Nov 2017 11:47:49 -0800
changeset 47838 f0c8554f0bce
parent 47216 71c04702a3d5
permissions -rw-r--r--
8186306: Remove pisces from Java2D sources + build. Reviewed-by: serb, neugens
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30468
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     1
/*
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     4
 *
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     8
 *
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    13
 * accompanied this code).
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    14
 *
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    18
 *
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    21
 * questions.
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    22
 *
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    23
 * @test
31888
f4cd67172b4d 8080932: [TEST_BUG] Test java/awt/BasicStroke/DashStrokeTest.java fails with Bad script error due to improper @run notation
pchopra
parents: 30468
diff changeset
    24
 * @bug 8075942 8080932
30468
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    25
 * @summary test there is no exception rendering a dashed stroke
31888
f4cd67172b4d 8080932: [TEST_BUG] Test java/awt/BasicStroke/DashStrokeTest.java fails with Bad script error due to improper @run notation
pchopra
parents: 30468
diff changeset
    26
 * @run main DashStrokeTest
30468
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    27
 */
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    28
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    29
import java.awt.BasicStroke;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    30
import java.awt.Color;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    31
import java.awt.Graphics2D;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    32
import java.awt.Stroke;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    33
import java.awt.geom.GeneralPath;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    34
import java.awt.image.BufferedImage;
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    35
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    36
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    37
public class DashStrokeTest {
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    38
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    39
    public static void main(String[] args) {
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    40
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    41
        GeneralPath shape = new GeneralPath();
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    42
        int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    43
        double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    44
        double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    45
        shape.moveTo(xpoints[0], ypoints[0]);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    46
        for (int i = 1; i < pointTypes.length; i++) {
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    47
            if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    48
                shape.quadTo(xpoints[i], ypoints[i],
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    49
                             xpoints[i + 1], ypoints[i + 1]);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    50
            } else {
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    51
                shape.lineTo(xpoints[i], ypoints[i]);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    52
            }
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    53
        }
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    54
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    55
        BufferedImage image = new
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    56
            BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    57
        Graphics2D g2 = image.createGraphics();
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    58
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    59
        Color color = new Color(124, 0, 124, 255);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    60
        g2.setColor(color);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    61
        Stroke stroke = new BasicStroke(1.0f,
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    62
                                        BasicStroke.CAP_BUTT,
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    63
                                        BasicStroke.JOIN_BEVEL,
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    64
                                        10.0f, new float[] {9, 6}, 0.0f);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    65
        g2.setStroke(stroke);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    66
        g2.draw(shape);
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    67
    }
a016d2637922 8075942: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
prr
parents:
diff changeset
    68
}