Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6599363
Votes 0
Synopsis Incorrect filling of GeneralPath under JDK 1.6
Category java:classes_2d
Reported Against
Release Fixed 7(b20), 6u10(b04) (Bug ID:2152382)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 30-AUG-2007
Description
The attached program correctly fills the intended area of the shape
under 1.5 but not 1.6

import java.awt.Graphics2D;
import java.awt.Font;
import java.awt.Shape;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.BasicStroke;
import java.awt.GradientPaint;
import java.awt.TexturePaint;
import java.awt.image.BufferedImage;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;


public class AffineGPTest

	public static void main(String[] args) {
		final int width = 200;
		final int height = 200;


		BufferedImage image;
		BufferedImage outimage = new BufferedImage(width*5, height*1, BufferedImage.TYPE_INT_RGB);

		/* the general path is a sine wave */
		GeneralPath oddShape = new GeneralPath();
		oddShape.moveTo(10,50);
		oddShape.curveTo(10,50,20,10,30,50);
		oddShape.moveTo(30,50);
		oddShape.curveTo(30,50,40,90,50,50);
		oddShape.moveTo(50,50);
		oddShape.curveTo(50,50,60,10,70,50);
		oddShape.moveTo(70,50);
		oddShape.curveTo(70,50,80,90,90,50);
		oddShape.closePath();

		Graphics2D g2;
		AffineTransform af;
		final Graphics2D outg2 = (Graphics2D)outimage.getGraphics();

		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g2 = (Graphics2D)image.getGraphics();
		g2.setColor(Color.GRAY);
		g2.fillRect(0,0,width,height);
		g2.setColor(Color.WHITE);
		af = new AffineTransform();
		af.translate(30,15);
		g2.setTransform(af);
		g2.fill(oddShape);

		outg2.drawImage(image,0,0,null);

		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g2 = (Graphics2D)image.getGraphics();
		g2.setColor(Color.BLACK);
		g2.fillRect(0,0,width,height);
		g2.setColor(Color.WHITE);
		af = new AffineTransform();
		af.rotate(Math.PI/2.0,85,100);
		g2.setTransform(af);
		g2.fill(oddShape);

		outg2.drawImage(image,width,0,null);

		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g2 = (Graphics2D)image.getGraphics();
		g2.setColor(Color.GRAY);
		g2.fillRect(0,0,width,height);
		g2.setColor(Color.WHITE);
		af = new AffineTransform();
		af.rotate(Math.PI,85,100);
		g2.setTransform(af);
		g2.fill(oddShape);

		outg2.drawImage(image,width*2,0,null);

		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g2 = (Graphics2D)image.getGraphics();
		g2.setColor(Color.BLACK);
		g2.fillRect(0,0,width,height);
		g2.setColor(Color.WHITE);
		af = new AffineTransform();
		af.rotate(-Math.PI/2.0,85,100);
		g2.setTransform(af);
		g2.fill(oddShape);

		outg2.drawImage(image,width*3,0,null);

		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g2 = (Graphics2D)image.getGraphics();
		g2.setColor(Color.GRAY);
		g2.fillRect(0,0,width,height);
		g2.setColor(Color.WHITE);
		af = new AffineTransform();
		af.rotate(10.0,85,100);
		af.scale(1.5,0.5);
		g2.setTransform(af);
		g2.fill(oddShape);

		outg2.drawImage(image,width*4,0,null);

		try {
			final String outname = "generalpath.png";
			System.out.println("Writing "+outname);
			final OutputStream os = new BufferedOutputStream(new FileOutputStream(outname));
			ImageIO.write(outimage,"png",os);
			os.flush();
			os.close();
		} catch (IOException e) {
			System.out.println("ouch io exception "+e);
		}
	}
}
Posted Date : 2007-08-30 14:57:44.0
Work Around
N/A
Evaluation
Invalid rendering happens because of incorrect tracking of current segment closing point in new ProcessPath pipeline. Please see suggested fix.
Posted Date : 2007-08-31 16:59:44.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang