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 Ken Larson <ke...@mindspring.com> on 2004/01/29 15:39:49 UTC

scripting from Java question

I am using a JSVGCanvas to display an svg.  In the svg I have some 
custom, top-level (global) script functions defined.  I know how I can 
manipulate the SVG DOM from the java code, but how do I call my 
functions that are defined in the SVG?

If the SVG is embedded in an html document, then it is possible for the 
HTML to call these functions.  But how do I do it from within Swing?

Thanks,

Ken

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


Re: scripting from Java question

Posted by Ken Larson <ke...@mindspring.com>.
thanks!

my quick solution was to subclass JSVGCanvas to get access to the 
protected member.

Thomas DeWeese wrote:

> Hi Chimera,
>
>    We should probably expose more directly but:
>
>     BridgeContext ctx;
>     ctx = canvas.getUpdateManager().getBridgeContext();
>
> Chimera wrote:
>
>> This is a stab in the dark, as I am a programming novice.
>>
>> But learning comes from trying, so here goes:
>>
>> The Constructors all expect a UserAgent parameter, except for the 
>> default
>> constructor, which is 'protected'.  Since protected methods require 
>> scope to
>> execute, and the JavaDocs for BridgeContext show that it extends
>> java.lang.Object... then you need an object first.
>>
>>   JSVGCanvas canvas = new JSVGCanvas();
>>   BridgeContext context = new canvas.BridgeContext();
>
>
>    This won't work (it isn't valid Java).
>
>> My guess is that this is done exactly like a GraphicsContext, which is
>> obtained for use with a particular component (our JSVGCanvas, in this 
>> case).
>>
>> Then again, there is the method in Class JSVGComponent, which 
>> JSVGCanvas is
>> a subclass of:
>>   protected BridgeContext createBridgeContext();
>
>
>    You are correct that this is a little like a GraphicsContext, so
> this is the factory method, so subclasses can create alternate
> implementations.
>
>> Again, I am a novice, but this is my stab at it.
>>
>>
>> Chimera
>>
>>
>> ----- Original Message ----- From: "Ken Larson" 
>> <ke...@mindspring.com>
>> To: "Batik Users" <ba...@xml.apache.org>
>> Sent: Thursday, January 29, 2004 7:33 AM
>> Subject: Re: scripting from Java question
>>
>>
>>
>>> thanks.  I'm new to batik, so maybe you could give me some pointers as
>>> to how to get the BridgeContext from the JSVGCanvas...
>>>
>>> "You can get the BridgeContext from the JSVGCanvas.  Of course you
>>> need to make sure you do this from the UpdateManager thread."
>>>
>>> Thomas DeWeese wrote:
>>>
>>>
>>>> Ken Larson wrote:
>>>>
>>>>
>>>>> I am using a JSVGCanvas to display an svg.  In the svg I have some
>>>>> custom, top-level (global) script functions defined.  I know how I
>>>>> can manipulate the SVG DOM from the java code, but how do I call my
>>>>> functions that are defined in the SVG?
>>>>
>>>>
>>>>
>>>>> If the SVG is embedded in an html document, then it is possible for
>>>>> the HTML to call these functions.  But how do I do it from within
>>>>
>>
>> Swing?
>>
>>>>
>>>>   See message:
>>>>
>>>>
>>
>> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=batik-users@xml.apache.org&msgId=1322271 
>>
>>
>>>>
>>>>   In your case the 'script' should be the call to the function to
>>>> run.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>>> For additional commands, e-mail: batik-users-help@xml.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>> For additional commands, e-mail: batik-users-help@xml.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>

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


Re: scripting from Java question

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Chimera,

    We should probably expose more directly but:

	BridgeContext ctx;
	ctx = canvas.getUpdateManager().getBridgeContext();

Chimera wrote:

> This is a stab in the dark, as I am a programming novice.
> 
> But learning comes from trying, so here goes:
> 
> The Constructors all expect a UserAgent parameter, except for the default
> constructor, which is 'protected'.  Since protected methods require scope to
> execute, and the JavaDocs for BridgeContext show that it extends
> java.lang.Object... then you need an object first.
> 
>   JSVGCanvas canvas = new JSVGCanvas();
>   BridgeContext context = new canvas.BridgeContext();

    This won't work (it isn't valid Java).

> My guess is that this is done exactly like a GraphicsContext, which is
> obtained for use with a particular component (our JSVGCanvas, in this case).
> 
> Then again, there is the method in Class JSVGComponent, which JSVGCanvas is
> a subclass of:
>   protected BridgeContext createBridgeContext();

    You are correct that this is a little like a GraphicsContext, so
this is the factory method, so subclasses can create alternate
implementations.

