X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fsf%2Fopenrocket%2Ffile%2Frocksim%2FRocksimNoseConeCode.java;fp=src%2Fnet%2Fsf%2Fopenrocket%2Ffile%2Frocksim%2FRocksimNoseConeCode.java;h=8cd7c82a856fb0527c7d177fe70d2798c565c637;hb=198227dc14b96901f3105fd816b6a9b84993adef;hp=0000000000000000000000000000000000000000;hpb=759de538156bbd2810075a5fd14ce9ddb3fbd274;p=debian%2Fopenrocket diff --git a/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java b/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java new file mode 100644 index 00000000..8cd7c82a --- /dev/null +++ b/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java @@ -0,0 +1,61 @@ +/* + * RocksimNoseConeCode.java + */ +package net.sf.openrocket.file.rocksim; + +import net.sf.openrocket.rocketcomponent.Transition; + +/** + * Models the nose cone shape of a rocket. Maps from Rocksim's notion to OpenRocket's. + */ +enum RocksimNoseConeCode { + CONICAL (0, Transition.Shape.CONICAL), + OGIVE (1, Transition.Shape.OGIVE), + PARABOLIC (2, Transition.Shape.ELLIPSOID), //Rocksim' PARABOLIC most closely resembles an ELLIPSOID in OpenRocket + ELLIPTICAL (3, Transition.Shape.ELLIPSOID), + POWER_SERIES (4, Transition.Shape.POWER), + PARABOLIC_SERIES(5, Transition.Shape.PARABOLIC), + HAACK (6, Transition.Shape.HAACK); + + /** The Rocksim enumeration value. Sent in XML. */ + private final int ordinal; + + /** The corresponding OpenRocket shape. */ + private final Transition.Shape shape; + + /** + * Constructor. + * + * @param idx the Rocksim shape code + * @param aShape the corresponding OpenRocket shape + */ + private RocksimNoseConeCode(int idx, Transition.Shape aShape) { + ordinal = idx; + shape = aShape; + } + + /** + * Get the OpenRocket shape that corresponds to the Rocksim shape. + * + * @return a shape + */ + public Transition.Shape asOpenRocket() { + return shape; + } + + /** + * Lookup an instance of this enum based upon the Rocksim code. + * + * @param rocksimShapeCode the Rocksim code (from XML) + * @return an instance of this enum + */ + public static RocksimNoseConeCode fromCode(int rocksimShapeCode) { + RocksimNoseConeCode[] values = values(); + for (RocksimNoseConeCode value : values) { + if (value.ordinal == rocksimShapeCode) { + return value; + } + } + return PARABOLIC; //Default + } +}