xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steiner, Dominik" <Dominik.Stei...@gigatronik.com>
Subject Drawing on a JSVGCanvas with SVGGenerator??
Date Wed, 10 Aug 2005 06:14:46 GMT
Hi my dear Batik fellows,

 

I'm trying to implement a drawing feature into my application:

 

* where the user can draw shapes (e.g. polygons) by clicking and
dragging with the mouse.

* Underlying is a SVG graphic of a map. 

* this shapes should get stored, preferably as a separate SVG file

* all is handled inside a JSVGCanvas

 

Up to now I try to implement this using the SVGGenerator, but I'm not
sure if this is a good approach and I'm having trouble using it.

 

1) I have to instantiate the SVGGenerator with the SVGDocument of my
underlying map

svgGenerator = new SVGGraphics2D(mapSVGDocument);

 

            2) I set the Canvas size of the Generator to that of the map

            svgGenerator.setSVGCanvasSize(mapCanvas.getSize());

 

            3) then the user by clicking on the canvas can draw a
rectangle

            svgGenerator.fill(new
Rectangle2D.Double(mouseEvent.getX(),mouseEvent.getY(),50,50));

 

            4) to get the drawings displayed in my map, I have to use
the UpdateManager of the JSVGCanvas??

 
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable(){

 

      public void run() {

 
mapCanvas.getSVGDocument().getRootElement().appendChild(svgGenerator.get
Root());

      }

    });

 

 

This doesn't work.

 

1) I also would like to add EventListener to the shapes the user is
drawing. I'm not sure where to add those listeners? Before I add them to
the mapCanvas on traversing the root I got from SVGGenerator?

 

I'm deeply grateful for the help you can give me.

 

Greetings from Germany.

 

Dominik Steiner


Mime
View raw message