/* * 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 6967436 * @summary This test check proper rendering of diagonal line when line coordinates are bigger than 16bit integer. * @run main Test6967436 * @author Denis Lila , Pavel Tisnovsky */ // TODO: this test use 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 Test6967436 extends RenderingEngineTest { public void run() { // NOTE - the rendering area should be square, not generic rectangle Object[] tmp = getGraphics(400, 400); BufferedImage bi = (BufferedImage) tmp[0]; Graphics2D g2 = (Graphics2D) tmp[1]; g2.setStroke(new BasicStroke(5)); g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g2.drawLine(0, 0, 1<<15, 1<<15); // test if two areas (above line and below line) contains only // white pixels int w = bi.getWidth(), h = bi.getHeight(); for (int i = 0; i < h; i++) { for (int j = i + 10; j < w; j++) { if (!(new Color(bi.getRGB(j, i)).equals(Color.white) && new Color(bi.getRGB(i, j)).equals(Color.white))) { throw new RuntimeException( "A non white background pixel was found.\n" + "OverflowTest failed"); } } } } public static void main(String[] argv) { new Test6967436().run(); } }