View Javadoc
1   package org.djunits.value.vfloat.vector;
2   
3   import java.util.List;
4   import java.util.Map;
5   
6   import org.djunits.unit.AngleUnit;
7   import org.djunits.unit.DirectionUnit;
8   import org.djunits.unit.scale.IdentityScale;
9   import org.djunits.value.storage.StorageType;
10  import org.djunits.value.vfloat.scalar.FloatAngle;
11  import org.djunits.value.vfloat.scalar.FloatDirection;
12  import org.djunits.value.vfloat.vector.base.FloatVectorRelWithAbs;
13  import org.djunits.value.vfloat.vector.data.FloatVectorData;
14  
15  import jakarta.annotation.Generated;
16  
17  /**
18   * Relative FloatAngle Vector.
19   * <p>
20   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
22   * </p>
23   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
24   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
25   */
26  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
27  public class FloatAngleVector extends
28          FloatVectorRelWithAbs<DirectionUnit, FloatDirection, FloatDirectionVector, AngleUnit, FloatAngle, FloatAngleVector>
29  {
30      /** */
31      private static final long serialVersionUID = 20151006L;
32  
33      /**
34       * Construct a FloatAngleVector from an internal data object.
35       * @param data FloatVectorData; the internal data object for the vector
36       * @param displayUnit AngleUnit; the display unit of the vector data
37       */
38      public FloatAngleVector(final FloatVectorData data, final AngleUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH float[] */
44  
45      /**
46       * Construct a FloatAngleVector from a float[] object. The Float values are expressed in the displayUnit, and will be
47       * printed using the displayUnit.
48       * @param data float[]; the data for the vector, expressed in the displayUnit
49       * @param displayUnit AngleUnit; the unit of the values in the data array, and display unit when printing
50       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
51       */
52      public FloatAngleVector(final float[] data, final AngleUnit displayUnit, final StorageType storageType)
53      {
54          this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a FloatAngleVector from a float[] object. The Float values are expressed in the displayUnit. Assume that the
59       * StorageType is DENSE since we offer the data as an array.
60       * @param data float[]; the data for the vector
61       * @param displayUnit AngleUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public FloatAngleVector(final float[] data, final AngleUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a FloatAngleVector from a float[] object with SI-unit values.
70       * @param data float[]; the data for the vector, in SI units
71       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
72       */
73      public FloatAngleVector(final float[] data, final StorageType storageType)
74      {
75          this(data, AngleUnit.SI, storageType);
76      }
77  
78      /**
79       * Construct a FloatAngleVector from a float[] object with SI-unit values. Assume that the StorageType is DENSE since we
80       * offer the data as an array.
81       * @param data float[]; the data for the vector, in SI units
82       */
83      public FloatAngleVector(final float[] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH FloatAngle[] */
89  
90      /**
91       * Construct a FloatAngleVector from an array of FloatAngle objects. The FloatAngle values are each expressed in their own
92       * unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
93       * @param data FloatAngle[]; the data for the vector
94       * @param displayUnit AngleUnit; the display unit of the values when printing
95       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
96       */
97      public FloatAngleVector(final FloatAngle[] data, final AngleUnit displayUnit, final StorageType storageType)
98      {
99          this(FloatVectorData.instantiate(data, storageType), displayUnit);
100     }
101 
102     /**
103      * Construct a FloatAngleVector from an array of FloatAngle objects. The FloatAngle values are each expressed in their own
104      * unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that the
105      * StorageType is DENSE since we offer the data as an array.
106      * @param data FloatAngle[]; the data for the vector
107      * @param displayUnit AngleUnit; the display unit of the values when printing
108      */
109     public FloatAngleVector(final FloatAngle[] data, final AngleUnit displayUnit)
110     {
111         this(data, displayUnit, StorageType.DENSE);
112     }
113 
114     /**
115      * Construct a FloatAngleVector from an array of FloatAngle objects. The FloatAngle values are each expressed in their own
116      * unit, but will be internally stored as SI values, and expressed using SI units when printing. since we offer the data as
117      * an array.
118      * @param data FloatAngle[]; the data for the vector
119      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
120      */
121     public FloatAngleVector(final FloatAngle[] data, final StorageType storageType)
122     {
123         this(data, AngleUnit.SI, storageType);
124     }
125 
126     /**
127      * Construct a FloatAngleVector from an array of FloatAngle objects. The FloatAngle values are each expressed in their own
128      * unit, but will be internally stored as SI values, and expressed using SI units when printing. Assume that the StorageType
129      * is DENSE since we offer the data as an array.
130      * @param data FloatAngle[]; the data for the vector
131      */
132     public FloatAngleVector(final FloatAngle[] data)
133     {
134         this(data, StorageType.DENSE);
135     }
136 
137     /* CONSTRUCTORS WITH List<Float> or List<Angle> */
138 
139     /**
140      * Construct a FloatAngleVector from a list of Number objects or a list of FloatAngle objects. Note that the displayUnit has
141      * a different meaning depending on whether the list contains Number objects (e.g., Float objects) or FloatAngle objects. In
142      * case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed,
143      * as well as the unit in which they will be printed. In case the list contains FloatAngle objects, each FloatAngle has its
144      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
145      * base values, and expressed using the display unit or base unit when printing.
146      * @param data List&lt;Float&gt; or List&lt;Angle&gt;; the data for the vector
147      * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is
148      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
149      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
150      */
151     public FloatAngleVector(final List<? extends Number> data, final AngleUnit displayUnit, final StorageType storageType)
152     {
153         this(data.size() == 0 ? FloatVectorData.instantiate(new float[] {}, IdentityScale.SCALE, storageType)
154                 : data.get(0) instanceof FloatAngle ? FloatVectorData.instantiate(data, IdentityScale.SCALE, storageType)
155                         : FloatVectorData.instantiate(data, displayUnit.getScale(), storageType),
156                 displayUnit);
157     }
158 
159     /**
160      * Construct a FloatAngleVector from a list of Number objects or a list of FloatAngle objects. Note that the displayUnit has
161      * a different meaning depending on whether the list contains Number objects (e.g., Float objects) or FloatAngle objects. In
162      * case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed,
163      * as well as the unit in which they will be printed. In case the list contains FloatAngle objects, each FloatAngle has its
164      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
165      * base values, and expressed using the display unit or base unit when printing. Assume the storage type is DENSE since we
166      * offer the data as a List.
167      * @param data List&lt;Float&gt; or List&lt;Angle&gt;; the data for the vector
168      * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is
169      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
170      */
171     public FloatAngleVector(final List<? extends Number> data, final AngleUnit displayUnit)
172     {
173         this(data, displayUnit, StorageType.DENSE);
174     }
175 
176     /**
177      * Construct a FloatAngleVector from a list of Number objects or a list of FloatAngle objects. When data contains numbers
178      * such as Float, assume that they are expressed using SI units. When the data consists of FloatAngle objects, they each
179      * have their own unit, but will be printed using SI units or base units. The values but will always be internally stored as
180      * SI values or base values, and expressed using the display unit or base unit when printing.
181      * @param data List&lt;Float&gt; or List&lt;Angle&gt;; the data for the vector
182      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
183      */
184     public FloatAngleVector(final List<? extends Number> data, final StorageType storageType)
185     {
186         this(data, AngleUnit.SI, storageType);
187     }
188 
189     /**
190      * Construct a FloatAngleVector from a list of Number objects or a list of FloatAngle objects. When data contains numbers
191      * such as Float, assume that they are expressed using SI units. When the data consists of FloatAngle objects, they each
192      * have their own unit, but will be printed using SI units or base units. The values but will always be internally stored as
193      * SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is
194      * DENSE since we offer the data as a List.
195      * @param data List&lt;Float&gt; or List&lt;Angle&gt;; the data for the vector
196      */
197     public FloatAngleVector(final List<? extends Number> data)
198     {
199         this(data, StorageType.DENSE);
200     }
201 
202     /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatAngle> */
203 
204     /**
205      * Construct a FloatAngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
206      * of FloatAngle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
207      * size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
208      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatAngle objects. In
209      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
210      * well as the unit in which they will be printed. In case the map contains FloatAngle objects, each FloatAngle has its own
211      * unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or base
212      * values, and expressed using the display unit or base unit when printing.
213      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatAngle&gt;; the data for the vector
214      * @param size int; the size off the vector, i.e., the highest index
215      * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is
216      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
217      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
218      */
219     public FloatAngleVector(final Map<Integer, ? extends Number> data, final int size, final AngleUnit displayUnit,
220             final StorageType storageType)
221     {
222         this(data.size() == 0 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
223                 : data.values().iterator().next() instanceof FloatAngle
224                         ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
225                         : FloatVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
226                 displayUnit);
227     }
228 
229     /**
230      * Construct a FloatAngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
231      * of FloatAngle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
232      * size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
233      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatAngle objects. In
234      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
235      * well as the unit in which they will be printed. In case the map contains FloatAngle objects, each FloatAngle has its own
236      * unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or base
237      * values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we offer
238      * the data as a Map.
239      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatAngle&gt;; the data for the vector
240      * @param size int; the size off the vector, i.e., the highest index
241      * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is
242      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
243      */
244     public FloatAngleVector(final Map<Integer, ? extends Number> data, final int size, final AngleUnit displayUnit)
245     {
246         this(data, size, displayUnit, StorageType.SPARSE);
247     }
248 
249     /**
250      * Construct a FloatAngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
251      * of FloatAngle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
252      * size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
253      * Float, assume that they are expressed using SI units. When the data consists of FloatAngle objects, they each have their
254      * own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values
255      * or base values, and expressed using the display unit or base unit when printing.
256      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatAngle&gt;; the data for the vector
257      * @param size int; the size off the vector, i.e., the highest index
258      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
259      */
260     public FloatAngleVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
261     {
262         this(data, size, AngleUnit.SI, storageType);
263     }
264 
265     /**
266      * Construct a FloatAngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
267      * of FloatAngle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
268      * size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
269      * Float, assume that they are expressed using SI units. When the data consists of FloatAngle objects, they each have their
270      * own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values
271      * or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since
272      * we offer the data as a Map.
273      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatAngle&gt;; the data for the vector
274      * @param size int; the size off the vector, i.e., the highest index
275      */
276     public FloatAngleVector(final Map<Integer, ? extends Number> data, final int size)
277     {
278         this(data, size, StorageType.SPARSE);
279     }
280 
281     /* ****************************** Other methods ****************************** */
282 
283     @Override
284     public Class<FloatAngle> getScalarClass()
285     {
286         return FloatAngle.class;
287     }
288 
289     @Override
290     public FloatAngleVector instantiateVector(final FloatVectorData fvd, final AngleUnit displayUnit)
291     {
292         return new FloatAngleVector(fvd, displayUnit);
293     }
294 
295     @Override
296     public FloatAngle instantiateScalarSI(final float valueSI, final AngleUnit displayUnit)
297     {
298         FloatAngle result = FloatAngle.instantiateSI(valueSI);
299         result.setDisplayUnit(displayUnit);
300         return result;
301     }
302 
303     @Override
304     public FloatDirectionVector instantiateVectorAbs(final FloatVectorData fvd, final DirectionUnit displayUnit)
305     {
306         return new FloatDirectionVector(fvd, displayUnit);
307     }
308 
309     @Override
310     public FloatDirection instantiateScalarAbsSI(final float valueSI, final DirectionUnit displayUnit)
311     {
312         FloatDirection result = FloatDirection.instantiateSI(valueSI);
313         result.setDisplayUnit(displayUnit);
314         return result;
315     }
316 
317 }