01: /*
02: * Created on 30.08.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.Polygon;
11: import java.awt.Shape;
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 TriangleVertexStyle extends VertexStyle {
23:
24: public TriangleVertexStyle() {
25: super (createDefaultTriangle());
26: }
27:
28: public void paint(Graphics2D g, Point2D p) {
29: //setFrame
30: //render
31: int angle = 45;
32: int halfSide = (int) (Math.sin(angle) * getSize());
33: int p1X = (int) p.getX();
34: int p1Y = (int) p.getY() - getSize();
35: int p2X = p1X - halfSide;
36: int p2Y = (int) p.getY() + halfSide;
37: int p3X = (p1X) + halfSide;
38: int p3Y = (int) p.getY() + halfSide;
39: ((Polygon) this .shape).xpoints = new int[] { p1X, p2X, p3X };
40: ((Polygon) this .shape).ypoints = new int[] { p1Y, p2Y, p3Y };
41: ((Polygon) this .shape).npoints = ((Polygon) this .shape).xpoints.length;
42: render(g);
43: }
44:
45: protected static Shape createDefaultTriangle() {
46: return new Polygon();
47: }
48: }
|