diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties
index da1358bf1..7c0b8385e 100644
--- a/core/resources/l10n/messages.properties
+++ b/core/resources/l10n/messages.properties
@@ -1376,7 +1376,9 @@ RocketComponent.Position.ABSOLUTE = Tip of the nose cone
! LaunchLug
-LaunchLug.Launchlug = Launch lug
+LaunchLug.Launchlug = Launch Lug
+! LaunchButton
+LaunchButton.LaunchButton = Launch Button
! NoseCone
NoseCone.NoseCone = Nose cone
! Transition
diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
index 6bd814a4d..d11760d1f 100644
--- a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
+++ b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
@@ -21,7 +21,9 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
import net.sf.openrocket.rocketcomponent.InnerTube;
+import net.sf.openrocket.rocketcomponent.Instanceable;
import net.sf.openrocket.rocketcomponent.LaunchLug;
+import net.sf.openrocket.rocketcomponent.LineInstanceable;
import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.NoseCone;
@@ -31,6 +33,7 @@ import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.rocketcomponent.ReferenceType;
import net.sf.openrocket.rocketcomponent.RingComponent;
+import net.sf.openrocket.rocketcomponent.RingInstanceable;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.ShockCord;
@@ -411,10 +414,28 @@ class DocumentConfig {
Reflection.findMethod(AxialStage.class, "getSeparationConfigurations"),
Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
- setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
- setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
- setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
+ /*
+ * The keys are of the form Class:param, where Class is the class name and param
+ * the element name. Setters are searched for in descending class order.
+ * A setter of null means setting the parameter is not allowed.
+ */
+// setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
+// setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
+// setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
+
+ setters.put("Instanceable:instancecount", new IntSetter(
+ Reflection.findMethod(Instanceable.class, "setInstanceCount",int.class)));
+ setters.put("RingInstanceable:radialoffset", new DoubleSetter(
+ Reflection.findMethod(RingInstanceable.class, "setRadialOffset", double.class)));
+ setters.put("RingInstance:angleoffset", new DoubleSetter(
+ Reflection.findMethod(RingInstanceable.class, "setAngularOffset", double.class)));
+
+ setters.put("LineInstanceable:instanceseparation", new DoubleSetter(
+ Reflection.findMethod( LineInstanceable.class, "setInstanceSeparation", double.class)));
+
+
+
}
diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java
index 4c7129e1d..2c367307e 100644
--- a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java
+++ b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java
@@ -25,7 +25,7 @@ class MotorMountHandler extends AbstractElementHandler {
public MotorMountHandler(MotorMount mount, DocumentLoadingContext context) {
this.mount = mount;
this.context = context;
- mount.setActive(true);
+ mount.setMotorMount(true);
}
@Override
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
index fc80e67e5..8b1ef6a58 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
@@ -27,7 +27,7 @@ public class BodyTubeSaver extends SymmetricComponentSaver {
else
elements.add("" + tube.getOuterRadius() + "");
- if (tube.isActive()) {
+ if (tube.isMotorMount()) {
elements.addAll(motorMountParams(tube));
}
}
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/ComponentAssemblySaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/ComponentAssemblySaver.java
index 088cf2ed2..de32832e5 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/ComponentAssemblySaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/ComponentAssemblySaver.java
@@ -6,7 +6,9 @@ import java.util.List;
import net.sf.openrocket.rocketcomponent.BoosterSet;
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
+import net.sf.openrocket.rocketcomponent.Instanceable;
import net.sf.openrocket.rocketcomponent.PodSet;
+import net.sf.openrocket.rocketcomponent.RingInstanceable;
import net.sf.openrocket.rocketcomponent.RocketComponent;
public class ComponentAssemblySaver extends RocketComponentSaver {
@@ -50,13 +52,16 @@ public class ComponentAssemblySaver extends RocketComponentSaver {
final String startangle_tag = "angleoffset";
- if (null != currentStage) {
+ if ( currentStage instanceof Instanceable) {
int instanceCount = currentStage.getInstanceCount();
elementsToReturn.add("<" + instCt_tag + ">" + instanceCount + "" + instCt_tag + ">");
- double radialOffset = currentStage.getRadialOffset();
- elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "" + radoffs_tag + ">");
- double angularOffset = currentStage.getAngularOffset();
- elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "" + startangle_tag + ">");
+ if( currentStage instanceof RingInstanceable ){
+ RingInstanceable ring = (RingInstanceable) currentStage;
+ double radialOffset = ring.getRadialOffset();
+ elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "" + radoffs_tag + ">");
+ double angularOffset = ring.getAngularOffset();
+ elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "" + startangle_tag + ">");
+ }
}
return elementsToReturn;
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/InnerTubeSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/InnerTubeSaver.java
index 1b4a2c1cf..7eb0a538e 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/InnerTubeSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/InnerTubeSaver.java
@@ -32,7 +32,7 @@ public class InnerTubeSaver extends ThicknessRingComponentSaver {
elements.add("" + (tube.getClusterRotation() * 180.0 / Math.PI)
+ "");
- if (tube.isActive()) {
+ if (tube.isMotorMount()) {
elements.addAll(motorMountParams(tube));
}
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java
index 778f5bd38..a3c556ead 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java
@@ -144,7 +144,7 @@ public class RocketComponentSaver {
protected final List motorMountParams(MotorMount mount) {
- if (!mount.isActive())
+ if (!mount.isMotorMount())
return Collections.emptyList();
//FlightConfigurationID[] motorConfigIDs = ((RocketComponent) mount).getRocket().getFlightConfigurationIDs();
diff --git a/core/src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java
index 55a88d805..18c56f70e 100644
--- a/core/src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java
+++ b/core/src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java
@@ -87,7 +87,7 @@ public class BodyTubeDTO extends BasePartDTO implements AttachableParts {
setID(theORBodyTube.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(theORBodyTube.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((theORBodyTube.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
- setMotorMount(theORBodyTube.isActive());
+ setMotorMount(theORBodyTube.isMotorMount());
List children = theORBodyTube.getChildren();
for (int i = 0; i < children.size(); i++) {
diff --git a/core/src/net/sf/openrocket/file/rocksim/export/InnerBodyTubeDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/InnerBodyTubeDTO.java
index e4019b35c..cf995a54d 100644
--- a/core/src/net/sf/openrocket/file/rocksim/export/InnerBodyTubeDTO.java
+++ b/core/src/net/sf/openrocket/file/rocksim/export/InnerBodyTubeDTO.java
@@ -49,7 +49,7 @@ public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
- setMotorMount(bt.isActive());
+ setMotorMount(bt.isMotorMount());
setInsideTube(true);
setRadialAngle(bt.getRadialDirection());
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
diff --git a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java
index aef7e4421..055759893 100644
--- a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java
+++ b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java
@@ -72,7 +72,7 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
MotorInstance inst = mount.getMotorInstance(fcid);
Motor motor = inst.getMotor();
- if (mount.isActive() && motor != null) {
+ if (mount.isMotorMount() && motor != null) {
String designation = motor.getDesignation(inst.getEjectionDelay());
for (int i = 0; i < mount.getMotorCount(); i++) {
diff --git a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java
index 696ce2850..ab207f6df 100644
--- a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java
+++ b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java
@@ -179,7 +179,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
// Conditional motor mount parameters
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
- if (mount.isActive()) {
+ if (mount.isMotorMount()) {
SimulationModifier mod = new GenericComponentModifier(
trans.get("optimization.modifier.motormount.overhang"),
diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java
index 49143c9b2..ecc1e2d59 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java
@@ -12,7 +12,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
private static final Translator trans = Application.getTranslator();
//private static final Logger log = LoggerFactory.getLogger(AxialStage.class);
- private FlightConfigurationSet separationConfigurations;
+ protected FlightConfigurationSet separationConfigurations;
protected int stageNumber;
diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
index c8b56d263..3068014a6 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
@@ -28,7 +28,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
// When changing the inner radius, thickness is modified
private double overhang = 0;
- private boolean isActiveMount = false;
+ private boolean isActing = false;
private MotorConfigurationSet motors;
@@ -382,7 +382,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
if( null != newMotorInstance ){
newMotorInstance.setMount( this);
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
- this.setActive(true);
+ this.setMotorMount(true);
}
}
}
@@ -398,21 +398,23 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
}
@Override
- public void setActive(boolean _active){
- if (this.isActiveMount == _active)
+ public void setMotorMount(boolean _active){
+ if (this.isActing == _active)
return;
- this.isActiveMount = _active;
+ this.isActing = _active;
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
}
@Override
- public boolean isActive(){
- return this.isActiveMount;
+ public boolean isMotorMount(){
+ return this.isActing;
}
- //@Override
+ @Override
public boolean hasMotor() {
- return ( 0 < this.motors.size());
+ // the default MotorInstance is the EMPTY_INSTANCE.
+ // If the class contains more instances, at least one will have motors.
+ return ( 1 < this.motors.size());
}
@Override
diff --git a/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java b/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java
index f69e2f7a0..3e9737978 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java
@@ -11,16 +11,28 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate;
-public class BoosterSet extends AxialStage implements FlightConfigurableComponent, OutsideComponent {
+public class BoosterSet extends AxialStage implements FlightConfigurableComponent, RingInstanceable, OutsideComponent {
private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(BoosterSet.class);
- private FlightConfigurationSet separationConfigurations;
+ protected int count = 1;
+
+ protected double angularSeparation = Math.PI;
+ protected double angularPosition_rad = 0;
+ protected double radialPosition_m = 0;
public BoosterSet() {
this.count = 2;
this.relativePosition = Position.BOTTOM;
+ this.angularSeparation = Math.PI * 2 / this.count;
+ }
+
+ public BoosterSet( final int _count ){
+ this();
+
+ this.count = _count;
+ this.angularSeparation = Math.PI * 2 / this.count;
}
@Override
@@ -71,7 +83,7 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
@Override
public void cloneFlightConfiguration(FlightConfigurationID oldConfigId, FlightConfigurationID newConfigId) {
- separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
+ this.separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
}
@Override
@@ -79,6 +91,21 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
BoosterSet copy = (BoosterSet) (super.copyWithOriginalID());
return copy;
}
+
+ @Override
+ public double getAngularOffset() {
+ return this.angularPosition_rad;
+ }
+
+ @Override
+ public int getInstanceCount() {
+ return this.count;
+ }
+
+ @Override
+ public double getRadialOffset() {
+ return this.radialPosition_m;
+ }
@Override
public Coordinate[] getLocation() {
@@ -102,6 +129,11 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return !isCenterline();
}
+ @Override
+ public String getPatternName(){
+ return (this.getInstanceCount() + "-ring");
+ }
+
/**
* Boosters are, by definition, not centerline.
*
@@ -130,6 +162,18 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return this.getAxialOffset();
}
+ @Override
+ public void setRadialOffset(final double radius) {
+ this.radialPosition_m = radius;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+ @Override
+ public void setAngularOffset(final double angle_rad) {
+ this.angularPosition_rad = angle_rad;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
@Override
public Coordinate[] shiftCoordinates(Coordinate[] c) {
checkState();
@@ -159,4 +203,31 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return toReturn;
}
+
+
+ @Override
+ public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
+
+ String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
+
+ buffer.append(String.format("%s %-24s %5.3f", prefix, thisLabel, this.getLength()));
+
+ if (this.isCenterline()) {
+ buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0]));
+ } else {
+ buffer.append(String.format(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
+ Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
+ Coordinate[] absCoords = this.getLocation();
+
+ for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
+ Coordinate instanceRelativePosition = relCoords[instanceNumber];
+ Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
+ buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
+ instanceRelativePosition, instanceAbsolutePosition));
+ }
+ }
+
+ }
+
+
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java
index 36822c4d0..deedd0814 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java
@@ -8,7 +8,8 @@ import net.sf.openrocket.startup.Application;
public class Bulkhead extends RadiusRingComponent {
private static final Translator trans = Application.getTranslator();
-
+
+
public Bulkhead() {
setOuterRadiusAutomatic(true);
setLength(0.002);
diff --git a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java
index 0dc9e1ee3..3f95060f9 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java
@@ -7,7 +7,7 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.Coordinate;
-public class CenteringRing extends RadiusRingComponent {
+public class CenteringRing extends RadiusRingComponent implements LineInstanceable {
public CenteringRing() {
setOuterRadiusAutomatic(true);
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Clusterable.java b/core/src/net/sf/openrocket/rocketcomponent/Clusterable.java
index fba858b1e..86ec92622 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Clusterable.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Clusterable.java
@@ -2,10 +2,13 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.util.ChangeSource;
-public interface Clusterable extends ChangeSource {
+public interface Clusterable extends ChangeSource, Instanceable {
public ClusterConfiguration getClusterConfiguration();
+
public void setClusterConfiguration(ClusterConfiguration cluster);
+
public double getClusterSeparation();
+
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java b/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java
index 9d7c139ea..fcd14176c 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java
@@ -4,11 +4,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import net.sf.openrocket.util.Coordinate;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.sf.openrocket.util.Coordinate;
+
/**
@@ -22,12 +22,6 @@ import org.slf4j.LoggerFactory;
public abstract class ComponentAssembly extends RocketComponent {
private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class);
- protected double angularPosition_rad = 0;
- protected double radialPosition_m = 0;
-
- protected int count = 1;
- protected double angularSeparation = Math.PI;
-
/**
* Sets the position of the components to POSITION_RELATIVE_AFTER.
* (Should have no effect.)
@@ -36,23 +30,11 @@ public abstract class ComponentAssembly extends RocketComponent {
super(RocketComponent.Position.AFTER);
}
-
- @Override
- public int getInstanceCount() {
- return this.count;
- }
-
- public double getAngularOffset() {
- return this.angularPosition_rad;
- }
-
-
@Override
public double getAxialOffset() {
return super.asPositionValue(this.relativePosition);
}
-
-
+
/**
* Null method (ComponentAssembly has no bounds of itself).
*/
@@ -77,11 +59,6 @@ public abstract class ComponentAssembly extends RocketComponent {
return 0;
}
- public double getRadialOffset() {
- return this.radialPosition_m;
- }
-
-
/**
* Null method (ComponentAssembly has no mass of itself).
*/
@@ -119,16 +96,7 @@ public abstract class ComponentAssembly extends RocketComponent {
public boolean isMassive() {
return false;
}
-
-
- public void setAngularOffset(final double angle_rad) {
- if (this.isCenterline()) {
- return;
- }
-
- this.angularPosition_rad = angle_rad;
- fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
- }
+
@Override
public void setAxialOffset(final double _pos) {
@@ -151,18 +119,9 @@ public abstract class ComponentAssembly extends RocketComponent {
return;
}
- this.count = _count;
- this.angularSeparation = Math.PI * 2 / this.count;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
- public void setRadialOffset(final double radius) {
- if (false == this.isCenterline()) {
- this.radialPosition_m = radius;
- fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
- }
- }
-
public void setRelativePositionMethod(final Position _newPosition) {
if (null == this.parent) {
throw new NullPointerException(" a Stage requires a parent before any positioning! ");
@@ -192,31 +151,6 @@ public abstract class ComponentAssembly extends RocketComponent {
return false;
}
-
- @Override
- public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
-
- String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
-
- buffer.append(String.format("%s %-24s %5.3f", prefix, thisLabel, this.getLength()));
-
- if (this.isCenterline()) {
- buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0]));
- } else {
- buffer.append(String.format(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
- Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
- Coordinate[] absCoords = this.getLocation();
-
- for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
- Coordinate instanceRelativePosition = relCoords[instanceNumber];
- Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
- buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
- instanceRelativePosition, instanceAbsolutePosition));
- }
- }
-
- }
-
@Override
protected void update() {
if (null == this.parent) {
diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java
index 156ad383a..228871729 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java
@@ -188,11 +188,12 @@ public class FlightConfiguration implements FlightConfigurableParameter instanceList = mount.getMotorInstance(this.fcid);
diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java
index 98213bbf3..50962fcc9 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java
@@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.MotorInstance;
@@ -23,13 +26,14 @@ import net.sf.openrocket.util.MathUtil;
*/
public class InnerTube extends ThicknessRingComponent implements Clusterable, RadialParent, MotorMount {
private static final Translator trans = Application.getTranslator();
+ private static final Logger log = LoggerFactory.getLogger(InnerTube.class);
private ClusterConfiguration cluster = ClusterConfiguration.SINGLE;
private double clusterScale = 1.0;
private double clusterRotation = 0.0;
private double overhang = 0;
- private boolean isActiveMount;
+ private boolean isActing;
private FlightConfigurationSet motors;
/**
@@ -63,6 +67,12 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return trans.get("InnerTube.InnerTube");
}
+ @Override
+ public String getPatternName() {
+ return this.cluster.getXMLName();
+ }
+
+
@Override
public boolean allowsChildren() {
return true;
@@ -133,6 +143,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return cluster.getClusterCount();
}
+ @Override
+ public void setInstanceCount( final int newCount ){
+ log.error("Programmer Error: cannot set the instance count of an "+this.getClass().getSimpleName()+" directly. Please set setClusterConfiguration(ClusterConfiguration) instead.");
+ }
+
/**
* Get the cluster scaling. A value of 1.0 indicates that the tubes are packed
* touching each other, larger values separate the tubes and smaller values
@@ -142,6 +157,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return clusterScale;
}
+ @Override
+ public boolean isCenterline() {
+ return (1 == this.getClusterCount());
+ }
+
/**
* Set the cluster scaling.
* @see #getClusterScale()
@@ -243,7 +263,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
if( null != newMotorInstance ){
newMotorInstance.setMount( this);
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
- this.setActive(true);
+ this.setMotorMount(true);
}
}
}
@@ -260,21 +280,22 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
@Override
- public void setActive(boolean _active){
- if (this.isActiveMount == _active)
+ public void setMotorMount(boolean _active){
+ if (this.isActing == _active)
return;
- this.isActiveMount = _active;
+ this.isActing = _active;
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
}
@Override
- public boolean isActive(){
- return this.isActiveMount;
+ public boolean isMotorMount(){
+ return this.isActing;
}
- //@Override
+ @Override
public boolean hasMotor() {
- return ( 0 < this.motors.size());
+ // the default MotorInstance is the EMPTY_INSTANCE. If we have more than that, then the other instance will have a motor.
+ return ( 1 < this.motors.size());
}
@Override
@@ -338,5 +359,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
copy.setName(splitName);
return copy;
}
+
+
}
\ No newline at end of file
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Instanceable.java b/core/src/net/sf/openrocket/rocketcomponent/Instanceable.java
new file mode 100644
index 000000000..c08ba43f7
--- /dev/null
+++ b/core/src/net/sf/openrocket/rocketcomponent/Instanceable.java
@@ -0,0 +1,26 @@
+package net.sf.openrocket.rocketcomponent;
+
+import net.sf.openrocket.util.Coordinate;
+
+public interface Instanceable {
+
+ /** duplicate override... especially vs shiftCoordinates...
+ // one of the two should be private
+ *
+ * @return coordinates each instance of this component
+ */
+ public Coordinate[] getLocation();
+
+ // overrides a method in RocketComponent
+ // not modifiable
+ public boolean isCenterline();
+
+ public void setInstanceCount( final int newCount );
+
+ public int getInstanceCount();
+
+ public Coordinate[] shiftCoordinates(Coordinate[] c);
+
+ public String getPatternName();
+
+}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchButton.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchButton.java
new file mode 100644
index 000000000..a9901a923
--- /dev/null
+++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchButton.java
@@ -0,0 +1,275 @@
+package net.sf.openrocket.rocketcomponent;
+
+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;
+
+/**
+ * WARNING! This class is stubbed out, partially implemented, but DEFINITELY not ready for use.
+ * @author widget (Daniel Williams)
+ *
+ */
+public abstract class LaunchButton extends ExternalComponent implements LineInstanceable {
+
+ private static final Translator trans = Application.getTranslator();
+
+ private double radius;
+ private double thickness;
+
+ private double radialDirection = 0;
+
+ private int instanceCount = 1;
+ private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
+
+ /* These are calculated when the component is first attached to any Rocket */
+ private double shiftY, shiftZ;
+
+
+
+ public LaunchButton() {
+ super(Position.MIDDLE);
+ radius = 0.01 / 2;
+ thickness = 0.001;
+ length = 0.03;
+ }
+
+
+// @Override
+// public double getOuterRadius() {
+// return radius;
+// }
+//
+// @Override
+// public void setOuterRadius(double radius) {
+// if (MathUtil.equals(this.radius, radius))
+// return;
+// this.radius = radius;
+// this.thickness = Math.min(this.thickness, this.radius);
+// clearPreset();
+// fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+// }
+
+// @Override
+// public double getInnerRadius() {
+// return radius - thickness;
+// }
+//
+// @Override
+// public void setInnerRadius(double innerRadius) {
+// setOuterRadius(innerRadius + thickness);
+// }
+//
+// @Override
+// public double getThickness() {
+// return thickness;
+// }
+
+ public void setThickness(double thickness) {
+ if (MathUtil.equals(this.thickness, thickness))
+ return;
+ this.thickness = MathUtil.clamp(thickness, 0, radius);
+ clearPreset();
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+ public double getRadialDirection() {
+ return radialDirection;
+ }
+
+ public void setRadialDirection(double direction) {
+ direction = MathUtil.reduce180(direction);
+ if (MathUtil.equals(this.radialDirection, direction))
+ return;
+ this.radialDirection = direction;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+
+ public void setLength(double length) {
+ if (MathUtil.equals(this.length, length))
+ return;
+ this.length = length;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+ @Override
+ public boolean isCenterline() {
+ return false;
+ }
+
+
+ @Override
+ public void setRelativePosition(RocketComponent.Position position) {
+ super.setRelativePosition(position);
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+ @Override
+ public void setPositionValue(double value) {
+ super.setPositionValue(value);
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+
+
+ @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);
+
+ for (int i = 0; i < array.length; i++) {
+ array[i] = array[i].add(0, shiftY, shiftZ);
+ }
+
+ return array;
+ }
+
+
+ @Override
+ public void componentChanged(ComponentChangeEvent e) {
+ super.componentChanged(e);
+
+ /*
+ * shiftY and shiftZ must be computed here since calculating them
+ * in shiftCoordinates() would cause an infinite loop due to .toRelative
+ */
+ RocketComponent body;
+ double parentRadius;
+
+ for (body = this.getParent(); body != null; body = body.getParent()) {
+ if (body instanceof SymmetricComponent)
+ break;
+ }
+
+ if (body == null) {
+ parentRadius = 0;
+ } else {
+ SymmetricComponent s = (SymmetricComponent) body;
+ double x1, x2;
+ x1 = this.toRelative(Coordinate.NUL, body)[0].x;
+ x2 = this.toRelative(new Coordinate(length, 0, 0), body)[0].x;
+ x1 = MathUtil.clamp(x1, 0, body.getLength());
+ x2 = MathUtil.clamp(x2, 0, body.getLength());
+ parentRadius = Math.max(s.getRadius(x1), s.getRadius(x2));
+ }
+
+ shiftY = Math.cos(radialDirection) * (parentRadius + radius);
+ shiftZ = Math.sin(radialDirection) * (parentRadius + radius);
+
+ // System.out.println("Computed shift: y="+shiftY+" z="+shiftZ);
+ }
+
+
+
+
+ @Override
+ public double getComponentVolume() {
+ return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius - thickness));
+ }
+
+ @Override
+ public Collection getComponentBounds() {
+ ArrayList set = new ArrayList();
+ addBound(set, 0, radius);
+ addBound(set, length, radius);
+ return set;
+ }
+
+ @Override
+ public Coordinate getComponentCG() {
+ return new Coordinate(length / 2, 0, 0, getComponentMass());
+ }
+
+ @Override
+ public String getComponentName() {
+ // Launch Button
+ return trans.get("LaunchButton.LaunchButton");
+ }
+
+ @Override
+ public double getLongitudinalUnitInertia() {
+ // 1/12 * (3 * (r2^2 + r1^2) + h^2)
+// return (3 * (MathUtil.pow2(getOuterRadius()) + MathUtil.pow2(getInnerRadius())) + MathUtil.pow2(getLength())) / 12;
+ return 0.0;
+ }
+
+ @Override
+ public double getRotationalUnitInertia() {
+ // 1/2 * (r1^2 + r2^2)
+// return (MathUtil.pow2(getInnerRadius()) + MathUtil.pow2(getOuterRadius())) / 2;
+ return 0.0;
+ }
+
+ @Override
+ public boolean allowsChildren() {
+ return false;
+ }
+
+ @Override
+ public boolean isCompatible(Class extends RocketComponent> type) {
+ // Allow nothing to be attached to a LaunchButton
+ return false;
+ }
+
+
+
+ @Override
+ public double getInstanceSeparation(){
+ return this.instanceSeparation;
+ }
+
+ @Override
+ public void setInstanceSeparation(final double _separation){
+ this.instanceSeparation = _separation;
+ }
+
+ @Override
+ public void setInstanceCount( final int newCount ){
+ if( 0 < newCount ){
+ this.instanceCount = newCount;
+ }
+ }
+
+ @Override
+ public int getInstanceCount(){
+ return this.instanceCount;
+ }
+
+ @Override
+ public String getPatternName(){
+ return (this.getInstanceCount() + "-Line");
+ }
+
+}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
index 414c561e1..35c888344 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java
@@ -12,7 +12,7 @@ import net.sf.openrocket.util.MathUtil;
-public class LaunchLug extends ExternalComponent implements Coaxial {
+public class LaunchLug extends ExternalComponent implements Coaxial, LineInstanceable {
private static final Translator trans = Application.getTranslator();
@@ -21,6 +21,9 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
private double radialDirection = 0;
+ private int instanceCount = 1;
+ private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
+
/* These are calculated when the component is first attached to any Rocket */
private double shiftY, shiftZ;
@@ -95,7 +98,10 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
}
-
+ @Override
+ public boolean isCenterline() {
+ return false;
+ }
@Override
@@ -232,4 +238,33 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
return false;
}
+
+
+ @Override
+ public double getInstanceSeparation(){
+ return this.instanceSeparation;
+ }
+
+ @Override
+ public void setInstanceSeparation(final double _separation){
+ this.instanceSeparation = _separation;
+ }
+
+ @Override
+ public void setInstanceCount( final int newCount ){
+ if( 0 < newCount ){
+ this.instanceCount = newCount;
+ }
+ }
+
+ @Override
+ public int getInstanceCount(){
+ return this.instanceCount;
+ }
+
+ @Override
+ public String getPatternName(){
+ return (this.getInstanceCount() + "-Line");
+ }
+
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/LineInstanceable.java b/core/src/net/sf/openrocket/rocketcomponent/LineInstanceable.java
new file mode 100644
index 000000000..a9c2131bc
--- /dev/null
+++ b/core/src/net/sf/openrocket/rocketcomponent/LineInstanceable.java
@@ -0,0 +1,9 @@
+package net.sf.openrocket.rocketcomponent;
+
+public interface LineInstanceable extends Instanceable {
+
+ public double getInstanceSeparation();
+
+ public void setInstanceSeparation(final double radius);
+
+}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/MotorConfigurationSet.java b/core/src/net/sf/openrocket/rocketcomponent/MotorConfigurationSet.java
index 66b537c9c..a7df5cdea 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/MotorConfigurationSet.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/MotorConfigurationSet.java
@@ -3,7 +3,7 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.motor.MotorInstance;
/**
- * FlightConfiguration implementation that prevents changing the default value.
+ * FlightConfigurationSet for motors.
* This is used for motors, where the default value is always no motor.
*/
public class MotorConfigurationSet extends FlightConfigurationSet {
@@ -15,7 +15,7 @@ public class MotorConfigurationSet extends FlightConfigurationSet
}
/**
- * Construct a copy of an existing FlightConfigurationImpl.
+ * Construct a copy of an existing FlightConfigurationSet.
*
* @param flightConfiguration another flightConfiguration to copy data from.
* @param component the rocket component on which events are fired when the parameter values are changed
diff --git a/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java b/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java
index bdfdfeefd..c4f97b815 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java
@@ -10,23 +10,28 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
/**
- * is this mount currently configured to carry a motor?
+ * Does this mount contain at least one motor?
*
* @return whether the component holds a motor
*/
public boolean hasMotor();
/**
- * Set whether the component is acting as a motor mount.
+ * Programmatically : implementing classes will always be (x instanceof MotorMount)
+ * The component may potentially act as a mount, or just a structural component.
+ * This flag indicates how the component behaves.
+ *
+ * @param acting if the component should behave like a motor mount. False if it's structural only.
*/
- public void setActive(boolean mount);
-
+ public void setMotorMount(boolean acting);
+
/**
- * Is the component currently acting as a motor mount.
- *
- * @return if the motor mount is turned on
+ * Programmatically : implementing classes will always be (x instanceof MotorMount)
+ * This flag indicates whether the component is acting as a motor mount, or just a structural component
+ *
+ * @return true if the component is acting as a motor mount
*/
- public boolean isActive();
+ public boolean isMotorMount();
/**
* Get all motors configured for this mount.
diff --git a/core/src/net/sf/openrocket/rocketcomponent/PodSet.java b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java
index a9bb3a293..1533a692c 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/PodSet.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java
@@ -8,13 +8,16 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PodSet extends ComponentAssembly implements OutsideComponent {
+public class PodSet extends ComponentAssembly implements RingInstanceable, OutsideComponent {
private static final Translator trans = Application.getTranslator();
- private static final Logger log = LoggerFactory.getLogger(PodSet.class);
+ //private static final Logger log = LoggerFactory.getLogger(PodSet.class);
+
+ protected int count = 1;
+
+ protected double angularSeparation = Math.PI;
+ protected double angularPosition_rad = 0;
+ protected double radialPosition_m = 0;
public PodSet() {
this.count = 2;
@@ -151,6 +154,22 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
return returnValue;
}
+
+ @Override
+ public double getAngularOffset() {
+ return this.angularPosition_rad;
+ }
+
+ @Override
+ public String getPatternName(){
+ return (this.getInstanceCount() + "-ring");
+ }
+
+ @Override
+ public double getRadialOffset() {
+ return this.radialPosition_m;
+ }
+
@Override
public Coordinate[] shiftCoordinates(Coordinate[] c) {
@@ -190,5 +209,17 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
// }
return buf;
}
+
+ @Override
+ public void setAngularOffset(double angle_rad) {
+ this.angularPosition_rad = angle_rad;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
+
+ @Override
+ public void setRadialOffset(double radius_m) {
+ this.radialPosition_m = radius_m;
+ fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
+ }
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java
index 9e2c16bc1..d96467a15 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java
@@ -16,18 +16,21 @@ import net.sf.openrocket.util.MathUtil;
*
* @author Sampo Niskanen
*/
-public abstract class RingComponent extends StructuralComponent implements Coaxial {
+public abstract class RingComponent extends StructuralComponent implements Coaxial, LineInstanceable {
protected boolean outerRadiusAutomatic = false;
protected boolean innerRadiusAutomatic = false;
- private double radialDirection = 0;
- private double radialPosition = 0;
+ protected double radialDirection = 0;
+ protected double radialPosition = 0;
private double shiftY = 0;
private double shiftZ = 0;
+ protected int instanceCount = 1;
+ // front-front along the positive rocket axis. i.e. [1,0,0];
+ protected double instanceSeparation = 0;
@Override
@@ -218,4 +221,33 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
return ringRotationalUnitInertia(getOuterRadius(), getInnerRadius());
}
+
+
+ @Override
+ public double getInstanceSeparation(){
+ return this.instanceSeparation;
+ }
+
+ @Override
+ public void setInstanceSeparation(final double _separation){
+ this.instanceSeparation = _separation;
+ }
+
+ @Override
+ public void setInstanceCount( final int newCount ){
+ if( 0 < newCount ){
+ this.instanceCount = newCount;
+ }
+ }
+
+ @Override
+ public int getInstanceCount(){
+ return this.instanceCount;
+ }
+
+ @Override
+ public String getPatternName(){
+ return (this.getInstanceCount() + "-Line");
+ }
+
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/RingInstanceable.java b/core/src/net/sf/openrocket/rocketcomponent/RingInstanceable.java
new file mode 100644
index 000000000..2b57af619
--- /dev/null
+++ b/core/src/net/sf/openrocket/rocketcomponent/RingInstanceable.java
@@ -0,0 +1,13 @@
+package net.sf.openrocket.rocketcomponent;
+
+public interface RingInstanceable extends Instanceable {
+
+ public double getAngularOffset();
+
+ public double getRadialOffset();
+
+ public void setAngularOffset(final double radius);
+
+ public void setRadialOffset(final double radius);
+
+}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java
index c6702e91c..98bcc450a 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java
@@ -582,7 +582,7 @@ public class Rocket extends RocketComponent {
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
- if (!mount.isActive())
+ if (!mount.isMotorMount())
continue;
if (mount.getMotorInstance(fcid).getMotor() != null) {
return true;
diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java
index 1a04f3a01..f17e60fcd 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java
@@ -270,7 +270,15 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
//////////// Methods that may be overridden ////////////
-
+ /**
+ * This enables one-line testing if a component is on the rocket center-line or not.
+ *
+ * @return indicates if this component is centered around the rocket's centerline
+ */
+ public boolean isCenterline() {
+ return true;
+ }
+
/**
* Shift the coordinates in the array corresponding to radial movement. A component
@@ -958,15 +966,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
mutex.verify();
return this.asPositionValue(this.relativePosition);
}
-
- /**
- *
- * @return always returns false for base components. This enables one-line testing if a component is on the rocket center-line or not.
- */
- public boolean isCenterline() {
- return true;
- }
-
+
public boolean isAncestor(final RocketComponent testComp) {
RocketComponent curComp = testComp.parent;
while (curComp != null) {
diff --git a/core/src/net/sf/openrocket/rocketvisitors/ListMotorMounts.java b/core/src/net/sf/openrocket/rocketvisitors/ListMotorMounts.java
index 9cbe4860c..f86960e5c 100644
--- a/core/src/net/sf/openrocket/rocketvisitors/ListMotorMounts.java
+++ b/core/src/net/sf/openrocket/rocketvisitors/ListMotorMounts.java
@@ -11,7 +11,7 @@ public class ListMotorMounts extends ListComponents {
@Override
protected void doAction(RocketComponent visitable) {
- if (visitable instanceof MotorMount && ((MotorMount) visitable).isActive()) {
+ if (visitable instanceof MotorMount && ((MotorMount) visitable).isMotorMount()) {
components.add(visitable);
}
}
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java
index 4b21d5aa0..66e551581 100644
--- a/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java
@@ -99,11 +99,11 @@ public class BodyTubeHandlerTest extends RocksimTestBase {
warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings);
- Assert.assertTrue(component.isActive());
+ Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings);
- Assert.assertFalse(component.isActive());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
- Assert.assertFalse(component.isActive());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java
index 75cb7141e..b361c33b2 100644
--- a/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java
@@ -98,11 +98,11 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase {
warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings);
- Assert.assertTrue(component.isActive());
+ Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings);
- Assert.assertFalse(component.isActive());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
- Assert.assertFalse(component.isActive());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
diff --git a/swing/src/net/sf/openrocket/gui/configdialog/FinSetConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/FinSetConfig.java
index b93140423..d881f9ac9 100644
--- a/swing/src/net/sf/openrocket/gui/configdialog/FinSetConfig.java
+++ b/swing/src/net/sf/openrocket/gui/configdialog/FinSetConfig.java
@@ -240,7 +240,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
RocketComponent rocketComponent = iter.next();
if (rocketComponent instanceof InnerTube) {
InnerTube it = (InnerTube) rocketComponent;
- if (it.isActive()) {
+ if (it.isMotorMount()) {
double depth = ((Coaxial) parent).getOuterRadius() - it.getOuterRadius();
//Set fin tab depth
if (depth >= 0.0d) {
diff --git a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java
index 26bc10ff0..1a3f0c80c 100644
--- a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java
+++ b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java
@@ -40,7 +40,7 @@ public class MotorConfig extends JPanel {
BooleanModel model;
- model = new BooleanModel(motorMount, "Active");
+ model = new BooleanModel(motorMount, "MotorMount");
JCheckBox check = new JCheckBox(model);
////This component is a motor mount
check.setText(trans.get("MotorCfg.checkbox.compmotormount"));
@@ -64,7 +64,6 @@ public class MotorConfig extends JPanel {
panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel");
-
// Select ignition event
//// Ignition at:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), "");
@@ -113,11 +112,11 @@ public class MotorConfig extends JPanel {
// Set enabled status
- setDeepEnabled(panel, motorMount.isActive());
+ setDeepEnabled(panel, motorMount.isMotorMount());
check.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
- setDeepEnabled(panel, mount.isActive());
+ setDeepEnabled(panel, mount.isMotorMount());
}
});
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorMountTableModel.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorMountTableModel.java
index 4e033db5a..fe9fbbd8c 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorMountTableModel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorMountTableModel.java
@@ -80,7 +80,7 @@ class MotorMountTableModel extends AbstractTableModel implements ComponentChange
public Object getValueAt(int row, int column) {
switch (column) {
case 0:
- return new Boolean(potentialMounts.get(row).isActive());
+ return new Boolean(potentialMounts.get(row).isMotorMount());
case 1:
return potentialMounts.get(row).toString();
diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java
index b73910a71..ef1e59163 100644
--- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java
+++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java
@@ -141,7 +141,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel
@Override
protected boolean includeComponent(MotorMount component) {
- return component.isActive();
+ return component.isMotorMount();
}
};
diff --git a/swing/src/net/sf/openrocket/gui/print/DesignReport.java b/swing/src/net/sf/openrocket/gui/print/DesignReport.java
index b3463b04f..3cd144ba8 100644
--- a/swing/src/net/sf/openrocket/gui/print/DesignReport.java
+++ b/swing/src/net/sf/openrocket/gui/print/DesignReport.java
@@ -356,11 +356,11 @@ public class DesignReport {
topBorder = true;
}
- if (c instanceof MotorMount && ((MotorMount) c).isActive()) {
+ if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
MotorMount mount = (MotorMount) c;
// TODO: refactor this... it's redundant with containing if, and could probably be simplified
- if (mount.isActive() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) {
+ if (mount.isMotorMount() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) {
Motor motor = mount.getMotorInstance(motorId).getMotor();
int motorCount = mount.getMotorCount();