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/03/14 04:50:58 UTC

How to get the element form SVG file.

Hello:
    I am new about the Batik. It has a big API. Now I want to get the
element from a SVG file and then draw the same thing using java2D. Could
someone give me some idea or suggestion.
   Thank you in advanced.
   zhao long

Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
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
>
>

Re: How to get the element form SVG file.

Posted by th...@kodak.com.
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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
Hello thomas:
      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*<file:///D:/Book/batik-doc/org/apache/batik/gvt/event/AWTEventDispatcher.html#mouseClicked(java.awt.event.MouseEvent)>
(MouseEvent<http://java.sun.com/j2se/1.3/docs/api/java/awt/event/MouseEvent.html>
 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. And then as you said, i just
need to add one line of  manager.getUpdateRunnableQueue();
is it right?
      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" <co...@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
>
>

Re: How to get the element form SVG file.

Posted by 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" <co...@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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
  Hello thomas:
      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?
      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?
     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 <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@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
>
>

Re: How to get the element form SVG file.

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

"comlong zhao" <co...@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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
  Hello thomas:
     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. 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 stoping as the animation.  what should i do?
please give me a idea.
   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
>
>

Re: How to get the element form SVG file.

Posted by Tonny Kohar <to...@kiyut.com>.
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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
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




On 3/22/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 03/21/2006 01:37:20 AM:
>
> >      Thanks for your help and excuse me to trouble you again.
> >      First, as your said, i should use the URL, but not the URI. But i
> can not
> > find any method that supports URL in many "DocumentFactory" classes. All
> of
> > them use URI, and i find it use the "inputstream" in the main method of
> > "createDocument" of the class "SAXSVGDocumentFactory"  how could i do?
>
> You pass the URL as a string (URL.toString()).
>
> >      Another thing is you said i should use "batik.gvt.event.
> > AWTEventDispatcher" to add the events to java3D.  i want to know whether
> it is
> > in the bufferedimage, and then when i add it as a texture, it could
> work, or i
> > have to set one area for one button of the SVG in the 3D object.
>
>   You need to map the pointer from Java3D to the u & v of the 3D object
> and then dispatch those as a pointer event into the SVG.  I don't think
> I can help much more here since I don't know anything about Java3D besides
> general knowledge of the basics of 3D.
>
> >      From the article named "BatikRenderingSummary", it said the  method
> "
> > installSVGDocument()"  could do the 5 steps automaticly, Is it possible
> for me
> > to use that method or some methods like that to get a bufferedimage and
> then
> > add it to my 3D world.
>
>   I would suggest using the code from the TestOffScreenRendering.  Trying
> to use the Canvas is likely to be problematic.
>
> >     As you said, the JSVGComponent uses the bufferedimage to show
> everything.
> > The only difference is i add the bufferedimage to Java3D, and the Batik
> has
> > existing method for JComponent. but i did find a method that add the
> > bufferedimage to the JComponent, if i could find it, what i need to do
> just
> > add it to java3D? Is it right and possible?
>
>   I really think that using the JSVGCanvas will be more problematic
> down the road.
>
> >      Thanks a lot.
> >      zhao long
> >
> >
> >
> > On 3/20/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <co...@gmail.com> wrote on 03/19/2006 10:51:54 PM:
> >
> > >     Thanks a lot for your help. Now i know how to run your code. For
> the
> >
> > > interaction,  it is like the mines.svg that i could play the simple
> game
> > on
> > > one plane of a java3D object.
> >
> >   Ok, then you will need to provide a Java3D replacement for the
> > batik.gvt.event.AWTEventDispatcher that dispatches mouse/keyboard
> > events from Java3D into the GVT tree.
> >
> > >     Now there are some problems that when i use some SVG file with a
> > element
> > > named "use", i could get the error
> > >   "batikLogo.svg#Batik_Tag_Box" specified on the element <use>
> > >   at org.apache.batik.bridge.BridgeContext.getReferencedElement
> (Unknown
> > Source)
> > >    .....
> >
> >   This is probably because you are giving Batik an InputStream rather
> > than a URL.  When you give Batik an InputStream Batik doesn't know
> > where the SVG content came from, so when it gets a relative reference
> > to another file it can't find it.  It is best to always give Batik
> > a URL when possible.
> >
> > >     if i delete the element of "use" in the SVG file, it works.  It
> > happened
> > > as i use the " anne.svg".    But, for some animation SVG file like
> > 3D.svg, I
> > > have to use that element, otherwise, i can not get the animaition. it
> > seems it
> > > is the interface of the javascript. is it right?  how could i do?
> >
> >   Actually I think the problem is that my sample code doesn't dispatch
> > the 'onload' event.  I think this is as simple as adding the line:
> >
> >            manager.dispatchSVGLoadEvent();
> >
> >   I've updated the Wiki Page so it now calls onload handlers.  The
> > original example was oriented around getting updates as Java manipulated
> > the document not JavaScript.
> >
> > >     For your code, that seems when the bufferedimage changed, i could
> > get a
> > > new bufferedimage,
> > >      manager.addUpdateManagerListener(new UpdateManagerAdapter() {
> > >                 public void updateCompleted(UpdateManagerEvent e) {
> > >        }
> > >     is it right?
> >
> >   Yes, this is correct.  This method is called after the offscreen image
>
> > is updated.
> >
> > > and then, i could add the BufferedImage to my java3d object.
> > > Do you think that will waste a lot of memory, and everything will be
> > slow.
> >
> >   I don't know, I've never done anything with Java3D.  Internally Batik
> > uses Single or Double buffering so there is really only one or two
> > BufferedImages
> > that are passed to this method.
> >
> > >    Is it the same structure as the SVG rendering in JSVGComponent.
> Same
> > every
> > > frame in bufferedimage, and then when bufferedimage changed, show the
> > new one.
> >
> >    Yes, this is what the component does.  It copies the modified regions
> > to
> > the screen when this callback is called by the update manager.
> >
> > > On 3/17/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > > "comlong zhao" <comlong@gmail.com > wrote on 03/16/2006 10:14:26 AM:
> > >
> > > >        Thanks a lot for your help. Why i have to use the
> bufferedimage
> > > is the
> > > > Java3D texture only support the bufferedimage. Now it seems the
> batik
> > > could
> > > > render SVG using the DynamicRenderer to save the animation to the
> > > > bufferedimage, and i think i could add the animation to Java3D
> texture
> > > through
> > > > the bufferedimage.
> > >
> > >   Yes.
> > >
> > > > But for the interaction, could it work well through the
> bufferedimage?
> > > > or i have to use another way to transform the javascript to java.
> > >
> > >   I'm not sure what you mean by 'interaction'.  The sample code I
> > > gave should run script and update the BufferedImage (you will be
> > > notified when the image changes by it calling the
> > > 'render(BufferedImage)' method).
> > >
> > >   If you want to handle interaction like 'pointer' and 'key' events.
> > > Then you will have to map a cursor position to the coordinate system
> > > of the root of the SVG document and dispatch it to the AWT tree by
> > > implementing the batik.gvt.event.EventDispatcher interface.
> > >
> > > > On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > wrote:
> > > > Hi Zhao,
> > > >
> > > > "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> > > >
> > > > >         Thanks a lot for your code. That is much useful for me and
> i
> >
> > > am
> > > > > learning it line by line. I found it was created by you, so I want
> > to
> > > > ask what
> > > > > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> > > > undefined
> > > > > by my eclipse and i also can not find from the API.
> > > >
> > > >    I added this line to avoid a problem where it would decide to
> > > > 'skip frames' because the updates had come too quickly.  This is
> good
> > > > for the normal usage of updating a screen (and is likely also good
> for
> >
> > > > your case as well) but is bad in the context of trying to 'record'
> the
> > > > image after each runnable.
> > > >
> > > >    This method is only in the SVN version of Batik. (I should add a
> > > > comment to the example to this effect).
> > > >
> > > > > If i remove this line, it could not work too.
> > > > >     The error is
> > > > > "Exception in thread "main"
> > java.lang.ArrayIndexOutOfBoundsException:
> > > 0
> > > > >  at Example.TestOffScreenRender.main
> (TestOffScreenRender.java:150)"
> > > > > How could i run it?
> > > >
> > > >     You have to provide the filename of an SVG file to load as the
> > > > 'background' to the animation.  For my testing I used
> > > 'samples/anne.svg'.
> > > > I'll add a println to this effect in the example when args.length is
> > > zero.
> > > >
> > > > >      Thank you again.
> > > >
> > > >     Good luck!
> > > >
> > > > >      zhao long
> > > > >
> > > > >
> > > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > > wrote:
> > > > > Hi Zhao,
> > > > >
> > > > >        You probably want to read:
> > > > > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> > > > >
> > > > >        This renders an SVG to an offscreen buffer.  This code even
>
> > > > > handles updating
> > > > > the offscreen buffer if the SVG Document is changed (I don't know
> if
> > > > this
> > > > > is useful to you).
> > > > >
> > > > > "comlong zhao" < comlong@gmail.com > wrote on 03/14/2006 09:15:19
> > AM:
> > > > >
> > > > > >  Hello:
> > > > > >      Thanks a lot. I will try it. What is the result i want to
> get
> > > is
> > > > > saving
> > > > > > the SVG into the Butteredimage and then add it as texture in
> > java3D.
> > >
> > > > Now
> > > > > it
> > > > > > seems i do not need to draw it using java2D, but does Batik
> > support
> > > > svg
> > > > > to
> > > > > > butteredimage directly? could someone give me some ideas or
> > > > suggestions.
> > > > > If
> > > > > > you have code demo, that's best. ;)
> > > > > >      Thank you very much.
> > > > > >      Thank thomas.deweese
> > > > > >      zhao long
> > > > > >
> > > > > >
> > > > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > > > wrote:
> > > > > > Hi Zhao,
> > > > > >
> > > > > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58
> > PM:
> > > > > >
> > > > > > >     I am new about the Batik. It has a big API. Now I want to
> > get
> > > > the
> > > > > > element
> > > > > > > from a SVG file and then draw the same thing using java2D.
> Could
> > > > > someone
> > > > > > give
> > > > > > > me some idea or suggestion.
> > > > > >
> > > > > >    Well all of Batik's drawing is done using Java2D so perhaps
> you
> > > > > > need to do nothing.  Once you have read the SVG file and built
> the
> > > > > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > > > > > get the GVT element for any node in the DOM by asking the
> > > > > > BridgeContext:
> > > > > >        Element x = document.getElementById ("foo");
> > > > > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > > > > >
> > > > > >    GraphicsNode has a method 'paint' that takes a standard
> > > > > > Graphics2D.
> > > > > >
> > > > > >
> > > > > >
> > > ---------------------------------------------------------------------
> > > > > > 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
> >
> >
> > ---------------------------------------------------------------------
> > 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 get the element form SVG file.

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

"comlong zhao" <co...@gmail.com> wrote on 03/21/2006 01:37:20 AM:

>      Thanks for your help and excuse me to trouble you again. 
>      First, as your said, i should use the URL, but not the URI. But i 
can not
> find any method that supports URL in many "DocumentFactory" classes. All 
of 
> them use URI, and i find it use the "inputstream" in the main method of 
> "createDocument" of the class "SAXSVGDocumentFactory"  how could i do? 

  You pass the URL as a string (URL.toString()).

>      Another thing is you said i should use "batik.gvt.event.
> AWTEventDispatcher" to add the events to java3D.  i want to know whether 
it is
> in the bufferedimage, and then when i add it as a texture, it could 
work, or i
> have to set one area for one button of the SVG in the 3D object.

   You need to map the pointer from Java3D to the u & v of the 3D object
and then dispatch those as a pointer event into the SVG.  I don't think
I can help much more here since I don't know anything about Java3D besides
general knowledge of the basics of 3D.

>      From the article named "BatikRenderingSummary", it said the  method 
" 
> installSVGDocument()"  could do the 5 steps automaticly, Is it possible 
for me
> to use that method or some methods like that to get a bufferedimage and 
then 
> add it to my 3D world. 

   I would suggest using the code from the TestOffScreenRendering.  Trying
to use the Canvas is likely to be problematic.

>     As you said, the JSVGComponent uses the bufferedimage to show 
everything. 
> The only difference is i add the bufferedimage to Java3D, and the Batik 
has 
> existing method for JComponent. but i did find a method that add the 
> bufferedimage to the JComponent, if i could find it, what i need to do 
just 
> add it to java3D? Is it right and possible? 

   I really think that using the JSVGCanvas will be more problematic 
down the road.

>      Thanks a lot.
>      zhao long
> 
> 
> 
> On 3/20/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote: 
> Hi Zhao,
> 
> "comlong zhao" <co...@gmail.com> wrote on 03/19/2006 10:51:54 PM: 
> 
> >     Thanks a lot for your help. Now i know how to run your code. For 
the
> 
> > interaction,  it is like the mines.svg that i could play the simple 
game
> on
> > one plane of a java3D object.
> 
>   Ok, then you will need to provide a Java3D replacement for the
> batik.gvt.event.AWTEventDispatcher that dispatches mouse/keyboard
> events from Java3D into the GVT tree.
> 
> >     Now there are some problems that when i use some SVG file with a 
> element
> > named "use", i could get the error
> >   "batikLogo.svg#Batik_Tag_Box" specified on the element <use>
> >   at org.apache.batik.bridge.BridgeContext.getReferencedElement 
(Unknown
> Source)
> >    .....
> 
>   This is probably because you are giving Batik an InputStream rather
> than a URL.  When you give Batik an InputStream Batik doesn't know
> where the SVG content came from, so when it gets a relative reference 
> to another file it can't find it.  It is best to always give Batik
> a URL when possible.
> 
> >     if i delete the element of "use" in the SVG file, it works.  It
> happened
> > as i use the " anne.svg".    But, for some animation SVG file like
> 3D.svg, I
> > have to use that element, otherwise, i can not get the animaition. it
> seems it
> > is the interface of the javascript. is it right?  how could i do? 
> 
>   Actually I think the problem is that my sample code doesn't dispatch
> the 'onload' event.  I think this is as simple as adding the line:
> 
>            manager.dispatchSVGLoadEvent();
> 
>   I've updated the Wiki Page so it now calls onload handlers.  The 
> original example was oriented around getting updates as Java manipulated
> the document not JavaScript.
> 
> >     For your code, that seems when the bufferedimage changed, i could
> get a
> > new bufferedimage, 
> >      manager.addUpdateManagerListener(new UpdateManagerAdapter() {
> >                 public void updateCompleted(UpdateManagerEvent e) {
> >        }
> >     is it right?
> 
>   Yes, this is correct.  This method is called after the offscreen image 

> is updated.
> 
> > and then, i could add the BufferedImage to my java3d object.
> > Do you think that will waste a lot of memory, and everything will be
> slow.
> 
>   I don't know, I've never done anything with Java3D.  Internally Batik 
> uses Single or Double buffering so there is really only one or two
> BufferedImages
> that are passed to this method.
> 
> >    Is it the same structure as the SVG rendering in JSVGComponent. 
Same
> every
> > frame in bufferedimage, and then when bufferedimage changed, show the 
> new one.
> 
>    Yes, this is what the component does.  It copies the modified regions
> to
> the screen when this callback is called by the update manager.
> 
> > On 3/17/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > 
wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <comlong@gmail.com > wrote on 03/16/2006 10:14:26 AM:
> >
> > >        Thanks a lot for your help. Why i have to use the 
bufferedimage
> > is the
> > > Java3D texture only support the bufferedimage. Now it seems the 
batik 
> > could
> > > render SVG using the DynamicRenderer to save the animation to the
> > > bufferedimage, and i think i could add the animation to Java3D 
texture
> > through
> > > the bufferedimage. 
> >
> >   Yes.
> >
> > > But for the interaction, could it work well through the 
bufferedimage?
> > > or i have to use another way to transform the javascript to java.
> >
> >   I'm not sure what you mean by 'interaction'.  The sample code I 
> > gave should run script and update the BufferedImage (you will be
> > notified when the image changes by it calling the
> > 'render(BufferedImage)' method).
> >
> >   If you want to handle interaction like 'pointer' and 'key' events. 
> > Then you will have to map a cursor position to the coordinate system
> > of the root of the SVG document and dispatch it to the AWT tree by
> > implementing the batik.gvt.event.EventDispatcher interface.
> >
> > > On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > > 
> > > "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> > >
> > > >         Thanks a lot for your code. That is much useful for me and 
i 
> 
> > am
> > > > learning it line by line. I found it was created by you, so I want
> to
> > > ask what
> > > > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> > > undefined 
> > > > by my eclipse and i also can not find from the API.
> > >
> > >    I added this line to avoid a problem where it would decide to
> > > 'skip frames' because the updates had come too quickly.  This is 
good 
> > > for the normal usage of updating a screen (and is likely also good 
for
> 
> > > your case as well) but is bad in the context of trying to 'record' 
the
> > > image after each runnable.
> > > 
> > >    This method is only in the SVN version of Batik. (I should add a
> > > comment to the example to this effect).
> > >
> > > > If i remove this line, it could not work too.
> > > >     The error is 
> > > > "Exception in thread "main"
> java.lang.ArrayIndexOutOfBoundsException:
> > 0
> > > >  at Example.TestOffScreenRender.main 
(TestOffScreenRender.java:150)"
> > > > How could i run it? 
> > >
> > >     You have to provide the filename of an SVG file to load as the
> > > 'background' to the animation.  For my testing I used
> > 'samples/anne.svg'.
> > > I'll add a println to this effect in the example when args.length is
> > zero.
> > >
> > > >      Thank you again.
> > >
> > >     Good luck!
> > >
> > > >      zhao long
> > > >
> > > >
> > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > wrote:
> > > > Hi Zhao,
> > > >
> > > >        You probably want to read: 
> > > > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> > > >
> > > >        This renders an SVG to an offscreen buffer.  This code even 

> > > > handles updating
> > > > the offscreen buffer if the SVG Document is changed (I don't know 
if
> > > this
> > > > is useful to you).
> > > >
> > > > "comlong zhao" < comlong@gmail.com > wrote on 03/14/2006 09:15:19
> AM:
> > > >
> > > > >  Hello:
> > > > >      Thanks a lot. I will try it. What is the result i want to 
get 
> > is
> > > > saving
> > > > > the SVG into the Butteredimage and then add it as texture in
> java3D.
> >
> > > Now
> > > > it
> > > > > seems i do not need to draw it using java2D, but does Batik 
> support
> > > svg
> > > > to
> > > > > butteredimage directly? could someone give me some ideas or
> > > suggestions.
> > > > If
> > > > > you have code demo, that's best. ;) 
> > > > >      Thank you very much.
> > > > >      Thank thomas.deweese
> > > > >      zhao long
> > > > >
> > > > >
> > > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > > wrote:
> > > > > Hi Zhao,
> > > > >
> > > > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58
> PM:
> > > > >
> > > > > >     I am new about the Batik. It has a big API. Now I want to
> get
> > > the 
> > > > > element
> > > > > > from a SVG file and then draw the same thing using java2D. 
Could
> > > > someone
> > > > > give
> > > > > > me some idea or suggestion. 
> > > > >
> > > > >    Well all of Batik's drawing is done using Java2D so perhaps 
you
> > > > > need to do nothing.  Once you have read the SVG file and built 
the
> > > > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can 
> > > > > get the GVT element for any node in the DOM by asking the
> > > > > BridgeContext:
> > > > >        Element x = document.getElementById ("foo");
> > > > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > > > >
> > > > >    GraphicsNode has a method 'paint' that takes a standard
> > > > > Graphics2D.
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > 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
> 
> 
> --------------------------------------------------------------------- 
> 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 get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
Hello thomas:
     Thanks for your help and excuse me to trouble you again.
     First, as your said, i should use the URL, but not the URI. But i can
not find any method that supports URL in many "DocumentFactory" classes. All
of them use URI, and i find it use the "inputstream" in the main method of
"createDocument" of the class "SAXSVGDocumentFactory"  how could i do?
     Another thing is you said i should use "
batik.gvt.event.AWTEventDispatcher" to add the events to java3D.  i want to
know whether it is in the bufferedimage, and then when i add it as a
texture, it could work, or i have to set one area for one button of the SVG
in the 3D object.
     From the article named "BatikRenderingSummary", it said the  method "
installSVGDocument()"  could do the 5 steps automaticly, Is it possible for
me to use that method or some methods like that to get a bufferedimage and
then add it to my 3D world.
    As you said, the JSVGComponent uses the bufferedimage to show
everything. The only difference is i add the bufferedimage to Java3D, and
the Batik has existing method for JComponent. but i did find a method that
add the bufferedimage to the JComponent, if i could find it, what i need to
do just add it to java3D? Is it right and possible?
     Thanks a lot.
     zhao long



On 3/20/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 03/19/2006 10:51:54 PM:
>
> >     Thanks a lot for your help. Now i know how to run your code. For the
>
> > interaction,  it is like the mines.svg that i could play the simple game
> on
> > one plane of a java3D object.
>
>   Ok, then you will need to provide a Java3D replacement for the
> batik.gvt.event.AWTEventDispatcher that dispatches mouse/keyboard
> events from Java3D into the GVT tree.
>
> >     Now there are some problems that when i use some SVG file with a
> element
> > named "use", i could get the error
> >   "batikLogo.svg#Batik_Tag_Box" specified on the element <use>
> >   at org.apache.batik.bridge.BridgeContext.getReferencedElement(Unknown
> Source)
> >    .....
>
>   This is probably because you are giving Batik an InputStream rather
> than a URL.  When you give Batik an InputStream Batik doesn't know
> where the SVG content came from, so when it gets a relative reference
> to another file it can't find it.  It is best to always give Batik
> a URL when possible.
>
> >     if i delete the element of "use" in the SVG file, it works.  It
> happened
> > as i use the "anne.svg".    But, for some animation SVG file like
> 3D.svg, I
> > have to use that element, otherwise, i can not get the animaition. it
> seems it
> > is the interface of the javascript. is it right?  how could i do?
>
>   Actually I think the problem is that my sample code doesn't dispatch
> the 'onload' event.  I think this is as simple as adding the line:
>
>            manager.dispatchSVGLoadEvent();
>
>   I've updated the Wiki Page so it now calls onload handlers.  The
> original example was oriented around getting updates as Java manipulated
> the document not JavaScript.
>
> >     For your code, that seems when the bufferedimage changed, i could
> get a
> > new bufferedimage,
> >      manager.addUpdateManagerListener(new UpdateManagerAdapter() {
> >                 public void updateCompleted(UpdateManagerEvent e) {
> >        }
> >     is it right?
>
>   Yes, this is correct.  This method is called after the offscreen image
> is updated.
>
> > and then, i could add the BufferedImage to my java3d object.
> > Do you think that will waste a lot of memory, and everything will be
> slow.
>
>   I don't know, I've never done anything with Java3D.  Internally Batik
> uses Single or Double buffering so there is really only one or two
> BufferedImages
> that are passed to this method.
>
> >    Is it the same structure as the SVG rendering in JSVGComponent. Same
> every
> > frame in bufferedimage, and then when bufferedimage changed, show the
> new one.
>
>    Yes, this is what the component does.  It copies the modified regions
> to
> the screen when this callback is called by the update manager.
>
> > On 3/17/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <co...@gmail.com> wrote on 03/16/2006 10:14:26 AM:
> >
> > >        Thanks a lot for your help. Why i have to use the bufferedimage
> > is the
> > > Java3D texture only support the bufferedimage. Now it seems the batik
> > could
> > > render SVG using the DynamicRenderer to save the animation to the
> > > bufferedimage, and i think i could add the animation to Java3D texture
> > through
> > > the bufferedimage.
> >
> >   Yes.
> >
> > > But for the interaction, could it work well through the bufferedimage?
> > > or i have to use another way to transform the javascript to java.
> >
> >   I'm not sure what you mean by 'interaction'.  The sample code I
> > gave should run script and update the BufferedImage (you will be
> > notified when the image changes by it calling the
> > 'render(BufferedImage)' method).
> >
> >   If you want to handle interaction like 'pointer' and 'key' events.
> > Then you will have to map a cursor position to the coordinate system
> > of the root of the SVG document and dispatch it to the AWT tree by
> > implementing the batik.gvt.event.EventDispatcher interface.
> >
> > > On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > > "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> > >
> > > >         Thanks a lot for your code. That is much useful for me and i
>
> > am
> > > > learning it line by line. I found it was created by you, so I want
> to
> > > ask what
> > > > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> > > undefined
> > > > by my eclipse and i also can not find from the API.
> > >
> > >    I added this line to avoid a problem where it would decide to
> > > 'skip frames' because the updates had come too quickly.  This is good
> > > for the normal usage of updating a screen (and is likely also good for
>
> > > your case as well) but is bad in the context of trying to 'record' the
> > > image after each runnable.
> > >
> > >    This method is only in the SVN version of Batik. (I should add a
> > > comment to the example to this effect).
> > >
> > > > If i remove this line, it could not work too.
> > > >     The error is
> > > > "Exception in thread "main"
> java.lang.ArrayIndexOutOfBoundsException:
> > 0
> > > >  at Example.TestOffScreenRender.main (TestOffScreenRender.java:150)"
> > > > How could i run it?
> > >
> > >     You have to provide the filename of an SVG file to load as the
> > > 'background' to the animation.  For my testing I used
> > 'samples/anne.svg'.
> > > I'll add a println to this effect in the example when args.length is
> > zero.
> > >
> > > >      Thank you again.
> > >
> > >     Good luck!
> > >
> > > >      zhao long
> > > >
> > > >
> > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > wrote:
> > > > Hi Zhao,
> > > >
> > > >        You probably want to read:
> > > > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> > > >
> > > >        This renders an SVG to an offscreen buffer.  This code even
> > > > handles updating
> > > > the offscreen buffer if the SVG Document is changed (I don't know if
> > > this
> > > > is useful to you).
> > > >
> > > > "comlong zhao" < comlong@gmail.com > wrote on 03/14/2006 09:15:19
> AM:
> > > >
> > > > >  Hello:
> > > > >      Thanks a lot. I will try it. What is the result i want to get
> > is
> > > > saving
> > > > > the SVG into the Butteredimage and then add it as texture in
> java3D.
> >
> > > Now
> > > > it
> > > > > seems i do not need to draw it using java2D, but does Batik
> support
> > > svg
> > > > to
> > > > > butteredimage directly? could someone give me some ideas or
> > > suggestions.
> > > > If
> > > > > you have code demo, that's best. ;)
> > > > >      Thank you very much.
> > > > >      Thank thomas.deweese
> > > > >      zhao long
> > > > >
> > > > >
> > > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > > wrote:
> > > > > Hi Zhao,
> > > > >
> > > > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58
> PM:
> > > > >
> > > > > >     I am new about the Batik. It has a big API. Now I want to
> get
> > > the
> > > > > element
> > > > > > from a SVG file and then draw the same thing using java2D. Could
> > > > someone
> > > > > give
> > > > > > me some idea or suggestion.
> > > > >
> > > > >    Well all of Batik's drawing is done using Java2D so perhaps you
> > > > > need to do nothing.  Once you have read the SVG file and built the
> > > > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > > > > get the GVT element for any node in the DOM by asking the
> > > > > BridgeContext:
> > > > >        Element x = document.getElementById ("foo");
> > > > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > > > >
> > > > >    GraphicsNode has a method 'paint' that takes a standard
> > > > > Graphics2D.
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: How to get the element form SVG file.

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

"comlong zhao" <co...@gmail.com> wrote on 03/19/2006 10:51:54 PM:

>     Thanks a lot for your help. Now i know how to run your code. For the 

> interaction,  it is like the mines.svg that i could play the simple game 
on 
> one plane of a java3D object.

   Ok, then you will need to provide a Java3D replacement for the 
batik.gvt.event.AWTEventDispatcher that dispatches mouse/keyboard
events from Java3D into the GVT tree.

>     Now there are some problems that when i use some SVG file with a 
element 
> named "use", i could get the error 
>   "batikLogo.svg#Batik_Tag_Box" specified on the element <use>
>   at org.apache.batik.bridge.BridgeContext.getReferencedElement(Unknown 
Source)
>    .....

   This is probably because you are giving Batik an InputStream rather
than a URL.  When you give Batik an InputStream Batik doesn't know
where the SVG content came from, so when it gets a relative reference 
to another file it can't find it.  It is best to always give Batik
a URL when possible.

>     if i delete the element of "use" in the SVG file, it works.  It 
happened 
> as i use the "anne.svg".    But, for some animation SVG file like 
3D.svg, I 
> have to use that element, otherwise, i can not get the animaition. it 
seems it
> is the interface of the javascript. is it right?  how could i do?

   Actually I think the problem is that my sample code doesn't dispatch
the 'onload' event.  I think this is as simple as adding the line:

            manager.dispatchSVGLoadEvent();

   I've updated the Wiki Page so it now calls onload handlers.  The
original example was oriented around getting updates as Java manipulated
the document not JavaScript.

>     For your code, that seems when the bufferedimage changed, i could 
get a 
> new bufferedimage,
>      manager.addUpdateManagerListener(new UpdateManagerAdapter() {
>                 public void updateCompleted(UpdateManagerEvent e) {
>        }
>     is it right? 

   Yes, this is correct.  This method is called after the offscreen image
is updated.

> and then, i could add the BufferedImage to my java3d object.
> Do you think that will waste a lot of memory, and everything will be 
slow.

   I don't know, I've never done anything with Java3D.  Internally Batik
uses Single or Double buffering so there is really only one or two 
BufferedImages
that are passed to this method.

>    Is it the same structure as the SVG rendering in JSVGComponent. Same 
every 
> frame in bufferedimage, and then when bufferedimage changed, show the 
new one.

    Yes, this is what the component does.  It copies the modified regions 
to
the screen when this callback is called by the update manager.

> On 3/17/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote: 
> Hi Zhao,
> 
> "comlong zhao" <co...@gmail.com> wrote on 03/16/2006 10:14:26 AM: 
> 
> >        Thanks a lot for your help. Why i have to use the bufferedimage
> is the
> > Java3D texture only support the bufferedimage. Now it seems the batik
> could
> > render SVG using the DynamicRenderer to save the animation to the 
> > bufferedimage, and i think i could add the animation to Java3D texture
> through
> > the bufferedimage.
> 
>   Yes.
> 
> > But for the interaction, could it work well through the bufferedimage?
> > or i have to use another way to transform the javascript to java. 
> 
>   I'm not sure what you mean by 'interaction'.  The sample code I
> gave should run script and update the BufferedImage (you will be
> notified when the image changes by it calling the
> 'render(BufferedImage)' method). 
> 
>   If you want to handle interaction like 'pointer' and 'key' events.
> Then you will have to map a cursor position to the coordinate system
> of the root of the SVG document and dispatch it to the AWT tree by
> implementing the batik.gvt.event.EventDispatcher interface.
> 
> > On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > 
wrote:
> > Hi Zhao,
> >
> > "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> >
> > >         Thanks a lot for your code. That is much useful for me and i 

> am
> > > learning it line by line. I found it was created by you, so I want 
to
> > ask what
> > > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> > undefined
> > > by my eclipse and i also can not find from the API. 
> >
> >    I added this line to avoid a problem where it would decide to
> > 'skip frames' because the updates had come too quickly.  This is good
> > for the normal usage of updating a screen (and is likely also good for 

> > your case as well) but is bad in the context of trying to 'record' the
> > image after each runnable.
> >
> >    This method is only in the SVN version of Batik. (I should add a
> > comment to the example to this effect). 
> >
> > > If i remove this line, it could not work too.
> > >     The error is
> > > "Exception in thread "main" 
java.lang.ArrayIndexOutOfBoundsException:
> 0
> > >  at Example.TestOffScreenRender.main (TestOffScreenRender.java:150)"
> > > How could i run it?
> >
> >     You have to provide the filename of an SVG file to load as the
> > 'background' to the animation.  For my testing I used
> 'samples/anne.svg'. 
> > I'll add a println to this effect in the example when args.length is
> zero.
> >
> > >      Thank you again.
> >
> >     Good luck!
> >
> > >      zhao long
> > >
> > > 
> > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > > 
> > >        You probably want to read:
> > > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> > >
> > >        This renders an SVG to an offscreen buffer.  This code even 
> > > handles updating
> > > the offscreen buffer if the SVG Document is changed (I don't know if
> > this
> > > is useful to you).
> > >
> > > "comlong zhao" < comlong@gmail.com > wrote on 03/14/2006 09:15:19 
AM:
> > >
> > > >  Hello:
> > > >      Thanks a lot. I will try it. What is the result i want to get
> is
> > > saving
> > > > the SVG into the Butteredimage and then add it as texture in 
java3D. 
> 
> > Now
> > > it
> > > > seems i do not need to draw it using java2D, but does Batik 
support
> > svg
> > > to
> > > > butteredimage directly? could someone give me some ideas or 
> > suggestions.
> > > If
> > > > you have code demo, that's best. ;)
> > > >      Thank you very much.
> > > >      Thank thomas.deweese
> > > >      zhao long
> > > > 
> > > >
> > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > wrote:
> > > > Hi Zhao, 
> > > >
> > > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58 
PM:
> > > >
> > > > >     I am new about the Batik. It has a big API. Now I want to 
get 
> > the
> > > > element
> > > > > from a SVG file and then draw the same thing using java2D. Could
> > > someone
> > > > give
> > > > > me some idea or suggestion. 
> > > >
> > > >    Well all of Batik's drawing is done using Java2D so perhaps you
> > > > need to do nothing.  Once you have read the SVG file and built the
> > > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can 
> > > > get the GVT element for any node in the DOM by asking the
> > > > BridgeContext:
> > > >        Element x = document.getElementById ("foo");
> > > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > > >
> > > >    GraphicsNode has a method 'paint' that takes a standard
> > > > Graphics2D.
> > > >
> > > >
> > > >
> --------------------------------------------------------------------- 
> > > > 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


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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
  Hello:
    Thanks a lot for your help. Now i know how to run your code. For the
interaction,  it is like the mines.svg that i could play the simple game on
one plane of a java3D object.
    Now there are some problems that when i use some SVG file with a element
named "use", i could get the error
  "batikLogo.svg#Batik_Tag_Box"
specified on the element <use>
  at org.apache.batik.bridge.BridgeContext.getReferencedElement(Unknown
Source)
   .....

    if i delete the element of "use" in the SVG file, it works.  It happened
as i use the "anne.svg".    But, for some animation SVG file like 3D.svg, I
have to use that element, otherwise, i can not get the animaition. it seems
it is the interface of the javascript. is it right?  how could i do?
    For your code, that seems when the bufferedimage changed, i could get a
new bufferedimage,
     manager.addUpdateManagerListener(new UpdateManagerAdapter() {
                public void updateCompleted(UpdateManagerEvent e) {
       }
    is it right?  and then, i could add the bufferedimage to my java3d
object. Do you think that will waste a lot of memory, and everything will be
slow.
   Is it the same structure as the SVG rendering in JSVGComponent.
Same every frame in bufferedimage, and then when bufferedimage changed, show
the new one.
   Thank you very much.
    Waiting for your perfect help.
   zhao long



On 3/17/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 03/16/2006 10:14:26 AM:
>
> >        Thanks a lot for your help. Why i have to use the bufferedimage
> is the
> > Java3D texture only support the bufferedimage. Now it seems the batik
> could
> > render SVG using the DynamicRenderer to save the animation to the
> > bufferedimage, and i think i could add the animation to Java3D texture
> through
> > the bufferedimage.
>
>   Yes.
>
> > But for the interaction, could it work well through the bufferedimage?
> > or i have to use another way to transform the javascript to java.
>
>   I'm not sure what you mean by 'interaction'.  The sample code I
> gave should run script and update the BufferedImage (you will be
> notified when the image changes by it calling the
> 'render(BufferedImage)' method).
>
>   If you want to handle interaction like 'pointer' and 'key' events.
> Then you will have to map a cursor position to the coordinate system
> of the root of the SVG document and dispatch it to the AWT tree by
> implementing the batik.gvt.event.EventDispatcher interface.
>
> > On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> > Hi Zhao,
> >
> > "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> >
> > >         Thanks a lot for your code. That is much useful for me and i
> am
> > > learning it line by line. I found it was created by you, so I want to
> > ask what
> > > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> > undefined
> > > by my eclipse and i also can not find from the API.
> >
> >    I added this line to avoid a problem where it would decide to
> > 'skip frames' because the updates had come too quickly.  This is good
> > for the normal usage of updating a screen (and is likely also good for
> > your case as well) but is bad in the context of trying to 'record' the
> > image after each runnable.
> >
> >    This method is only in the SVN version of Batik. (I should add a
> > comment to the example to this effect).
> >
> > > If i remove this line, it could not work too.
> > >     The error is
> > > "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
> 0
> > >  at Example.TestOffScreenRender.main(TestOffScreenRender.java:150)"
> > > How could i run it?
> >
> >     You have to provide the filename of an SVG file to load as the
> > 'background' to the animation.  For my testing I used
> 'samples/anne.svg'.
> > I'll add a println to this effect in the example when args.length is
> zero.
> >
> > >      Thank you again.
> >
> >     Good luck!
> >
> > >      zhao long
> > >
> > >
> > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > >        You probably want to read:
> > > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> > >
> > >        This renders an SVG to an offscreen buffer.  This code even
> > > handles updating
> > > the offscreen buffer if the SVG Document is changed (I don't know if
> > this
> > > is useful to you).
> > >
> > > "comlong zhao" <comlong@gmail.com > wrote on 03/14/2006 09:15:19 AM:
> > >
> > > >  Hello:
> > > >      Thanks a lot. I will try it. What is the result i want to get
> is
> > > saving
> > > > the SVG into the Butteredimage and then add it as texture in java3D.
>
> > Now
> > > it
> > > > seems i do not need to draw it using java2D, but does Batik support
> > svg
> > > to
> > > > butteredimage directly? could someone give me some ideas or
> > suggestions.
> > > If
> > > > you have code demo, that's best. ;)
> > > >      Thank you very much.
> > > >      Thank thomas.deweese
> > > >      zhao long
> > > >
> > > >
> > > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> > wrote:
> > > > Hi Zhao,
> > > >
> > > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58 PM:
> > > >
> > > > >     I am new about the Batik. It has a big API. Now I want to get
> > the
> > > > element
> > > > > from a SVG file and then draw the same thing using java2D. Could
> > > someone
> > > > give
> > > > > me some idea or suggestion.
> > > >
> > > >    Well all of Batik's drawing is done using Java2D so perhaps you
> > > > need to do nothing.  Once you have read the SVG file and built the
> > > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > > > get the GVT element for any node in the DOM by asking the
> > > > BridgeContext:
> > > >        Element x = document.getElementById ("foo");
> > > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > > >
> > > >    GraphicsNode has a method 'paint' that takes a standard
> > > > Graphics2D.
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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
>
>

Re: How to get the element form SVG file.

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

"comlong zhao" <co...@gmail.com> wrote on 03/16/2006 10:14:26 AM:

>        Thanks a lot for your help. Why i have to use the bufferedimage 
is the 
> Java3D texture only support the bufferedimage. Now it seems the batik 
could 
> render SVG using the DynamicRenderer to save the animation to the 
> bufferedimage, and i think i could add the animation to Java3D texture 
through
> the bufferedimage.

   Yes.

> But for the interaction, could it work well through the bufferedimage? 
> or i have to use another way to transform the javascript to java.

   I'm not sure what you mean by 'interaction'.  The sample code I
gave should run script and update the BufferedImage (you will be
notified when the image changes by it calling the 
'render(BufferedImage)' method).

   If you want to handle interaction like 'pointer' and 'key' events.
Then you will have to map a cursor position to the coordinate system 
of the root of the SVG document and dispatch it to the AWT tree by
implementing the batik.gvt.event.EventDispatcher interface.

> On 3/15/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> Hi Zhao,
> 
> "comlong zhao" < comlong@gmail.com> wrote on 03/15/2006 12:09:33 AM:
> 
> >         Thanks a lot for your code. That is much useful for me and i 
am
> > learning it line by line. I found it was created by you, so I want to
> ask what
> > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> undefined
> > by my eclipse and i also can not find from the API.
> 
>    I added this line to avoid a problem where it would decide to 
> 'skip frames' because the updates had come too quickly.  This is good
> for the normal usage of updating a screen (and is likely also good for
> your case as well) but is bad in the context of trying to 'record' the 
> image after each runnable.
> 
>    This method is only in the SVN version of Batik. (I should add a
> comment to the example to this effect).
> 
> > If i remove this line, it could not work too.
> >     The error is 
> > "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 
0
> >  at Example.TestOffScreenRender.main(TestOffScreenRender.java:150)"
> > How could i run it?
> 
>     You have to provide the filename of an SVG file to load as the 
> 'background' to the animation.  For my testing I used 
'samples/anne.svg'.
> I'll add a println to this effect in the example when args.length is 
zero.
> 
> >      Thank you again.
> 
>     Good luck!
> 
> >      zhao long 
> >
> >
> > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > 
wrote:
> > Hi Zhao,
> >
> >        You probably want to read:
> > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> >
> >        This renders an SVG to an offscreen buffer.  This code even 
> > handles updating
> > the offscreen buffer if the SVG Document is changed (I don't know if
> this
> > is useful to you).
> >
> > "comlong zhao" <comlong@gmail.com > wrote on 03/14/2006 09:15:19 AM:
> >
> > >  Hello:
> > >      Thanks a lot. I will try it. What is the result i want to get 
is
> > saving
> > > the SVG into the Butteredimage and then add it as texture in java3D. 

> Now
> > it
> > > seems i do not need to draw it using java2D, but does Batik support
> svg
> > to
> > > butteredimage directly? could someone give me some ideas or
> suggestions.
> > If
> > > you have code demo, that's best. ;)
> > >      Thank you very much.
> > >      Thank thomas.deweese
> > >      zhao long
> > >
> > >
> > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > > "comlong zhao" < comlong@gmail.com> wrote on 03/13/2006 10:50:58 PM:
> > >
> > > >     I am new about the Batik. It has a big API. Now I want to get
> the
> > > element
> > > > from a SVG file and then draw the same thing using java2D. Could 
> > someone
> > > give
> > > > me some idea or suggestion.
> > >
> > >    Well all of Batik's drawing is done using Java2D so perhaps you
> > > need to do nothing.  Once you have read the SVG file and built the 
> > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > > get the GVT element for any node in the DOM by asking the
> > > BridgeContext:
> > >        Element x = document.getElementById ("foo");
> > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > >
> > >    GraphicsNode has a method 'paint' that takes a standard
> > > Graphics2D.
> > >
> > > 
> > > 
---------------------------------------------------------------------
> > > 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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
  Hello:
       Thanks a lot for your help. Why i have to use the bufferedimage is
the Java3D texture only support the bufferedimage. Now it seems the batik
could render SVG using the DynamicRenderer to save the animation to the
bufferedimage, and i think i could add the animation to Java3D texture
through the bufferedimage. But for the interaction, could it work well
through the bufferedimage? or i have to use another way to transform the
javascript to java.
       Thank you again.
       zhao long

On 3/15/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 03/15/2006 12:09:33 AM:
>
> >         Thanks a lot for your code. That is much useful for me and i am
> > learning it line by line. I found it was created by you, so I want to
> ask what
> > is the method in line 94(manager.setMinRepaintTime(-1))   which is
> undefined
> > by my eclipse and i also can not find from the API.
>
>    I added this line to avoid a problem where it would decide to
> 'skip frames' because the updates had come too quickly.  This is good
> for the normal usage of updating a screen (and is likely also good for
> your case as well) but is bad in the context of trying to 'record' the
> image after each runnable.
>
>    This method is only in the SVN version of Batik. (I should add a
> comment to the example to this effect).
>
> > If i remove this line, it could not work too.
> >     The error is
> > "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
> >  at Example.TestOffScreenRender.main(TestOffScreenRender.java:150)"
> > How could i run it?
>
>     You have to provide the filename of an SVG file to load as the
> 'background' to the animation.  For my testing I used 'samples/anne.svg'.
> I'll add a println to this effect in the example when args.length is zero.
>
> >      Thank you again.
>
>     Good luck!
>
> >      zhao long
> >
> >
> > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> > Hi Zhao,
> >
> >        You probably want to read:
> > http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> >
> >        This renders an SVG to an offscreen buffer.  This code even
> > handles updating
> > the offscreen buffer if the SVG Document is changed (I don't know if
> this
> > is useful to you).
> >
> > "comlong zhao" <co...@gmail.com> wrote on 03/14/2006 09:15:19 AM:
> >
> > >  Hello:
> > >      Thanks a lot. I will try it. What is the result i want to get is
> > saving
> > > the SVG into the Butteredimage and then add it as texture in java3D.
> Now
> > it
> > > seems i do not need to draw it using java2D, but does Batik support
> svg
> > to
> > > butteredimage directly? could someone give me some ideas or
> suggestions.
> > If
> > > you have code demo, that's best. ;)
> > >      Thank you very much.
> > >      Thank thomas.deweese
> > >      zhao long
> > >
> > >
> > > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com >
> wrote:
> > > Hi Zhao,
> > >
> > > "comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM:
> > >
> > > >     I am new about the Batik. It has a big API. Now I want to get
> the
> > > element
> > > > from a SVG file and then draw the same thing using java2D. Could
> > someone
> > > give
> > > > me some idea or suggestion.
> > >
> > >    Well all of Batik's drawing is done using Java2D so perhaps you
> > > need to do nothing.  Once you have read the SVG file and built the
> > > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > > get the GVT element for any node in the DOM by asking the
> > > BridgeContext:
> > >        Element x = document.getElementById("foo");
> > >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> > >
> > >    GraphicsNode has a method 'paint' that takes a standard
> > > Graphics2D.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
>

Re: How to get the element form SVG file.

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

"comlong zhao" <co...@gmail.com> wrote on 03/15/2006 12:09:33 AM:

>         Thanks a lot for your code. That is much useful for me and i am 
> learning it line by line. I found it was created by you, so I want to 
ask what
> is the method in line 94(manager.setMinRepaintTime(-1))   which is 
undefined 
> by my eclipse and i also can not find from the API. 

   I added this line to avoid a problem where it would decide to
'skip frames' because the updates had come too quickly.  This is good
for the normal usage of updating a screen (and is likely also good for 
your case as well) but is bad in the context of trying to 'record' the
image after each runnable.

   This method is only in the SVN version of Batik. (I should add a
comment to the example to this effect).

> If i remove this line, it could not work too. 
>     The error is 
> "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
>  at Example.TestOffScreenRender.main(TestOffScreenRender.java:150)"
> How could i run it?

    You have to provide the filename of an SVG file to load as the
'background' to the animation.  For my testing I used 'samples/anne.svg'.
I'll add a println to this effect in the example when args.length is zero.

>      Thank you again. 

    Good luck!

>      zhao long
> 
> 
> On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote: 
> Hi Zhao,
> 
>        You probably want to read:
> http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
> 
>        This renders an SVG to an offscreen buffer.  This code even
> handles updating
> the offscreen buffer if the SVG Document is changed (I don't know if 
this 
> is useful to you).
> 
> "comlong zhao" <co...@gmail.com> wrote on 03/14/2006 09:15:19 AM:
> 
> >  Hello:
> >      Thanks a lot. I will try it. What is the result i want to get is 
> saving
> > the SVG into the Butteredimage and then add it as texture in java3D. 
Now
> it
> > seems i do not need to draw it using java2D, but does Batik support 
svg
> to
> > butteredimage directly? could someone give me some ideas or 
suggestions. 
> If
> > you have code demo, that's best. ;)
> >      Thank you very much.
> >      Thank thomas.deweese
> >      zhao long
> >
> >
> > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > 
wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM: 
> >
> > >     I am new about the Batik. It has a big API. Now I want to get 
the
> > element
> > > from a SVG file and then draw the same thing using java2D. Could
> someone
> > give
> > > me some idea or suggestion. 
> >
> >    Well all of Batik's drawing is done using Java2D so perhaps you
> > need to do nothing.  Once you have read the SVG file and built the
> > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can 
> > get the GVT element for any node in the DOM by asking the
> > BridgeContext:
> >        Element x = document.getElementById("foo");
> >        GraphicsNode gn = bridgeContext.getGraphicsNode (x);
> >
> >    GraphicsNode has a method 'paint' that takes a standard
> > Graphics2D.
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: How to get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
   Hello thomas:
        Thanks a lot for your code. That is much useful for me and i am
learning it line by line. I found it was created by you, so I want to ask
what is the method in line 94(manager.setMinRepaintTime(-1))   which is
undefined by my eclipse and i also can not find from the API. If i remove
this line, it could not work too.
    The error is
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
 at Example.TestOffScreenRender.main(TestOffScreenRender.java:150)"
How could i run it?
     Thank you again.
     zhao long


On 3/14/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
>        You probably want to read:
> http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen
>
>        This renders an SVG to an offscreen buffer.  This code even
> handles updating
> the offscreen buffer if the SVG Document is changed (I don't know if this
> is useful to you).
>
> "comlong zhao" <co...@gmail.com> wrote on 03/14/2006 09:15:19 AM:
>
> >  Hello:
> >      Thanks a lot. I will try it. What is the result i want to get is
> saving
> > the SVG into the Butteredimage and then add it as texture in java3D. Now
> it
> > seems i do not need to draw it using java2D, but does Batik support svg
> to
> > butteredimage directly? could someone give me some ideas or suggestions.
> If
> > you have code demo, that's best. ;)
> >      Thank you very much.
> >      Thank thomas.deweese
> >      zhao long
> >
> >
> > On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM:
> >
> > >     I am new about the Batik. It has a big API. Now I want to get the
> > element
> > > from a SVG file and then draw the same thing using java2D. Could
> someone
> > give
> > > me some idea or suggestion.
> >
> >    Well all of Batik's drawing is done using Java2D so perhaps you
> > need to do nothing.  Once you have read the SVG file and built the
> > GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> > get the GVT element for any node in the DOM by asking the
> > BridgeContext:
> >        Element x = document.getElementById("foo");
> >        GraphicsNode gn = bridgeContext.getGraphicsNode(x);
> >
> >    GraphicsNode has a method 'paint' that takes a standard
> > Graphics2D.
> >
> >
> > ---------------------------------------------------------------------
> > 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 get the element form SVG file.

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

        You probably want to read:
 http://wiki.apache.org/xmlgraphics-batik/DynamicSvgOffscreen

        This renders an SVG to an offscreen buffer.  This code even 
handles updating
the offscreen buffer if the SVG Document is changed (I don't know if this 
is useful to you).

"comlong zhao" <co...@gmail.com> wrote on 03/14/2006 09:15:19 AM:

>  Hello:
>      Thanks a lot. I will try it. What is the result i want to get is 
saving 
> the SVG into the Butteredimage and then add it as texture in java3D. Now 
it 
> seems i do not need to draw it using java2D, but does Batik support svg 
to 
> butteredimage directly? could someone give me some ideas or suggestions. 
If 
> you have code demo, that's best. ;) 
>      Thank you very much.
>      Thank thomas.deweese
>      zhao long
> 
> 
> On 3/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote: 
> Hi Zhao,
> 
> "comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM: 
> 
> >     I am new about the Batik. It has a big API. Now I want to get the
> element
> > from a SVG file and then draw the same thing using java2D. Could 
someone
> give
> > me some idea or suggestion.
> 
>    Well all of Batik's drawing is done using Java2D so perhaps you
> need to do nothing.  Once you have read the SVG file and built the
> GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> get the GVT element for any node in the DOM by asking the 
> BridgeContext:
>        Element x = document.getElementById("foo");
>        GraphicsNode gn = bridgeContext.getGraphicsNode(x);
> 
>    GraphicsNode has a method 'paint' that takes a standard
> Graphics2D. 
> 
> 
> ---------------------------------------------------------------------
> 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 get the element form SVG file.

Posted by comlong zhao <co...@gmail.com>.
 Hello:
     Thanks a lot. I will try it. What is the result i want to get is saving
the SVG into the Butteredimage and then add it as texture in java3D. Now it
seems i do not need to draw it using java2D, but does Batik support svg to
butteredimage directly? could someone give me some ideas or suggestions. If
you have code demo, that's best. ;)
     Thank you very much.
     Thank thomas.deweese
     zhao long


On 3/14/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi Zhao,
>
> "comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM:
>
> >     I am new about the Batik. It has a big API. Now I want to get the
> element
> > from a SVG file and then draw the same thing using java2D. Could someone
> give
> > me some idea or suggestion.
>
>    Well all of Batik's drawing is done using Java2D so perhaps you
> need to do nothing.  Once you have read the SVG file and built the
> GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
> get the GVT element for any node in the DOM by asking the
> BridgeContext:
>        Element x = document.getElementById("foo");
>        GraphicsNode gn = bridgeContext.getGraphicsNode(x);
>
>    GraphicsNode has a method 'paint' that takes a standard
> Graphics2D.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: How to get the element form SVG file.

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

"comlong zhao" <co...@gmail.com> wrote on 03/13/2006 10:50:58 PM:

>     I am new about the Batik. It has a big API. Now I want to get the 
element 
> from a SVG file and then draw the same thing using java2D. Could someone 
give 
> me some idea or suggestion. 

    Well all of Batik's drawing is done using Java2D so perhaps you
need to do nothing.  Once you have read the SVG file and built the
GVT tree (see Wiki HowTo section on booting SVG DOM).  You can
get the GVT element for any node in the DOM by asking the 
BridgeContext:
        Element x = document.getElementById("foo");
        GraphicsNode gn = bridgeContext.getGraphicsNode(x);

    GraphicsNode has a method 'paint' that takes a standard
Graphics2D.


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