You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by comlong zhao <co...@gmail.com> on 2006/08/09 10:13:03 UTC

How to change the GVT tree

Hello thomas, hello all:
         First, I want to ask what is difference between the GVTtree and the
GraphicsNode. If the GVTtree is changed, whether the GraphicsNode is changed
too?  more details more better. thanks a lot.
         For my project, I do not use the JSVGCanvas, the event is come from
Canvas3D. I use the AWTEventDispatcher, the instance named "ad".  I use the
normal way that
        ad.setRootNode(gvtRoot);
        ad.setBaseTransform(curTxf);     //curTxf is the AffineTransform
         And then from the Frame I could call the MouseEvent of like this:

     public void mouseEvent1(final MouseEvent evt){        //transport the
parameter of evt to this method
        final Element rect = r;       // the element r has been initialized
        RunnableQueue rq = manager.getUpdateRunnableQueue();     // add the
event to RunableQueue
          try {   rq.invokeAndWait(new Runnable() {
                        public void run() {
                            ad.mouseClicked(evt);               // set mouse
event to change the GTV tree
                           rect.setAttributeNS(null, "x", ""+5);        //
setAttribute of the document
                       };
                    });
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
           if(manager.getUpdateTracker().hasChanged())      // test whether
the GVTtree has been changed
            System.out.println("GTV changed");    }

       But unfortunately, I could find the GVTtree has been changed only by
the Attribute changed. If I removed the line of attribute, it seems that the
GTVTree will not been changed.  I want to know whether this is a right way
that just only setRootNode() and then call the mouseCliked(). Or I should
add some code. For the RunableQueue, I think this way is right, because if I
removed it, I can not see the result of the Attribute changed.

       What should I do to change the GVTtree by one mouseclick?

       Thanks a lot

        Regards

         zhao

Re: How to change the GVT tree

Posted by th...@kodak.com.
Hi Zhao,

"comlong zhao" <co...@gmail.com> wrote on 08/09/2006 12:00:28 PM:

>       Thanks a lot for your suggestion. I used a really large Button to 
try 
> whether it could work well.

    What do you mean "a really large Button"?  there is no button in SVG.

>       Now, by your words, it seems the GVTtree is not changed by my 
code. I 
> have to modifies the document to change the GVTtree, but not only by the 
code 
> of "ad.mouseClicked(evt);" .Is it right?

    Why would you expect that dispatching an event would change GVTtree?

>       And, what is the event handler I could use? Could you explain a 
litter 
> more?   What is the correlative method I could use.

    There are several ways to add a DOM event handler.  The simplest is by
using one of the event attributes in the SVG:

        <!--- very large rect which should turn blue when mouse moves over 
it -->
        <rect onmousemove="evt.target.setAttribute('fill', 'blue')"
                x="-1000%" y="-1000%" width="3000%" height="3000%"
                fill="red"/>

        You can also investigate W3C DOM Events spec in particular the
'EventTarget.addEventHandler' method, which you can call from Java to
add event handlers to just about any rendered SVG Element.

> On 8/9/06, thomas.deweese@kodak.com <th...@kodak.com> wrote: 
> Hi Zhao,
> 
> "comlong zhao" <co...@gmail.com> wrote on 08/09/2006 04:13:03 AM: 
> 
> >          First, I want to ask what is difference between the GVTtree 
and
> the
> > GraphicsNode. If the GVTtree is changed, whether the GraphicsNode is
> changed
> > too?  more details more better. thanks a lot. 
> 
>    The GVT tree is the collection of GraphicsNodes.  Put another way
> the GraphicsNodes are the nodes in the GVT tree.
> 
> >          For my project, I do not use the JSVGCanvas, the event is 
come
> from
> > Canvas3D. I use the AWTEventDispatcher, the instance named "ad".  I 
use
> the
> > normal way that
> 
>    The code all looks pretty good. The important thing to know is that
> an event is only dispatched in the SVG tree if the mouse event is over 
> an SVG element.
> 
> >         ad.setRootNode(gvtRoot);
> >         ad.setBaseTransform(curTxf);     //curTxf is the 
AffineTransform
> 
>     The mouse coordinates in evt are transformed to the user coordinate 
> system of the root SVG element by 'curTxf' this point is then checked to
> see if it is inside any of the SVG elements if it is then a mouse event
> is dispatched.   Otherwise no event will be dispatched.  Also obviously 
> you must have an event handler that modifies the document, simply
> dispatching
> an event won't change anything.
> 
>     I would start with a very simple SVG document that just contains a
> very large rectangle (much larger than the 'displayed' document) and 
have 
> a mousemove handler that prints the clientX/Y of the DOM event to see 
what
> you
> are getting and if they make sense.
> 
> >          And then from the Frame I could call the MouseEvent of like
> this:
> >      public void mouseEvent1(final MouseEvent evt){        //transport 

> the
> > parameter of evt to this method
> >         final Element rect = r;       // the element r has been
> initialized
> >         RunnableQueue rq = manager.getUpdateRunnableQueue();     // 
add
> the 
> > event to RunableQueue
> >           try {   rq.invokeAndWait(new Runnable() {
> >                         public void run() {
> >                             ad.mouseClicked(evt);               // set 

> mouse
> > event to change the GTV tree
> >                            rect.setAttributeNS(null, "x", ""+5); //
> > setAttribute of the document
> >                        };
> >                     }); 
> >             } catch (InterruptedException ie) {
> >                 ie.printStackTrace();
> >             }
> >            if(manager.getUpdateTracker().hasChanged())      // test
> whether
> > the GVTtree has been changed 
> >             System.out.println("GTV changed");    }
> 
> >        But unfortunately, I could find the GVTtree has been changed 
only
> by
> > the Attribute changed. If I removed the line of attribute, it seems 
that 
> the
> > GTVTree will not been changed.  I want to know whether this is a right
> way
> > that just only setRootNode() and then call the mouseCliked(). Or I
> should add
> > some code. For the RunableQueue, I think this way is right, because if 
I 
> 
> > removed it, I can not see the result of the Attribute changed.
> >        What should I do to change the GVTtree by one mouseclick?
> >        Thanks a lot
> >         Regards
> >          zhao 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


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


Re: How to change the GVT tree

Posted by comlong zhao <co...@gmail.com>.
Hello thomas:
      Thanks a lot for your suggestion. I used a really large Button to try
whether it could work well.
      Now, by your words, it seems the GVTtree is not changed by my code. I
have to modifies the document to change the GVTtree, but not only by the
code of "ad.mouseClicked(evt);" .Is it right?
      And, what is the event handler I could use? Could you explain a litter
more?   What is the correlative method I could use.
      Thanks a lot
      Best Regards
      zhao

On 8/9/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 08/09/2006 04:13:03 AM:
>
> >          First, I want to ask what is difference between the GVTtree and
> the
> > GraphicsNode. If the GVTtree is changed, whether the GraphicsNode is
> changed
> > too?  more details more better. thanks a lot.
>
>    The GVT tree is the collection of GraphicsNodes.  Put another way
> the GraphicsNodes are the nodes in the GVT tree.
>
> >          For my project, I do not use the JSVGCanvas, the event is come
> from
> > Canvas3D. I use the AWTEventDispatcher, the instance named "ad".  I use
> the
> > normal way that
>
>    The code all looks pretty good. The important thing to know is that
> an event is only dispatched in the SVG tree if the mouse event is over
> an SVG element.
>
> >         ad.setRootNode(gvtRoot);
> >         ad.setBaseTransform(curTxf);     //curTxf is the AffineTransform
>
>     The mouse coordinates in evt are transformed to the user coordinate
> system of the root SVG element by 'curTxf' this point is then checked to
> see if it is inside any of the SVG elements if it is then a mouse event
> is dispatched.   Otherwise no event will be dispatched.  Also obviously
> you must have an event handler that modifies the document, simply
> dispatching
> an event won't change anything.
>
>     I would start with a very simple SVG document that just contains a
> very large rectangle (much larger than the 'displayed' document) and have
> a mousemove handler that prints the clientX/Y of the DOM event to see what
> you
> are getting and if they make sense.
>
> >          And then from the Frame I could call the MouseEvent of like
> this:
> >      public void mouseEvent1(final MouseEvent evt){        //transport
> the
> > parameter of evt to this method
> >         final Element rect = r;       // the element r has been
> initialized
> >         RunnableQueue rq = manager.getUpdateRunnableQueue();     // add
> the
> > event to RunableQueue
> >           try {   rq.invokeAndWait(new Runnable() {
> >                         public void run() {
> >                             ad.mouseClicked(evt);               // set
> mouse
> > event to change the GTV tree
> >                            rect.setAttributeNS(null, "x", ""+5); //
> > setAttribute of the document
> >                        };
> >                     });
> >             } catch (InterruptedException ie) {
> >                 ie.printStackTrace();
> >             }
> >            if(manager.getUpdateTracker().hasChanged())      // test
> whether
> > the GVTtree has been changed
> >             System.out.println("GTV changed");    }
>
> >        But unfortunately, I could find the GVTtree has been changed only
> by
> > the Attribute changed. If I removed the line of attribute, it seems that
> the
> > GTVTree will not been changed.  I want to know whether this is a right
> way
> > that just only setRootNode() and then call the mouseCliked(). Or I
> should add
> > some code. For the RunableQueue, I think this way is right, because if I
>
> > removed it, I can not see the result of the Attribute changed.
> >        What should I do to change the GVTtree by one mouseclick?
> >        Thanks a lot
> >         Regards
> >          zhao
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: How to change the GVT tree

Posted by th...@kodak.com.
Hi Zhao,

"comlong zhao" <co...@gmail.com> wrote on 08/09/2006 04:13:03 AM:

>          First, I want to ask what is difference between the GVTtree and 
the 
> GraphicsNode. If the GVTtree is changed, whether the GraphicsNode is 
changed 
> too?  more details more better. thanks a lot.

    The GVT tree is the collection of GraphicsNodes.  Put another way
the GraphicsNodes are the nodes in the GVT tree.

>          For my project, I do not use the JSVGCanvas, the event is come 
from 
> Canvas3D. I use the AWTEventDispatcher, the instance named "ad".  I use 
the 
> normal way that

    The code all looks pretty good. The important thing to know is that
an event is only dispatched in the SVG tree if the mouse event is over
an SVG element. 
 
>         ad.setRootNode(gvtRoot);
>         ad.setBaseTransform(curTxf);     //curTxf is the AffineTransform

     The mouse coordinates in evt are transformed to the user coordinate
system of the root SVG element by 'curTxf' this point is then checked to
see if it is inside any of the SVG elements if it is then a mouse event
is dispatched.   Otherwise no event will be dispatched.  Also obviously 
you must have an event handler that modifies the document, simply 
dispatching
an event won't change anything.

     I would start with a very simple SVG document that just contains a
very large rectangle (much larger than the 'displayed' document) and have
a mousemove handler that prints the clientX/Y of the DOM event to see what 
you
are getting and if they make sense.

>          And then from the Frame I could call the MouseEvent of like 
this:
>      public void mouseEvent1(final MouseEvent evt){        //transport 
the 
> parameter of evt to this method 
>         final Element rect = r;       // the element r has been 
initialized 
>         RunnableQueue rq = manager.getUpdateRunnableQueue();     // add 
the 
> event to RunableQueue
>           try {   rq.invokeAndWait(new Runnable() {
>                         public void run() {
>                             ad.mouseClicked(evt);               // set 
mouse 
> event to change the GTV tree
>                            rect.setAttributeNS(null, "x", ""+5); // 
> setAttribute of the document
>                        }; 
>                     });
>             } catch (InterruptedException ie) {
>                 ie.printStackTrace();
>             }
>            if(manager.getUpdateTracker().hasChanged())      // test 
whether 
> the GVTtree has been changed 
>             System.out.println("GTV changed");    }

>        But unfortunately, I could find the GVTtree has been changed only 
by 
> the Attribute changed. If I removed the line of attribute, it seems that 
the 
> GTVTree will not been changed.  I want to know whether this is a right 
way 
> that just only setRootNode() and then call the mouseCliked(). Or I 
should add 
> some code. For the RunableQueue, I think this way is right, because if I 

> removed it, I can not see the result of the Attribute changed. 
>        What should I do to change the GVTtree by one mouseclick?
>        Thanks a lot
>         Regards
>          zhao

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