/* * Copyright 2010 Red Hat, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ import java.awt.*; import java.awt.image.*; import static java.awt.RenderingHints.*; /* * @test * @bug 6967433 * @summary This test check rendering of dashed lines with applied scaling. * @run main Test6967433 * @author Denis Lila , Pavel Tisnovsky */ // TODO: this test uses lines. That's good for now, but it should really use // Path2Ds as Shapes. That's because lines could be treated as special cases, // and the code we want to test (in the rendering engine) might not even run. // So we must use shapes that are as general as possible. public class Test6967433 extends RenderingEngineTest { public void run() { Object[] tmp = getGraphics(400, 400); BufferedImage bi = (BufferedImage) tmp[0]; Graphics2D g2 = (Graphics2D) tmp[1]; // draw dashed line using scaling (magnification) final int scale = 32; g2.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1, new float[] {1,1}, 0)); g2.scale(scale, scale); g2.drawLine(0, 0, 10, 0); // test if dashed shape rendering is correct if (new Color(bi.getRGB(scale + scale/2, 0)).equals(Color.black)) { throw new RuntimeException("ScaledDashedLines test failed."); } } public static void main(String[] args) { new Test6967433().run(); } }