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 J B <mo...@gmail.com> on 2006/02/11 18:51:50 UTC

a reference from the classpath

I would like to place several reusable resources in the def section of an
svg file that will be bundled within my deployed jar file.  I would like to
reference the resources in this SVG from within another svg file using the
<use> element.

library.svg

<svg contentScriptType="text/ecmascript"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns="http://www.w3.org/2000/svg" version="1.0">
    <defs>
        <g id="lib1">
            <polygon fill="#CC6600" points="0,28 26,28 40,14 26,0 0,0 "/>
            <polygon points="4,24 24,24 34,14 24,4 4,4 "/>
        </g>
    </defs>
</svg>

test.xvg

<svg contentScriptType="text/ecmascript"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns="http://www.w3.org/2000/svg" version="1.0">
    <g>
        <use id="foo" xlink:href="jar:!/com/proteus/svg/library.svg#lib1"/>
    </g>
</svg>

I need to access the library.svg like I would any other resource in java.
Since it is bundled within hte same jar, I don't want to have to specify an
actual jar file.

Any thoughts?

Birch

Re: a reference from the classpath

Posted by J B <mo...@gmail.com>.
OK, I was able to get this to work, but not as clean as I wanted it to be.
I did not end up using a protocol handler...that just didn't seem towork.  I
instead overrode the JSVGCanvas and plugged in my own DocumentLoader.

Birch

On 2/15/06, J B <mo...@gmail.com> wrote:
>
> I still seem to be stuck here.  I can never get any of the openStream
> methods to get called.  Attached is my source file.
>
> It simply loades up the test.svg file.  It contains a use tag that
> *should* invoke my protocol handler.  It seems to, but the streams are never
> called on the parsedURLData objects.
>
> If someone could take a look at it, I'd appreciate it!
>
> Thanks!
>
> Birch
>
> On 2/14/06, thomas.deweese@kodak.com <thomas.deweese@kodak.com > wrote:
> >
> > Hi JB,
> >
> > J B <moatas@gmail.com > wrote on 02/12/2006 03:08:36 PM:
> >
> > > Guess I should change the scope of my question.  I see how pluggin in
> > my
> > own
> > > protocol handler works for loading images.  Can I hook in my own
> > protocol
> > > handler the loading resource with a <use>?
> >
> >    Yes.  Since there are a number of 'openStream' methods I suspect
> > you are missing an important one.  The SAXSVGDocumentHandler uses
> >         InputStream is =
> > purl.openStream(MimeTypeConstants.MIME_TYPES_SVG);
> >
> >    To open the stream.
> >
> > >
> > > Birch
> >
> > > On 2/11/06, J B <mo...@gmail.com> wrote:
> > > Yes, but with my own protocol handler, I would not necesarily use it
> > that way.
> > > The method: public ParsedURLData parseURL(String arg0) gets called,
> > but
> > none
> > > of the methods overridden to return the stream of the resource are
> > called.
> > > But when used with the <image> tag, they are.
> > >
> > > Birch
> > >
> >
> > > On 2/11/06, Andrew Plotkin < erkyrath@eblong.com> wrote:
> > > On Sat, 11 Feb 2006, J B wrote:
> > >
> > > > After a bit of reading, I have registered my own protocol handler
> > and
> > can
> > > > successfully load up images with it (<image id="foo"
> > xlink:href="sentinel:
> > > > lib.png" width="50" height="50"/>).  However, if I do this (<use
> > id="foo"
> > > > xlink:href="sentinel:lib.svg"/>), it does not work.
> > >
> > > Have you tried using a specific object from the destination file?
> > >
> > > <use id="foo" xlink:href="sentinel: lib.svg#id" />
> > >
> > > --Z
> > >
> > > --
> > > "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
> > borogoves..."
> > > *
> > > It's a nice distinction to tell American soldiers (and Iraqis) to die
> > in
> >
> > > Iraq for the sake of democracy (ignoring the question of whether it's
> > > *working*) and then whine that "The Constitution is not a suicide
> > pact."
> > >
> > > ---------------------------------------------------------------------
> > > 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: a reference from the classpath

Posted by J B <mo...@gmail.com>.
I still seem to be stuck here.  I can never get any of the openStream
methods to get called.  Attached is my source file.

It simply loades up the test.svg file.  It contains a use tag that *should*
invoke my protocol handler.  It seems to, but the streams are never called
on the parsedURLData objects.

If someone could take a look at it, I'd appreciate it!

Thanks!

Birch

