2 * RocksimDensityType.java
4 package net.sf.openrocket.file.rocksim;
7 * Models the nose cone shape of a rocket. Maps from Rocksim's notion to OpenRocket's.
9 enum RocksimDensityType {
10 ROCKSIM_BULK (0, RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY),
11 ROCKSIM_SURFACE(1, RocksimHandler.ROCKSIM_TO_OPENROCKET_SURFACE_DENSITY),
12 ROCKSIM_LINE (2, RocksimHandler.ROCKSIM_TO_OPENROCKET_LINE_DENSITY);
14 /** The Rocksim enumeration value. Sent in XML. */
15 private final int ordinal;
17 /** The corresponding OpenRocket shape. */
18 private final double conversion;
23 * @param idx the Rocksim shape code
24 * @param theConversion the numerical conversion ratio to OpenRocket
26 private RocksimDensityType(int idx, double theConversion) {
28 conversion = theConversion;
32 * Get the OpenRocket shape that corresponds to the Rocksim value.
34 * @return a conversion
36 public double asOpenRocket() {
41 * Lookup an instance of this enum based upon the Rocksim code.
43 * @param rocksimDensityType the Rocksim code (from XML)
44 * @return an instance of this enum
46 public static RocksimDensityType fromCode(int rocksimDensityType) {
47 RocksimDensityType[] values = values();
48 for (RocksimDensityType value : values) {
49 if (value.ordinal == rocksimDensityType) {
53 return ROCKSIM_BULK; //Default