From: kruland2607 Date: Fri, 27 Apr 2012 20:09:27 +0000 (+0000) Subject: Variety of changes to the orc file processing. Added unit annotations to all lengths... X-Git-Tag: upstream/12.09^2~311 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e3c85b33f4a043d428a88d3611aaa8a8d44562c3;p=debian%2Fopenrocket Variety of changes to the orc file processing. Added unit annotations to all lengths and masses so a vendor can hand craft a file in units other than MKS system. Fixed a bug in the nose cone where the outerdiameter and shoulder diameter were flipped. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@628 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java index b646f7f7..d107abf5 100644 --- a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java @@ -1,19 +1,21 @@ package net.sf.openrocket.preset.xml; -import net.sf.openrocket.database.Databases; -import net.sf.openrocket.material.Material; -import net.sf.openrocket.motor.Manufacturer; -import net.sf.openrocket.preset.ComponentPreset; -import net.sf.openrocket.preset.InvalidComponentPresetException; -import net.sf.openrocket.preset.TypedPropertyMap; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlValue; -import java.util.List; + +import net.sf.openrocket.database.Databases; +import net.sf.openrocket.material.Material; +import net.sf.openrocket.motor.Manufacturer; +import net.sf.openrocket.preset.ComponentPreset; +import net.sf.openrocket.preset.InvalidComponentPresetException; +import net.sf.openrocket.preset.TypedPropertyMap; +import net.sf.openrocket.unit.UnitGroup; /** * Base class for the external representation of all component presets. @@ -30,7 +32,7 @@ public abstract class BaseComponentDTO { @XmlElement(name = "Material") private AnnotatedMaterialDTO material; @XmlElement(name = "Mass") - private Double mass; + private AnnotatedMassDTO mass; @XmlElement(name="Filled") private Boolean filled; @@ -97,13 +99,17 @@ public abstract class BaseComponentDTO { } public double getMass() { - return mass; + return mass.getValue(); } - public void setMass(final double theMass) { + public void setMass(final AnnotatedMassDTO theMass) { mass = theMass; } + public void setMass(final double theMass) { + mass = new AnnotatedMassDTO(theMass); + } + public Boolean getFilled() { return filled; } @@ -125,10 +131,10 @@ public abstract class BaseComponentDTO { props.put(ComponentPreset.MATERIAL, find(materialList, material)); } if ( mass != null ) { - props.put(ComponentPreset.MASS, mass); + props.put(ComponentPreset.MASS, getMass()); } if ( filled != null ) { - props.put(ComponentPreset.FILLED, filled); + props.put(ComponentPreset.FILLED, getFilled()); } } @@ -156,4 +162,38 @@ public abstract class BaseComponentDTO { material = theMaterial.getName(); } } + + static class AnnotatedLengthDTO { + @XmlAttribute(name="Unit", required=false) + private String unitName = "m"; + @XmlValue + private double length; + + AnnotatedLengthDTO() {} + + AnnotatedLengthDTO( double length ) { + this.length = length; + } + + public double getValue() { + return UnitGroup.UNITS_LENGTH.getUnit(unitName).fromUnit(length); + } + } + + static class AnnotatedMassDTO { + @XmlAttribute(name="Unit", required=false) + private String unitName = "kg"; + @XmlValue + private double mass; + + AnnotatedMassDTO() {} + + AnnotatedMassDTO( double mass ) { + this.mass = mass; + } + + public double getValue() { + return UnitGroup.UNITS_MASS.getUnit(unitName).fromUnit(mass); + } + } } diff --git a/core/src/net/sf/openrocket/preset/xml/BodyTubeDTO.java b/core/src/net/sf/openrocket/preset/xml/BodyTubeDTO.java index c751c041..536944f2 100644 --- a/core/src/net/sf/openrocket/preset/xml/BodyTubeDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/BodyTubeDTO.java @@ -20,11 +20,11 @@ import java.util.List; public class BodyTubeDTO extends BaseComponentDTO { @XmlElement(name = "InsideDiameter") - private double insideDiameter; + private AnnotatedLengthDTO insideDiameter; @XmlElement(name = "OutsideDiameter") - private double outsideDiameter; + private AnnotatedLengthDTO outsideDiameter; @XmlElement(name = "Length") - private double length; + private AnnotatedLengthDTO length; /** * Default constructor. @@ -47,29 +47,42 @@ public class BodyTubeDTO extends BaseComponentDTO { } public double getInsideDiameter() { - return insideDiameter; + return insideDiameter.getValue(); } + public void setInsideDiameter( final AnnotatedLengthDTO theLength ) { + insideDiameter = theLength; + } + public void setInsideDiameter(final double theId) { - insideDiameter = theId; + insideDiameter = new AnnotatedLengthDTO(theId); } public double getOutsideDiameter() { - return outsideDiameter; + return outsideDiameter.getValue(); } - public void setOutsideDiameter(final double theOd) { + public void setOutsideDiameter(final AnnotatedLengthDTO theOd) { outsideDiameter = theOd; } + public void setOutsideDiameter(final double theOd) { + outsideDiameter = new AnnotatedLengthDTO(theOd); + } + public double getLength() { - return length; + return length.getValue(); } - public void setLength(final double theLength) { + public void setLength(final AnnotatedLengthDTO theLength) { length = theLength; } + public void setLength(final double theLength) { + length = new AnnotatedLengthDTO(theLength); + } + + @Override public ComponentPreset asComponentPreset(java.util.List materials) throws InvalidComponentPresetException { return asComponentPreset(ComponentPreset.Type.BODY_TUBE, materials); } diff --git a/core/src/net/sf/openrocket/preset/xml/BulkHeadDTO.java b/core/src/net/sf/openrocket/preset/xml/BulkHeadDTO.java index 57d3fc40..1db3dd7d 100644 --- a/core/src/net/sf/openrocket/preset/xml/BulkHeadDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/BulkHeadDTO.java @@ -20,9 +20,9 @@ import java.util.List; public class BulkHeadDTO extends BaseComponentDTO { @XmlElement(name = "OutsideDiameter") - private double outsideDiameter; + private AnnotatedLengthDTO outsideDiameter; @XmlElement(name = "Length") - private double length; + private AnnotatedLengthDTO length; public BulkHeadDTO() { } @@ -41,21 +41,30 @@ public class BulkHeadDTO extends BaseComponentDTO { } public double getOutsideDiameter() { - return outsideDiameter; + return outsideDiameter.getValue(); } - public void setOutsideDiameter(final double theOutsideDiameter) { + public void setOutsideDiameter(final AnnotatedLengthDTO theOutsideDiameter) { outsideDiameter = theOutsideDiameter; } + public void setOutsideDiameter(final double theOutsideDiameter) { + outsideDiameter = new AnnotatedLengthDTO(theOutsideDiameter); + } + public double getLength() { - return length; + return length.getValue(); } - public void setLength(final double theLength) { + public void setLength(final AnnotatedLengthDTO theLength) { length = theLength; } + public void setLength(final double theLength) { + length = new AnnotatedLengthDTO(theLength); + } + + @Override public ComponentPreset asComponentPreset(List materials) throws InvalidComponentPresetException { TypedPropertyMap props = new TypedPropertyMap(); addProps(props, materials); diff --git a/core/src/net/sf/openrocket/preset/xml/CenteringRingDTO.java b/core/src/net/sf/openrocket/preset/xml/CenteringRingDTO.java index 1312b196..9866a15a 100644 --- a/core/src/net/sf/openrocket/preset/xml/CenteringRingDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/CenteringRingDTO.java @@ -1,30 +1,21 @@ package net.sf.openrocket.preset.xml; -import net.sf.openrocket.preset.ComponentPreset; -import net.sf.openrocket.preset.ComponentPresetFactory; -import net.sf.openrocket.preset.InvalidComponentPresetException; -import net.sf.openrocket.preset.TypedPropertyMap; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; + +import net.sf.openrocket.preset.ComponentPreset; +import net.sf.openrocket.preset.InvalidComponentPresetException; /** - * Centering ring preset XML handler. + * Centering Ring preset XML handler. */ @XmlRootElement(name = "CenteringRing") @XmlAccessorType(XmlAccessType.FIELD) -public class CenteringRingDTO extends BaseComponentDTO { - - @XmlElement(name = "InsideDiameter") - private double insideDiameter; - @XmlElement(name = "OutsideDiameter") - private double outsideDiameter; - @XmlElement(name = "Length") - private double length; +public class CenteringRingDTO extends BodyTubeDTO { /** * Default constructor. @@ -33,55 +24,18 @@ public class CenteringRingDTO extends BaseComponentDTO { } /** - * Most-useful constructor that maps a CenteringRing preset to a CenteringRingDTO. + * Most-useful constructor that maps a TubeCoupler preset to a TubeCouplerDTO. * * @param thePreset the preset * - * @throws net.sf.openrocket.util.BugException thrown if the expected centering ring keys are not in the preset + * @throws net.sf.openrocket.util.BugException thrown if the expected tube coupler keys are not in the preset */ - public CenteringRingDTO(final ComponentPreset thePreset) { + public CenteringRingDTO(ComponentPreset thePreset) { super(thePreset); - setInsideDiameter(thePreset.get(ComponentPreset.INNER_DIAMETER)); - setOutsideDiameter(thePreset.get(ComponentPreset.OUTER_DIAMETER)); - setLength(thePreset.get(ComponentPreset.LENGTH)); - } - - public double getInsideDiameter() { - return insideDiameter; - } - - public void setInsideDiameter(final double theInsideDiameter) { - insideDiameter = theInsideDiameter; - } - - public double getOutsideDiameter() { - return outsideDiameter; - } - - public void setOutsideDiameter(final double theOutsideDiameter) { - outsideDiameter = theOutsideDiameter; - } - - public double getLength() { - return length; - } - - public void setLength(final double theLength) { - length = theLength; } + @Override public ComponentPreset asComponentPreset(List materials) throws InvalidComponentPresetException { - return asComponentPreset(ComponentPreset.Type.CENTERING_RING, materials); - } - - public ComponentPreset asComponentPreset(ComponentPreset.Type type, List materials) throws InvalidComponentPresetException { - TypedPropertyMap props = new TypedPropertyMap(); - addProps(props, materials); - props.put(ComponentPreset.INNER_DIAMETER, this.getInsideDiameter()); - props.put(ComponentPreset.OUTER_DIAMETER, this.getOutsideDiameter()); - props.put(ComponentPreset.LENGTH, this.getLength()); - props.put(ComponentPreset.TYPE, type); - - return ComponentPresetFactory.create(props); + return super.asComponentPreset(ComponentPreset.Type.CENTERING_RING, materials); } } diff --git a/core/src/net/sf/openrocket/preset/xml/EngineBlockDTO.java b/core/src/net/sf/openrocket/preset/xml/EngineBlockDTO.java index 71d0e668..6c3f61fa 100644 --- a/core/src/net/sf/openrocket/preset/xml/EngineBlockDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/EngineBlockDTO.java @@ -14,7 +14,7 @@ import java.util.List; */ @XmlRootElement(name = "EngineBlock") @XmlAccessorType(XmlAccessType.FIELD) -public class EngineBlockDTO extends CenteringRingDTO { +public class EngineBlockDTO extends BodyTubeDTO { /** * Default constructor. diff --git a/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java b/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java index 929d8495..5d38be8f 100644 --- a/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java @@ -1,15 +1,18 @@ package net.sf.openrocket.preset.xml; -import net.sf.openrocket.database.Databases; -import net.sf.openrocket.material.Material; - +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import net.sf.openrocket.database.Databases; +import net.sf.openrocket.material.Material; +import net.sf.openrocket.util.Chars; + /** * XML handler for materials. */ @@ -79,4 +82,34 @@ public class MaterialDTO { Material asMaterial() { return Databases.findMaterial(type.getORMaterialType(), name, density, false); } + + + /** + * Special directive to the JAXB system. After the object is parsed from xml, + * we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the + * opposite transformation as doen in beforeMarshal. + * @param unmarshaller + * @param parent + */ + @SuppressWarnings("unused") + private void afterUnmarshal( Unmarshaller unmarshaller, Object parent ) { + if (uom != null) { + uom = uom.replace('2', Chars.SQUARED); + uom = uom.replace('3', Chars.CUBED); + } + } + + /** + * Special directive to the JAXB system. Before the object is serialized into xml, + * we strip out the special unicode characters for cubed and squared so they appear + * as simple "3" and "2" chars. The reverse transformation is done in afterUnmarshal. + * @param marshaller + */ + @SuppressWarnings("unused") + private void beforeMarshal( Marshaller marshaller ) { + if (uom != null ) { + uom = uom.replace(Chars.SQUARED, '2'); + uom = uom.replace(Chars.CUBED, '3'); + } + } } diff --git a/core/src/net/sf/openrocket/preset/xml/NoseConeDTO.java b/core/src/net/sf/openrocket/preset/xml/NoseConeDTO.java index 41368db6..0a071d6c 100644 --- a/core/src/net/sf/openrocket/preset/xml/NoseConeDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/NoseConeDTO.java @@ -1,15 +1,16 @@ package net.sf.openrocket.preset.xml; -import net.sf.openrocket.preset.ComponentPreset; -import net.sf.openrocket.preset.ComponentPresetFactory; -import net.sf.openrocket.preset.InvalidComponentPresetException; -import net.sf.openrocket.preset.TypedPropertyMap; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; + +import net.sf.openrocket.preset.ComponentPreset; +import net.sf.openrocket.preset.ComponentPresetFactory; +import net.sf.openrocket.preset.InvalidComponentPresetException; +import net.sf.openrocket.preset.TypedPropertyMap; /** * A NoseCone preset XML handler. @@ -21,14 +22,16 @@ public class NoseConeDTO extends BaseComponentDTO { @XmlElement(name = "Shape") private ShapeDTO shape; @XmlElement(name = "OutsideDiameter") - private double outsideDiameter; + private AnnotatedLengthDTO outsideDiameter; @XmlElement(name = "ShoulderDiameter") - private double shoulderDiameter; + private AnnotatedLengthDTO shoulderDiameter; + @XmlElement(name = "ShoulderLength") + private AnnotatedLengthDTO shoulderLength; @XmlElement(name = "Length") - private double length; + private AnnotatedLengthDTO length; @XmlElement(name = "Thickness") - private Double thickness; + private AnnotatedLengthDTO thickness; /** * Default constructor. @@ -47,7 +50,12 @@ public class NoseConeDTO extends BaseComponentDTO { super(thePreset); setShape(ShapeDTO.asDTO(thePreset.get(ComponentPreset.SHAPE))); setOutsideDiameter(thePreset.get(ComponentPreset.AFT_OUTER_DIAMETER)); - setShoulderDiameter(thePreset.get(ComponentPreset.AFT_SHOULDER_DIAMETER)); + if ( thePreset.has(ComponentPreset.AFT_SHOULDER_DIAMETER)) { + setShoulderDiameter(thePreset.get(ComponentPreset.AFT_SHOULDER_DIAMETER)); + } + if ( thePreset.has(ComponentPreset.AFT_SHOULDER_LENGTH)) { + setShoulderLength(thePreset.get(ComponentPreset.AFT_SHOULDER_LENGTH)); + } setLength(thePreset.get(ComponentPreset.LENGTH)); if ( thePreset.has(ComponentPreset.THICKNESS)) { setThickness(thePreset.get(ComponentPreset.THICKNESS)); @@ -63,47 +71,81 @@ public class NoseConeDTO extends BaseComponentDTO { } public double getOutsideDiameter() { - return outsideDiameter; + return outsideDiameter.getValue(); } - public void setOutsideDiameter(final double theOutsideDiameter) { + public void setOutsideDiameter(final AnnotatedLengthDTO theOutsideDiameter) { outsideDiameter = theOutsideDiameter; } + public void setOutsideDiameter(final double theOutsideDiameter) { + outsideDiameter = new AnnotatedLengthDTO(theOutsideDiameter); + } + public double getShoulderDiameter() { - return shoulderDiameter; + return shoulderDiameter.getValue(); } - public void setShoulderDiameter(final double theShoulderDiameter) { + public void setShoulderDiameter(final AnnotatedLengthDTO theShoulderDiameter) { shoulderDiameter = theShoulderDiameter; } + public void setShoulderDiameter(final double theShoulderDiameter) { + shoulderDiameter = new AnnotatedLengthDTO(theShoulderDiameter); + } + + public double getShoulderLength() { + return shoulderLength.getValue(); + } + + public void setShoulderLength(final AnnotatedLengthDTO theShoulderLength) { + shoulderLength = theShoulderLength; + } + + public void setShoulderLength(final double theShoulderLength) { + shoulderLength = new AnnotatedLengthDTO(theShoulderLength); + } + public double getLength() { - return length; + return length.getValue(); } - public void setLength(final double theLength) { + public void setLength(final AnnotatedLengthDTO theLength) { length = theLength; } - public Double getThickness() { - return thickness; + public void setLength(final double theLength) { + length = new AnnotatedLengthDTO(theLength); + } + + public double getThickness() { + return thickness.getValue(); } - public void setThickness(Double thickness) { + public void setThickness(AnnotatedLengthDTO thickness) { this.thickness = thickness; } + public void setThickness(double thickness) { + this.thickness = new AnnotatedLengthDTO(thickness); + } + + @Override public ComponentPreset asComponentPreset(List materials) throws InvalidComponentPresetException { TypedPropertyMap props = new TypedPropertyMap(); addProps(props, materials); props.put(ComponentPreset.SHAPE, shape.getORShape()); - props.put(ComponentPreset.AFT_OUTER_DIAMETER, this.getShoulderDiameter()); - props.put(ComponentPreset.AFT_SHOULDER_DIAMETER, this.getOutsideDiameter()); + props.put(ComponentPreset.AFT_OUTER_DIAMETER, this.getOutsideDiameter()); + if ( shoulderLength != null ) { + props.put(ComponentPreset.AFT_SHOULDER_LENGTH, this.getShoulderLength()); + } + if ( shoulderDiameter != null ) { + props.put(ComponentPreset.AFT_SHOULDER_DIAMETER, this.getShoulderDiameter()); + } props.put(ComponentPreset.LENGTH, this.getLength()); props.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE); if ( thickness != null ) { - props.put(ComponentPreset.THICKNESS, thickness); + props.put(ComponentPreset.THICKNESS, this.getThickness()); } return ComponentPresetFactory.create(props); diff --git a/core/src/net/sf/openrocket/preset/xml/TransitionDTO.java b/core/src/net/sf/openrocket/preset/xml/TransitionDTO.java index c978b846..1aaaac65 100644 --- a/core/src/net/sf/openrocket/preset/xml/TransitionDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/TransitionDTO.java @@ -23,24 +23,24 @@ public class TransitionDTO extends BaseComponentDTO { private ShapeDTO shape; @XmlElement(name = "ForeOutsideDiameter") - private double foreOutsideDiameter; + private AnnotatedLengthDTO foreOutsideDiameter; @XmlElement(name = "ForeShoulderDiameter") - private double foreShoulderDiameter; + private AnnotatedLengthDTO foreShoulderDiameter; @XmlElement(name = "ForeShoulderLength") - private double foreShoulderLength; + private AnnotatedLengthDTO foreShoulderLength; @XmlElement(name = "AftOutsideDiameter") - private double aftOutsideDiameter; + private AnnotatedLengthDTO aftOutsideDiameter; @XmlElement(name = "AftShoulderDiameter") - private double aftShoulderDiameter; + private AnnotatedLengthDTO aftShoulderDiameter; @XmlElement(name = "AftShoulderLength") - private double aftShoulderLength; + private AnnotatedLengthDTO aftShoulderLength; @XmlElement(name = "Length") - private double length; + private AnnotatedLengthDTO length; @XmlElement(name = "Thickness") - private Double thickness; + private AnnotatedLengthDTO thickness; /** @@ -80,69 +80,102 @@ public class TransitionDTO extends BaseComponentDTO { } public double getForeOutsideDiameter() { - return foreOutsideDiameter; + return foreOutsideDiameter.getValue(); } - public void setForeOutsideDiameter(final double theForeOutsideDiameter) { + public void setForeOutsideDiameter(final AnnotatedLengthDTO theForeOutsideDiameter) { foreOutsideDiameter = theForeOutsideDiameter; } + public void setForeOutsideDiameter(final double theForeOutsideDiameter) { + foreOutsideDiameter = new AnnotatedLengthDTO(theForeOutsideDiameter); + } + public double getForeShoulderDiameter() { - return foreShoulderDiameter; + return foreShoulderDiameter.getValue(); } - public void setForeShoulderDiameter(final double theForeShoulderDiameter) { + public void setForeShoulderDiameter(final AnnotatedLengthDTO theForeShoulderDiameter) { foreShoulderDiameter = theForeShoulderDiameter; } + public void setForeShoulderDiameter(final double theForeShoulderDiameter) { + foreShoulderDiameter = new AnnotatedLengthDTO(theForeShoulderDiameter); + } + public double getForeShoulderLength() { - return foreShoulderLength; + return foreShoulderLength.getValue(); } - public void setForeShoulderLength(final double theForeShoulderLength) { + public void setForeShoulderLength(final AnnotatedLengthDTO theForeShoulderLength) { foreShoulderLength = theForeShoulderLength; } + public void setForeShoulderLength(final double theForeShoulderLength) { + foreShoulderLength = new AnnotatedLengthDTO(theForeShoulderLength); + } + public double getAftOutsideDiameter() { - return aftOutsideDiameter; + return aftOutsideDiameter.getValue(); } - public void setAftOutsideDiameter(final double theAftOutsideDiameter) { + public void setAftOutsideDiameter(final AnnotatedLengthDTO theAftOutsideDiameter) { aftOutsideDiameter = theAftOutsideDiameter; } + public void setAftOutsideDiameter(final double theAftOutsideDiameter) { + aftOutsideDiameter = new AnnotatedLengthDTO(theAftOutsideDiameter); + } + public double getAftShoulderDiameter() { - return aftShoulderDiameter; + return aftShoulderDiameter.getValue(); } - public void setAftShoulderDiameter(final double theAftShoulderDiameter) { + public void setAftShoulderDiameter(final AnnotatedLengthDTO theAftShoulderDiameter) { aftShoulderDiameter = theAftShoulderDiameter; } + public void setAftShoulderDiameter(final double theAftShoulderDiameter) { + aftShoulderDiameter = new AnnotatedLengthDTO(theAftShoulderDiameter); + } + public double getAftShoulderLength() { - return aftShoulderLength; + return aftShoulderLength.getValue(); } - public void setAftShoulderLength(final double theAftShoulderLength) { + public void setAftShoulderLength(final AnnotatedLengthDTO theAftShoulderLength) { aftShoulderLength = theAftShoulderLength; } + public void setAftShoulderLength(final double theAftShoulderLength) { + aftShoulderLength = new AnnotatedLengthDTO(theAftShoulderLength); + } + public double getLength() { - return length; + return length.getValue(); } - public void setLength(final double theLength) { + public void setLength(final AnnotatedLengthDTO theLength) { length = theLength; } - public Double getThickness() { - return thickness; + public void setLength(final double theLength) { + length = new AnnotatedLengthDTO(theLength); + } + + public double getThickness() { + return thickness.getValue(); } - public void setThickness(Double thickness) { + public void setThickness(AnnotatedLengthDTO thickness) { this.thickness = thickness; } + public void setThickness(double thickness) { + this.thickness = new AnnotatedLengthDTO(thickness); + } + + @Override public ComponentPreset asComponentPreset(List materials) throws InvalidComponentPresetException { TypedPropertyMap props = new TypedPropertyMap(); addProps(props, materials); @@ -156,7 +189,7 @@ public class TransitionDTO extends BaseComponentDTO { props.put(ComponentPreset.LENGTH, this.getLength()); props.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION); if ( thickness != null ) { - props.put(ComponentPreset.THICKNESS, thickness); + props.put(ComponentPreset.THICKNESS, this.getThickness()); } return ComponentPresetFactory.create(props);