312N/A/*
2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
312N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
312N/A *
312N/A * This code is free software; you can redistribute it and/or modify it
312N/A * under the terms of the GNU General Public License version 2 only, as
312N/A * published by the Free Software Foundation.
312N/A *
312N/A * This code is distributed in the hope that it will be useful, but WITHOUT
312N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
312N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
312N/A * version 2 for more details (a copy is included in the LICENSE file that
312N/A * accompanied this code).
312N/A *
312N/A * You should have received a copy of the GNU General Public License version
312N/A * 2 along with this work; if not, write to the Free Software Foundation,
312N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
312N/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.
312N/A */
312N/A
312N/A/*
312N/A * @test TranslatedOutlineTest
312N/A * @bug 6703377
312N/A * @summary This test verifies that outline is translated in a correct direction
312N/A * @run main TranslatedOutlineTest
312N/A */
312N/A
312N/Aimport java.awt.Color;
312N/Aimport java.awt.Graphics2D;
312N/Aimport java.awt.RenderingHints;
312N/Aimport java.awt.font.FontRenderContext;
312N/Aimport java.awt.font.GlyphVector;
312N/Aimport java.awt.image.BufferedImage;
312N/A
312N/Apublic class TranslatedOutlineTest {
312N/A public static void main(String a[]) {
312N/A /* prepare blank image */
312N/A BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
312N/A Graphics2D g2 = (Graphics2D) bi.getGraphics();
312N/A g2.setColor(Color.WHITE);
312N/A g2.fillRect(0, 0, 50, 50);
312N/A
312N/A /* draw outline somethere in the middle of the image */
312N/A FontRenderContext frc = new FontRenderContext(null, false, false);
312N/A g2.setColor(Color.RED);
312N/A g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
312N/A GlyphVector gv = g2.getFont().createGlyphVector(frc, "test");
312N/A g2.fill(gv.getOutline(20, 20));
312N/A
312N/A /* Check if anything was drawn.
312N/A * If y direction is not correct then image is still blank and
312N/A * test will fail.
312N/A */
312N/A int bgcolor = Color.WHITE.getRGB();
312N/A for (int i=0; i<bi.getWidth(); i++) {
312N/A for(int j=0; j<bi.getHeight(); j++) {
312N/A if (bi.getRGB(i, j) != bgcolor) {
312N/A System.out.println("Test passed.");
312N/A return;
312N/A }
312N/A }
312N/A }
312N/A throw new RuntimeException("Outline was not detected");
312N/A }
312N/A}