View Javadoc
1   package org.opentrafficsim.core.network.point2d;
2   
3   import java.awt.geom.Point2D;
4   
5   import org.opentrafficsim.core.network.AbstractNode;
6   import org.opentrafficsim.core.unit.AnglePlaneUnit;
7   import org.opentrafficsim.core.unit.AngleSlopeUnit;
8   import org.opentrafficsim.core.value.vdouble.scalar.DoubleScalar;
9   
10  /**
11   * <p>
12   * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
14   * <p>
15   * @version 11 Nov 2014 <br>
16   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   * @param <ID> Type of the node name (e.g., String, Integer).
19   */
20  public class NodePoint2D<ID> extends AbstractNode<ID, Point2D>
21  {
22      /** */
23      private static final long serialVersionUID = 20150104L;
24  
25      /**
26       * Construct a new Node.
27       * @param id the Id of the new Node
28       * @param point the location of the Node
29       */
30      public NodePoint2D(final ID id, final Point2D point)
31      {
32          super(id, point);
33      }
34  
35      /**
36       * Construct a new Node.
37       * @param id the Id of the new Node
38       * @param point the location of the Node
39       * @param direction the 3D direction. "East" is 0 degrees. "North" is 90 degrees (1/2 pi radians).
40       * @param slope the slope as an angle.
41       */
42      public NodePoint2D(final ID id, final Point2D point, final DoubleScalar.Abs<AnglePlaneUnit> direction,
43          final DoubleScalar.Abs<AngleSlopeUnit> slope)
44      {
45          super(id, point, direction, slope);
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public final double getX()
51      {
52          return getPoint().getX();
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public final double getY()
58      {
59          return getPoint().getY();
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public final double getZ()
65      {
66          return 0.0d;
67      }
68  
69      /**
70       * String ID implementation of the Point2D node.
71       * <p>
72       * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br>
73       * All rights reserved. <br>
74       * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
75       * <p>
76       * @version Jan 4, 2015 <br>
77       * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
78       * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
79       */
80      public static class STR extends NodePoint2D<String>
81      {
82          /** */
83          private static final long serialVersionUID = 20150104L;
84  
85          /**
86           * @param id String id.
87           * @param point the location of the Node.
88           */
89          public STR(final String id, final Point2D point)
90          {
91              super(id, point);
92          }
93  
94          /**
95           * @param id the String Id of the new Node
96           * @param point the location of the Node
97           * @param direction the 3D direction. "East" is 0 degrees. "North" is 90 degrees (1/2 pi radians).
98           * @param slope the slope as an angle.
99           */
100         public STR(final String id, final Point2D point, final DoubleScalar.Abs<AnglePlaneUnit> direction,
101             final DoubleScalar.Abs<AngleSlopeUnit> slope)
102         {
103             super(id, point, direction, slope);
104         }
105 
106     }
107 
108     /**
109      * Integer ID implementation of the Point2D node.
110      * <p>
111      * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br>
112      * All rights reserved. <br>
113      * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
114      * <p>
115      * @version Jan 4, 2015 <br>
116      * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
117      * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
118      */
119     public static class INT extends NodePoint2D<Integer>
120     {
121         /** */
122         private static final long serialVersionUID = 20150104L;
123 
124         /**
125          * @param id Integer id.
126          * @param point the location of the Node.
127          */
128         public INT(final int id, final Point2D point)
129         {
130             super(id, point);
131         }
132 
133         /**
134          * @param id the Integer Id of the new Node
135          * @param point the location of the Node
136          * @param direction the 3D direction. "East" is 0 degrees. "North" is 90 degrees (1/2 pi radians).
137          * @param slope the slope as an angle.
138          */
139         public INT(final int id, final Point2D point, final DoubleScalar.Abs<AnglePlaneUnit> direction,
140             final DoubleScalar.Abs<AngleSlopeUnit> slope)
141         {
142             super(id, point, direction, slope);
143         }
144 
145     }
146 
147 }