Path: blob/master/test/jdk/sun/java2d/marlin/DashStrokeTest.java
41149 views
/*1* Copyright (c) 2009, 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*/2223/* @test24* @summary verify that first element is a dash25* @bug 679334426*/2728import java.awt.*;29import java.awt.image.*;3031import javax.swing.JButton;32import javax.swing.JFrame;33import javax.swing.SwingUtilities;34import javax.swing.WindowConstants;3536public class DashStrokeTest extends Component {3738static BufferedImage bi;39static boolean printed = false;4041public Dimension getPreferredSize() {42return new Dimension(200,200);43}4445public static void drawGui() {46bi = new BufferedImage(200, 20, BufferedImage.TYPE_INT_RGB);47Graphics2D g2d = bi.createGraphics();48BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,49BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 200 },501.0f);5152g2d.setStroke(dashStroke);53g2d.setColor(Color.RED);54g2d.drawLine(5,10, 100,10);55printed =true;56}5758public static void main(String[] args) {59try {60SwingUtilities.invokeAndWait(new Runnable() {6162@Override63public void run() {64drawGui();65}6667});68} catch (Exception e) {69}7071if (printed) {72checkBI(bi, Color.RED);73}74}7576static void checkBI(BufferedImage bi, Color badColor) {77int badrgb = badColor.getRGB();7879int col = bi.getRGB(6, 9);80if (col == badrgb) {81throw new RuntimeException("A pixel was turned on. ");82}83}84}85868788