1.1 --- a/src/share/classes/sun/java2d/pisces/Stroker.java Mon Apr 20 12:31:36 2009 -0700
1.2 +++ b/src/share/classes/sun/java2d/pisces/Stroker.java Tue Apr 21 09:43:49 2009 -0700
1.3 @@ -181,7 +181,7 @@
1.4 Transform4 transform) {
1.5 this.lineWidth = lineWidth;
1.6 this.lineWidth2 = lineWidth >> 1;
1.7 - this.scaledLineWidth2 = (long)transform.m00*lineWidth2;
1.8 + this.scaledLineWidth2 = ((long)transform.m00*lineWidth2) >> 16;
1.9 this.capStyle = capStyle;
1.10 this.joinStyle = joinStyle;
1.11 this.miterLimit = miterLimit;
1.12 @@ -243,8 +243,8 @@
1.13 if (ilen == 0) {
1.14 dx = dy = 0;
1.15 } else {
1.16 - dx = (int)( (ly*scaledLineWidth2)/ilen >> 16);
1.17 - dy = (int)(-(lx*scaledLineWidth2)/ilen >> 16);
1.18 + dx = (int)( (ly*scaledLineWidth2)/ilen);
1.19 + dy = (int)(-(lx*scaledLineWidth2)/ilen);
1.20 }
1.21 } else {
1.22 double dlx = x1 - x0;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/test/sun/pisces/StrokeShapeTest.java Tue Apr 21 09:43:49 2009 -0700
2.3 @@ -0,0 +1,71 @@
2.4 +/*
2.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2.7 + *
2.8 + * This code is free software; you can redistribute it and/or modify it
2.9 + * under the terms of the GNU General Public License version 2 only, as
2.10 + * published by the Free Software Foundation.
2.11 + *
2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2.15 + * version 2 for more details (a copy is included in the LICENSE file that
2.16 + * accompanied this code).
2.17 + *
2.18 + * You should have received a copy of the GNU General Public License version
2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2.21 + *
2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
2.24 + * have any questions.
2.25 + */
2.26 +import java.awt.*;
2.27 +import java.awt.geom.Ellipse2D;
2.28 +import java.awt.geom.GeneralPath;
2.29 +import java.awt.image.BufferedImage;
2.30 +import java.io.File;
2.31 +
2.32 +import javax.imageio.ImageIO;
2.33 +
2.34 +/**
2.35 + * @author chrisn@google.com (Chris Nokleberg)
2.36 + * @author yamauchi@google.com (Hiroshi Yamauchi)
2.37 + */
2.38 +public class StrokeShapeTest {
2.39 + public static void main(String[] args) throws Exception {
2.40 + BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
2.41 + Graphics2D g = image.createGraphics();
2.42 + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
2.43 + g.setPaint(Color.WHITE);
2.44 + g.fill(new Rectangle(image.getWidth(), image.getHeight()));
2.45 + g.translate(25, 100);
2.46 +
2.47 + Stroke stroke = new BasicStroke(200, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
2.48 + Shape shape = new Polygon(new int[] {0, 1500, 0}, new int[] {750, 0, -750}, 3);
2.49 +
2.50 + g.scale(.1, .1);
2.51 + g.setPaint(Color.BLACK);
2.52 + g.setStroke(stroke);
2.53 + g.draw(shape);
2.54 + g.setPaint(Color.RED);
2.55 + g.fill(stroke.createStrokedShape(shape));
2.56 +
2.57 + // To visually check it
2.58 + //ImageIO.write(image, "PNG", new File(args[0]));
2.59 +
2.60 + boolean blackPixelFound = false;
2.61 + outer:
2.62 + for (int x = 0; x < 200; ++x) {
2.63 + for (int y = 0; y < 200; ++y) {
2.64 + if (image.getRGB(x, y) == Color.BLACK.getRGB()) {
2.65 + blackPixelFound = true;
2.66 + break outer;
2.67 + }
2.68 + }
2.69 + }
2.70 + if (blackPixelFound) {
2.71 + throw new RuntimeException("The shape hasn't been filled in red.");
2.72 + }
2.73 + }
2.74 +}