In SVG, your API to manipulate the graphics is the DOM and the best
way to do what you want is to use scripting (e.g., Java or JavaScript).
The problem is that right now, Batik does not support scripting. One
way to work around this (and until we support scripting) is to do
a setDocument on the JSVGCanvas after you have modified the DOM.
So, for example:
Document doc = ...;
Element elt = doc.getElementById("myLayer");
elt.setAttributeNS(null, "visibility", "hidden");
myCanvas.setDocument(doc);
I think it is better now to hook in at the GVT level.
I hope this helps.
Vincent.
[EMAIL PROTECTED] wrote:
>
> Hi,
>
> I have an svg document containing more than 1 SVG layer. The layers are
> displayed on the screen. I want to give the user the ability to turn of
> some of the layers after it has been displayed.
>
> However I am having a problem with this. I have attempted to set the
> graphic nodes in the GVT tree invisible and to redisplay the updated GVT
> tree. However the changes in the GVT Tree are not updated on the display
> immediately. But I noticed that the changes seem to take effect, ie a
> layer set to invisible no longer appears, only when you zoom in.
>
> Question : how can I get the display to reflect the changes in the GVT Tree
> immediately.
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> The code to set the visibility of the graphic nodes and re-rendering is as
> follows:
>
> ****************************************************
>
> public class RimisCanvas extends JSVGCanvas {
>
> public RimisCanvas() {
> super();
>
> }
>
> public void modifySVG(String id, boolean visflag){
> System.out.println(bridgeContext);
> System.out.println(id);
> System.out.println(visflag);
> System.out.println(svgDocument);
> org.w3c.dom.Element e = svgDocument.getElementById(id);
> System.out.println("e:"+e);
> GraphicsNode gn = bridgeContext.getGraphicsNode(e);
> if (gn instanceof CompositeGraphicsNode){
> CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
> for (int i = 0; i<cgn.size();i++){
> System.out.println("CGN 1:"+cgn.get(i));
> if (cgn.get(i) instanceof CompositeGraphicsNode){
> CompositeGraphicsNode cgn2 =
> (CompositeGraphicsNode)cgn.get(i);
> for (int j = 0; j<cgn2.size();j++){
> System.out.println("j:"+j);
> System.out.println("CGN
> 2:"+((CompositeGraphicsNode)cgn2.get(j)).get(0));
> GraphicsNode shpnode =
> (GraphicsNode)((CompositeGraphicsNode)cgn2.get(j)).get(0);
> if (visflag) {
> System.out.print("inside visflag true");
> shpnode.setVisible(true);
> } else {
> System.out.print("inside visflag false");
> shpnode.setVisible(false);
> }
>
> }
> }
> }
> AffineTransform at = new AffineTransform(getRenderingTransform());
> setRenderingTransform(at);
> }
> }
>
> **************************************************************
> ++++++++++++++++++++++++++++++++++++++++++++++
>
> The operating system : Windows 2000. Java version : JDK1.3.1. Batik version
> 1.1rc2.
>
> Some of the commands I have tried unsuccessfully to repaint are as follows:
> (a) immediateRepaint()
> (b) invalidate()
> (c)AffineTransform at = getRenderingTransform()
> setRenderingTransform(at)
>
> Could you also advise me if there is a better way of setting a layer to be
> invisible after it is displayed on the screen.
>
> Thank you.
>
> Regards
> Leakha
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]