jdk/test/sun/java2d/pipe/Test8004821.java
author alexsch
Thu, 31 Jul 2014 14:28:10 +0400
changeset 26019 10a56d28f48d
parent 15503 39523ee9d3be
permissions -rw-r--r--
8051838: [Findbugs]sun.awt.image.MultiResolutionCachedImage expose internal representation Reviewed-by: serb, pchelko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15503
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     1
/*
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     4
 *
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     8
 *
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    13
 * accompanied this code).
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    14
 *
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    18
 *
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    21
 * questions.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    22
 */
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    23
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    24
import java.awt.Graphics2D;
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    25
import java.awt.Polygon;
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    26
import java.awt.image.BufferedImage;
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    27
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    28
/**
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    29
 * @test
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    30
 * @bug 8004821
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    31
 * @summary Verifies that drawPolygon() works with empty arrays.
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    32
 * @author Sergey Bylokhov
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    33
 */
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    34
public final class Test8004821 {
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    35
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    36
    public static void main(final String[] args) {
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    37
        final int[] arrEmpty = {};
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    38
        final int[] arr1elem = {150};
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    39
        final BufferedImage bi = new BufferedImage(300, 300,
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    40
                                                   BufferedImage.TYPE_INT_RGB);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    41
        final Graphics2D g = (Graphics2D) bi.getGraphics();
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    42
        test(g, arrEmpty);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    43
        test(g, arr1elem);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    44
        g.translate(2.0, 2.0);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    45
        test(g, arrEmpty);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    46
        test(g, arr1elem);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    47
        g.scale(2.0, 2.0);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    48
        test(g, arrEmpty);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    49
        test(g, arr1elem);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    50
        g.dispose();
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    51
    }
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    52
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    53
    private static void test(final Graphics2D g, final int[] arr) {
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    54
        g.drawPolygon(arr, arr, arr.length);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    55
        g.drawPolygon(new Polygon(arr, arr, arr.length));
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    56
        g.fillPolygon(arr, arr, arr.length);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    57
        g.fillPolygon(new Polygon(arr, arr, arr.length));
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    58
        g.drawPolyline(arr, arr, arr.length);
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    59
    }
39523ee9d3be 8004821: Graphics2D.drawPolygon() fails with IllegalPathStateException
serb
parents:
diff changeset
    60
}