test/jdk/java/awt/Graphics2D/ScaledCopyArea/ScaledCopyArea.java
author jboes
Fri, 08 Nov 2019 11:15:16 +0000
changeset 59029 3786a0962570
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException Summary: Change implementation to use iterator instead of plain LinkedList Reviewed-by: dfuchs, vtewari
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     1
/*
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     4
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     8
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    13
 * accompanied this code).
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    14
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    18
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    21
 * questions.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    22
 */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    23
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    24
import java.awt.Color;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    25
import java.awt.Graphics2D;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    26
import java.awt.image.BufferedImage;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    27
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    28
/**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    29
 * @test
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    30
 * @bug 8029455
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    31
 * @summary Tests that copyarea on offscreen images works as expected when
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    32
 *          scaled transform is set
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    33
 * @run main ScaledCopyArea
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    34
 */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    35
public final class ScaledCopyArea {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    36
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    37
    public static void main(final String[] args) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    38
        final BufferedImage bi = new BufferedImage(100, 300,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    39
                                                   BufferedImage.TYPE_INT_RGB);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    40
        final Graphics2D g = bi.createGraphics();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    41
        g.scale(2, 2);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    42
        g.setColor(Color.RED);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    43
        g.fillRect(0, 0, 100, 300);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    44
        g.setColor(Color.GREEN);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    45
        g.fillRect(0, 100, 100, 100);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    46
        g.copyArea(0, 100, 100, 100, 0, -100);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    47
        g.dispose();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    48
        for (int x = 0; x < 100; ++x) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    49
            for (int y = 0; y < 100; ++y) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    50
                final int actual = bi.getRGB(x, y);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    51
                final int exp = Color.GREEN.getRGB();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    52
                if (actual != exp) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    53
                    System.err.println("Expected:" + Integer.toHexString(exp));
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    54
                    System.err.println("Actual:" + Integer.toHexString(actual));
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    55
                    throw new RuntimeException("Test " + "failed");
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    56
                }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    57
            }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    58
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    59
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    60
}