I'm afraid I can't reproduce your problem. In a short test, this was working fine. But I noticed something in your code snippet:
You do setPaint on "g2d": g2d.setPaint(fillColour); But then, you fill using "g2d2": g2d2.fill(generalPath); I believe that could be your problem. You need to set the paint on the same Graphics2D object that you intend to paint with. On 11.02.2009 02:49:04 Graeme Kidd wrote: > 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 > Jeremias Maerki --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
