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 AW: Drawing on a JSVGCanvas with SVGGenerator??
Date Thu, 11 Aug 2005 12:46:02 GMT


I solved my problem and for those who might run into similar isues:


1)       svgGenerator.fill(new


 -----> I had to convert the mouseEvent coordinates to the underlying
viewport by 


SVGMatrix screenCTM =

    //    matrix now holds scale/rotation/translate/skew values for both
x and y

    coords[0] = screenCTM.getA() * mouseEvent.getX(),+ screenCTM.getC()
* mouseEvent.getY(),

        + screenCTM.getE();

    coords[1] = screenCTM.getB() * mouseEvent.getX(), + screenCTM.getD()
* mouseEvent.getY(),

        + screenCTM.getF();




--> I had to get the <g>-Node and not the whole <svg> root to append it
to the underlying canvas (which makes sense anyway) through:




And then it worked.


Dominik Steiner






Von: Steiner, Dominik 
Gesendet: Mittwoch, 10. August 2005 08:15
An: batik-users@xmlgraphics.apache.org
Betreff: Drawing on a JSVGCanvas with SVGGenerator??


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



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



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



      public void run() {






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

View raw message