diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java index c0222b4f5..a5607615e 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java @@ -145,7 +145,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC public void setStageNumber(final int newStageNumber) { this.stageNumber = newStageNumber; } - + @Override protected StringBuilder toDebugDetail() { StringBuilder buf = super.toDebugDetail(); @@ -197,7 +197,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC if( 1 == getInstanceCount()){ buffer.append(String.format("%-40s| %5.3f; %24s; %24s;", indent+this.getName()+" (# "+this.getStageNumber()+")", this.getLength(), this.getPosition(), this.getComponentLocations()[0])); - buffer.append(String.format("len: %6.4f )(offset: %4.1f via: %s )\n", this.getLength(), this.getAxialOffset(), this.axialMethod.name )); + buffer.append(String.format("len: %6.4f )(offset: %4.1f via: %s )\n", this.getLength(), this.getAxialOffset(), this.axialMethod.name() )); }else{ buffer.append(String.format("%-40s|(len: %6.4f )(offset: %4.1f via: %s)\n", (indent+this.getName()+"(# "+this.getStageNumber()+")"), this.getLength(), this.getAxialOffset(), this.axialMethod.name() )); for (int instanceNumber = 0; instanceNumber < this.getInstanceCount(); instanceNumber++) { diff --git a/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java b/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java index f6bb62b95..16c40b0ac 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ComponentAssembly.java @@ -8,6 +8,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sf.openrocket.rocketcomponent.position.AxialMethod; +import net.sf.openrocket.rocketcomponent.position.AxialPositionable; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; @@ -21,7 +22,7 @@ import net.sf.openrocket.util.Coordinate; * * @author Sampo Niskanen */ -public abstract class ComponentAssembly extends RocketComponent { +public abstract class ComponentAssembly extends RocketComponent implements AxialPositionable { private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class); /** @@ -131,17 +132,18 @@ public abstract class ComponentAssembly extends RocketComponent { super.setAxialOffset(this.axialMethod, _pos); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } - - public void setRelativePositionMethod(final AxialMethod _newPosition) { + + @Override + public void setAxialMethod( final AxialMethod newMethod ) { if (null == this.parent) { throw new NullPointerException(" a Stage requires a parent before any positioning! "); } if ((this instanceof ParallelStage ) || ( this instanceof PodSet )){ - if (AxialMethod.AFTER == _newPosition) { + if (AxialMethod.AFTER == newMethod) { log.warn("Stages (or Pods) cannot be relative to other stages via AFTER! Ignoring."); super.setAxialMethod(AxialMethod.TOP); } else { - super.setAxialMethod(_newPosition); + super.setAxialMethod(newMethod); } }else if( this.getClass().equals( AxialStage.class)){ // Centerline stages must be set via AFTER-- regardless of what was requested: diff --git a/core/src/net/sf/openrocket/rocketcomponent/ParallelStage.java b/core/src/net/sf/openrocket/rocketcomponent/ParallelStage.java index f84676a35..daf79abda 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ParallelStage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ParallelStage.java @@ -22,7 +22,7 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo protected double angleSeparation = Math.PI; protected double angleOffset_rad = 0; - protected RadiusMethod radiusMethod = RadiusMethod.SURFACE; + protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE; protected double radiusOffset_m = 0; public ParallelStage() { diff --git a/core/src/net/sf/openrocket/rocketcomponent/PodSet.java b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java index fed1cd7c3..4f159fbfd 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/PodSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java @@ -25,7 +25,7 @@ public class PodSet extends ComponentAssembly implements RingInstanceable { // angle to the first pod protected double angleOffset_rad = 0; - protected RadiusMethod radiusMethod = RadiusMethod.SURFACE; + protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE; protected double radiusOffset_m = 0; public PodSet() { @@ -155,7 +155,7 @@ public class PodSet extends ComponentAssembly implements RingInstanceable { if (this.isAfter()){ // remember the implicit (this instanceof Stage) - throw new BugException("found a Stage on centerline, but not positioned as AFTER. Please fix this! " + this.getName() + " is " + this.getAxialMethod().name ); + throw new BugException("found a pod positioned via: AFTER, but is not on the centerline?!: " + this.getName() + " is " + this.getAxialMethod().name() ); } else { returnValue = super.asPositionValue(this.axialMethod); } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index 57874f89b..050367c8f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -967,7 +967,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab }else if( AxialMethod.BOTTOM == asMethod) { result = this.position.x + ( this.length - parentLength); }else { - throw new BugException("Unknown position type: " + asMethod.name); + throw new BugException("Unknown position type: " + asMethod.name() ); } return result; @@ -2176,7 +2176,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); buf.append(" >> Dumping Detailed Information from: " + stackTrace[1].getMethodName() + "\n"); buf.append(" current Component: " + this.getName() + " ofClass: " + this.getClass().getSimpleName() + "\n"); - buf.append(" offset: " + this.axialOffset + " via: " + this.axialMethod.name + " => " + this.getAxialOffset() + "\n"); + buf.append(" offset: " + this.axialOffset + " via: " + this.axialMethod.name() + " => " + this.getAxialOffset() + "\n"); buf.append(" thisCenterX: " + this.position.x + "\n"); buf.append(" this length: " + this.length + "\n"); return buf; diff --git a/core/src/net/sf/openrocket/rocketcomponent/position/AngleMethod.java b/core/src/net/sf/openrocket/rocketcomponent/position/AngleMethod.java index ace87b62d..59395da17 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/position/AngleMethod.java +++ b/core/src/net/sf/openrocket/rocketcomponent/position/AngleMethod.java @@ -46,15 +46,20 @@ public enum AngleMethod implements DistanceMethod { }; public static final AngleMethod[] choices(){ - return new AngleMethod[]{ AngleMethod.RELATIVE, AngleMethod.FIXED }; + return new AngleMethod[]{ AngleMethod.RELATIVE }; } - public final String name; + public final String description; - private AngleMethod( final String _name ) { - this.name= _name; + private AngleMethod( final String descr ) { + this.description= descr; } + @Override + public String toString() { + return description; + } + @Override public boolean clampToZero() { return true; } diff --git a/core/src/net/sf/openrocket/rocketcomponent/position/AxialMethod.java b/core/src/net/sf/openrocket/rocketcomponent/position/AxialMethod.java index 74304dc48..c3db78e07 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/position/AxialMethod.java +++ b/core/src/net/sf/openrocket/rocketcomponent/position/AxialMethod.java @@ -35,13 +35,18 @@ public enum AxialMethod implements DistanceMethod { public static final AxialMethod[] axialOffsetMethods = { TOP, MIDDLE, BOTTOM }; - public final String name; + public final String description; - private AxialMethod( final String _name ) { - this.name=_name; + private AxialMethod( final String newDescription ) { + this.description=newDescription; } @Override public boolean clampToZero() { return true; } + @Override + public String toString() { + return description; + } + } diff --git a/core/src/net/sf/openrocket/rocketcomponent/position/RadiusMethod.java b/core/src/net/sf/openrocket/rocketcomponent/position/RadiusMethod.java index 0201fec67..eccba4d08 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/position/RadiusMethod.java +++ b/core/src/net/sf/openrocket/rocketcomponent/position/RadiusMethod.java @@ -55,15 +55,20 @@ public enum RadiusMethod implements DistanceMethod { }; public static final RadiusMethod[] choices(){ - return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE, RadiusMethod.SURFACE }; + return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE }; } - public final String name; + public final String description; // ============= - private RadiusMethod( final String _name ) { - this.name = _name; + private RadiusMethod( final String descr ) { + this.description = descr; + } + + @Override + public String toString() { + return description; } @Override diff --git a/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java b/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java index 965b07f3c..ccd83a88a 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java @@ -173,7 +173,7 @@ public class ParallelStageTest extends BaseTestCase { // without making the rocket 'external' and the Stage should be restricted to AFTER positioning. - sustainer.setRelativePositionMethod(AxialMethod.ABSOLUTE); + sustainer.setAxialMethod(AxialMethod.ABSOLUTE); assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isAfter(), equalTo(true)); assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getAxialMethod(), equalTo(AxialMethod.AFTER)); @@ -613,7 +613,7 @@ public class ParallelStageTest extends BaseTestCase { boosterA.setAxialOffset(AxialMethod.TOP, targetOffset); - boosterB.setRelativePositionMethod(AxialMethod.TOP); + boosterB.setAxialMethod(AxialMethod.TOP); boosterB.setAxialOffset(targetOffset); String treeDump = rocket.toDebugTree(); diff --git a/swing/src/net/sf/openrocket/gui/configdialog/ComponentAssemblyConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/ComponentAssemblyConfig.java index e310cf2b7..eaea5a57f 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/ComponentAssemblyConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/ComponentAssemblyConfig.java @@ -64,12 +64,12 @@ public class ComponentAssemblyConfig extends RocketComponentConfig { motherPanel.add(radiusUnitSelector, "growx 1, wrap"); // autoRadOffsModel.addEnableComponent(radiusUnitSelector, false); - // set location angle around the primary stage - JLabel angleMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Angle.Label")); - motherPanel.add( angleMethodLabel, "align left"); - EnumModel angleMethodModel = new EnumModel( boosters, "AngleMethod", AngleMethod.choices() ); - final JComboBox angleMethodCombo = new JComboBox( angleMethodModel ); - motherPanel.add( angleMethodCombo, "align left, wrap"); +// // set location angle around the primary stage +// JLabel angleMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Angle.Label")); +// motherPanel.add( angleMethodLabel, "align left"); +// EnumModel angleMethodModel = new EnumModel( boosters, "AngleMethod", AngleMethod.choices() ); +// final JComboBox angleMethodCombo = new JComboBox( angleMethodModel ); +// motherPanel.add( angleMethodCombo, "align left, wrap"); JLabel angleLabel = new JLabel(trans.get("StageConfig.parallel.angle")); motherPanel.add( angleLabel, "align left");