1 /*
   2  * Copyright 2010 Red Hat, Inc. All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  */
  19 
  20 import java.awt.*;
  21 import static java.awt.RenderingHints.*;
  22 import java.awt.image.*;
  23 
  24 /*
  25  * @test
  26  * bug 661554 - note that this is a Red Hat bugzilla bug ID, so we cannot
  27  *              use real tag "bug" (starting with "at" character) here.
  28  * @summary This test check rendering of dashed lines with applied scaling.
  29  * @run main Test661554
  30  * @author Denis Lila <dlila@redhat.com>, Pavel Tisnovsky <ptisnovs@redhat.com>
  31  */
  32 public class Test661554 extends RenderingEngineTest {
  33     public void run() {
  34         Graphics2D g2 = (Graphics2D) getGraphics(400, 400)[1];
  35 
  36         g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
  37         g2.setStroke(new BasicStroke(2f));
  38         g2.scale(0.0000001, 0.0000001);
  39 
  40         // draw line using minification and check if divide by zero is not thrown
  41         try {
  42             g2.drawLine(10, 10, 10, 100);
  43         }
  44         catch (ArithmeticException e) {
  45             // this might be kinda stupid. Maybe we should just let the DVZ
  46             // fall through.
  47             throw new RuntimeException("Divide by zero occurred; test failed.");
  48         }
  49     }
  50 
  51     public static void main(String[] argv) {
  52         new Test661554().run();
  53     }
  54 }
  55