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 Urs Reupke <ur...@gmx.net> on 2004/10/26 00:15:05 UTC

"Broken Image" in Image-Element

Hi again,

just when I thought I was done, bad stuff happened:
After some major refactoring, the image-elements in my graphics aren't shown properly anymore, 
but the problem is different from the last time we met:
Instead of showing the default "image not found"-icon, the SVG-Canvas displays
an image just the size I indicated in the referencing tag: 

<symbol id="ArrowLeft">
    <image x="0" y="0" width="46" height="46" xlink:href="Arrow_Left.svg"/>
</symbol>

This and similar symbols are referenced throughout my documents in use-tags similar to this one:

<use xlink:href="#ArrowLeft" transform="translate(916 339)"/>

which are children of a hierarchy of group elements. 

The only thing of impact (only thing of impact that comes to my mind, that is) during said refactoring was that I 
switched to the (more reliable) Java ClassLoader.getResource(String)-method instead of manually 
creating the URL to set as the documents base URL via setURLObject(URL).

I checked, the URL is set correctly, as far as I can determine, to the directory containing both the parent image as
well as the referenced one. Neither the containing image nor the referenced image were changed by any means apart
from changing their absolute (but by no means relative) position in the filesystem, so there should be no difference
in displaying them.

Can you help me out, again?
Thanks
-Urs

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


Re: "Broken Image" in Image-Element

Posted by Urs Reupke <ur...@gmx.net>.
Hi Tonny,

> If by anycase you use jnlp/webstart thing, java ClassLoader have
> peculiar that you need to be aware of. The ClassLoader only can only get
> resources if in the same jar file, if it is in different jar. You need
> to create some empty anchor Java class to reference to the classloader
> to different jar.
Indeed, I plan to use JNLP, and I already use the classloader that way - 
my projects in eclipse are arranged in parallel to the JARs I plan to distribute,
so I already encountered and solved that problem.

Thanks anyway
-Urs

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


Re: "Broken Image" in Image-Element

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> <symbol id="ArrowLeft">
>     <image x="0" y="0" width="46" height="46" xlink:href="Arrow_Left.svg"/>
> </symbol>
> 
> This and similar symbols are referenced throughout my documents in use-tags similar to this one:
> 
> <use xlink:href="#ArrowLeft" transform="translate(916 339)"/>

> The only thing of impact (only thing of impact that comes to my mind, that is) during said refactoring was that I 
> switched to the (more reliable) Java ClassLoader.getResource(String)-method instead of manually 
> creating the URL to set as the documents base URL via setURLObject(URL).

If by anycase you use jnlp/webstart thing, java ClassLoader have
peculiar that you need to be aware of. The ClassLoader only can only get
resources if in the same jar file, if it is in different jar. You need
to create some empty anchor Java class to reference to the classloader
to different jar.
eg: app.jar, res.jar if you need to get something from res.jar you need
to create simple empty class and put it on the res.jar for the class
loader to work and get the class loader from that empty class file.
ClassLoader cl = TheEmptyClassAnchor.class.getClassLoader();
URL url = cl.getResource("something");

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com



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


Re: how to get position and size of a SVG group

Posted by Maik Schürer proveo GmbH <Ma...@proveo.de>.
Thanks Urs,
yes, thats the way. It works fine.
If you have at minimum a instanceof SVGGraphicsElement, you can get position
and size via getBBox() / getX() etc.
Maik
----- Original Message ----- 
From: "Urs Reupke" <ur...@gmx.net>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Tuesday, October 26, 2004 2:54 PM
Subject: Re: how to get position and size of a SVG group


> Hi,
>
> >I  got a group ( <g> ) by ID from a document and want to know the
position
> > and size of the group.
> > With 'position' I mean the upper left corner of an imaginary rectangle
> > arround all elements of the group. 'Size' should be the edge length of
the
> > rectangle...
>
> I've thought about this myself, recently, and though I have not tested
this,
> I figured the easiest way would be to get the bounding box of the
> g-element by calling "getBBox()" and afterwards checking the respective
> parameters of that bounding box via getX(), getY(), getWidth() and
getHeight().
>
> As I said, it's untested, but I hope it works - if it doesn't, please post
your
> solution to the ML.
>
> Bye
> -Urs
>
> ---------------------------------------------------------------------
> 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: how to get position and size of a SVG group

Posted by Urs Reupke <ur...@gmx.net>.
Hi,

>I  got a group ( <g> ) by ID from a document and want to know the position
> and size of the group.
> With 'position' I mean the upper left corner of an imaginary rectangle
> arround all elements of the group. 'Size' should be the edge length of the
> rectangle...

