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.LocalEventProducer;
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.NetworkException;
14
15
16
17
18
19
20
21
22
23
24
25 public class StaticObject extends LocalEventProducer implements LocatedObject, Serializable, Identifiable, Drawable
26 {
27
28 private static final long serialVersionUID = 20160400L;
29
30
31 private final String id;
32
33
34 private final OtsLine3d geometry;
35
36
37 private final Length height;
38
39
40
41
42
43
44 protected StaticObject(final String id, final OtsLine3d geometry, final Length height)
45 {
46 Throw.whenNull(id, "object id cannot be null");
47 Throw.whenNull(geometry, "geometry cannot be null");
48 Throw.whenNull(height, "height cannot be null");
49
50 this.id = id;
51 this.geometry = geometry;
52 this.height = height;
53 }
54
55
56
57
58
59 @SuppressWarnings("checkstyle:designforextension")
60 protected void init() throws NetworkException
61 {
62
63
64
65
66 }
67
68
69
70
71
72
73
74
75
76 public static StaticObject create(final String id, final OtsLine3d geometry, final Length height) throws NetworkException
77 {
78 StaticObject staticObject = new StaticObject(id, geometry, height);
79 staticObject.init();
80 return staticObject;
81 }
82
83
84
85
86
87
88
89
90 public static StaticObject create(final String id, final OtsLine3d geometry) throws NetworkException
91 {
92 return create(id, geometry, Length.ZERO);
93 }
94
95
96 @Override
97 public final OtsLine3d getGeometry()
98 {
99 return this.geometry;
100 }
101
102
103 @Override
104 public final Length getHeight()
105 {
106 return this.height;
107 }
108
109
110 @Override
111 public final String getId()
112 {
113 return this.id;
114 }
115
116
117 @Override
118 @SuppressWarnings("checkstyle:designforextension")
119 public String getFullId()
120 {
121 return this.id;
122 }
123
124
125 @Override
126 @SuppressWarnings("checkstyle:designforextension")
127 public DirectedPoint getLocation()
128 {
129 return this.geometry.getLocation();
130 }
131
132
133 @Override
134 @SuppressWarnings("checkstyle:designforextension")
135 public Bounds getBounds()
136 {
137 return this.geometry.getBounds();
138 }
139
140
141 @Override
142 @SuppressWarnings("checkstyle:designforextension")
143 public String toString()
144 {
145 return "StaticObject [geometry=" + getGeometry() + ", height=" + this.height + "]";
146 }
147
148 }