2 package net.sf.openrocket.preset.xml;
4 import net.sf.openrocket.preset.ComponentPreset;
5 import net.sf.openrocket.preset.ComponentPresetFactory;
6 import net.sf.openrocket.preset.InvalidComponentPresetException;
7 import net.sf.openrocket.preset.TypedPropertyMap;
9 import javax.xml.bind.annotation.XmlAccessType;
10 import javax.xml.bind.annotation.XmlAccessorType;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13 import java.util.List;
16 * Streamer preset XML handler.
18 @XmlRootElement(name = "Streamer")
19 @XmlAccessorType(XmlAccessType.FIELD)
20 public class StreamerDTO extends BaseComponentDTO {
22 @XmlElement(name = "Length")
23 private AnnotatedLengthDTO length;
24 @XmlElement(name = "Width")
25 private AnnotatedLengthDTO width;
26 @XmlElement(name = "Thickness")
27 private AnnotatedLengthDTO thickness;
30 * Default constructor.
32 public StreamerDTO() {
36 * Most-useful constructor that maps a BodyTube preset to a BodyTubeDTO.
38 * @param preset the preset
40 * @throws net.sf.openrocket.util.BugException thrown if the expected body tube keys are not in the preset
42 public StreamerDTO(final ComponentPreset preset) {
44 setWidth(preset.get(ComponentPreset.WIDTH));
45 setThickness(preset.get(ComponentPreset.THICKNESS));
46 setLength(preset.get(ComponentPreset.LENGTH));
49 public double getWidth() {
50 return width.getValue();
53 public void setWidth( final AnnotatedLengthDTO theWidth ) {
57 public void setWidth(final double theId) {
58 width = new AnnotatedLengthDTO(theId);
61 public double getThickness() {
62 return thickness.getValue();
65 public void setThickness(final AnnotatedLengthDTO theThickness) {
66 thickness = theThickness;
69 public void setThickness(final double theThickness) {
70 thickness = new AnnotatedLengthDTO(theThickness);
73 public double getLength() {
74 return length.getValue();
77 public void setLength(final AnnotatedLengthDTO theLength) {
81 public void setLength(final double theLength) {
82 length = new AnnotatedLengthDTO(theLength);
86 public ComponentPreset asComponentPreset(java.util.List<MaterialDTO> materials) throws InvalidComponentPresetException {
87 return asComponentPreset(ComponentPreset.Type.STREAMER, materials);
90 public ComponentPreset asComponentPreset(ComponentPreset.Type type, List<MaterialDTO> materials) throws InvalidComponentPresetException {
91 TypedPropertyMap props = new TypedPropertyMap();
92 addProps(props, materials);
93 // TODO - seems some vendors use a bulk material for the sheet along with a Thickness.
94 // need to fix the MATERIAL packed into the componentpreset.
95 props.put(ComponentPreset.WIDTH, this.getWidth());
96 props.put(ComponentPreset.THICKNESS, this.getThickness());
97 props.put(ComponentPreset.LENGTH, this.getLength());
98 props.put(ComponentPreset.TYPE, type);
100 return ComponentPresetFactory.create(props);