xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Toussaint <and...@onemileup.com>
Subject Re: getbbox() and update view problems
Date Mon, 01 Aug 2005 14:23:25 GMT
Hello Dominik:

>
> 1.) how do you get the bounding box of a graphical element from the 
> svg-file that includes the transform?
>

To my knowledge there is no easy way to recover the bounding box (over 
the x,y axis of your canvas) of a transformed shape.

The only way i can think of doing it involves retrieving the Java2D 
rendering of the element (from the GVTTree), create a new Java2D shape 
with affineTransform.createTransformedShape and then query the bounds 
of that new shape. Care should be taken that all elements remain in the 
same coordinate space.

Thomas:  Where would be a the appropriate package to suggest inserting 
this kind of utility?

>  
> 2.) when I change a node’s attributes, the display doesn’t update the 
> view, only if I’m moving the mouse e.g . How can I tell my SVGCanvas 
> to repaint itself? Or shouldn’t it note that automatically? (My 
> SVGCanvas is setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);)
>  
> I tried this
>  
> Element elementById = rootElement.getElementById(“id1”);
> if (elementById != null) {
>   elementById.setAttributeNS(null, "cx", new Double(gps.x).toString());
>   elementById.setAttributeNS(null, "cy", new Double(gps.y).toString());
> }
>  

You need to do your DOM changes in the UpdateManager Thread. You can 
get an instance of the UpdateManager thread, once the 
gvtRendeingCompleted is called:

  svgCanvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
             public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
                             ...
             }
             public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
                 updateM = svgCanvas.getUpdateManager();
             }
         });


AND you use it like this:

  updateM.getUpdateRunnableQueue().invokeLater(new Runnable() {
                 public void run() {
                    // do your DOM changes here.
                 }
             });

Regards,

Andres.
Mime
View raw message