Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

Java +Batik +SVG

Thread view: 
Christian-Josef Schrattenthaler - 08 Jul 2006 08:47 GMT
Hi!

I want to use SVG images in my Java application. I only need to display
some images, nothing other is to do!

The only powerful API I found was Batik.

I searched and tried many hours, but I didn't find an easy way to display
my SVG images in my JFrames, JDialogs, ...

Please, can anyone give me a hint?

Thanks and kind greetings,
Christian.
Oliver Wong - 10 Jul 2006 20:27 GMT
> Hi!
>
[quoted text clipped - 7 lines]
>
> Please, can anyone give me a hint?

http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/swing/svg/AbstractJ
SVGComponent.html


   - Oliver
Christian-Josef Schrattenthaler - 11 Jul 2006 21:22 GMT
Hi Oliver!

> http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/swing/svg/AbstractJ
SVGComponent.html

Sorry, but I am a Java-Newbie, and I didn't get this to work.

At this time, I can display a svg image over the JSVGCanvas:

***
JSVGCanvas jsvgc = new JSVGCanvas();
jsvgc.setURI(new File("CJSCardIndexLogo.svg").toURI().toString());
jsvgc.setPreferredSize(new Dimension(300, 300));
add(jsvgc);
***

This is ok, but I also need to use this svg image as IconImage for my
JFrame. Do you have a solution for this?

Greetings,
Christian.
Oliver Wong - 12 Jul 2006 15:40 GMT
> Hi Oliver!
>
[quoted text clipped - 16 lines]
> Greetings,
> Christian.

   The page I linked to has 5 phases. Which phase did you get stuck at?

   - Oliver
Christian-Josef Schrattenthaler - 12 Jul 2006 16:41 GMT
Hi Oliver!

> The page I linked to has 5 phases. Which phase did you get stuck at?

I want to use the svg graphic as an java.awt.Image. For Example to use in
'setIconImage("mygraphic.svg")' for the Icon of a JFrame.

I tried:

***
final JSVGComponent svgComp = new JSVGComponent();
svgComp.loadSVGDocument("CJSCardIndexLogo.svg");
setIconImage(svgComp);
***

But svgComp is not an Image, and I can't cast it to an Image.

I found no information about using an svg graphic under Java as an Image.

Can you tell me how to do?

Greetings,
Christian.
Oliver Wong - 12 Jul 2006 18:27 GMT
> Hi Oliver!
>
[quoted text clipped - 16 lines]
>
> Can you tell me how to do?

   Previously, you said you wanted to display an SVG image within a JFrame.
Now you're saying you want to convert it to an Image object somehow. Which
is it that you actually want to do? The solution for each will probably be
vastly different.

   - Oliver
Christian-Josef Schrattenthaler - 12 Jul 2006 19:55 GMT
Hello Oliver!

> Previously, you said you wanted to display an SVG image within a JFrame.
> Now you're saying you want to convert it to an Image object somehow. Which
> is it that you actually want to do? The solution for each will probably be
> vastly different.

Till now I used JPG images for the Icon of a JFrame, for the Icon of a
JLabel, to display a graphic in a frame, and so on.

But vector graphics are better than pixel graphics, if you want to resize
them without losing quality, and SVG images are the future of vector
graphics. I searched also for a solution for EPS images, but I didn't find
anything.

I know how to display an image in a frame over JSVGCanvas. It's quit
simple, if you know that you have to use JSVGCanvas for this.

But now I want also replace my JPG images with my new SVG images for:
JFrame.setIconImage(Image) and JLabel.setIcon(Image).

Do you knwo how I can do this? Is it possible to create an Image Object
from an SVG image to use it with setIconImage() and setIcon()?

Thanks and kind greetings,
Christian.
Oliver Wong - 12 Jul 2006 21:25 GMT
> Hello Oliver!
>
[quoted text clipped - 24 lines]
> Thanks and kind greetings,
> Christian.

   for JFrame.setIconImage(Image), the icon is likely to be no bigger than
128 by 128 pixels on all the OSes that I know of. I believe that on Windows,
it may be as small as 32x32. In this case, use a 128x128 JPG, and you'll be
set for the next 5 years.

   For JLabel.setIcon(Image), I recommend you use an AbstractJSVGComponent,
and position it relative to your label using a layout manager.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.