I've thought about this myself, recently, and though I have not tested this,
I figured the easiest way would be to get the bounding box of the
g-element by calling "getBBox()" and afterwards checking the respective
parameters of that bounding box via getX(), getY(), getWidth() and getHeight().

As I said, it's untested, but I hope it works - if it doesn't, please post your
solution to the ML.

Bye
-Urs

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


how to get position and size of a SVG group

Posted by Maik Schürer proveo GmbH <Ma...@proveo.de>.
I  got a group ( <g> ) by ID from a document and want to know the position
and size of the group.
With 'position' I mean the upper left corner of an imaginary rectangle
arround all elements of the group. 'Size' should be the edge length of the
rectangle...
How can I do this ?
Thanks
Maik


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


Re: "Broken Image" in Image-Element

Posted by Urs Reupke <ur...@gmx.net>.
Hello Thomas,

In a strange fashion, the problem is 'solved': 
As tried using the facilities provided by batik
for loading the document instead of using dom4j,
and thus switched the parameter given for loading
back to a URL - which I *thought* I had already tried
before.

The Result, however, didn't differ apart from now displaying
the "broken image" with the little circled "i", instead of just
showing the text "broken image".

Frustrated, I kicked the code again, but forgot to revert the
input parameter back to an InputStream - dom4j takes both
as parameter and thus didn't complain when I wanted to
show the problem to a friend of mine. 
Et voila... what happens? Everything displays just fine.
I don't know what happened, seems to be some minor 
incompatibility between dom4j and the W3C-DOM.

Thanks for your great support.
-Urs

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


Re: "Broken Image" in Image-Element

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

Urs Reupke wrote:

>>> Instead of showing the default "image not found"-icon, the SVG-Canvas 
>>> displays an image just the size I indicated in the referencing tag:
>>
>>    Displays an image of what?
> 
> Uh...shouldn't write mails that late :)
> It displays an "broken image" image.
> What makes me wonder is that the images seem to be found ("Broken Image"
> instead of default "image not found" icon, but not displayed.

    I think there is only one broken image icon that we use in
all cases that we can't find/decode the image.  However if you
have it displayed in a JSVGCanvas we set the title and desc on the
little 'i' in a circle, in the lower right hand corner to be a
short summary of why we couldn't load the image, this should popup
in a tooltip if the document has any dynamic behavior turned on.

    If that doesn't work or isn't particularly useful (it
usually isn't) I would start adding prints to the Batik source.

>>    What happens if you switch back?
> 
> I already tried - there is no change. [...]

    Then I'm guessing this is a red-herring.

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


Re: "Broken Image" in Image-Element

Posted by Urs Reupke <ur...@gmx.net>.
Hi Thomas,

>> Instead of showing the default "image not found"-icon, the SVG-Canvas 
>> displays an image just the size I indicated in the referencing tag:
>    Displays an image of what?

Uh...shouldn't write mails that late :)
It displays an "broken image" image.
What makes me wonder is that the images seem to be found ("Broken Image"
instead of default "image not found" icon, but not displayed.
 
>   Are you doing anything with 'display' or 'visibility' in your
> application?
I don't touch them at all.

>    What happens if you switch back?
I already tried - there is no change. 
Another thing came to my mind,
I also changed the way the image is loaded from a URL to an InputStream
(which I both give to dom4j for handling, so I expected no changes in behaviour),
but changing it back to an URL and even constructing that URL the oldfashioned 
way yielded no difference.

Regards
-Urs


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


Re: "Broken Image" in Image-Element

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

Urs Reupke wrote:

> Instead of showing the default "image not found"-icon, the SVG-Canvas 
> displays an image just the size I indicated in the referencing tag:

    Displays an image of what?

> <symbol id="ArrowLeft">
>    <image x="0" y="0" width="46" height="46" xlink:href="Arrow_Left.svg"/>
> </symbol>
> 
> This and similar symbols are referenced throughout my documents in 
> use-tags similar to this one:
> 
> <use xlink:href="#ArrowLeft" transform="translate(916 339)"/>

   Are you doing anything with 'display' or 'visibility' in your
application?

> which are children of a hierarchy of group elements.
> The only thing of impact (only thing of impact that comes to my mind, 
> that is) during said refactoring was that I switched to the (more 
> reliable) Java ClassLoader.getResource(String)-method instead of 
> manually creating the URL to set as the documents base URL via 
> setURLObject(URL).

    What happens if you switch back?


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