On 2/14/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi JB,
>
> J B <mo...@gmail.com> wrote on 02/12/2006 03:08:36 PM:
>
> > Guess I should change the scope of my question.  I see how pluggin in my
> own
> > protocol handler works for loading images.  Can I hook in my own
> protocol
> > handler the loading resource with a <use>?
>
>    Yes.  Since there are a number of 'openStream' methods I suspect
> you are missing an important one.  The SAXSVGDocumentHandler uses
>         InputStream is =
> purl.openStream(MimeTypeConstants.MIME_TYPES_SVG);
>
>    To open the stream.
>
> >
> > Birch
>
> > On 2/11/06, J B <mo...@gmail.com> wrote:
> > Yes, but with my own protocol handler, I would not necesarily use it
> that way.
> > The method: public ParsedURLData parseURL(String arg0) gets called, but
> none
> > of the methods overridden to return the stream of the resource are
> called.
> > But when used with the <image> tag, they are.
> >
> > Birch
> >
>
> > On 2/11/06, Andrew Plotkin < erkyrath@eblong.com> wrote:
> > On Sat, 11 Feb 2006, J B wrote:
> >
> > > After a bit of reading, I have registered my own protocol handler and
> can
> > > successfully load up images with it (<image id="foo"
> xlink:href="sentinel:
> > > lib.png" width="50" height="50"/>).  However, if I do this (<use
> id="foo"
> > > xlink:href="sentinel:lib.svg"/>), it does not work.
> >
> > Have you tried using a specific object from the destination file?
> >
> > <use id="foo" xlink:href="sentinel:lib.svg#id" />
> >
> > --Z
> >
> > --
> > "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
> borogoves..."
> > *
> > It's a nice distinction to tell American soldiers (and Iraqis) to die in
>
> > Iraq for the sake of democracy (ignoring the question of whether it's
> > *working*) and then whine that "The Constitution is not a suicide pact."
> >
> > ---------------------------------------------------------------------
> > 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: a reference from the classpath

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

J B <mo...@gmail.com> wrote on 02/12/2006 03:08:36 PM:

> Guess I should change the scope of my question.  I see how pluggin in my 
own 
> protocol handler works for loading images.  Can I hook in my own 
protocol 
> handler the loading resource with a <use>?

   Yes.  Since there are a number of 'openStream' methods I suspect
you are missing an important one.  The SAXSVGDocumentHandler uses
        InputStream is = 
purl.openStream(MimeTypeConstants.MIME_TYPES_SVG);

   To open the stream.

> 
> Birch

> On 2/11/06, J B <mo...@gmail.com> wrote:
> Yes, but with my own protocol handler, I would not necesarily use it 
that way.
> The method: public ParsedURLData parseURL(String arg0) gets called, but 
none 
> of the methods overridden to return the stream of the resource are 
called. 
> But when used with the <image> tag, they are. 
> 
> Birch
> 

> On 2/11/06, Andrew Plotkin < erkyrath@eblong.com> wrote:
> On Sat, 11 Feb 2006, J B wrote:
> 
> > After a bit of reading, I have registered my own protocol handler and 
can
> > successfully load up images with it (<image id="foo" 
xlink:href="sentinel:
> > lib.png" width="50" height="50"/>).  However, if I do this (<use 
id="foo"
> > xlink:href="sentinel:lib.svg"/>), it does not work.
> 
> Have you tried using a specific object from the destination file? 
> 
> <use id="foo" xlink:href="sentinel:lib.svg#id" />
> 
> --Z
> 
> --
> "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the 
borogoves..."
> *
> It's a nice distinction to tell American soldiers (and Iraqis) to die in 

> Iraq for the sake of democracy (ignoring the question of whether it's
> *working*) and then whine that "The Constitution is not a suicide pact."
> 
> --------------------------------------------------------------------- 
> 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: a reference from the classpath

Posted by J B <mo...@gmail.com>.
Guess I should change the scope of my question.  I see how pluggin in my own
protocol handler works for loading images.  Can I hook in my own protocol
handler the loading resource with a <use>?

Birch

