create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / file / rocksim / export / FinSetDTO.java
1 package net.sf.openrocket.file.rocksim.export;
2
3 import net.sf.openrocket.file.TipShapeCode;
4 import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
5 import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
6 import net.sf.openrocket.rocketcomponent.FinSet;
7 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
8 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
9
10 import javax.xml.bind.annotation.XmlAccessType;
11 import javax.xml.bind.annotation.XmlAccessorType;
12 import javax.xml.bind.annotation.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
14
15 /**
16  * This class models XML elements for Rocksim finsets.
17  */
18 @XmlRootElement(name = RocksimCommonConstants.FIN_SET)
19 @XmlAccessorType(XmlAccessType.FIELD)
20 public class FinSetDTO extends BasePartDTO {
21
22     @XmlElement(name = RocksimCommonConstants.FIN_COUNT)
23     private int finCount = 0;
24     @XmlElement(name = RocksimCommonConstants.ROOT_CHORD)
25     private double rootChord = 0d;
26     @XmlElement(name = RocksimCommonConstants.TIP_CHORD)
27     private double tipChord = 0d;
28     @XmlElement(name = RocksimCommonConstants.SEMI_SPAN)
29     private double semiSpan = 0d;
30     @XmlElement(name = RocksimCommonConstants.SWEEP_DISTANCE)
31     private double sweepDistance = 0d;
32     @XmlElement(name = RocksimCommonConstants.THICKNESS)
33     private double thickness = 0d;
34     @XmlElement(name = RocksimCommonConstants.SHAPE_CODE)
35     private int shapeCode = 0;
36     @XmlElement(name = RocksimCommonConstants.TIP_SHAPE_CODE)
37     private int tipShapeCode = 0;
38     @XmlElement(name = RocksimCommonConstants.TAB_LENGTH)
39     private double tabLength = 0d;
40     @XmlElement(name = RocksimCommonConstants.TAB_DEPTH)
41     private double tabDepth = 0d;
42     @XmlElement(name = RocksimCommonConstants.TAB_OFFSET)
43     private double tabOffset = 0d;
44     @XmlElement(name = RocksimCommonConstants.SWEEP_MODE)
45     private int sweepMode = 1;
46     @XmlElement(name = RocksimCommonConstants.CANT_ANGLE)
47     private double cantAngle = 0d;
48
49     /**
50      * Constructor.
51      */
52     public FinSetDTO() {
53     }
54
55     /**
56      * Full copy constructor.
57      *
58      * @param theORFinSet  the OpenRocket finset
59      */
60     public FinSetDTO(FinSet theORFinSet) {
61         super(theORFinSet);
62
63         setFinCount(theORFinSet.getFinCount());
64         setCantAngle(theORFinSet.getCantAngle());
65         setTabDepth(theORFinSet.getTabHeight() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
66         setTabLength(theORFinSet.getTabLength() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
67         setTabOffset(theORFinSet.getTabShift() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
68         setThickness(theORFinSet.getThickness() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
69
70         setRadialAngle(theORFinSet.getBaseRotation());
71         setTipShapeCode(TipShapeCode.convertTipShapeCode(theORFinSet.getCrossSection()));
72         if (theORFinSet instanceof TrapezoidFinSet) {
73             TrapezoidFinSet tfs = (TrapezoidFinSet) theORFinSet;
74             setShapeCode(0);
75             setRootChord(theORFinSet.getLength() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
76             setSemiSpan(tfs.getHeight() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
77             setTipChord(tfs.getTipChord() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
78             setSweepDistance(tfs.getSweep() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
79         }
80         else if (theORFinSet instanceof EllipticalFinSet) {
81             EllipticalFinSet efs = (EllipticalFinSet) theORFinSet;
82             setShapeCode(1);
83             setRootChord(theORFinSet.getLength() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
84             setSemiSpan(efs.getHeight() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
85         }
86         else if (theORFinSet instanceof FreeformFinSet) {
87             setShapeCode(2);
88         }
89     }
90
91     public int getFinCount() {
92         return finCount;
93     }
94
95     public void setFinCount(int theFinCount) {
96         finCount = theFinCount;
97     }
98
99     public double getRootChord() {
100         return rootChord;
101     }
102
103     public void setRootChord(double theRootChord) {
104         rootChord = theRootChord;
105     }
106
107     public double getTipChord() {
108         return tipChord;
109     }
110
111     public void setTipChord(double theTipChord) {
112         tipChord = theTipChord;
113     }
114
115     public double getSemiSpan() {
116         return semiSpan;
117     }
118
119     public void setSemiSpan(double theSemiSpan) {
120         semiSpan = theSemiSpan;
121     }
122
123     public double getSweepDistance() {
124         return sweepDistance;
125     }
126
127     public void setSweepDistance(double theSweepDistance) {
128         sweepDistance = theSweepDistance;
129     }
130
131     public double getThickness() {
132         return thickness;
133     }
134
135     public void setThickness(double theThickness) {
136         thickness = theThickness;
137     }
138
139     public int getShapeCode() {
140         return shapeCode;
141     }
142
143     public void setShapeCode(int theShapeCode) {
144         shapeCode = theShapeCode;
145     }
146
147     public int getTipShapeCode() {
148         return tipShapeCode;
149     }
150
151     public void setTipShapeCode(int theTipShapeCode) {
152         tipShapeCode = theTipShapeCode;
153     }
154
155     public double getTabLength() {
156         return tabLength;
157     }
158
159     public void setTabLength(double theTabLength) {
160         tabLength = theTabLength;
161     }
162
163     public double getTabDepth() {
164         return tabDepth;
165     }
166
167     public void setTabDepth(double theTabDepth) {
168         tabDepth = theTabDepth;
169     }
170
171     public double getTabOffset() {
172         return tabOffset;
173     }
174
175     public void setTabOffset(double theTabOffset) {
176         tabOffset = theTabOffset;
177     }
178
179     public int getSweepMode() {
180         return sweepMode;
181     }
182
183     public void setSweepMode(int theSweepMode) {
184         sweepMode = theSweepMode;
185     }
186
187     public double getCantAngle() {
188         return cantAngle;
189     }
190
191     public void setCantAngle(double theCantAngle) {
192         cantAngle = theCantAngle;
193     }
194 }