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/05/04 04:48:57 UTC

Re: How to get the element form SVG file.

Hello:
   Thanks a lot for your help. But so pity, i have not achieved it. I just
use your demo code now, and when i run my java3D code, your code is running
and i could get a lot of bufferedimage. Now, when i click one key or mouse
button, i could call one method which is in your file. So i think i create
one method like that:
  AWTEventDispatcher ad = new AWTEventDispatcher();

  public void interactive(){
     ctx.addDOMListeners();
    ad.setRootNode(gvtRoot);
   ad.mouseClicked((MouseEvent) *evt*);
    manager.getUpdateRunnableQueue();
}
 is that right?
 and I do not know how to use the evt, for the java 3d, i just could call
the method, but i do now know how to transform the parameter now. For the
basic way, I just want that when i press one button or click the mouse, i
could call the method and then i could get the new Bufferedimage.

  Sorry to trouble you again.
  Thank you very much.
  zhao long


On 4/25/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 04/23/2006 06:04:05 PM:
>
> >       Thanks a lot for your help.  There is only one problem left for me
> that
> > how to use the "batik.gvt.event.AWTEventDispatcher" to add the
> interactive
> > event. Now i use one simple SVG file for test, only one event of
> clicking left
> > button of mouse. I found there is a method of " mouseClicked( MouseEvent
> evt)"
> > in the class of batik.gvt.event.AWTEventDispatcher. But in your demo
> file,
> > there are some objects of manager, document, gvtRoot. which one i could
> use to
> > call that method? or i need to create a new object, but how to make the
> > connetion with the current SVG file.
>
>   You need to construct your own instance, and then call
> 'setRootNode(gvtRoot)'.
> You may also need to notify it of the 'baseTransform' Which is the mapping
> from
> the screen coordinates to the documents coordinate system (the rendering
> transform).
>
> > And then as you said, i just need to add one line of
> > manager.getUpdateRunnableQueue(); is it right?
>
>   I'm not sure I follow but, 'mouseClicked' should be called in the
> UpdateManager thread...
>
>
> >       If it is possible, could you show me some code?
> >       Thank you very much.
> >       zhao long.
> >
> > 2006/4/4, thomas.deweese@kodak.com <th...@kodak.com>:
> > Hi Zhao,
> >
> > "comlong zhao" <co...@gmail.com> wrote on 04/03/2006 07:42:48 PM:
> >
> > >       Thanks a lot for your help, and coached by your word, the
> > animaiton has
> > > been added on the java3D object.  But, i could only use the animation
> > > controled by the javascript, if you use some animation which is
> > controled by
> > > the tag named <animateTransform>, it does not work. Also for your
> code,
> > it
> > > could not generate the different .png files.  What is this problem,
> > shold i
> > > add some new functions?
> >
> >   Batik does not support SMIL animation at the moment.  Cameron has
> > started
> > to add some support in the animation branch, also you might look at Doug
> > Schepters SMIL Script, which is part of SMIL animation written in
> > JavaScript.
> >
> > >       And next step for me is to add the interaction. I want to know
> how
> > i
> > > could tell the svg file that i have pressed one button,and then i
> could
> > get
> > > the result (bufferedimages), so i need to rewrite the javascript to
> > java?
> >
> >   Generally you just need to make the sure the DOM Event listener
> > get's called.  This is done by dispatching the event to the GVT tree.
> > The code Batik uses for this is in batik.gvt.event.AWTEventDispatcher .
> > Once the event is dispatched it will normally modify the document which
> > will
> > cause the update manager to run and hence the BufferedImage to be
> updated.
> > You must dispatch the event to the GVT tree in the UpdateManager's
> > RunnableQueue or else it won't notice the changes.
> >
> > >      please give me some suggestion, i will follow your help to do.
> > >      Thank you very much
> > >      zhao long
> > >
> > >
> > > On 3/23/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > > "comlong zhao" < comlong@gmail.com> wrote on 03/22/2006 12:16:45 PM:
> > >
> > > >      Thanks for your words, it works well now. And for the SVG
> > animation
> > > of
> > > > "3D.svg", i could only get 4 or 5 .png files.
> > >
> > >    Why are you still generating PNG files?  You should delete to code
> > > that
> > > saves PNG and just use BufferedImage.
> > >
> > > > If i change the display size, i could get more .png files. They are
> > from
> > > the
> > > > bufferedimage that is just what i need. But i want to know why they
> > have
> > > limited
> > > > numbers. I want to get a lot of bufferedimages, not stopping as the
> > > animation.
> > > > what should i do? please give me a idea.
> > >
> > >   I suspect you want to remove this code from the end of main:
> > >
> > >         for (int i=1; i<10; i++) {
> > >            final int x = 100+ (i*10);
> > >            try {
> > >                rq.invokeAndWait(new Runnable() {
> > >                        public void run() {
> > >                            rect.setAttributeNS(null, "x", ""+x);
> > >                        }
> > >                    });
> > >            } catch (InterruptedException ie) {
> > >                ie.printStackTrace();
> > >            }
> > >        }
> > >        render.manager.suspend ();
> > >
> > >   In particular the last line stops the updatemanager so no more
> > > updates will be delivered.  If you just delete all of this code you
> > > should get an endless supply of calls to the 'render' method...
> > >
> > >
> > > >    Thank you very much.
> > > >    zhao long
> > >
> > > > On 3/22/06, Tonny Kohar <to...@kiyut.com> wrote:
> > > > Hi,
> > > >
> > > > On Wed, 2006-03-22 at 06:26 +0100, comlong zhao wrote:
> > > > > Hello thomas:
> > > > >     In your code, you have already used the toString way.
> > > > >             File f = new File(" anne.svg");
> > > > >             doc = df.createSVGDocument(f.toURL ().toString());
> > > > >    I use the annd.svg directly here.  When i run your code,  it
> also
> > > > > shows the error of
> > > > >   An I/O error occured while processing the URI:
> > > > >  "batikLogo.svg#Batik_Tag_Box "
> > > > >  specified on the element <use>
> > > > >         if i delete the element of use in anne.svg , it works
> well.
> > Is
> > > > > it strange or i should not input the file name directly.
> > > > >      Thank you very much
> > > > >      zhao long
> > > > >
> > > >
> > > > anne.svg in batik sample directory contains reference to
> batikLogo.svg
> > > > in the same directory. So if you move anne.svg out from the sample
> > > > directory, you also need to copy / move batikLogo.svg as well. If
> not
> > > > the reference will be broken
> > > >
> > > > Regards
> > > > Tonny Kohar
> > > > --
> > > > Sketsa
> > > > SVG Graphics Editor
> > > > http://www.kiyut.com
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>