1286N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1286N/A *
1286N/A * This code is free software; you can redistribute it and/or modify it
1286N/A * under the terms of the GNU General Public License version 2 only, as
1286N/A * published by the Free Software Foundation.
1286N/A *
1286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1286N/A * version 2 for more details (a copy is included in the LICENSE file that
1286N/A * accompanied this code).
1286N/A *
1286N/A * You should have received a copy of the GNU General Public License version
1286N/A * 2 along with this work; if not, write to the Free Software Foundation,
1286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1286N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1286N/A */
1286N/A
1286N/Aimport java.awt.*;
1286N/Aimport java.awt.geom.Ellipse2D;
1286N/Aimport java.awt.image.BufferedImage;
1286N/Aimport java.io.File;
1286N/Aimport javax.imageio.ImageIO;
1286N/A
1286N/A
1286N/Apublic class ScaleTest {
1286N/A public static void main(String[] args) throws Exception {
1286N/A BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
1286N/A Graphics2D g = image.createGraphics();
1286N/A
1286N/A g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
1286N/A g.setPaint(Color.WHITE);
1286N/A g.fill(new Rectangle(image.getWidth(), image.getHeight()));
1286N/A g.scale(.9, .9);
1286N/A g.setPaint(Color.BLACK);
1286N/A g.setStroke(new BasicStroke(0.5f));
1286N/A g.draw(new Ellipse2D.Double(25, 25, 150, 150));
1286N/A
1286N/A // To visually check it
1286N/A //ImageIO.write(image, "PNG", new File(args[0]));
1286N/A
1286N/A boolean nonWhitePixelFound = false;
1286N/A for (int x = 100; x < 200; ++x) {
1286N/A if (image.getRGB(x, 90) != Color.WHITE.getRGB()) {
1286N/A nonWhitePixelFound = true;
1286N/A break;
1286N/A }
1286N/A }
1286N/A if (!nonWhitePixelFound) {
1286N/A throw new RuntimeException("A circle is rendered like a 'C' shape.");
1286N/A }
1286N/A }
1286N/A}