> Again, I am a novice, but this is my stab at it.
> 
> 
> Chimera
> 
> 
> ----- Original Message ----- 
> From: "Ken Larson" <ke...@mindspring.com>
> To: "Batik Users" <ba...@xml.apache.org>
> Sent: Thursday, January 29, 2004 7:33 AM
> Subject: Re: scripting from Java question
> 
> 
> 
>>thanks.  I'm new to batik, so maybe you could give me some pointers as
>>to how to get the BridgeContext from the JSVGCanvas...
>>
>>"You can get the BridgeContext from the JSVGCanvas.  Of course you
>>need to make sure you do this from the UpdateManager thread."
>>
>>Thomas DeWeese wrote:
>>
>>
>>>Ken Larson wrote:
>>>
>>>
>>>>I am using a JSVGCanvas to display an svg.  In the svg I have some
>>>>custom, top-level (global) script functions defined.  I know how I
>>>>can manipulate the SVG DOM from the java code, but how do I call my
>>>>functions that are defined in the SVG?
>>>
>>>
>>>>If the SVG is embedded in an html document, then it is possible for
>>>>the HTML to call these functions.  But how do I do it from within
> 
> Swing?
> 
>>>
>>>   See message:
>>>
>>>
> 
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=batik-users@xml.apache.org&msgId=1322271
> 
>>>
>>>   In your case the 'script' should be the call to the function to
>>>run.
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 




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


Re: scripting from Java question

Posted by Chimera <ch...@Ennersea.net>.
This is a stab in the dark, as I am a programming novice.

But learning comes from trying, so here goes:

The Constructors all expect a UserAgent parameter, except for the default
constructor, which is 'protected'.  Since protected methods require scope to
execute, and the JavaDocs for BridgeContext show that it extends
java.lang.Object... then you need an object first.

  JSVGCanvas canvas = new JSVGCanvas();
  BridgeContext context = new canvas.BridgeContext();

My guess is that this is done exactly like a GraphicsContext, which is
obtained for use with a particular component (our JSVGCanvas, in this case).

Then again, there is the method in Class JSVGComponent, which JSVGCanvas is
a subclass of:
  protected BridgeContext createBridgeContext();

Again, I am a novice, but this is my stab at it.


Chimera


----- Original Message ----- 
From: "Ken Larson" <ke...@mindspring.com>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Thursday, January 29, 2004 7:33 AM
Subject: Re: scripting from Java question


> thanks.  I'm new to batik, so maybe you could give me some pointers as
> to how to get the BridgeContext from the JSVGCanvas...
>
> "You can get the BridgeContext from the JSVGCanvas.  Of course you
> need to make sure you do this from the UpdateManager thread."
>
> Thomas DeWeese wrote:
>
> > Ken Larson wrote:
> >
> >> I am using a JSVGCanvas to display an svg.  In the svg I have some
> >> custom, top-level (global) script functions defined.  I know how I
> >> can manipulate the SVG DOM from the java code, but how do I call my
> >> functions that are defined in the SVG?
> >
> >
> >> If the SVG is embedded in an html document, then it is possible for
> >> the HTML to call these functions.  But how do I do it from within
Swing?
> >
> >
> >    See message:
> >
> >
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=batik-users@xml.apache.org&msgId=1322271
> >
> >
> >    In your case the 'script' should be the call to the function to
> > run.
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: batik-users-help@xml.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>


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


Re: scripting from Java question

Posted by Ken Larson <ke...@mindspring.com>.
thanks.  I'm new to batik, so maybe you could give me some pointers as 
to how to get the BridgeContext from the JSVGCanvas...

"You can get the BridgeContext from the JSVGCanvas.  Of course you
need to make sure you do this from the UpdateManager thread."

Thomas DeWeese wrote:

> Ken Larson wrote:
>
>> I am using a JSVGCanvas to display an svg.  In the svg I have some 
>> custom, top-level (global) script functions defined.  I know how I 
>> can manipulate the SVG DOM from the java code, but how do I call my 
>> functions that are defined in the SVG?
>
>
>> If the SVG is embedded in an html document, then it is possible for 
>> the HTML to call these functions.  But how do I do it from within Swing?
>
>
>    See message:
>
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=batik-users@xml.apache.org&msgId=1322271 
>
>
>    In your case the 'script' should be the call to the function to
> run.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>

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


Re: scripting from Java question

Posted by Thomas DeWeese <Th...@Kodak.com>.
Ken Larson wrote:
> I am using a JSVGCanvas to display an svg.  In the svg I have some 
> custom, top-level (global) script functions defined.  I know how I can 
> manipulate the SVG DOM from the java code, but how do I call my 
> functions that are defined in the SVG?

> If the SVG is embedded in an html document, then it is possible for the 
> HTML to call these functions.  But how do I do it from within Swing?

    See message:

http://nagoya.apache.org/eyebrowse/ReadMsg?listName=batik-users@xml.apache.org&msgId=1322271

    In your case the 'script' should be the call to the function to
run.





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