diff --git a/core/resources/datafiles/presets/bms.orc b/core/resources/datafiles/presets/bms.orc
index e0a1b48d5..bcaaf18ba 100644
--- a/core/resources/datafiles/presets/bms.orc
+++ b/core/resources/datafiles/presets/bms.orc
@@ -1672,5 +1672,50 @@
0.035559999999999994
0.0508
+
+ BalsaMachining.com
+ LL18-125
+ 1/8 x 1.25 inch LL
+ Paper
+ 0.004064
+ 0.0042926
+ 0.03175
+
+
+ BalsaMachining.com
+ LL316-200
+ 3/16 x 2 inch LL
+ Paper
+ 0.0055626
+ 0.006096
+ 0.0508
+
+
+ BalsaMachining.com
+ LL316-1200
+ 3/16 x 12 inch LL
+ Paper
+ 0.0054356
+ 0.006096
+ 0.0508
+
+
+ BalsaMachining.com
+ LL14-300
+ 0.316x0.280x.018x34 1/4 inch Launch lug
+ Paper
+ 0.007112
+ 0.0080264
+ 0.07619999999999999
+
+
+ BalsaMachining.com
+ LL14-3400
+ 0.316x0.280x.018x34 1/4 inch Launch lug
+ Paper
+ 0.007112
+ 0.0080264
+ 0.8635999999999999
+
diff --git a/core/resources/datafiles/presets/giantleaprocketry.orc b/core/resources/datafiles/presets/giantleaprocketry.orc
index 6299fa691..91e598637 100644
--- a/core/resources/datafiles/presets/giantleaprocketry.orc
+++ b/core/resources/datafiles/presets/giantleaprocketry.orc
@@ -642,5 +642,76 @@
0.41910000000000003
0.002032
+
+ Giant Leap
+ LL
+ ACME Launch Lug
+ 0.01016
+ 0.012700000000000001
+ 0.025400000000000002
+
+
+ Giant Leap
+ RG
+ ACME Rail Guide
+ 0.01016
+ 0.012700000000000001
+ 0.025400000000000002
+
+
+ Giant Leap
+ TAC-24
+ TAC-1 24 in. Parachute
+ Rip stop nylon
+ 0.153087
+ 0.6096
+ 6
+ 6
+ 0.0
+
+
+ Giant Leap
+ TAC-36
+ TAC-1 36 in. Parachute
+ Rip stop nylon
+ 0.229631
+ 0.9144
+ 6
+ 6
+ 0.0
+
+
+ Giant Leap
+ TAC-48
+ TAC-1 48 in. Parachute
+ Rip stop nylon
+ 0.30617500000000003
+ 1.2192
+ 6
+ 6
+ 0.0
+
+
+ Giant Leap
+ TAC-60
+ TAC-1 60 in. Parachute
+ Rip stop nylon
+ 0.40539800000000004
+ 1.524
+ 6
+ 6
+ 0.0
+
+
+ Giant Leap
+ TAC-72
+ TAC-1 72 in. Parachute
+ Rip stop nylon
+ 0.510291
+ 1.8288
+ 6
+ 6
+ 0.0
+
diff --git a/core/resources/datafiles/presets/publicmissiles.orc b/core/resources/datafiles/presets/publicmissiles.orc
index 855b6977a..d09b3b757 100644
--- a/core/resources/datafiles/presets/publicmissiles.orc
+++ b/core/resources/datafiles/presets/publicmissiles.orc
@@ -1283,5 +1283,239 @@
0.30479999999999996
0.0016002
+
+ Public Missiles
+ PML LL-25
+ 1/4 brass launch lug
+ Brass
+ 0.005715
+ 0.00635
+ 0.30479999999999996
+
+
+ Public Missiles
+ PML LL-38
+ 3/8 brass launch lug
+ Brass
+ 0.0085725
+ 0.009524999999999999
+ 0.30479999999999996
+
+
+ Public Missiles
+ PML LL-50
+ 1/2 brass launch lug
+ Brass
+ 0.01143
+ 0.0127
+ 0.30479999999999996
+
+
+ Public Missiles
+ PML LL-75
+ 3/4 copper launch lug
+ Copper (rolled)
+ 0.017145
+ 0.019049999999999997
+ 0.30479999999999996
+
+
+ Public Missiles
+ PML TBD123
+ Streamer
+ Polyethylene LDPE
+ 3.048
+ 0.07619999999999999
+ 5.08E-5
+
+
+ Public Missiles
+ STREAMER
+ F111 streamer
+ Rip stop nylon
+ 3.6576
+ 0.1016
+ 1.27E-5
+
+
+ Public Missiles
+ PML Xform
+ 12 in. nylon
+ Rip stop nylon
+ 0.008504856929999999
+ 0.30479999999999996
+ 4
+ 4
+ 0.30479999999999996
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-18-F111
+ 18 in. nylon
+ Rip stop nylon
+ 0.017009713859999998
+ 0.4572
+ 8
+ 8
+ 0.3302
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-24R
+ 24 in. nylon
+ Rip stop nylon
+ 0.04535923696
+ 0.6095999999999999
+ 8
+ 8
+ 0.508
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-30R
+ 30 in. nylon
+ Rip stop nylon
+ 0.06803885543999999
+ 0.762
+ 8
+ 8
+ 0.6095999999999999
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-34R
+ 34 in. nylon
+ Rip stop nylon
+ 0.08221361699
+ 0.8635999999999999
+ 8
+ 8
+ 0.635
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-36R
+ 36 in. nylon
+ Rip stop nylon
+ 0.08788352161
+ 0.9144
+ 8
+ 8
+ 0.6858
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-44R
+ 44 in. nylon
+ Rip stop nylon
+ 0.11623304470999998
+ 1.1176
+ 8
+ 8
+ 0.8128
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-48R
+ 48 in. nylon
+ Rip stop nylon
+ 0.12473790164000001
+ 1.2191999999999998
+ 8
+ 8
+ 0.9144
+ Thin poly
+
+
+ Public Missiles
+ PML PAR-54R
+ 54 in. nylon
+ Rip stop nylon
+ 0.13607771087999998
+ 1.3716
+ 8
+ 8
+ 1.0413999999999999
+ Medium poly
+
+
+ Public Missiles
+ PML PAR-60R
+ 60 in. nylon
+ Rip stop nylon
+ 0.22396123249
+ 1.524
+ 8
+ 10
+ 1.0668
+ Heavy poly
+
+
+ Public Missiles
+ PML PAR-62R
+ 62 in. nylon
+ Rip stop nylon
+ 0.23530104173000002
+ 1.5748
+ 8
+ 10
+ 1.1176
+ Heavy poly
+
+
+ Public Missiles
+ PML PAR-72R
+ 72 in. nylon
+ Rip stop nylon
+ 0.2551457079
+ 1.8288
+ 8
+ 10
+ 1.143
+ Heavy poly
+
+
+ Public Missiles
+ PML PAR-74R
+ 74 in. nylon
+ Rip stop nylon
+ 0.26932046945
+ 1.8796
+ 8
+ 10
+ 1.1938
+ Heavy poly
+
+
+ Public Missiles
+ PML PAR-84R
+ 84 in. nylon
+ Rip stop nylon
+ 0.33735932489
+ 2.1336
+ 8
+ 10
+ 1.524
+ Heavy poly
+
+
+ Public Missiles
+ PML PAR-96R
+ 96 in. nylon
+ Rip stop nylon
+ 0.72291283905
+ 2.4383999999999997
+ 8
+ 10
+ 1.8288
+ Heavy poly
+
diff --git a/core/resources/datafiles/presets/semroc.orc b/core/resources/datafiles/presets/semroc.orc
index 94ab97b5b..7105504c8 100644
--- a/core/resources/datafiles/presets/semroc.orc
+++ b/core/resources/datafiles/presets/semroc.orc
@@ -10219,5 +10219,349 @@
0.0
0.13208
+
+ SEMROC Astronautics
+ LL-2A
+ Launch Lug 1/8 x 1.25
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.03175
+
+
+ SEMROC Astronautics
+ LL-2AM
+ Launch Lug 1/8 x .375
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.009524999999999999
+
+
+ SEMROC Astronautics
+ LL-2B
+ Launch Lug 1/8 x 2.375
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.060325
+
+
+ SEMROC Astronautics
+ LL-2C
+ Launch Lug 1/8 x 5
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.127
+
+
+ SEMROC Astronautics
+ LL-2D
+ Launch Lug 1/8 x 8
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.2032
+
+
+ SEMROC Astronautics
+ LL-2E
+ Launch Lug 1/8 x 9.5
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.2413
+
+
+ SEMROC Astronautics
+ LL-3B
+ Launch Lug 3/16 x 2
+ Paper
+ 0.0054356
+ 0.006096
+ 0.0508
+
+
+ SEMROC Astronautics
+ LL-103
+ Launch Lug 1/8 x .375
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.009524999999999999
+
+
+ SEMROC Astronautics
+ LL-110
+ Launch Lug 1/8 x 1
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.0254
+
+
+ SEMROC Astronautics
+ LL-115
+ Launch Lug 1/8 x 1.5
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.038099999999999995
+
+
+ SEMROC Astronautics
+ LL-117
+ Launch Lug 1/8 x 1.75
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.044449999999999996
+
+
+ SEMROC Astronautics
+ LL-122
+ Launch Lug 1/8 x 2.25
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.05715
+
+
+ SEMROC Astronautics
+ LL-130
+ Launch Lug 1/8 x 3
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.07619999999999999
+
+
+ SEMROC Astronautics
+ LL-180
+ Launch Lug 1/8 x 8
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.2032
+
+
+ SEMROC Astronautics
+ LL-195
+ Launch Lug 1/8 x 9.5
+ Paper
+ 0.0038099999999999996
+ 0.004470399999999999
+ 0.2413
+
+
+ SEMROC Astronautics
+ LL-310
+ Launch Lug 3/16 x 1
+ Paper
+ 0.0054356
+ 0.006096
+ 0.0254
+
+
+ SEMROC Astronautics
+ LL-320
+ Launch Lug 3/16 x 2
+ Paper
+ 0.0054356
+ 0.006096
+ 0.0508
+
+
+ SEMROC Astronautics
+ LL-330
+ Launch Lug 3/16 x 3
+ Paper
+ 0.0054356
+ 0.006096
+ 0.07619999999999999
+
+
+ SEMROC Astronautics
+ LL-423
+ Launch Lug 1/4 x 2.25
+ Paper
+ 0.0070104
+ 0.007670799999999999
+ 0.05715
+
+
+ SEMROC Astronautics
+ SM-1A
+ Streamer 1 x 8
+ Paper
+ 0.2032
+ 0.0254
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RS-118
+ Streamer 1 x 18
+ Paper
+ 0.4572
+ 0.0254
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RS-124
+ Streamer 1 x 24
+ Paper
+ 0.6095999999999999
+ 0.0254
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RS-136
+ Streamer 1 x 36
+ Paper
+ 0.9144
+ 0.0254
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RS-224
+ Streamer 1.75 x 24
+ Paper
+ 0.6095999999999999
+ 0.044449999999999996
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RS-236
+ Streamer 1.75 x 36
+ Paper
+ 0.9144
+ 0.044449999999999996
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ RSW-36
+ Streamer 3 x 36
+ Paper
+ 0.9144
+ 0.07619999999999999
+ 5.08E-5
+
+
+ SEMROC Astronautics
+ CP-12
+ 12 in. Plastic Chute
+ Polyethylene LDPE
+ 0.30479999999999996
+ 6
+ 6
+ 0.30479999999999996
+ 30 Lb. kevlar
+
+
+ SEMROC Astronautics
+ CP-16
+ 16 in. Plastic Chute
+ Polyethylene LDPE
+ 0.4064
+ 8
+ 8
+ 0.4064
+ 30 Lb. kevlar
+
+
+ SEMROC Astronautics
+ CP-20
+ 20 in. Plastic Chute
+ Polyethylene LDPE
+ 0.508
+ 8
+ 8
+ 0.508
+ 30 Lb. kevlar
+
+
+ SEMROC Astronautics
+ CP-24
+ 24 in. Plastic Chute
+ Polyethylene LDPE
+ 0.6095999999999999
+ 8
+ 8
+ 0.6095999999999999
+ 30 Lb. kevlar
+
+
+ SEMROC Astronautics
+ CP-32
+ 32 in. Plastic Chute
+ Polyethylene LDPE
+ 0.8128
+ 8
+ 8
+ 0.8128
+ 30 Lb. kevlar
+
+
+ SEMROC Astronautics
+ PN-14
+ 14 in. Nylon Chute
+ Rip Stop Nylon
+ 0.35559999999999997
+ 6
+ 6
+ 0.4064
+ 1/16 In. braided nylon
+
+
+ SEMROC Astronautics
+ PN-18
+ 18 In. Nylon Chute
+ Rip Stop Nylon
+ 0.4572
+ 8
+ 8
+ 0.508
+ 1/16 In. braided nylon
+
+
+ SEMROC Astronautics
+ PN-24
+ 24 In. Nylon Chute
+ Rip Stop Nylon
+ 0.6095999999999999
+ 0
+ 10
+ 0.6095999999999999
+ 1/16 In. braided nylon
+
+
+ SEMROC Astronautics
+ PN-30
+ 30 In. Nylon Chute
+ Rip Stop Nylon
+ 0.762
+ 0
+ 10
+ 0.762
+ 1/16 In. braided nylon
+
+
+ SEMROC Astronautics
+ PN-36
+ 36 In. Nylon Chute
+ Rip Stop Nylon
+ 0.9144
+ 0
+ 10
+ 0.9144
+ 1/16 In. braided nylon
+
diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties
index 02977c5bd..4978126cb 100644
--- a/core/resources/l10n/messages.properties
+++ b/core/resources/l10n/messages.properties
@@ -1,4 +1,3 @@
-
#
# English base translation file
#
@@ -1605,6 +1604,7 @@ table.column.PartNo = Part Number
table.column.Description = Description
table.column.Type = Type
table.column.Length = Length
+table.column.Width = Width
table.column.InnerDiameter = Inner Diameter
table.column.OuterDiameter = Outer Diameter
table.column.AftOuterDiameter = Aft Outer Diameter
@@ -1619,5 +1619,10 @@ table.column.Finish = Finish
table.column.Thickness = Thickness
table.column.Filled = Filled
table.column.Mass = Mass
+table.column.Diameter = Diameter
+table.column.Sides = Sides
+table.column.LineCount = Line Count
+table.column.LineLength = Line Length
+table.column.LineMaterial = Line Material
diff --git a/core/src/net/sf/openrocket/preset/ComponentPreset.java b/core/src/net/sf/openrocket/preset/ComponentPreset.java
index 4af709c78..ca33af84a 100644
--- a/core/src/net/sf/openrocket/preset/ComponentPreset.java
+++ b/core/src/net/sf/openrocket/preset/ComponentPreset.java
@@ -96,7 +96,35 @@ public class ComponentPreset implements Comparable {
ComponentPreset.DESCRIPTION,
ComponentPreset.INNER_DIAMETER,
ComponentPreset.OUTER_DIAMETER,
- ComponentPreset.LENGTH} );
+ ComponentPreset.LENGTH} ),
+
+ LAUNCH_LUG( new TypedKey>[] {
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.DESCRIPTION,
+ ComponentPreset.INNER_DIAMETER,
+ ComponentPreset.OUTER_DIAMETER,
+ ComponentPreset.LENGTH} ),
+
+ STREAMER( new TypedKey>[] {
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.DESCRIPTION,
+ ComponentPreset.LENGTH,
+ ComponentPreset.WIDTH,
+ ComponentPreset.THICKNESS,
+ ComponentPreset.MATERIAL} ),
+
+ PARACHUTE( new TypedKey>[] {
+ ComponentPreset.MANUFACTURER,
+ ComponentPreset.PARTNO,
+ ComponentPreset.DESCRIPTION,
+ ComponentPreset.DIAMETER,
+ ComponentPreset.SIDES,
+ ComponentPreset.LINE_COUNT,
+ ComponentPreset.LINE_LENGTH,
+ ComponentPreset.LINE_MATERIAL,
+ ComponentPreset.MATERIAL} );
TypedKey>[] displayedColumns;
@@ -115,8 +143,9 @@ public class ComponentPreset implements Comparable {
private static Map> compatibleTypeMap = new HashMap>();
static {
- compatibleTypeMap.put( BODY_TUBE, Arrays.asList( BODY_TUBE, TUBE_COUPLER) );
- compatibleTypeMap.put( TUBE_COUPLER, Arrays.asList( BODY_TUBE,TUBE_COUPLER) );
+ compatibleTypeMap.put( BODY_TUBE, Arrays.asList( BODY_TUBE, TUBE_COUPLER, LAUNCH_LUG ) );
+ compatibleTypeMap.put( TUBE_COUPLER, Arrays.asList( BODY_TUBE,TUBE_COUPLER, LAUNCH_LUG ) );
+ compatibleTypeMap.put( LAUNCH_LUG, Arrays.asList( BODY_TUBE,TUBE_COUPLER, LAUNCH_LUG ) );
compatibleTypeMap.put( CENTERING_RING, Arrays.asList( CENTERING_RING, ENGINE_BLOCK ) );
compatibleTypeMap.put( NOSE_CONE, Arrays.asList( NOSE_CONE, TRANSITION));
}
@@ -128,6 +157,7 @@ public class ComponentPreset implements Comparable {
public final static TypedKey DESCRIPTION = new TypedKey("Description", String.class);
public final static TypedKey TYPE = new TypedKey("Type",Type.class);
public final static TypedKey LENGTH = new TypedKey("Length", Double.class, UnitGroup.UNITS_LENGTH);
+ public final static TypedKey WIDTH = new TypedKey("Width", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey INNER_DIAMETER = new TypedKey("InnerDiameter", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey OUTER_DIAMETER = new TypedKey("OuterDiameter", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey FORE_SHOULDER_LENGTH = new TypedKey("ForeShoulderLength",Double.class, UnitGroup.UNITS_LENGTH);
@@ -142,29 +172,12 @@ public class ComponentPreset implements Comparable {
public final static TypedKey THICKNESS = new TypedKey("Thickness", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey FILLED = new TypedKey("Filled", Boolean.class);
public final static TypedKey MASS = new TypedKey("Mass", Double.class, UnitGroup.UNITS_MASS);
+ public final static TypedKey DIAMETER = new TypedKey("Diameter", Double.class, UnitGroup.UNITS_LENGTH);
+ public final static TypedKey SIDES = new TypedKey("Sides", Integer.class);
+ public final static TypedKey LINE_COUNT = new TypedKey("LineCount", Integer.class);
+ public final static TypedKey LINE_LENGTH = new TypedKey("LineLength", Double.class, UnitGroup.UNITS_LENGTH);
+ public final static TypedKey LINE_MATERIAL = new TypedKey("LineMaterial", Material.class);
- public final static Map> keyMap = new HashMap>();
- static {
- keyMap.put(MANUFACTURER.getName(), MANUFACTURER);
- keyMap.put(PARTNO.getName(), PARTNO);
- keyMap.put(TYPE.getName(), TYPE);
- keyMap.put(DESCRIPTION.getName(), DESCRIPTION);
- keyMap.put(LENGTH.getName(), LENGTH);
- keyMap.put(INNER_DIAMETER.getName(), INNER_DIAMETER);
- keyMap.put(OUTER_DIAMETER.getName(), OUTER_DIAMETER);
- keyMap.put(FORE_SHOULDER_LENGTH.getName(), FORE_SHOULDER_LENGTH);
- keyMap.put(FORE_SHOULDER_DIAMETER.getName(), FORE_SHOULDER_DIAMETER);
- keyMap.put(FORE_OUTER_DIAMETER.getName(), FORE_OUTER_DIAMETER);
- keyMap.put(AFT_SHOULDER_LENGTH.getName(), AFT_SHOULDER_LENGTH);
- keyMap.put(AFT_SHOULDER_DIAMETER.getName(), AFT_SHOULDER_DIAMETER);
- keyMap.put(AFT_OUTER_DIAMETER.getName(), AFT_OUTER_DIAMETER);
- keyMap.put(SHAPE.getName(), SHAPE);
- keyMap.put(MATERIAL.getName(), MATERIAL);
- keyMap.put(FINISH.getName(), FINISH);
- keyMap.put(THICKNESS.getName(), THICKNESS);
- keyMap.put(FILLED.getName(), FILLED);
- keyMap.put(MASS.getName(), MASS);
- }
public final static List> orderedKeyList = Arrays.>asList(
MANUFACTURER,
@@ -175,6 +188,7 @@ public class ComponentPreset implements Comparable {
AFT_OUTER_DIAMETER,
INNER_DIAMETER,
LENGTH,
+ WIDTH,
AFT_SHOULDER_DIAMETER,
AFT_SHOULDER_LENGTH,
FORE_SHOULDER_DIAMETER,
@@ -182,6 +196,11 @@ public class ComponentPreset implements Comparable {
SHAPE,
THICKNESS,
FILLED,
+ DIAMETER,
+ SIDES,
+ LINE_COUNT,
+ LINE_LENGTH,
+ LINE_MATERIAL,
MASS,
FINISH,
MATERIAL
diff --git a/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java b/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java
index 62273704c..0315974a8 100644
--- a/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java
+++ b/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java
@@ -58,6 +58,19 @@ public abstract class ComponentPresetFactory {
makeEngineBlock(preset);
break;
}
+ case LAUNCH_LUG: {
+ // Same processing as BODY_TUBE
+ makeBodyTube(preset);
+ break;
+ }
+ case STREAMER: {
+ makeStreamer(preset);
+ break;
+ }
+ case PARACHUTE: {
+ makeParachute(preset);
+ break;
+ }
}
preset.computeDigest();
@@ -192,6 +205,15 @@ public abstract class ComponentPresetFactory {
}
+ private static void makeStreamer( ComponentPreset preset ) throws InvalidComponentPresetException {
+ checkRequiredFields( preset, LENGTH, WIDTH );
+ }
+
+ private static void makeParachute( ComponentPreset preset ) throws InvalidComponentPresetException {
+ checkRequiredFields( preset, DIAMETER, LINE_COUNT, LINE_LENGTH );
+ }
+
+
private static void checkRequiredFields( ComponentPreset preset, TypedKey> ... keys ) throws InvalidComponentPresetException {
for( TypedKey> key: keys ) {
if (! preset.has(key) ) {
diff --git a/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java b/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java
new file mode 100644
index 000000000..d871be1ce
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java
@@ -0,0 +1,21 @@
+package net.sf.openrocket.preset.loader;
+
+import net.sf.openrocket.preset.TypedKey;
+import net.sf.openrocket.preset.TypedPropertyMap;
+
+public class IntegerColumnParser extends BaseColumnParser {
+
+ private TypedKey propKey;
+
+ public IntegerColumnParser(String columnHeader, TypedKey propKey) {
+ super(columnHeader);
+ this.propKey = propKey;
+ }
+
+ @Override
+ protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
+ int value = Integer.valueOf(columnData);
+ props.put(propKey, value);
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/loader/LaunchLugLoader.java b/core/src/net/sf/openrocket/preset/loader/LaunchLugLoader.java
new file mode 100644
index 000000000..e0a295845
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/LaunchLugLoader.java
@@ -0,0 +1,31 @@
+package net.sf.openrocket.preset.loader;
+
+import java.util.Map;
+
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
+
+public class LaunchLugLoader extends BaseComponentLoader {
+
+ public LaunchLugLoader(Map materials) {
+ super(materials);
+ fileColumns.add(new DoubleUnitColumnParser("ID","Units",ComponentPreset.INNER_DIAMETER));
+ fileColumns.add(new DoubleUnitColumnParser("OD","Units",ComponentPreset.OUTER_DIAMETER));
+ fileColumns.add(new DoubleUnitColumnParser("Length","Units",ComponentPreset.LENGTH));
+
+ }
+
+
+ @Override
+ protected Type getComponentPresetType() {
+ return ComponentPreset.Type.LAUNCH_LUG;
+ }
+
+
+ @Override
+ protected RocksimComponentFileType getFileType() {
+ return RocksimComponentFileType.LAUNCH_LUG;
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/loader/LineMaterialColumnParser.java b/core/src/net/sf/openrocket/preset/loader/LineMaterialColumnParser.java
new file mode 100644
index 000000000..c888845e0
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/LineMaterialColumnParser.java
@@ -0,0 +1,44 @@
+package net.sf.openrocket.preset.loader;
+
+import java.util.Collections;
+import java.util.Map;
+
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.TypedKey;
+import net.sf.openrocket.preset.TypedPropertyMap;
+
+public class LineMaterialColumnParser extends BaseColumnParser {
+
+ private Map materialMap = Collections.emptyMap();
+
+ private final TypedKey param;
+
+ public LineMaterialColumnParser(Map materialMap, String columnName, TypedKey param) {
+ super(columnName);
+ this.param = param;
+ this.materialMap = materialMap;
+ }
+
+
+ @Override
+ protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
+
+ if ( columnData == null || "".equals(columnData.trim())) {
+ return;
+ }
+
+ Material.Line myMaterial;
+
+ Material m = materialMap.get(columnData);
+
+ if ( m == null || m.getType() != Material.Type.LINE ) {
+ myMaterial = new Material.Line(columnData, 0.0, true);
+ } else {
+ myMaterial =(Material.Line) m;
+ }
+
+ props.put(param, myMaterial);
+
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/loader/MaterialColumnParser.java b/core/src/net/sf/openrocket/preset/loader/MaterialColumnParser.java
index c6ef8c5fa..41f1ab209 100644
--- a/core/src/net/sf/openrocket/preset/loader/MaterialColumnParser.java
+++ b/core/src/net/sf/openrocket/preset/loader/MaterialColumnParser.java
@@ -5,26 +5,38 @@ import java.util.Map;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.preset.TypedPropertyMap;
public class MaterialColumnParser extends BaseColumnParser {
private Map materialMap = Collections.emptyMap();
+
+ private final TypedKey param;
- // FIXME - BULK vs other types.
+ public MaterialColumnParser(Map materialMap, String columnName, TypedKey param) {
+ super(columnName);
+ this.param = param;
+ this.materialMap = materialMap;
+ }
public MaterialColumnParser(Map materialMap) {
- super("Material");
+ this(materialMap, "Material", ComponentPreset.MATERIAL);
}
+
@Override
protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
+ if ( columnData == null || "".equals(columnData.trim())) {
+ return;
+ }
+
Material m = materialMap.get(columnData);
if ( m == null ) {
m = new Material.Bulk(columnData, 0.0, true);
}
- props.put(ComponentPreset.MATERIAL, m);
+ props.put(param, m);
}
diff --git a/core/src/net/sf/openrocket/preset/loader/ParachuteLoader.java b/core/src/net/sf/openrocket/preset/loader/ParachuteLoader.java
new file mode 100644
index 000000000..5e19796a6
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/ParachuteLoader.java
@@ -0,0 +1,37 @@
+package net.sf.openrocket.preset.loader;
+
+import java.util.Map;
+
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
+
+public class ParachuteLoader extends BaseComponentLoader {
+
+ Map materialMap;
+
+ public ParachuteLoader(Map materials) {
+ super(materials);
+ this.materialMap = materials;
+ fileColumns.add(new IntegerColumnParser("n sides", ComponentPreset.SIDES));
+ fileColumns.add(new DoubleUnitColumnParser("OD","Units",ComponentPreset.DIAMETER));
+ fileColumns.add(new IntegerColumnParser("Shroud Count", ComponentPreset.LINE_COUNT));
+ fileColumns.add(new DoubleUnitColumnParser("Shroud Len", "Units", ComponentPreset.LINE_LENGTH));
+ fileColumns.add(new LineMaterialColumnParser(materials,"Shroud Material",ComponentPreset.LINE_MATERIAL));
+ fileColumns.add(new DoubleUnitColumnParser("Chute Thickness", "Units", ComponentPreset.THICKNESS));
+ fileColumns.add( new SurfaceMaterialColumnParser(materials,"Chute Material", ComponentPreset.MATERIAL));
+ }
+
+
+ @Override
+ protected Type getComponentPresetType() {
+ return ComponentPreset.Type.PARACHUTE;
+ }
+
+
+ @Override
+ protected RocksimComponentFileType getFileType() {
+ return RocksimComponentFileType.PARACHUTE;
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileTranslator.java b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileTranslator.java
index 9a47bb264..4b3f08d5d 100644
--- a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileTranslator.java
+++ b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileTranslator.java
@@ -11,6 +11,7 @@ import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.xml.OpenRocketComponentSaver;
import net.sf.openrocket.startup.Application;
+import net.sf.openrocket.startup.Startup;
import net.sf.openrocket.util.ArrayList;
public class RocksimComponentFileTranslator {
@@ -36,6 +37,7 @@ public class RocksimComponentFileTranslator {
System.err.println("Loading csv files from directory " + args[0]);
+ Startup.initializeLogging();
Application.setPreferences(new SwingPreferences());
MaterialLoader mats = new MaterialLoader();
@@ -54,7 +56,7 @@ public class RocksimComponentFileTranslator {
BulkHeadLoader bhs = new BulkHeadLoader(materialMap);
bhs.load();
allPresets.addAll(bhs.getPresets());
- System.err.println("\tBody Tubes loaded: " + bhs.getPresets().size());
+ System.err.println("\tBulkheads loaded: " + bhs.getPresets().size());
}
{
CenteringRingLoader crs = new CenteringRingLoader(materialMap);
@@ -86,6 +88,24 @@ public class RocksimComponentFileTranslator {
allPresets.addAll(trs.getPresets());
System.err.println("\tTransitions loaded: " + trs.getPresets().size());
}
+ {
+ LaunchLugLoader lls = new LaunchLugLoader(materialMap);
+ lls.load();
+ allPresets.addAll(lls.getPresets());
+ System.err.println("\tLaunch Lugs loaded: " + lls.getPresets().size());
+ }
+ {
+ StreamerLoader sts = new StreamerLoader(materialMap);
+ sts.load();
+ allPresets.addAll(sts.getPresets());
+ System.err.println("\tStreamers loaded: " + sts.getPresets().size());
+ }
+ {
+ ParachuteLoader pcs = new ParachuteLoader(materialMap);
+ pcs.load();
+ allPresets.addAll(pcs.getPresets());
+ System.err.println("Parachutes loaded: " + pcs.getPresets().size());
+ }
System.err.println("\tMarshalling to XML");
String xml = new OpenRocketComponentSaver().marshalToOpenRocketComponent(new ArrayList(materialMap.values()), allPresets);
diff --git a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileType.java b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileType.java
index c4b85d90a..13ac86209 100644
--- a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileType.java
+++ b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileType.java
@@ -13,7 +13,7 @@ public enum RocksimComponentFileType {
CUSTOM_FIN("CSDATA.CSV"),
ENGINE_BLOCK("EBDATA.CSV", "Mfg.", "Part No.", "Desc.", "Units", "ID", "OD", "Length", "Material", "CG", "Mass Units", "Mass", "AutoSize"),
FIN("FSDATA.CSV"),
- LAUNCH_LUG("LLDATA.CSV"),
+ LAUNCH_LUG("LLDATA.CSV", "Mfg.", "Part No.", "Desc.", "Units", "ID", "OD", "Length", "Material"),
MASS_OBJECT("MODATA.CSV", "Mfg.", "Part no", "Desc", "Units", "Name", "Type", "Length", "Material", "Mass units", "Mass"),
MATERIAL("MATERIAL.CSV", "Material Name", "Units", "Density", "Low", "High", "Class", "Rocketry Use", "Body Tubes",
"Fin Sets", "Launch Lugs", "Cords", "Nose", "Chute", "Stream", "Trans", "Ring", "Bulkhead", "Engine Block", "Sleeve",
@@ -22,7 +22,7 @@ public enum RocksimComponentFileType {
"Thickness","Shape","Config","Material","CG Loc","Mass Units","Mass","Base Ext. Len"),
PARACHUTE("PCDATA.CSV"),
SLEEVE("SLDATA.CSV"),
- STREAMER("STDATA.CSV"),
+ STREAMER("STDATA.CSV", "Mfg.", "Part No.", "Desc.", "Units", "Length", "Width", "Thickness", "Count", "Material"),
TUBE_COUPLER("TCDATA.CSV", "Mfg.", "Part No.", "Desc.", "Units", "ID", "OD", "Length", "Material", "Mass Units", "CG", "Mass", "AutoSize"),
TRANSITION("TRDATA.CSV", "Mfg.", "Part No.", "Desc.", "Units", "Front Insert Len", "Front Insert OD", "Front OD", "Length",
"Rear OD", "Core Dia.", "Rear Insert Len", "Rear Insert OD", "Thickness", "Config", "Material", "CG Loc",
diff --git a/core/src/net/sf/openrocket/preset/loader/StreamerLoader.java b/core/src/net/sf/openrocket/preset/loader/StreamerLoader.java
new file mode 100644
index 000000000..bc7905c5b
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/StreamerLoader.java
@@ -0,0 +1,34 @@
+package net.sf.openrocket.preset.loader;
+
+import java.util.Map;
+
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
+
+public class StreamerLoader extends BaseComponentLoader {
+
+ Map materialMap;
+
+ public StreamerLoader(Map materials) {
+ super(materials);
+ this.materialMap = materials;
+ fileColumns.add(new SurfaceMaterialColumnParser(materials,"Material",ComponentPreset.MATERIAL));
+ fileColumns.add(new DoubleUnitColumnParser("Length","Units",ComponentPreset.LENGTH));
+ fileColumns.add(new DoubleUnitColumnParser("Width","Units",ComponentPreset.WIDTH));
+ fileColumns.add(new DoubleUnitColumnParser("Thickness","Units",ComponentPreset.THICKNESS));
+ }
+
+
+ @Override
+ protected Type getComponentPresetType() {
+ return ComponentPreset.Type.STREAMER;
+ }
+
+
+ @Override
+ protected RocksimComponentFileType getFileType() {
+ return RocksimComponentFileType.STREAMER;
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/loader/SurfaceMaterialColumnParser.java b/core/src/net/sf/openrocket/preset/loader/SurfaceMaterialColumnParser.java
new file mode 100644
index 000000000..fc797fbd8
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/loader/SurfaceMaterialColumnParser.java
@@ -0,0 +1,44 @@
+package net.sf.openrocket.preset.loader;
+
+import java.util.Collections;
+import java.util.Map;
+
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.TypedKey;
+import net.sf.openrocket.preset.TypedPropertyMap;
+
+public class SurfaceMaterialColumnParser extends BaseColumnParser {
+
+ private Map materialMap = Collections.emptyMap();
+
+ private final TypedKey param;
+
+ public SurfaceMaterialColumnParser(Map materialMap, String columnName, TypedKey param) {
+ super(columnName);
+ this.param = param;
+ this.materialMap = materialMap;
+ }
+
+
+ @Override
+ protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
+
+ if ( columnData == null || "".equals(columnData.trim())) {
+ return;
+ }
+
+ Material.Surface myMaterial;
+
+ Material m = materialMap.get(columnData);
+
+ if ( m == null || m.getType() != Material.Type.SURFACE ) {
+ myMaterial = new Material.Surface(columnData, 0.0, true);
+ } else {
+ myMaterial =(Material.Surface) m;
+ }
+
+ props.put(param, myMaterial);
+
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java
index 6be6ebd96..a67b9ca8c 100644
--- a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java
+++ b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java
@@ -173,15 +173,33 @@ public abstract class BaseComponentDTO {
}
}
- private Material find(List materialList, AnnotatedMaterialDTO dto) {
+ protected Material find(List materialList, AnnotatedMaterialDTO dto) {
+ if ( dto == null ) {
+ return null;
+ }
for (int i = 0; i < materialList.size(); i++) {
MaterialDTO materialDTO = materialList.get(i);
if (materialDTO.getType().name().equals(dto.type) && materialDTO.getName().equals(dto.material)) {
return materialDTO.asMaterial();
}
}
- //Otherwise fallback and look at factory default materials.
- return Databases.findMaterial(Material.Type.valueOf(material.type), material.material);
+ // Check for the material in the default database.
+ Material defaultMaterial = Databases.findMaterial(Material.Type.valueOf(material.type), material.material);
+ if ( defaultMaterial != null ) {
+ return defaultMaterial;
+ }
+ // Don't have one, build one.
+
+ if ( "BULK".equals( dto.type ) ) {
+ return new Material.Bulk(dto.material, 0.0, true);
+ } else if ( "SURFACE".equals( dto.type ) ) {
+ return new Material.Surface(dto.material, 0.0, true);
+ } else if ( "LINE".equals( dto.type ) ) {
+ return new Material.Line(dto.material, 0.0, true);
+ } else {
+ return null;
+ }
+
}
static class AnnotatedMaterialDTO {
diff --git a/core/src/net/sf/openrocket/preset/xml/LaunchLugDTO.java b/core/src/net/sf/openrocket/preset/xml/LaunchLugDTO.java
new file mode 100644
index 000000000..e723861b7
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/xml/LaunchLugDTO.java
@@ -0,0 +1,100 @@
+
+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 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;
+
+/**
+ * Body tube preset XML handler.
+ */
+@XmlRootElement(name = "LaunchLug")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class LaunchLugDTO extends BaseComponentDTO {
+
+ @XmlElement(name = "InsideDiameter")
+ private AnnotatedLengthDTO insideDiameter;
+ @XmlElement(name = "OutsideDiameter")
+ private AnnotatedLengthDTO outsideDiameter;
+ @XmlElement(name = "Length")
+ private AnnotatedLengthDTO length;
+
+ /**
+ * Default constructor.
+ */
+ public LaunchLugDTO() {
+ }
+
+ /**
+ * Most-useful constructor that maps a LaunchLug preset to a LaunchLugDTO.
+ *
+ * @param preset the preset
+ *
+ * @throws net.sf.openrocket.util.BugException thrown if the expected body tube keys are not in the preset
+ */
+ public LaunchLugDTO(final ComponentPreset preset) {
+ super(preset);
+ setInsideDiameter(preset.get(ComponentPreset.INNER_DIAMETER));
+ setOutsideDiameter(preset.get(ComponentPreset.OUTER_DIAMETER));
+ setLength(preset.get(ComponentPreset.LENGTH));
+ }
+
+ public double getInsideDiameter() {
+ return insideDiameter.getValue();
+ }
+
+ public void setInsideDiameter( final AnnotatedLengthDTO theLength ) {
+ insideDiameter = theLength;
+ }
+
+ public void setInsideDiameter(final double theId) {
+ insideDiameter = new AnnotatedLengthDTO(theId);
+ }
+
+ public double getOutsideDiameter() {
+ return outsideDiameter.getValue();
+ }
+
+ public void setOutsideDiameter(final AnnotatedLengthDTO theOd) {
+ outsideDiameter = theOd;
+ }
+
+ public void setOutsideDiameter(final double theOd) {
+ outsideDiameter = new AnnotatedLengthDTO(theOd);
+ }
+
+ public double getLength() {
+ return length.getValue();
+ }
+
+ 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.LAUNCH_LUG, 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);
+ }
+}
diff --git a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentDTO.java b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentDTO.java
index 51c868539..8c60d656b 100644
--- a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentDTO.java
+++ b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentDTO.java
@@ -35,7 +35,10 @@ public class OpenRocketComponentDTO {
@XmlElementRef(name = "Transitions", type = TransitionDTO.class),
@XmlElementRef(name = "BulkHeads", type = BulkHeadDTO.class),
@XmlElementRef(name = "CenteringRings", type = CenteringRingDTO.class),
- @XmlElementRef(name = "EngineBlocks", type = EngineBlockDTO.class)})
+ @XmlElementRef(name = "EngineBlocks", type = EngineBlockDTO.class),
+ @XmlElementRef(name = "LaunchLugs", type = LaunchLugDTO.class),
+ @XmlElementRef(name = "Streamers", type = StreamerDTO.class),
+ @XmlElementRef(name = "Parachutes", type = ParachuteDTO.class)})
private List components = new ArrayList();
public OpenRocketComponentDTO() {
diff --git a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java
index add220a69..f3452ed46 100644
--- a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java
+++ b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java
@@ -153,6 +153,12 @@ public class OpenRocketComponentSaver {
return new CenteringRingDTO(thePreset);
case ENGINE_BLOCK:
return new EngineBlockDTO(thePreset);
+ case LAUNCH_LUG:
+ return new LaunchLugDTO(thePreset);
+ case STREAMER:
+ return new StreamerDTO(thePreset);
+ case PARACHUTE:
+ return new ParachuteDTO(thePreset);
}
return null;
diff --git a/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java b/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java
new file mode 100644
index 000000000..b21f5d4ab
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java
@@ -0,0 +1,140 @@
+
+package net.sf.openrocket.preset.xml;
+
+import net.sf.openrocket.material.Material;
+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 net.sf.openrocket.preset.xml.BaseComponentDTO.AnnotatedMaterialDTO;
+
+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;
+
+/**
+ * Streamer preset XML handler.
+ */
+@XmlRootElement(name = "Parachute")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ParachuteDTO extends BaseComponentDTO {
+
+ @XmlElement(name = "Diameter")
+ private AnnotatedLengthDTO diameter;
+ @XmlElement(name = "Sides")
+ private Integer sides;
+ @XmlElement(name = "LineCount")
+ private Integer lineCount;
+ @XmlElement(name = "LineLength")
+ private AnnotatedLengthDTO lineLength;
+
+ @XmlElement(name = "LineMaterial")
+ private AnnotatedMaterialDTO lineMaterial;
+
+
+ /**
+ * Default constructor.
+ */
+ public ParachuteDTO() {
+ }
+
+ public double getDiameter() {
+ return diameter.getValue();
+ }
+
+ public void setDiameter(AnnotatedLengthDTO diameter) {
+ this.diameter = diameter;
+ }
+ public void setDiameter(double diameter) {
+ this.diameter = new AnnotatedLengthDTO(diameter);
+ }
+
+ public Integer getSides() {
+ return sides;
+ }
+
+ public void setSides(Integer sides) {
+ this.sides = sides;
+ }
+
+ public Integer getLineCount() {
+ return lineCount;
+ }
+
+ public void setLineCount(Integer lineCount) {
+ this.lineCount = lineCount;
+ }
+
+ public double getLineLength() {
+ return lineLength.getValue();
+ }
+
+ public void setLineLength(AnnotatedLengthDTO lineLength) {
+ this.lineLength = lineLength;
+ }
+
+ public void setLineLength(double lineLength) {
+ this.lineLength = new AnnotatedLengthDTO(lineLength);
+ }
+
+ public AnnotatedMaterialDTO getLineMaterial() {
+ return lineMaterial;
+ }
+
+ public void setLineMaterial(AnnotatedMaterialDTO lineMaterial) {
+ this.lineMaterial = lineMaterial;
+ }
+
+ /**
+ * Most-useful constructor that maps a BodyTube preset to a BodyTubeDTO.
+ *
+ * @param preset the preset
+ *
+ * @throws net.sf.openrocket.util.BugException thrown if the expected body tube keys are not in the preset
+ */
+ public ParachuteDTO(final ComponentPreset preset) {
+ super(preset);
+ setDiameter(preset.get(ComponentPreset.DIAMETER));
+ setLineCount(preset.get(ComponentPreset.LINE_COUNT));
+ if ( preset.has(ComponentPreset.LINE_LENGTH)) {
+ setLineLength(preset.get(ComponentPreset.LINE_LENGTH));
+ }
+ if ( preset.has(ComponentPreset.SIDES)) {
+ setSides(preset.get(ComponentPreset.SIDES));
+ }
+ if ( preset.has(ComponentPreset.LINE_MATERIAL)) {
+ setLineMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.LINE_MATERIAL)));
+ }
+ }
+
+ @Override
+ public ComponentPreset asComponentPreset(java.util.List materials) throws InvalidComponentPresetException {
+ return asComponentPreset(ComponentPreset.Type.PARACHUTE, materials);
+ }
+
+ public ComponentPreset asComponentPreset(ComponentPreset.Type type, List materials) throws InvalidComponentPresetException {
+ TypedPropertyMap props = new TypedPropertyMap();
+ addProps(props, materials);
+ // FIXME - seems some vendors use a bulk material for the sheet along with a Thickness.
+ // need to fix the MATERIAL packed into the componentpreset.
+ props.put(ComponentPreset.TYPE, type);
+ props.put(ComponentPreset.DIAMETER, this.getDiameter());
+ props.put(ComponentPreset.LINE_COUNT, this.getLineCount());
+ if ( this.lineLength != null ) {
+ props.put(ComponentPreset.LINE_LENGTH, this.getLineLength());
+ }
+ if ( this.sides != null ) {
+ props.put(ComponentPreset.SIDES, this.getSides());
+ }
+ if ( this.lineMaterial != null ) {
+ Material m = find(materials, this.lineMaterial);
+ if ( m != null ) {
+ props.put(ComponentPreset.LINE_MATERIAL, m);
+ }
+ }
+
+ return ComponentPresetFactory.create(props);
+ }
+}
diff --git a/core/src/net/sf/openrocket/preset/xml/StreamerDTO.java b/core/src/net/sf/openrocket/preset/xml/StreamerDTO.java
new file mode 100644
index 000000000..b80f64106
--- /dev/null
+++ b/core/src/net/sf/openrocket/preset/xml/StreamerDTO.java
@@ -0,0 +1,102 @@
+
+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 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;
+
+/**
+ * Streamer preset XML handler.
+ */
+@XmlRootElement(name = "Streamer")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class StreamerDTO extends BaseComponentDTO {
+
+ @XmlElement(name = "Length")
+ private AnnotatedLengthDTO length;
+ @XmlElement(name = "Width")
+ private AnnotatedLengthDTO width;
+ @XmlElement(name = "Thickness")
+ private AnnotatedLengthDTO thickness;
+
+ /**
+ * Default constructor.
+ */
+ public StreamerDTO() {
+ }
+
+ /**
+ * Most-useful constructor that maps a BodyTube preset to a BodyTubeDTO.
+ *
+ * @param preset the preset
+ *
+ * @throws net.sf.openrocket.util.BugException thrown if the expected body tube keys are not in the preset
+ */
+ public StreamerDTO(final ComponentPreset preset) {
+ super(preset);
+ setWidth(preset.get(ComponentPreset.WIDTH));
+ setThickness(preset.get(ComponentPreset.THICKNESS));
+ setLength(preset.get(ComponentPreset.LENGTH));
+ }
+
+ public double getWidth() {
+ return width.getValue();
+ }
+
+ public void setWidth( final AnnotatedLengthDTO theWidth ) {
+ width = theWidth;
+ }
+
+ public void setWidth(final double theId) {
+ width = new AnnotatedLengthDTO(theId);
+ }
+
+ public double getThickness() {
+ return thickness.getValue();
+ }
+
+ public void setThickness(final AnnotatedLengthDTO theThickness) {
+ thickness = theThickness;
+ }
+
+ public void setThickness(final double theThickness) {
+ thickness = new AnnotatedLengthDTO(theThickness);
+ }
+
+ public double getLength() {
+ return length.getValue();
+ }
+
+ 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.STREAMER, materials);
+ }
+
+ public ComponentPreset asComponentPreset(ComponentPreset.Type type, List materials) throws InvalidComponentPresetException {
+ TypedPropertyMap props = new TypedPropertyMap();
+ addProps(props, materials);
+ // FIXME - seems some vendors use a bulk material for the sheet along with a Thickness.
+ // need to fix the MATERIAL packed into the componentpreset.
+ props.put(ComponentPreset.WIDTH, this.getWidth());
+ props.put(ComponentPreset.THICKNESS, this.getThickness());
+ props.put(ComponentPreset.LENGTH, this.getLength());
+ props.put(ComponentPreset.TYPE, type);
+
+ return ComponentPresetFactory.create(props);
+ }
+}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
index 5614e0771..437094368 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collection;
import net.sf.openrocket.l10n.Translator;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.MathUtil;
@@ -43,6 +45,7 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
return;
this.radius = radius;
this.thickness = Math.min(this.thickness, this.radius);
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -65,6 +68,7 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
if (MathUtil.equals(this.thickness, thickness))
return;
this.thickness = MathUtil.clamp(thickness, 0, radius);
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -109,6 +113,29 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
+ @Override
+ protected void loadFromPreset(ComponentPreset preset) {
+ if ( preset.has(ComponentPreset.OUTER_DIAMETER) ) {
+ double outerDiameter = preset.get(ComponentPreset.OUTER_DIAMETER);
+ this.radius = outerDiameter/2.0;
+ if ( preset.has(ComponentPreset.INNER_DIAMETER) ) {
+ double innerDiameter = preset.get(ComponentPreset.INNER_DIAMETER);
+ this.thickness = (outerDiameter-innerDiameter) / 2.0;
+ }
+ }
+
+ super.loadFromPreset(preset);
+
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+ @Override
+ public Type getPresetType() {
+ return ComponentPreset.Type.LAUNCH_LUG;
+ }
+
+
@Override
public Coordinate[] shiftCoordinates(Coordinate[] array) {
array = super.shiftCoordinates(array);
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java
index 640810bb2..aabb6117f 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java
@@ -2,6 +2,8 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
@@ -32,6 +34,7 @@ public class Parachute extends RecoveryDevice {
if (MathUtil.equals(this.diameter, d))
return;
this.diameter = d;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -62,6 +65,7 @@ public class Parachute extends RecoveryDevice {
if (this.lineCount == n)
return;
this.lineCount = n;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
@@ -94,6 +98,7 @@ public class Parachute extends RecoveryDevice {
if (MathUtil.equals(getArea(), area))
return;
diameter = MathUtil.safeSqrt(area / Math.PI) * 2;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -118,5 +123,29 @@ public class Parachute extends RecoveryDevice {
public boolean isCompatible(Class extends RocketComponent> type) {
return false;
}
+
+
+ @Override
+ protected void loadFromPreset(ComponentPreset preset) {
+ if( preset.has( ComponentPreset.DIAMETER )) {
+ this.diameter = preset.get( ComponentPreset.DIAMETER );
+ }
+ if( preset.has( ComponentPreset.LINE_COUNT )) {
+ this.lineCount = preset.get( ComponentPreset.LINE_COUNT );
+ }
+ if( preset.has( ComponentPreset.LINE_LENGTH )) {
+ this.lineLength = preset.get( ComponentPreset.LINE_LENGTH );
+ }
+ if( preset.has( ComponentPreset.LINE_MATERIAL )) {
+ this.lineMaterial = preset.get( ComponentPreset.LINE_MATERIAL );
+ }
+ super.loadFromPreset(preset);
+ }
+
+
+ @Override
+ public Type getPresetType() {
+ return ComponentPreset.Type.PARACHUTE;
+ }
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java b/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java
index e9c493db7..3c5a88f1b 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java
@@ -2,6 +2,7 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
@@ -169,6 +170,7 @@ public abstract class RecoveryDevice extends MassObject {
if (mat.equals(material))
return;
this.material = (Material.Surface) mat;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
@@ -220,5 +222,16 @@ public abstract class RecoveryDevice extends MassObject {
public double getComponentMass() {
return getArea() * getMaterial().getDensity();
}
-
+
+ @Override
+ protected void loadFromPreset(ComponentPreset preset) {
+ if ( preset.has(ComponentPreset.MATERIAL)) {
+ Material m = preset.get(ComponentPreset.MATERIAL);
+ this.material = (Material.Surface)m;
+ }
+ super.loadFromPreset(preset);
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+
+ }
+
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java
index 8d73c4571..94f9986ba 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java
@@ -1,5 +1,7 @@
package net.sf.openrocket.rocketcomponent;
+import net.sf.openrocket.preset.ComponentPreset;
+import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.util.MathUtil;
public class Streamer extends RecoveryDevice {
@@ -27,6 +29,7 @@ public class Streamer extends RecoveryDevice {
if (MathUtil.equals(this.stripLength, stripLength))
return;
this.stripLength = stripLength;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -39,6 +42,7 @@ public class Streamer extends RecoveryDevice {
return;
this.stripWidth = stripWidth;
this.length = stripWidth;
+ clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@@ -83,6 +87,27 @@ public class Streamer extends RecoveryDevice {
+ @Override
+ public Type getPresetType() {
+ return ComponentPreset.Type.STREAMER;
+ }
+
+
+ @Override
+ protected void loadFromPreset(ComponentPreset preset) {
+ if ( preset.has(ComponentPreset.LENGTH)) {
+ this.stripLength = preset.get(ComponentPreset.LENGTH);
+ }
+ if ( preset.has(ComponentPreset.WIDTH)) {
+ this.stripWidth = preset.get(ComponentPreset.WIDTH);
+ }
+ super.loadFromPreset(preset);
+ // Fix the length to the stripWidth since RocketComponent assigns ComponentPreset.LENGTH to length.
+ this.length = this.stripWidth;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
@Override
public double getComponentCD(double mach) {
double density = this.getMaterial().getDensity();
diff --git a/core/test/net/sf/openrocket/preset/LaunchLugComponentTests.java b/core/test/net/sf/openrocket/preset/LaunchLugComponentTests.java
new file mode 100644
index 000000000..0a7e9b726
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/LaunchLugComponentTests.java
@@ -0,0 +1,126 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.*;
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.motor.Manufacturer;
+import net.sf.openrocket.rocketcomponent.LaunchLug;
+import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
+import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test application of ComponentPresets to LaunchLug RocketComponents through
+ * the LaunchLug.loadFromPreset mechanism.
+ *
+ * Test LaunchLug is well defined.
+ *
+ * Test calling setters on LaunchLug will clear the ComponentPreset.
+ *
+ */
+public class LaunchLugComponentTests extends BaseTestCase {
+
+ ComponentPreset preset;
+
+ @Before
+ public void createPreset() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.MASS, 100.0);
+ preset = ComponentPresetFactory.create(presetspec);
+ }
+
+ @Test
+ public void testComponentType() {
+ LaunchLug bt = new LaunchLug();
+
+ assertSame( ComponentPreset.Type.LAUNCH_LUG, bt.getPresetType() );
+ }
+
+ @Test
+ public void testLoadFromPresetIsSane() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ assertEquals( 2.0, bt.getLength(), 0.0 );
+ assertEquals( 1.0, bt.getOuterRadius(), 0.0 );
+ assertEquals( 0.5, bt.getInnerRadius(), 0.0 );
+
+ assertSame( preset.get( ComponentPreset.MATERIAL), bt.getMaterial() );
+ assertEquals( 100.0, bt.getMass(), 0.05);
+ }
+
+ @Test
+ public void changeLengthLeavesPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setLength(1.0);
+
+ assertSame( preset, bt.getPresetComponent() );
+ }
+
+ @Test
+ public void changeODClearsPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setOuterRadius(2.0);
+
+ assertNull( bt.getPresetComponent() );
+ }
+
+ @Test
+ public void changeIDClearsPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setInnerRadius(0.75);
+
+ assertNull( bt.getPresetComponent() );
+ }
+
+ @Test
+ public void changeThicknessClearsPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setThickness(0.1);
+
+ assertNull( bt.getPresetComponent() );
+ }
+
+ @Test
+ public void changeMaterialClearsPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setMaterial( new Material.Bulk("new", 1.0, true));
+
+ assertNull( bt.getPresetComponent() );
+ }
+
+ @Test
+ public void changeFinishLeavesPreset() {
+ LaunchLug bt = new LaunchLug();
+
+ bt.loadPreset(preset);
+
+ bt.setFinish( Finish.POLISHED );
+
+ assertSame( preset, bt.getPresetComponent() );
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/preset/LaunchLugPresetTests.java b/core/test/net/sf/openrocket/preset/LaunchLugPresetTests.java
new file mode 100644
index 000000000..d37443b03
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/LaunchLugPresetTests.java
@@ -0,0 +1,227 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.motor.Manufacturer;
+
+import org.junit.Test;
+
+/**
+ * Test construction of LAUNCH_LUG type ComponentPresets based on TypedPropertyMap through the
+ * ComponentPresetFactory.create() method.
+ *
+ * Ensure required properties are populated
+ *
+ * Ensure any computed values are correctly computed.
+ *
+ */
+public class LaunchLugPresetTests {
+
+ @Test
+ public void testManufacturerRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
+ }
+ }
+
+ @Test
+ public void testPartNoRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
+ }
+ }
+
+ @Test
+ public void testLengthRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
+ }
+ }
+
+ @Test
+ public void testOnlyOuterDiameter() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
+ }
+ }
+
+ @Test
+ public void testOnlyInnerDiameter() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
+ }
+ }
+
+ @Test
+ public void testOnlyThicknessDiameter() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.THICKNESS, 2.0);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
+ }
+ }
+
+ @Test
+ public void testComputeInnerDiameter() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ assertEquals(1.0,preset.get(ComponentPreset.INNER_DIAMETER).doubleValue(),0.0);
+ }
+
+ @Test
+ public void testComputeOuterDiameter() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.THICKNESS, 0.5);
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ assertEquals(2.0,preset.get(ComponentPreset.OUTER_DIAMETER).doubleValue(),0.0);
+ }
+
+ @Test
+ public void testComputeThickness() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+ }
+
+ @Test
+ public void testComputeThicknessLooses() throws Exception {
+ // If all OUTER_DIAMETER, INNER_DIAMETER and THICKNESS are
+ // specified, THICKNESS is recomputed.
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.THICKNESS, 15.0);
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ assertEquals(0.5,preset.get(ComponentPreset.THICKNESS).doubleValue(),0.0);
+ }
+
+ @Test
+ public void testComputeDensityNoMaterial() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.MASS, 100.0);
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ // Compute the volume by hand here using a slightly different formula from
+ // the real implementation. The magic numbers are based on the
+ // constants put into the presetspec above.
+ double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ volume *= 2.0; /* times length */
+
+ double density = 100.0 / volume;
+
+ assertEquals("TubeCustom",preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ }
+
+ @Test
+ public void testMaterial() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.MATERIAL, new Material.Bulk("test", 2.0, true));
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+
+ }
+
+ @Test
+ public void testComputeDensityWithMaterial() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.INNER_DIAMETER, 1.0);
+ presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put( ComponentPreset.MATERIAL, new Material.Bulk("test", 2.0, true));
+ ComponentPreset preset = ComponentPresetFactory.create(presetspec);
+
+ // Compute the volume by hand here using a slightly different formula from
+ // the real implementation. The magic numbers are based on the
+ // constants put into the presetspec above.
+ double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
+ volume *= 2.0; /* times length */
+
+ double density = 100.0 / volume;
+
+ assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
+ assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/preset/ParachutePresetTests.java b/core/test/net/sf/openrocket/preset/ParachutePresetTests.java
new file mode 100644
index 000000000..321c96da6
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/ParachutePresetTests.java
@@ -0,0 +1,84 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.assertTrue;
+import net.sf.openrocket.motor.Manufacturer;
+
+import org.junit.Test;
+
+/**
+ * Test construction of PARACHUTE type ComponentPresets based on TypedPropertyMap through the
+ * ComponentPresetFactory.create() method.
+ *
+ * Ensure required properties are populated
+ *
+ * Ensure any computed values are correctly computed.
+ *
+ */
+public class ParachutePresetTests {
+
+ @Test
+ public void testManufacturerRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
+ }
+ }
+
+ @Test
+ public void testPartNoRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
+ }
+ }
+
+ @Test
+ public void testDiameterRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Diameter specified"));
+ }
+ }
+
+ @Test
+ public void testLineCountRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.DIAMETER, 2.0);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No LineCount specified"));
+ }
+ }
+
+ @Test
+ public void testLineLengthRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.DIAMETER, 2.0);
+ presetspec.put( ComponentPreset.LINE_COUNT, 6);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No LineLength specified"));
+ }
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/preset/ParachuterComponentTests.java b/core/test/net/sf/openrocket/preset/ParachuterComponentTests.java
new file mode 100644
index 000000000..2c4b4442c
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/ParachuterComponentTests.java
@@ -0,0 +1,130 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.motor.Manufacturer;
+import net.sf.openrocket.rocketcomponent.Parachute;
+import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test application of ComponentPresets to Parachute RocketComponents through
+ * the Parachute.loadFromPreset mechanism.
+ *
+ * Test Parachute is well defined.
+ *
+ * Test calling setters on Parachute will clear the ComponentPreset.
+ *
+ */
+public class ParachuterComponentTests extends BaseTestCase {
+
+ ComponentPreset preset;
+
+ @Before
+ public void createPreset() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.DIAMETER, 20.0);
+ presetspec.put( ComponentPreset.LINE_COUNT, 8);
+ presetspec.put( ComponentPreset.LINE_LENGTH, 12.0);
+ Material m = new Material.Surface("testMaterial", 2.0, true);
+ presetspec.put( ComponentPreset.MATERIAL, m);
+ m = new Material.Line("testLineMaterial", 3, true);
+ presetspec.put( ComponentPreset.LINE_MATERIAL, m);
+ preset = ComponentPresetFactory.create(presetspec);
+ }
+
+ @Test
+ public void testComponentType() {
+ Parachute cr = new Parachute();
+
+ assertSame( ComponentPreset.Type.PARACHUTE, cr.getPresetType() );
+ }
+
+ @Test
+ public void testLoadFromPresetIsSane() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ assertEquals( 20.0, cr.getDiameter(), 0.0 );
+ assertEquals( 8, cr.getLineCount(), 0.0 );
+ assertEquals( 12.0, cr.getLineLength(), 0.0 );
+
+ assertSame( preset.get( ComponentPreset.MATERIAL), cr.getMaterial() );
+ assertSame( preset.get( ComponentPreset.LINE_MATERIAL), cr.getLineMaterial() );
+ }
+
+ @Test
+ public void changeDiameterClearsPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setDiameter(1.0);
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeAreaClearsPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setArea(1.0);
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeLineCountClearsPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setLineCount(12);
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeLineLengthLeavesPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setLineLength(24);
+
+ assertSame( preset, cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeMaterialClearsPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setMaterial( new Material.Surface("new", 1.0, true));
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeLineMaterialLeavesPreset() {
+ Parachute cr = new Parachute();
+
+ cr.loadPreset(preset);
+
+ cr.setLineMaterial( new Material.Line("new", 1.0, true));
+
+ assertSame( preset, cr.getPresetComponent() );
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/preset/StreamerComponentTests.java b/core/test/net/sf/openrocket/preset/StreamerComponentTests.java
new file mode 100644
index 000000000..e9c78e088
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/StreamerComponentTests.java
@@ -0,0 +1,94 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import net.sf.openrocket.material.Material;
+import net.sf.openrocket.motor.Manufacturer;
+import net.sf.openrocket.rocketcomponent.Streamer;
+import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test application of ComponentPresets to Streamer RocketComponents through
+ * the Streamer.loadFromPreset mechanism.
+ *
+ * Test Streamer is well defined.
+ *
+ * Test calling setters on Streamer will clear the ComponentPreset.
+ *
+ */
+public class StreamerComponentTests extends BaseTestCase {
+
+ ComponentPreset preset;
+
+ @Before
+ public void createPreset() throws Exception {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 20.0);
+ presetspec.put( ComponentPreset.WIDTH, 2.0);
+ Material m = new Material.Surface("testMaterial", 2.0, true);
+ presetspec.put( ComponentPreset.MATERIAL, m);
+ preset = ComponentPresetFactory.create(presetspec);
+ }
+
+ @Test
+ public void testComponentType() {
+ Streamer cr = new Streamer();
+
+ assertSame( ComponentPreset.Type.STREAMER, cr.getPresetType() );
+ }
+
+ @Test
+ public void testLoadFromPresetIsSane() {
+ Streamer cr = new Streamer();
+
+ cr.loadPreset(preset);
+
+ assertEquals( 20.0, cr.getStripLength(), 0.0 );
+ assertEquals( 2.0, cr.getStripWidth(), 0.0 );
+ assertEquals( 2.0, cr.getLength(), 0.0 );
+
+ assertSame( preset.get( ComponentPreset.MATERIAL), cr.getMaterial() );
+ assertEquals( 80.0, cr.getMass(), 0.05);
+ }
+
+ @Test
+ public void changeLengthClearsPreset() {
+ Streamer cr = new Streamer();
+
+ cr.loadPreset(preset);
+
+ cr.setStripLength(1.0);
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeWidthClearsPreset() {
+ Streamer cr = new Streamer();
+
+ cr.loadPreset(preset);
+
+ cr.setStripWidth(1.0);
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+ @Test
+ public void changeMaterialClearsPreset() {
+ Streamer cr = new Streamer();
+
+ cr.loadPreset(preset);
+
+ cr.setMaterial( new Material.Surface("new", 1.0, true));
+
+ assertNull( cr.getPresetComponent() );
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/preset/StreamerPresetTests.java b/core/test/net/sf/openrocket/preset/StreamerPresetTests.java
new file mode 100644
index 000000000..176cdb327
--- /dev/null
+++ b/core/test/net/sf/openrocket/preset/StreamerPresetTests.java
@@ -0,0 +1,69 @@
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.assertTrue;
+import net.sf.openrocket.motor.Manufacturer;
+
+import org.junit.Test;
+
+/**
+ * Test construction of STREAMER type ComponentPresets based on TypedPropertyMap through the
+ * ComponentPresetFactory.create() method.
+ *
+ * Ensure required properties are populated
+ *
+ * Ensure any computed values are correctly computed.
+ *
+ */
+public class StreamerPresetTests {
+
+ @Test
+ public void testManufacturerRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
+ }
+ }
+
+ @Test
+ public void testPartNoRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
+ }
+ }
+
+ @Test
+ public void testLengthRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
+ }
+ }
+
+ @Test
+ public void testWidthRequired() {
+ try {
+ TypedPropertyMap presetspec = new TypedPropertyMap();
+ presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
+ presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put( ComponentPreset.PARTNO, "partno");
+ presetspec.put( ComponentPreset.LENGTH, 2.0);
+ ComponentPresetFactory.create(presetspec);
+ } catch ( InvalidComponentPresetException ex ) {
+ assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Width specified"));
+ }
+ }
+
+}