01: /*
02: * Created on 15.09.2005
03: *
04: * TODO To change the template for this generated file go to
05: * Window - Preferences - Java - Code Style - Code Templates
06: */
07: package de.latlon.deejump.plugin.style;
08:
09: import java.awt.Graphics2D;
10: import java.awt.Image;
11: import java.awt.Toolkit;
12: import java.awt.geom.Point2D;
13:
14: import com.vividsolutions.jump.workbench.ui.renderer.style.VertexStyle;
15:
16: /**
17: * @author hamammi
18: *
19: * TODO To change the template for this generated type comment go to
20: * Window - Preferences - Java - Code Style - Code Templates
21: */
22: public class BitmapVertexStyle extends VertexStyle {
23:
24: private Image image;
25: private Point2D point;
26: private String imageURL;
27:
28: public BitmapVertexStyle() {
29: }
30:
31: /**
32: *
33: * @param image cannot be null
34: */
35: public BitmapVertexStyle(String imageURL) {
36: // init with a this.shape = poly with 1 point (?)
37: super (null);
38: if (imageURL == null) {
39: throw new NullPointerException("Image URL cannot be null.");
40: }
41: setImageURL(imageURL);
42: }
43:
44: public void paint(Graphics2D g, Point2D p) {
45: // don't use this, use this.shape
46:
47: // this.polygon.xpoints = new int [] { (int) p.getX()};
48: // this.polygon.ypoints = new int [] { (int) p.getY() };
49: // this.polygon.npoints=1;
50: this .point = p;
51: render(g);
52: }
53:
54: protected void render(Graphics2D g) {
55: g.drawImage(image, (int) point.getX()
56: - ((image.getWidth(null)) / 2), (int) point.getY()
57: - ((image.getHeight(null)) / 2), null);
58:
59: }
60:
61: public Image getImage() {
62: return image;
63: }
64:
65: public String getImageURL() {
66: return imageURL;
67: }
68:
69: public void setImageURL(String imageURL) {
70:
71: this.imageURL = imageURL;
72: this.image = Toolkit.getDefaultToolkit().getImage(imageURL);
73: }
74: }
|