test/jdk/java/awt/Graphics2D/DeviceBounds.java
author prr
Wed, 29 Nov 2017 09:47:02 -0800
changeset 47982 44371ff1ee9a
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33254
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     1
/*
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     4
 *
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     8
 *
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    13
 * accompanied this code).
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    14
 *
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    18
 *
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    21
 * questions.
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    22
 */
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    23
import java.awt.*;
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    24
import java.awt.image.BufferedImage;
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    25
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    26
/**
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    27
 * @test
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    28
 * @bug 8072682
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    29
 * @summary Graphics.getDeviceConfiguration().getBounds returns wrong width/height
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    30
 * @run main DeviceBounds
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    31
 */
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    32
public class DeviceBounds {
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    33
    public static void main(String[] args) {
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    34
        // NB: all images have the same type
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    35
        BufferedImage[] images = new BufferedImage[] {
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    36
                new BufferedImage(200, 200, BufferedImage.TYPE_3BYTE_BGR),
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    37
                new BufferedImage(400, 400, BufferedImage.TYPE_3BYTE_BGR),
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    38
                new BufferedImage(100, 100, BufferedImage.TYPE_3BYTE_BGR)
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    39
        };
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    40
        int count = 0;
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    41
        for (BufferedImage i : images) {
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    42
            Graphics2D g = i.createGraphics();
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    43
            Rectangle bounds[] = new Rectangle[images.length];
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    44
            bounds[count] = g.getDeviceConfiguration().getBounds();
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    45
            System.out.println(bounds[count]);
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    46
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    47
            g.dispose();
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    48
            if (bounds[count].width != Integer.MAX_VALUE) {
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    49
                throw new RuntimeException("Wrong getBounds");
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    50
            }
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    51
            count++;
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    52
        }
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    53
    }
2ce30cca1503 8072682: getBounds call on graphics.getDeviceConfiguration() returning cached information
psadhukhan
parents:
diff changeset
    54
}