Hi Zhao,

"comlong zhao" <[EMAIL PROTECTED]> wrote on 08/04/2006 02:17:00 AM:

>      Thanks a lot for your help. But something I am also puzzled now. 
>      Your said I could use " ctx.getInterpreter("text/ecmascript").
>      what is the "text" mean? the path of my svg file? 

    This is the mime type of the interpreter you want to get.  Batik
supports multiple script engines.

>       And for the "(evt)" you said if i want use that, I should set some 

> properties of the evt. But I think the "mouseClick1(evt)" is a string 
mode 
> here,  Could the Batik find the the java code of " evt.setX=" has 
relation 
> with the String "evt"?  Is it a way to set a "GraphicsNodeMouseEvent"?

    You are right this is a string, but the string is evaluated in the
global scope of the Interpreter.  So the text can be any valid ECMA 
script:

 
        int clientX = 10;
        int clientY = 10;
        [...]
        ctx.getInterpreter("text/ecmascript").
        evaluate("evt = new function { this.clientX=" + clientX + 
                 "; this.clientY=" + clientY + "; " + /* what ever else */
                   " }; mouseClick1(evt)");

>      Another very important question I want to ask is last time you said 
I should 
> "dispatch the event to the GVT tree in the UpdateManager's 
RunnableQueue" . 
> How should I understand this sentence? or which are the key mothods I 
should use? 

   I would carefully review the code in 
AWTEventDispatcher.dispatchMouseEvent
this does what you want, and you should be able to use that code to make 
your
own version using whatever info you have available.

>      Thanks a lot.
>      Regards
>      Sincerely
>      zhao
> 
> 
> On 8/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: 
> Hi Zhao,
> 
> "comlong zhao" <[EMAIL PROTECTED]> wrote on 08/02/2006 01:27:51 AM: 
> 
> >      Thanks a lot for your help.  If i have a function named
> > "mouseClick1(evt)" and i want to call it, I should use
> > "ctx.getInterpreter("mouseClick1(evt)").evaluate("mouseClick1(evt)");" 

> > ctx is the BridgeContext here.
> 
>   It would be more like:
> ctx.getInterpreter("text/ecmascript").evaluate("mouseClick1(evt)");
> 
> > Is it correct? or i should remove the "(evt)". 
> 
>   If you want to pass 'evt' to mouseClick1 you need to include it
> but you also need to set it up.  So you would need to provide
> clientX/Y, screenX/Y, target, currentTarget, etc.  Assuming you use
> any of those in your function (which is quite common). 
> 
>   If you can use the AWTEventDispatcher (I know it wants a Component
> but it doesn't have to be a particularly "real" Component).  Really
> what it cares about is, when, modifiers, clickCount, x and y.  So you 
> could construct a 'dummy' MouseEvent to pass to the dispatch method.
> 
> >      Because I do not use any component, I just want to get the
> BufferedImage,
> > so if i use this way, whether only the GVTtree will be changed? or I 
> have to
> > set a component for it.
> 
> The GVTTree will be changed if the script changes anything without any
> component.
> 
> >       I have tried just using the "evaluate" in my code, and got some 
> errors
> > of "AWT-EventQueue-0"
> 
>    When you get errors including the stack trace is essential if you
> expect
> any help.  I suspect the problem is that
> 
> >      Thanks a lot
> >      zhao 
> >
> >
> >
> > On 7/31/06, [EMAIL PROTECTED] <[EMAIL PROTECTED] > 
wrote:
> > Hi Zhao,
> >
> > "comlong zhao" <[EMAIL PROTECTED]> wrote on 07/27/2006 03:09:28 PM:
> >
> > >      I think it is possible. Could some kind person give me some 
> ideas.
> > I need
> > > to ust a Button to give an event to one SVG file, and then the SVG
> > changes on
> > > the JCanvas.  Like the demo of mines.svg, you could press the SVG
> button
> > to 
> > > restart a new game, How to use a JButton to do the same thing?
> >
> >   This is a little unclear to me.  Do you want to dispatch an event
> > or do you want to call a specific ECMA script function in the 
document. 
> >
> >   If you want to dispatch an event then you will probably want to
> > use the batik.gvt.event.AWTEventDispatcher class to dispatch a
> > Swing/AWT event into the GVT tree (which will eventually dispatch 
> > into the DOM tree).
> >
> >   If you want to call an ECMA script function you can get the
> > ECMAScript batik.script.Interpretor from the BridgeContext
> > (BridgeContext.getInterpreter(String lang) ) and use it's 
> > 'evaluate(String str)' to call the function.  You can also
> > use 'bindObject(String name, Object obj)' to bind a Java
> > Object into the script environment.
> >
> >
> >
> > --------------------------------------------------------------------- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
[EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to