Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/BasicStroke/DashStrokeTest.java
38813 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22* @test23* @bug 8075942 808093224* @summary test there is no exception rendering a dashed stroke25* @run main DashStrokeTest26* @run main/othervm -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine DashStrokeTest27*/2829import java.awt.BasicStroke;30import java.awt.Color;31import java.awt.Graphics2D;32import java.awt.Stroke;33import java.awt.geom.GeneralPath;34import java.awt.image.BufferedImage;353637public class DashStrokeTest {3839public static void main(String[] args) {4041GeneralPath shape = new GeneralPath();42int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};43double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};44double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};45shape.moveTo(xpoints[0], ypoints[0]);46for (int i = 1; i < pointTypes.length; i++) {47if (pointTypes[i] == 1 && i < pointTypes.length - 1) {48shape.quadTo(xpoints[i], ypoints[i],49xpoints[i + 1], ypoints[i + 1]);50} else {51shape.lineTo(xpoints[i], ypoints[i]);52}53}5455BufferedImage image = new56BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);57Graphics2D g2 = image.createGraphics();5859Color color = new Color(124, 0, 124, 255);60g2.setColor(color);61Stroke stroke = new BasicStroke(1.0f,62BasicStroke.CAP_BUTT,63BasicStroke.JOIN_BEVEL,6410.0f, new float[] {9, 6}, 0.0f);65g2.setStroke(stroke);66g2.draw(shape);67}68}697071