1 package org.opentrafficsim.draw.object;
2
3 import java.awt.BasicStroke;
4 import java.awt.Color;
5 import java.awt.Graphics2D;
6 import java.awt.Stroke;
7 import java.awt.image.ImageObserver;
8 import java.io.Serializable;
9 import java.rmi.RemoteException;
10
11 import javax.naming.NamingException;
12
13 import org.opentrafficsim.core.object.StaticObject;
14 import org.opentrafficsim.draw.core.PaintPolygons;
15
16 import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
17 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
18
19
20
21
22
23
24
25
26
27
28 public class StaticObjectAnimation extends Renderable2D implements Serializable
29 {
30
31 private static final long serialVersionUID = 20160400L;
32
33
34 private float width;
35
36
37 private Color color;
38
39
40 private boolean fill;
41
42
43
44
45
46
47
48
49
50
51 public StaticObjectAnimation(final StaticObject source, final SimulatorInterface.TimeDoubleUnit simulator,
52 final float width, final Color color, final boolean fill) throws NamingException, RemoteException
53 {
54 super(source, simulator);
55 this.width = width;
56 this.color = color;
57 this.fill = fill;
58 }
59
60
61 @Override
62 public final void paint(final Graphics2D graphics, final ImageObserver observer) throws RemoteException
63 {
64 if (this.width > 0.0f)
65 {
66 Stroke oldStroke = graphics.getStroke();
67 graphics.setStroke(new BasicStroke(this.width));
68 PaintPolygons.paintMultiPolygon(graphics, this.color, getSource().getLocation(),
69 ((StaticObject) getSource()).getGeometry(), this.fill);
70 graphics.setStroke(oldStroke);
71 }
72 }
73
74
75
76
77 public final float getWidth()
78 {
79 return this.width;
80 }
81
82
83
84
85 public final void setWidth(final float width)
86 {
87 this.width = width;
88 }
89
90
91
92
93 public final Color getColor()
94 {
95 return this.color;
96 }
97
98
99
100
101 public final void setColor(final Color color)
102 {
103 this.color = color;
104 }
105
106
107
108
109 public final boolean isFill()
110 {
111 return this.fill;
112 }
113
114
115
116
117 public final void setFill(final boolean fill)
118 {
119 this.fill = fill;
120 }
121
122
123 @Override
124 public final String toString()
125 {
126 return "StaticObjectAnimation [width=" + this.width + ", color=" + this.color + ", fill=" + this.fill + "]";
127 }
128
129 }