xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas E Deweese <thomas.dewe...@kodak.com>
Subject Re: FW: Refreshing screen display after modifying attributes on graphics node of tree
Date Mon, 29 Oct 2001 13:10:43 GMT
>>>>> "VH" == Vincent Hardy <vincent.hardy@sun.com> writes:

VH> In SVG, your API to manipulate the graphics is the DOM and the
VH> best way to do what you want is to use scripting (e.g., Java or
VH> JavaScript).

    Agreed this is the 'correct' way to do this (and keeps you
independent of a particular SVG implementation).

VH> The problem is that right now, Batik does not support
VH> scripting. One way to work around this (and until we support
VH> scripting) is to do a setDocument on the JSVGCanvas after you have
VH> modified the DOM.

    This will work but forces the recreation of the GVT tree.  Since
they are actually manipulating the GVT tree directly they can make use
of JGVTComponent.flush() (JGVTComponent is JSVGCanvas's parent class).
This should clear the rendering cache for them.  So at the end of your
modify run just call flush().  You can also call flush with a
java.awt.Rectangle and only that region of the cached data will be

    Hope this helps...

VH> So, for example:

VH> Document doc = ...;

VH> Element elt = doc.getElementById("myLayer");

VH> elt.setAttributeNS(null, "visibility", "hidden");

VH> myCanvas.setDocument(doc);

VH> I think it is better now to hook in at the GVT level.  I hope this
VH> helps.  Vincent.

VH> Leakha.Henry@csiro.au 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: batik-users-unsubscribe@xml.apache.org For
>> additional commands, e-mail: batik-users-help@xml.apache.org

VH> ---------------------------------------------------------------------
VH> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
VH> additional commands, e-mail: batik-users-help@xml.apache.org

To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message