Path: blob/master/test/jdk/sun/java2d/pipe/Test8004821.java
41149 views
/*1* Copyright (c) 2013, 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*/2223import java.awt.Graphics2D;24import java.awt.Polygon;25import java.awt.image.BufferedImage;2627/**28* @test29* @bug 800482130* @summary Verifies that drawPolygon() works with empty arrays.31* @author Sergey Bylokhov32*/33public final class Test8004821 {3435public static void main(final String[] args) {36final int[] arrEmpty = {};37final int[] arr1elem = {150};38final BufferedImage bi = new BufferedImage(300, 300,39BufferedImage.TYPE_INT_RGB);40final Graphics2D g = (Graphics2D) bi.getGraphics();41test(g, arrEmpty);42test(g, arr1elem);43g.translate(2.0, 2.0);44test(g, arrEmpty);45test(g, arr1elem);46g.scale(2.0, 2.0);47test(g, arrEmpty);48test(g, arr1elem);49g.dispose();50}5152private static void test(final Graphics2D g, final int[] arr) {53g.drawPolygon(arr, arr, arr.length);54g.drawPolygon(new Polygon(arr, arr, arr.length));55g.fillPolygon(arr, arr, arr.length);56g.fillPolygon(new Polygon(arr, arr, arr.length));57g.drawPolyline(arr, arr, arr.length);58}59}606162