1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.animation;
11
12 import java.util.HashMap;
13 import java.util.Map;
14 import java.util.Properties;
15
16 import javax.media.j3d.BoundingSphere;
17 import javax.media.j3d.Bounds;
18
19 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
20 import nl.tudelft.simulation.event.EventProducer;
21 import nl.tudelft.simulation.event.EventType;
22 import nl.tudelft.simulation.language.d3.DirectedPoint;
23 import nl.tudelft.simulation.language.d3.CartesianPoint;
24 import nl.tudelft.simulation.language.io.URLResource;
25 import nl.tudelft.simulation.logger.Logger;
26
27 /***
28 * An Editable object is a simulation object that can be edited by the user.
29 * That means that the user is capable of instantiating, moving, rotating, and
30 * editing the vertices that span up the shape of this object during the
31 * simulation.
32 * <p>
33 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
34 * University of Technology </a>, the Netherlands. <br>
35 * See for project information <a
36 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
37 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
38 * License (GPL) </a>, no warranty <br>
39 *
40 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
41 * Jacobs </a>
42 * @version 1.2 Aug 3, 2004
43 * @since 1.4
44 */
45 public abstract class Editable extends EventProducer implements
46 LocatableInterface
47 {
48 /*** the static map of editables */
49 private static Map editables = new HashMap();
50
51
52
53
54 static
55 {
56 try
57 {
58 Properties properties = new Properties();
59 properties.load(URLResource
60 .getResourceAsStream("/editable.properties"));
61 Editable.editables.putAll(properties);
62 } catch (Exception exception)
63 {
64 Logger.severe(Editable.class, "<clinit>", exception);
65 }
66 }
67
68 /*** LOCATION_CHANGED_EVENT the LOCATION_CHANGED_EVENT */
69 public static final EventType LOCATION_CHANGED_EVENT = new EventType(
70 "LOCATION_CHANGED_EVENT");
71
72 /*** the simulator to use */
73 protected SimulatorInterface simulator = null;
74
75 /*** the location of the editable */
76 protected DirectedPoint location = null;
77
78 /*** the location of the bounds */
79 protected Bounds bounds = new BoundingSphere();
80
81 /*** the vertices */
82 protected CartesianPoint[] vertices = new CartesianPoint[0];
83
84 /***
85 * returns the editables as a list of name=class
86 *
87 * @return the map
88 */
89 public static Map listEditables()
90 {
91 return Editable.editables;
92 }
93
94 /***
95 * constructs a new Editable
96 *
97 * @param simulator
98 * the simulator to schedule on
99 * @param location
100 * the initial location
101 */
102 public Editable(final SimulatorInterface simulator,
103 final DirectedPoint location)
104 {
105 super();
106 this.simulator = simulator;
107 this.location = location;
108 }
109
110 /***
111 * @return @throws
112 * RemoteException
113 */
114 public CartesianPoint[] getVertices()
115 {
116 return this.vertices;
117 }
118
119 /***
120 * @param bounds
121 */
122 public void setBounds(final Bounds bounds)
123 {
124 this.bounds = bounds;
125 }
126
127 /***
128 * @param location
129 */
130 public void setLocation(final DirectedPoint location)
131 {
132 this.location = location;
133 }
134
135 /***
136 * @param vertices
137 */
138 public void setVertices(final CartesianPoint[] vertices)
139 {
140 this.vertices = vertices;
141 }
142
143 /***
144 * @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getBounds()
145 */
146 public Bounds getBounds()
147 {
148 return this.bounds;
149 }
150
151 /***
152 * @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getLocation()
153 */
154 public DirectedPoint getLocation()
155 {
156 return this.location;
157 }
158 }