X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fpreset%2Fxml%2FShapeDTO.java;fp=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fpreset%2Fxml%2FShapeDTO.java;h=d85fbcb0f0a5e0d8d5b3fb6062a5b38ffdadf670;hb=9349577cdfdff682b2aabd6daa24fdc3a7449b58;hp=0000000000000000000000000000000000000000;hpb=30ba0a882f0c061176ba14dbf86d3d6fad096c02;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java b/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java new file mode 100644 index 00000000..d85fbcb0 --- /dev/null +++ b/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java @@ -0,0 +1,41 @@ + +package net.sf.openrocket.preset.xml; + +import net.sf.openrocket.rocketcomponent.Transition; + +import javax.xml.bind.annotation.XmlEnum; + +/** + * A mirror class to Transition.Shape to adapt that class to/from XML. + */ +@XmlEnum(String.class) +public enum ShapeDTO { + + CONICAL (Transition.Shape.CONICAL), + OGIVE (Transition.Shape.OGIVE), + ELLIPSOID (Transition.Shape.ELLIPSOID), + POWER (Transition.Shape.POWER), + PARABOLIC (Transition.Shape.PARABOLIC), + HAACK (Transition.Shape.HAACK); + + private Transition.Shape corollary; + + private ShapeDTO(Transition.Shape theShape) { + corollary = theShape; + } + + public static ShapeDTO asDTO(Transition.Shape targetShape) { + ShapeDTO[] values = values(); + for (int i = 0; i < values.length; i++) { + ShapeDTO value = values[i]; + if (value.corollary.equals(targetShape)) { + return value; + } + } + return ELLIPSOID; //default + } + + public Transition.Shape getORShape() { + return corollary; + } +}