Hello Dominik:

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

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?

<x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>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);)</x-tad-bigger>
<x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>I tried this</x-tad-bigger>
<x-tad-bigger> </x-tad-bigger>
<x-tad-bigger>Element elementById = rootElement.getElementById(“id1”);</x-tad-bigger>
<x-tad-bigger>if (elementById != null) {</x-tad-bigger>
<x-tad-bigger>  elementById.setAttributeNS(null, "cx", new Double(gps.x).toString());</x-tad-bigger>
<x-tad-bigger>  elementById.setAttributeNS(null, "cy", new Double(gps.y).toString());</x-tad-bigger>
<x-tad-bigger>}</x-tad-bigger>
<x-tad-bigger> </x-tad-bigger>

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.

Reply via email to