On 2/11/06, J B <mo...@gmail.com> wrote:
>
> Yes, but with my own protocol handler, I would not necesarily use it that
> way.  The method: public ParsedURLData parseURL(String arg0) gets called,
> but none of the methods overridden to return the stream of the resource are
> called.  But when used with the <image> tag, they are.
>
> Birch
>
> On 2/11/06, Andrew Plotkin <er...@eblong.com> wrote:
> >
> > On Sat, 11 Feb 2006, J B wrote:
> >
> > > After a bit of reading, I have registered my own protocol handler and
> > can
> > > successfully load up images with it (<image id="foo"
> > xlink:href="sentinel:
> > > lib.png" width="50" height="50"/>).  However, if I do this (<use
> > id="foo"
> > > xlink:href="sentinel:lib.svg"/>), it does not work.
> >
> > Have you tried using a specific object from the destination file?
> >
> > <use id="foo" xlink:href="sentinel:lib.svg#id" />
> >
> > --Z
> >
> > --
> > "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
> > borogoves..."
> > *
> > It's a nice distinction to tell American soldiers (and Iraqis) to die in
> >
> > Iraq for the sake of democracy (ignoring the question of whether it's
> > *working*) and then whine that "The Constitution is not a suicide pact."
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> >
> >
>

Re: a reference from the classpath

Posted by J B <mo...@gmail.com>.
Yes, but with my own protocol handler, I would not necesarily use it that
way.  The method: public ParsedURLData parseURL(String arg0) gets called,
but none of the methods overridden to return the stream of the resource are
called.  But when used with the <image> tag, they are.

Birch

On 2/11/06, Andrew Plotkin <er...@eblong.com> wrote:
>
> On Sat, 11 Feb 2006, J B wrote:
>
> > After a bit of reading, I have registered my own protocol handler and
> can
> > successfully load up images with it (<image id="foo"
> xlink:href="sentinel:
> > lib.png" width="50" height="50"/>).  However, if I do this (<use
> id="foo"
> > xlink:href="sentinel:lib.svg"/>), it does not work.
>
> Have you tried using a specific object from the destination file?
>
> <use id="foo" xlink:href="sentinel:lib.svg#id" />
>
> --Z
>
> --
> "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
> borogoves..."
> *
> It's a nice distinction to tell American soldiers (and Iraqis) to die in
> Iraq for the sake of democracy (ignoring the question of whether it's
> *working*) and then whine that "The Constitution is not a suicide pact."
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: a reference from the classpath

Posted by Andrew Plotkin <er...@eblong.com>.
On Sat, 11 Feb 2006, J B wrote:

> After a bit of reading, I have registered my own protocol handler and can
> successfully load up images with it (<image id="foo" xlink:href="sentinel:
> lib.png" width="50" height="50"/>).  However, if I do this (<use id="foo"
> xlink:href="sentinel:lib.svg"/>), it does not work.

Have you tried using a specific object from the destination file?

<use id="foo" xlink:href="sentinel:lib.svg#id" />

--Z

-- 
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
It's a nice distinction to tell American soldiers (and Iraqis) to die in
Iraq for the sake of democracy (ignoring the question of whether it's
*working*) and then whine that "The Constitution is not a suicide pact."

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


Re: a reference from the classpath

Posted by J B <mo...@gmail.com>.
After a bit of reading, I have registered my own protocol handler and can
successfully load up images with it (<image id="foo" xlink:href="sentinel:
lib.png" width="50" height="50"/>).  However, if I do this (<use id="foo"
xlink:href="sentinel:lib.svg"/>), it does not work.

Thoughts?

Birch

On 2/11/06, J B <mo...@gmail.com> wrote:
>
> I would like to place several reusable resources in the def section of an
> svg file that will be bundled within my deployed jar file.  I would like to
> reference the resources in this SVG from within another svg file using the
> <use> element.
>
> library.svg
>
> <svg contentScriptType="text/ecmascript"
>             xmlns:xlink="http://www.w3.org/1999/xlink"
>             xmlns=" http://www.w3.org/2000/svg" version="1.0">
>     <defs>
>         <g id="lib1">
>             <polygon fill="#CC6600" points="0,28 26,28 40,14 26,0 0,0 "/>
>             <polygon points="4,24 24,24 34,14 24,4 4,4 "/>
>         </g>
>     </defs>
> </svg>
>
> test.xvg
>
> <svg contentScriptType="text/ecmascript"
>             xmlns:xlink=" http://www.w3.org/1999/xlink"
>             xmlns="http://www.w3.org/2000/svg" version="1.0">
>     <g>
>         <use id="foo"
> xlink:href="jar:!/com/proteus/svg/library.svg#lib1"/>
>     </g>
> </svg>
>
> I need to access the library.svg like I would any other resource in java.
> Since it is bundled within hte same jar, I don't want to have to specify an
> actual jar file.
>
> Any thoughts?
>
> Birch
>