/* * 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 static java.awt.RenderingHints.*; import java.awt.image.*; /* * @test * bug 661554 - note that this is a Red Hat bugzilla bug ID, so we cannot * use real tag "bug" (starting with "at" character) here. * @summary This test check rendering of dashed lines with applied scaling. * @run main Test661554 * @author Denis Lila , Pavel Tisnovsky */ public class Test661554 extends RenderingEngineTest { public void run() { Graphics2D g2 = (Graphics2D) getGraphics(400, 400)[1]; g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g2.setStroke(new BasicStroke(2f)); g2.scale(0.0000001, 0.0000001); // draw line using minification and check if divide by zero is not thrown try { g2.drawLine(10, 10, 10, 100); } catch (ArithmeticException e) { // this might be kinda stupid. Maybe we should just let the DVZ // fall through. throw new RuntimeException("Divide by zero occurred; test failed."); } } public static void main(String[] argv) { new Test661554().run(); } }