DGP - changes to relative position; custom fin set points
[debian/openrocket] / core / src / net / sf / openrocket / file / rocksim / export / CustomFinSetDTO.java
1 package net.sf.openrocket.file.rocksim.export;
2
3 import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
4 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
5 import net.sf.openrocket.util.Coordinate;
6
7 import javax.xml.bind.annotation.XmlAccessType;
8 import javax.xml.bind.annotation.XmlAccessorType;
9 import javax.xml.bind.annotation.XmlElement;
10 import javax.xml.bind.annotation.XmlRootElement;
11
12 /**
13  */
14 @XmlRootElement(name = "CustomFinSet")
15 @XmlAccessorType(XmlAccessType.FIELD)
16 public class CustomFinSetDTO extends FinSetDTO {
17
18     @XmlElement(name = "PointList")
19     private String pointList = "";
20
21     public CustomFinSetDTO() {
22     }
23
24     public CustomFinSetDTO(FreeformFinSet ec) {
25         super(ec);
26         setPointList(convertFreeFormPoints(ec.getFinPoints()));
27     }
28
29
30     private String convertFreeFormPoints(Coordinate[] points) {
31         StringBuilder sb = new StringBuilder();
32
33         //Reverse the order for Rocksim
34         for (int i = points.length - 1; i >= 0; i--) {
35             Coordinate point = points[i];
36             sb.append(point.x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append(",")
37                     .append(point.y * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append("|");
38         }
39         return sb.toString();
40     }
41
42     public String getPointList() {
43         return pointList;
44     }
45
46     public void setPointList(String thePointList) {
47         pointList = thePointList;
48     }
49 }
50