xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graeme Kidd" <coolki...@hotmail.com>
Subject g2d.draw(path) Wipes what was last drawn
Date Wed, 11 Feb 2009 01:49:04 GMT
Hi,
I need to draw multiple paths on EPSDocumentGraphics2D but g2d.draw(path) 
seems to wipe what was displayed previous. Here is an example of my code:

//Instantiate the EPSDocumentGraphics2D instance
g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

...

// For all the path data
generalPath = new GeneralPath();
GetPathdata();

// Fill the path
g2d.setPaint(fillColour);
System.out.println(fillColour);
g2d2.fill(generalPath);

//Stroke the path
g2d2.setPaint(pathColour);
BasicStroke stroke =
        new BasicStroke(thickness, caps, joins);
g2d.setStroke(stroke);
g2d.setPaint(pathColour);
g2d.draw(generalPath);
//End of for

I can display all path data if I don't make a new general path and simply 
append to it every time. Problem with that is that the individual shapes 
don't retain their colours.

I have attempted to use a buffered image e.g.

// Create buffered image that does not support transparency
BufferedImage bimage = new BufferedImage(width, height, 
BufferedImage.TYPE_INT_RGB);
g2dBi = bimage.createGraphics();

...

// For all the path data
generalPath = new GeneralPath();
GetPathdata();

// Fill the path
g2dBi .setPaint(fillColour);
System.out.println(fillColour);
g2dBi .fill(generalPath);

//Stroke the path
g2dBi .setPaint(pathColour);
BasicStroke stroke =
        new BasicStroke(thickness, caps, joins);
g2dBi .setStroke(stroke);
g2dBi .setPaint(pathColour);
g2dBi .draw(generalPath);
//End of for

g2d.drawImage(bimage, 0, 0, null);

That seems to work but it creates a rasterized image inside the EPS file 
instead of a bunch of vector graphics.

Any ideas what I am doing wrong?
Thanks,
Graeme 


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message