Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java +Batik +SVG

Reply
Thread Tools

Java +Batik +SVG

 
 
Christian-Josef Schrattenthaler
Guest
Posts: n/a
 
      07-08-2006
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.
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      07-10-2006

"Christian-Josef Schrattenthaler" <> wrote in message
news:1hy9687uzh9qx.nbpuc123svww$....
> 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?


http://xmlgraphics.apache.org/batik/...Component.html

- Oliver

 
Reply With Quote
 
 
 
 
Christian-Josef Schrattenthaler
Guest
Posts: n/a
 
      07-11-2006
Hi Oliver!

> http://xmlgraphics.apache.org/batik/...Component.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.
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      07-12-2006

"Christian-Josef Schrattenthaler" <> wrote in message
news:ks8jitzqw159$.erb0z8yk8he4$....
> Hi Oliver!
>
>> http://xmlgraphics.apache.org/batik/...Component.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.


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

- Oliver

 
Reply With Quote
 
Christian-Josef Schrattenthaler
Guest
Posts: n/a
 
      07-12-2006
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.
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      07-12-2006

"Christian-Josef Schrattenthaler" <> wrote in message
news:tevwd2tcvmd9.1k07572fpcc4m$....
> 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?


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

 
Reply With Quote
 
Christian-Josef Schrattenthaler
Guest
Posts: n/a
 
      07-12-2006
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.
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      07-12-2006

"Christian-Josef Schrattenthaler" <> wrote in message
news:...
> 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.


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hot Requirements: 1.Sr Java Developer,2.Java Developer (Java with EJB) Isaac Java 0 01-20-2011 08:41 PM
hey i am just started java,, can anyone tell me the use ,application, why java , importance of java.. manish sahu Java 3 02-14-2008 12:00 AM
[JAVA] [EVALUATION] - The Java Failure (Sorry: The Java(tm) Failure) Ilias Lazaridis Java 0 02-01-2005 10:32 AM
JAVA VIRTUAL MUCHINE OR SUN JAVA Fernando Kohan Firefox 1 11-14-2004 02:04 AM
Job to convert Java App 1.3.1 to Java Newest of Java Michael Kintner Java 0 11-30-2003 04:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57