1 package org.opentrafficsim.core.object;
2
3 import java.io.Serializable;
4
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.djutils.event.EventProducer;
7 import org.djutils.exceptions.Throw;
8 import org.opentrafficsim.base.Identifiable;
9 import org.opentrafficsim.core.animation.Drawable;
10 import org.opentrafficsim.core.geometry.Bounds;
11 import org.opentrafficsim.core.geometry.DirectedPoint;
12 import org.opentrafficsim.core.geometry.OTSLine3D;
13 import org.opentrafficsim.core.network.Network;
14 import org.opentrafficsim.core.network.NetworkException;
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class StaticObject extends EventProducer implements ObjectInterface, Serializable, Identifiable, Drawable
29 {
30
31 private static final long serialVersionUID = 20160400L;
32
33
34 private final String id;
35
36
37 private final OTSLine3D geometry;
38
39
40 private final Length height;
41
42
43
44
45
46
47 protected StaticObject(final String id, final OTSLine3D geometry, final Length height)
48 {
49 Throw.whenNull(id, "object id cannot be null");
50 Throw.whenNull(geometry, "geometry cannot be null");
51 Throw.whenNull(height, "height cannot be null");
52
53 this.id = id;
54 this.geometry = geometry;
55 this.height = height;
56 }
57
58
59
60
61
62 @SuppressWarnings("checkstyle:designforextension")
63 protected void init() throws NetworkException
64 {
65
66
67
68
69 }
70
71
72
73
74
75
76
77
78
79 public static StaticObject create(final String id, final OTSLine3D geometry, final Length height) throws NetworkException
80 {
81 StaticObject staticObject = new StaticObject(id, geometry, height);
82 staticObject.init();
83 return staticObject;
84 }
85
86
87
88
89
90
91
92
93 public static StaticObject create(final String id, final OTSLine3D geometry) throws NetworkException
94 {
95 return create(id, geometry, Length.ZERO);
96 }
97
98
99 @Override
100 public final OTSLine3D getGeometry()
101 {
102 return this.geometry;
103 }
104
105
106 @Override
107 public final Length getHeight()
108 {
109 return this.height;
110 }
111
112
113 @Override
114 public final String getId()
115 {
116 return this.id;
117 }
118
119
120 @Override
121 @SuppressWarnings("checkstyle:designforextension")
122 public String getFullId()
123 {
124 return this.id;
125 }
126
127
128 @Override
129 @SuppressWarnings("checkstyle:designforextension")
130 public DirectedPoint getLocation()
131 {
132 return this.geometry.getLocation();
133 }
134
135
136 @Override
137 @SuppressWarnings("checkstyle:designforextension")
138 public Bounds getBounds()
139 {
140 return this.geometry.getBounds();
141 }
142
143
144 @Override
145 @SuppressWarnings("checkstyle:designforextension")
146 public String toString()
147 {
148 return "StaticObject3D [geometry=" + getGeometry() + ", height=" + this.height + "]";
149 }
150
151
152
153
154
155
156
157
158 @SuppressWarnings("checkstyle:designforextension")
159 public StaticObject clone(final Network newNetwork, final boolean animation) throws NetworkException
160 {
161
162 return new StaticObject(this.id, this.geometry, this.height);
163 }
164
165
166 @Override
167 public Serializable getSourceId()
168 {
169 return this.id;
170 }
171
172 }