Bonjour,
J'ai besoin d'afficher une image svg à partir de mon programme Java.
J'ai abandonné la solution d'utiliser un applet, parce que j'ai
besoin, non seulement de récupérer des paramètres suite à
des événements sur l'image, mais aussi de manipuler l'image en
fonction des traitements spéciaux en Java de ces paramètres...
en gros: je prend les coordonnées des événements (clicks) sur
l'image, je fais mon traitement en Java, et après je fais des
feedbacks sur l'image ...
mon programme marchait très bien avec une image raster (jpeg, etc.),
mais je voulais passer en svg ..., il y a un petit souçi
ce que j'ai fait est le suivant :
j'ai téléchargé la librairie Batik. J'ai crée l'image à
partir du fichier SVG, je l'ai ajouté dans un Panel comme montré
dans le code ci-dessous. Mais finalement j'ai le frame vide, pourtant
j'ai bien activé mon panel dans le frame...
public class ImagePanel extends JPanel
{
private Image image;
private int x,y;// coordonnées du coin sup gauche
public ImagePanel(URL url,int x,int y)
{
super();
try {
image = new SvgImage(url).getImage(500,300);
} catch (IOException e) {
image = null;
System.err.println("Fichier invalide");
}
System.out.println("image: " + image);
this.x = x;
this.y = y;
setVisible(true);
}
/**
* Gere l'affichage graphique du JPanel, ainsi que le refraichissement.
*/
public void paintComponent(Graphics g)
{
System.out.println("Dans paintComponent. x = " + x + " y = " + y);
super.paintComponent(g);
g.drawImage(image,x,y,null);//w,h,null);
}
/**
* Teste la classe.
*/
public static void main(String[] args) throws Exception{
Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
JFrame w = new JFrame("Essai");
w.pack();
w.setLocation(screenSize.width/2, screenSize.height/2);
URL fichierSvg = new URL("http://.../butterfly.svg
<http://.../butterfly.svg> ");
ImagePanel p = new ImagePanel(fichierSvg,0,5);
p.setVisible(true);
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.getContentPane().add(p);
w.setSize(550,375);
w.setVisible(true);
}
}
Merci de votre aide,
Send instant messages to your online friends
http://uk.messenger.yahoo.com
[Non-text portions of this message have been removed]
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/