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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| package affichage;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import traitement.POI;
public class Carte extends JPanel {
private static final long serialVersionUID = 1L;
/*** DESSINER UN OBJET ***/
POI poi1 = new POI("blabla", "paris je t'aime", "description",100,100);
public void paintComponent(Graphics g){
try {
Image img = ImageIO.read(new File("images/londres.jpg"));
g.drawImage(img, 0, 0, this);
paintPoint(g, 30,30);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// dessiner une POI
public void paintPoint(Graphics x, int positionX, int positionY){
try {
Image img = ImageIO.read(new File("images/POI.gif"));
x.drawImage(img, positionX, positionY, this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
// dessiner une POI
public void paintPoint(Graphics x, POI p){
int positionX = p.getPositionX();
int positionY = p.getPositionY();
try {
Image img = ImageIO.read(new File("images/POI.gif"));
x.drawImage(img, positionX, positionY, this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} */
} |
Partager