diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 3bcbb0c0d..7637dbaaa 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -670,6 +670,11 @@ compaddbuttons.Coupler = Coupler compaddbuttons.Centeringring = Centering\nring compaddbuttons.Bulkhead = Bulkhead compaddbuttons.Engineblock = Engine\nblock +compaddbuttons.assembly = Assembly Components +compaddbuttons.newBooster.lbl = New\nBoosters +compaddbuttons.newBooster.ttip = Add a new set booster stage to the rocket design. +compaddbuttons.newPods.lbl = New Pods +compaddbuttons.newPods.ttip = Add a new set of pods to the rocket design. compaddbuttons.Massobjects = Mass objects compaddbuttons.Parachute = Parachute compaddbuttons.Streamer = Streamer @@ -1382,7 +1387,6 @@ Stage.SeparationEvent.EJECTION = Current stage ejection charge Stage.SeparationEvent.LAUNCH = Launch Stage.SeparationEvent.NEVER = Never -Stage.parallel.toggle = Make this Stage Parallel Stage.parallel.radius = Radial Distance Stage.parallel.angle = Angle Stage.parallel.count = Number of Boosters @@ -1390,6 +1394,10 @@ Stage.parallel.rotation = Rotation Stage.parallel.componentname = Relative to Stage Stage.parallel.offset = Offset Value +BoosterSet.BoosterSet = Booster Set + +PodSet.PodSet = Pod Set + ! BodyTube BodyTube.BodyTube = Body tube ! TubeCoupler @@ -1463,6 +1471,8 @@ ComponentIcons.Parachute = Parachute ComponentIcons.Streamer = Streamer ComponentIcons.Shockcord = Shock cord ComponentIcons.Masscomponent = Mass component +ComponentIcons.Boosters = Booster Stage +ComponentIcons.Pods = Pod Stage ComponentIcons.disabled = (disabled) ComponentIcons.Altimeter = Altimeter ComponentIcons.Flightcomputer = Flight computer diff --git a/core/resources/pix/componenticons/boosters-large.png b/core/resources/pix/componenticons/boosters-large.png new file mode 100644 index 000000000..ece2d65e4 Binary files /dev/null and b/core/resources/pix/componenticons/boosters-large.png differ diff --git a/core/resources/pix/componenticons/boosters-small.png b/core/resources/pix/componenticons/boosters-small.png new file mode 100644 index 000000000..205882901 Binary files /dev/null and b/core/resources/pix/componenticons/boosters-small.png differ diff --git a/core/resources/pix/componenticons/pods-large.png b/core/resources/pix/componenticons/pods-large.png new file mode 100644 index 000000000..0d95a5ca4 Binary files /dev/null and b/core/resources/pix/componenticons/pods-large.png differ diff --git a/core/resources/pix/componenticons/pods-small.png b/core/resources/pix/componenticons/pods-small.png new file mode 100644 index 000000000..d1b13765d Binary files /dev/null and b/core/resources/pix/componenticons/pods-small.png differ diff --git a/core/src/net/sf/openrocket/document/OpenRocketDocumentFactory.java b/core/src/net/sf/openrocket/document/OpenRocketDocumentFactory.java index e649a06d0..eefef3e8e 100644 --- a/core/src/net/sf/openrocket/document/OpenRocketDocumentFactory.java +++ b/core/src/net/sf/openrocket/document/OpenRocketDocumentFactory.java @@ -2,7 +2,7 @@ package net.sf.openrocket.document; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.startup.Application; public class OpenRocketDocumentFactory { @@ -11,7 +11,7 @@ public class OpenRocketDocumentFactory { public static OpenRocketDocument createNewRocket() { Rocket rocket = new Rocket(); - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); //// Sustainer stage.setName(trans.get("BasicFrame.StageName.Sustainer")); rocket.addChild(stage); diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java index c22099caa..dfd2c4430 100644 --- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java @@ -22,7 +22,7 @@ import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.TubeCoupler; import net.sf.openrocket.rocketcomponent.TubeFinSet; import net.sf.openrocket.simulation.FlightData; @@ -284,8 +284,8 @@ public class OpenRocketSaver extends RocketSaver { return FILE_VERSION_DIVISOR + 6; } } - if (c instanceof Stage) { - Stage stage = (Stage) c; + if (c instanceof AxialStage) { + AxialStage stage = (AxialStage) c; if (stage.getStageSeparationConfiguration().size() > 0) { return FILE_VERSION_DIVISOR + 6; } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/ComponentParameterHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/ComponentParameterHandler.java index 01e2bb3c7..a23673e72 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/ComponentParameterHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/ComponentParameterHandler.java @@ -13,7 +13,7 @@ import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; /** * A handler that populates the parameters of a previously constructed rocket component. @@ -69,11 +69,11 @@ class ComponentParameterHandler extends AbstractElementHandler { return new DeploymentConfigurationHandler( (RecoveryDevice) component, context ); } if ( element.equals("separationconfiguration")) { - if ( !(component instanceof Stage) ) { + if ( !(component instanceof AxialStage) ) { warnings.add(Warning.fromString("Illegal component defined as stage.")); return null; } - return new StageSeparationConfigurationHandler( (Stage) component, context ); + return new StageSeparationConfigurationHandler( (AxialStage) component, context ); } return PlainTextHandler.INSTANCE; 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 76f51942f..6ed07f5dc 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java @@ -31,7 +31,7 @@ import net.sf.openrocket.rocketcomponent.RingComponent; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.ShockCord; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.Streamer; import net.sf.openrocket.rocketcomponent.StructuralComponent; @@ -86,7 +86,7 @@ class DocumentConfig { constructors.put("streamer", Streamer.class.getConstructor(new Class[0])); // Other - constructors.put("stage", Stage.class.getConstructor(new Class[0])); + constructors.put("stage", AxialStage.class.getConstructor(new Class[0])); } catch (NoSuchMethodException e) { throw new BugException( @@ -400,17 +400,17 @@ class DocumentConfig { // Stage setters.put("Stage:separationevent", new EnumSetter( - Reflection.findMethod(Stage.class, "getStageSeparationConfiguration"), + Reflection.findMethod(AxialStage.class, "getStageSeparationConfiguration"), Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationEvent", StageSeparationConfiguration.SeparationEvent.class), StageSeparationConfiguration.SeparationEvent.class)); setters.put("Stage:separationdelay", new DoubleSetter( - Reflection.findMethod(Stage.class, "getStageSeparationConfiguration"), + Reflection.findMethod(AxialStage.class, "getStageSeparationConfiguration"), Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class))); - setters.put("Stage:outside", new BooleanSetter(Reflection.findMethod(Stage.class, "setOutside", boolean.class))); - setters.put("Stage:relativeto", new IntSetter(Reflection.findMethod(Stage.class, "setRelativeToStage", int.class))); - setters.put("Stage:instancecount", new IntSetter(Reflection.findMethod(Stage.class, "setInstanceCount", int.class))); - setters.put("Stage:radialoffset", new DoubleSetter(Reflection.findMethod(Stage.class, "setRadialOffset", double.class))); - setters.put("Stage:angleoffset", new DoubleSetter(Reflection.findMethod(Stage.class, "setAngularOffset", double.class))); + setters.put("Stage:outside", new BooleanSetter(Reflection.findMethod(AxialStage.class, "setOutside", boolean.class))); + setters.put("Stage:relativeto", new IntSetter(Reflection.findMethod(AxialStage.class, "setRelativeToStage", int.class))); + setters.put("Stage:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class))); + setters.put("Stage:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class))); + setters.put("Stage:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class))); } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/PositionSetter.java b/core/src/net/sf/openrocket/file/openrocket/importt/PositionSetter.java index 77c689a60..bc7744246 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/PositionSetter.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/PositionSetter.java @@ -9,7 +9,7 @@ import net.sf.openrocket.rocketcomponent.InternalComponent; import net.sf.openrocket.rocketcomponent.LaunchLug; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent.Position; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.TubeFinSet; class PositionSetter implements Setter { @@ -45,8 +45,8 @@ class PositionSetter implements Setter { } else if (c instanceof TubeFinSet) { ((TubeFinSet) c).setRelativePosition(type); c.setAxialOffset(pos); - } else if (c instanceof Stage) { - ((Stage) c).setRelativePositionMethod(type); + } else if (c instanceof AxialStage) { + ((AxialStage) c).setRelativePositionMethod(type); c.setAxialOffset(pos); } else { warnings.add(Warning.FILE_INVALID_PARAMETER); diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/StageSeparationConfigurationHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/StageSeparationConfigurationHandler.java index a349c91df..c22455287 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/StageSeparationConfigurationHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/StageSeparationConfigurationHandler.java @@ -8,19 +8,19 @@ import net.sf.openrocket.file.DocumentLoadingContext; import net.sf.openrocket.file.simplesax.AbstractElementHandler; import net.sf.openrocket.file.simplesax.ElementHandler; import net.sf.openrocket.file.simplesax.PlainTextHandler; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration.SeparationEvent; import org.xml.sax.SAXException; class StageSeparationConfigurationHandler extends AbstractElementHandler { - private final Stage stage; + private final AxialStage stage; private SeparationEvent event = null; private double delay = Double.NaN; - public StageSeparationConfigurationHandler(Stage stage, DocumentLoadingContext context) { + public StageSeparationConfigurationHandler(AxialStage stage, DocumentLoadingContext context) { this.stage = stage; } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java index c5d4f5327..5d74199e9 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java @@ -7,7 +7,7 @@ import java.util.Locale; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; public class StageSaver extends ComponentAssemblySaver { @@ -27,7 +27,7 @@ public class StageSaver extends ComponentAssemblySaver { @Override protected void addParams(RocketComponent c, List elements) { super.addParams(c, elements); - Stage stage = (Stage) c; + AxialStage stage = (AxialStage) c; if (stage.getOutside()) { elements.addAll(this.addStageReplicationParams(stage)); @@ -60,7 +60,7 @@ public class StageSaver extends ComponentAssemblySaver { } } - private Collection addStageReplicationParams(final Stage currentStage) { + private Collection addStageReplicationParams(final AxialStage currentStage) { List elementsToReturn = new ArrayList(); final String instCt_tag = "instancecount"; final String radoffs_tag = "radialoffset"; diff --git a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java index 60dfec83f..a6e1f7b85 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java @@ -17,7 +17,7 @@ import net.sf.openrocket.masscalc.BasicMassCalculator; import net.sf.openrocket.masscalc.MassCalculator; import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,7 +125,7 @@ public class RocksimSaver extends RocketSaver { return result; } - private StageDTO toStageDTO(Stage stage, RocketDesignDTO designDTO, int stageNumber) { + private StageDTO toStageDTO(AxialStage stage, RocketDesignDTO designDTO, int stageNumber) { return new StageDTO(stage, designDTO, stageNumber); } diff --git a/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java index e0303e7fc..e6afdd355 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java @@ -4,7 +4,7 @@ import net.sf.openrocket.file.rocksim.RocksimCommonConstants; import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.util.ArrayList; @@ -40,7 +40,7 @@ public class StageDTO { * @param design the encompassing container DTO * @param stageNumber the stage number (3 is always at the top, even if it's the only one) */ - public StageDTO(Stage theORStage, RocketDesignDTO design, int stageNumber) { + public StageDTO(AxialStage theORStage, RocketDesignDTO design, int stageNumber) { if (stageNumber == 3) { if (theORStage.isMassOverridden()) { diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/RocksimHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/RocksimHandler.java index 0178df8dc..5c14afdd4 100644 --- a/core/src/net/sf/openrocket/file/rocksim/importt/RocksimHandler.java +++ b/core/src/net/sf/openrocket/file/rocksim/importt/RocksimHandler.java @@ -16,7 +16,7 @@ import net.sf.openrocket.file.simplesax.ElementHandler; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import org.xml.sax.SAXException; @@ -205,7 +205,7 @@ class RocketDesignHandler extends AbstractElementHandler { * rocket defines stage '2' as the initial booster with stage '3' sitting atop it. And so on. */ if ("Stage3Parts".equals(element)) { - final Stage stage = new Stage(); + final AxialStage stage = new AxialStage(); if (stage3Mass > 0.0d) { stage.setMassOverridden(true); stage.setOverrideSubcomponents(true); //Rocksim does not support this type of override @@ -221,7 +221,7 @@ class RocketDesignHandler extends AbstractElementHandler { } if ("Stage2Parts".equals(element)) { if (stageCount >= 2) { - final Stage stage = new Stage(); + final AxialStage stage = new AxialStage(); if (stage2Mass > 0.0d) { stage.setMassOverridden(true); stage.setOverrideSubcomponents(true); //Rocksim does not support this type of override @@ -238,7 +238,7 @@ class RocketDesignHandler extends AbstractElementHandler { } if ("Stage1Parts".equals(element)) { if (stageCount == 3) { - final Stage stage = new Stage(); + final AxialStage stage = new AxialStage(); if (stage1Mass > 0.0d) { stage.setMassOverridden(true); stage.setOverrideSubcomponents(true); //Rocksim does not support this type of override diff --git a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java index 9963594c0..3959e2816 100644 --- a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java +++ b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java @@ -12,7 +12,7 @@ import net.sf.openrocket.plugin.Plugin; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.Chars; @@ -59,7 +59,7 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor { while (iterator.hasNext()) { RocketComponent c = iterator.next(); - if (c instanceof Stage) { + if (c instanceof AxialStage) { currentList = new ArrayList(); list.add(currentList); diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java new file mode 100644 index 000000000..196bbeb58 --- /dev/null +++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java @@ -0,0 +1,289 @@ +package net.sf.openrocket.rocketcomponent; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import net.sf.openrocket.l10n.Translator; +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 AxialStage extends ComponentAssembly implements FlightConfigurableComponent { + + private static final Translator trans = Application.getTranslator(); + private static final Logger log = LoggerFactory.getLogger(AxialStage.class); + + private FlightConfigurationImpl separationConfigurations; + + private int stageNumber; + private static int stageCount; + + public AxialStage() { + this.separationConfigurations = new FlightConfigurationImpl(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration()); + this.relativePosition = Position.AFTER; + stageNumber = AxialStage.stageCount; + AxialStage.stageCount++; + } + + @Override + public boolean allowsChildren() { + return true; + } + + @Override + public String getComponentName() { + //// Stage + return trans.get("Stage.Stage"); + } + + public static int getStageCount() { + return AxialStage.stageCount; + } + + public FlightConfiguration getStageSeparationConfiguration() { + return separationConfigurations; + } + + // not strictly accurate, but this should provide an acceptable estimate for total vehicle size + @Override + public Collection getComponentBounds() { + Collection bounds = new ArrayList(8); + Coordinate[] instanceLocations = this.getLocation(); + double x_min = instanceLocations[0].x; + double x_max = x_min + this.length; + double r_max = 0; + + + addBound(bounds, x_min, r_max); + addBound(bounds, x_max, r_max); + + return bounds; + } + + /** + * Check whether the given type can be added to this component. A Stage allows + * only BodyComponents to be added. + * + * @param type The RocketComponent class type to add. + * + * @return Whether such a component can be added. + */ + @Override + public boolean isCompatible(Class type) { + if (type.equals(AxialStage.class)) { + return true; + } else { + return BodyComponent.class.isAssignableFrom(type); + } + } + + @Override + public void cloneFlightConfiguration(String oldConfigId, String newConfigId) { + separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId); + } + + @Override + protected RocketComponent copyWithOriginalID() { + AxialStage copy = (AxialStage) super.copyWithOriginalID(); + copy.separationConfigurations = new FlightConfigurationImpl(separationConfigurations, + copy, ComponentChangeEvent.EVENT_CHANGE); + return copy; + } + + @Override + public Coordinate[] getLocation() { + if (null == this.parent) { + throw new BugException(" Attempted to get absolute position Vector of a Stage without a parent. "); + } + + if (this.isCenterline()) { + return super.getLocation(); + } else { + Coordinate[] parentInstances = this.parent.getLocation(); + if (1 != parentInstances.length) { + throw new BugException(" OpenRocket does not (yet) support external stages attached to external stages. " + + "(assumed reason for getting multiple parent locations into an external stage.)"); + } + + Coordinate[] toReturn = this.shiftCoordinates(parentInstances); + + return toReturn; + } + + } + + + + public void setRelativePositionMethod(final Position _newPosition) { + if (null == this.parent) { + throw new NullPointerException(" a Stage requires a parent before any positioning! "); + } + if (this.isCenterline()) { + // Centerline stages must be set via AFTER-- regardless of what was requested: + super.setRelativePosition(Position.AFTER); + } else if (this.parent instanceof AxialStage) { + if (Position.AFTER == _newPosition) { + log.warn("Stages cannot be relative to other stages via AFTER! Ignoring."); + super.setRelativePosition(Position.TOP); + } else { + super.setRelativePosition(_newPosition); + } + } + fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); + } + + @Override + public double getPositionValue() { + mutex.verify(); + + return this.getAxialOffset(); + } + + /** + * Stages may be positioned relative to other stages. In that case, this will set the stage number + * against which this stage is positioned. + * + * @return the stage number which this stage is positioned relative to + */ + public int getRelativeToStage() { + if (null == this.parent) { + return -1; + } else if (this.parent instanceof AxialStage) { + return this.parent.parent.getChildPosition(this.parent); + } else if (this.isCenterline()) { + if (0 < this.stageNumber) { + return --this.stageNumber; + } + } + + return -1; + } + + public static void resetStageCount() { + AxialStage.stageCount = 0; + } + + @Override + public int getStageNumber() { + return this.stageNumber; + } + + @Override + public double getAxialOffset() { + double returnValue = Double.NaN; + + if ((this.isCenterline() && (Position.AFTER != this.relativePosition))) { + // 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.getRelativePosition().name()); + } else { + returnValue = super.asPositionValue(this.relativePosition); + } + + if (0.000001 > Math.abs(returnValue)) { + returnValue = 0.0; + } + + return returnValue; + } + + @Override + public void setAxialOffset(final double _pos) { + this.updateBounds(); + super.setAxialOffset(this.relativePosition, _pos); + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); + } + + @Override + public Coordinate[] shiftCoordinates(Coordinate[] c) { + checkState(); + return c; + } + + @Override + protected StringBuilder toDebugDetail() { + StringBuilder buf = super.toDebugDetail(); + // if (-1 == this.getRelativeToStage()) { + // System.err.println(" >>refStageName: " + null + "\n"); + // } else { + // Stage refStage = (Stage) this.parent; + // System.err.println(" >>refStageName: " + refStage.getName() + "\n"); + // System.err.println(" ..refCenterX: " + refStage.position.x + "\n"); + // System.err.println(" ..refLength: " + refStage.getLength() + "\n"); + // } + return buf; + } + + @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())); + buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0])); + + } + + @Override + public void updateBounds() { + // currently only updates the length + this.length = 0; + Iterator childIterator = this.getChildren().iterator(); + while (childIterator.hasNext()) { + RocketComponent curChild = childIterator.next(); + if (curChild.isCenterline()) { + this.length += curChild.getLength(); + } + } + + } + + @Override + protected void update() { + if (null == this.parent) { + return; + } + + this.updateBounds(); + if (this.parent instanceof Rocket) { + // stages which are directly children of the rocket are inline, and positioned + int childNumber = this.parent.getChildPosition(this); + if (0 == childNumber) { + this.setAfter(this.parent); + } else { + RocketComponent prevStage = this.parent.getChild(childNumber - 1); + this.setAfter(prevStage); + } + } else if (this.parent instanceof AxialStage) { + this.updateBounds(); + // because if parent is instanceof Stage, that means 'this' is positioned externally + super.update(); + } + + // updates the internal 'previousComponent' field. + this.updateChildSequence(); + + return; + } + + protected void updateChildSequence() { + Iterator childIterator = this.getChildren().iterator(); + RocketComponent prevComp = null; + while (childIterator.hasNext()) { + RocketComponent curChild = childIterator.next(); + if (curChild.isCenterline()) { + //curChild.previousComponent = prevComp; + curChild.setAfter(prevComp); + prevComp = curChild; + // } else { + // curChild.previousComponent = null; + } + } + } + + + +} diff --git a/core/src/net/sf/openrocket/rocketcomponent/Stage.java b/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java similarity index 93% rename from core/src/net/sf/openrocket/rocketcomponent/Stage.java rename to core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java index 64db559fc..588f63c4c 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Stage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BoosterSet.java @@ -12,10 +12,10 @@ import net.sf.openrocket.util.Coordinate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class Stage extends ComponentAssembly implements FlightConfigurableComponent, OutsideComponent { +public class BoosterSet extends AxialStage implements FlightConfigurableComponent, OutsideComponent { - static final Translator trans = Application.getTranslator(); - private static final Logger log = LoggerFactory.getLogger(Stage.class); + private static final Translator trans = Application.getTranslator(); + private static final Logger log = LoggerFactory.getLogger(BoosterSet.class); private FlightConfigurationImpl separationConfigurations; @@ -29,11 +29,8 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon private int stageNumber; private static int stageCount; - public Stage() { - this.separationConfigurations = new FlightConfigurationImpl(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration()); - this.relativePosition = Position.AFTER; - stageNumber = Stage.stageCount; - Stage.stageCount++; + public BoosterSet() { + } @Override @@ -44,11 +41,11 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon @Override public String getComponentName() { //// Stage - return trans.get("Stage.Stage"); + return trans.get("BoosterSet.BoosterSet"); } public static int getStageCount() { - return Stage.stageCount; + return BoosterSet.stageCount; } public FlightConfiguration getStageSeparationConfiguration() { @@ -93,7 +90,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon */ @Override public boolean isCompatible(Class type) { - if (type.equals(Stage.class)) { + if (type.equals(BoosterSet.class)) { return true; } else { return BodyComponent.class.isAssignableFrom(type); @@ -107,7 +104,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon @Override protected RocketComponent copyWithOriginalID() { - Stage copy = (Stage) super.copyWithOriginalID(); + BoosterSet copy = (BoosterSet) super.copyWithOriginalID(); copy.separationConfigurations = new FlightConfigurationImpl(separationConfigurations, copy, ComponentChangeEvent.EVENT_CHANGE); return copy; @@ -233,7 +230,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon if (this.isCenterline()) { // Centerline stages must be set via AFTER-- regardless of what was requested: super.setRelativePosition(Position.AFTER); - } else if (this.parent instanceof Stage) { + } else if (this.parent instanceof BoosterSet) { if (Position.AFTER == _newPosition) { log.warn("Stages cannot be relative to other stages via AFTER! Ignoring."); super.setRelativePosition(Position.TOP); @@ -267,7 +264,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon public int getRelativeToStage() { if (null == this.parent) { return -1; - } else if (this.parent instanceof Stage) { + } else if (this.parent instanceof BoosterSet) { return this.parent.parent.getChildPosition(this.parent); } else if (this.isCenterline()) { if (0 < this.stageNumber) { @@ -279,7 +276,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon } public static void resetStageCount() { - Stage.stageCount = 0; + BoosterSet.stageCount = 0; } @Override @@ -409,7 +406,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon RocketComponent prevStage = this.parent.getChild(childNumber - 1); this.setAfter(prevStage); } - } else if (this.parent instanceof Stage) { + } else if (this.parent instanceof BoosterSet) { this.updateBounds(); // because if parent is instanceof Stage, that means 'this' is positioned externally super.update(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/Configuration.java b/core/src/net/sf/openrocket/rocketcomponent/Configuration.java index 338aa8fae..52bbeff24 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Configuration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Configuration.java @@ -68,7 +68,7 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi public void setAllStages() { stagesActive.clear(); - stagesActive.set(0, Stage.getStageCount()); + stagesActive.set(0, AxialStage.getStageCount()); fireChangeEvent(); } @@ -107,18 +107,18 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi * Check whether the stage specified by the index is active. */ public boolean isStageActive(int stage) { - if (stage >= Stage.getStageCount()) + if (stage >= AxialStage.getStageCount()) return false; return stagesActive.get(stage); } public int getStageCount() { - return Stage.getStageCount(); + return AxialStage.getStageCount(); } public int getActiveStageCount() { int count = 0; - int s = Stage.getStageCount(); + int s = AxialStage.getStageCount(); for (int i = 0; i < s; i++) { if (stagesActive.get(i)) @@ -324,7 +324,7 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi private List getActiveComponents(List accumulator, final List toScan) { for (RocketComponent rc : toScan) { - if (rc instanceof Stage) { + if (rc instanceof AxialStage) { if (!isStageActive(rc.getStageNumber())) { continue; } diff --git a/core/src/net/sf/openrocket/rocketcomponent/PodSet.java b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java new file mode 100644 index 000000000..e22f7cd01 --- /dev/null +++ b/core/src/net/sf/openrocket/rocketcomponent/PodSet.java @@ -0,0 +1,451 @@ +package net.sf.openrocket.rocketcomponent; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import net.sf.openrocket.l10n.Translator; +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 FlightConfigurableComponent, OutsideComponent { + + private static final Translator trans = Application.getTranslator(); + private static final Logger log = LoggerFactory.getLogger(PodSet.class); + + private FlightConfigurationImpl separationConfigurations; + + private boolean centerline = true; + private double angularPosition_rad = 0; + private double radialPosition_m = 0; + + private int count = 2; + private double angularSeparation = Math.PI; + + private int stageNumber; + private static int stageCount; + + public PodSet() { + this.separationConfigurations = new FlightConfigurationImpl(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration()); + this.relativePosition = Position.AFTER; + stageNumber = PodSet.stageCount; + PodSet.stageCount++; + } + + public class Boosters extends PodSet { + public Boosters() { + super(); + } + }; + + public class Pods extends PodSet { + public Pods() { + super(); + } + + }; + + + @Override + public boolean allowsChildren() { + return true; + } + + @Override + public String getComponentName() { + //// Stage + return trans.get("PodSet.PodSet"); + } + + public FlightConfiguration getStageSeparationConfiguration() { + return separationConfigurations; + } + + // not strictly accurate, but this should provide an acceptable estimate for total vehicle size + @Override + public Collection getComponentBounds() { + Collection bounds = new ArrayList(8); + + double x_min = Double.MAX_VALUE; + double x_max = Double.MIN_VALUE; + double r_max = 0; + + Coordinate[] instanceLocations = this.getLocation(); + + for (Coordinate currentInstanceLocation : instanceLocations) { + if (x_min > (currentInstanceLocation.x)) { + x_min = currentInstanceLocation.x; + } + if (x_max < (currentInstanceLocation.x + this.length)) { + x_max = currentInstanceLocation.x + this.length; + } + if (r_max < (this.getRadialOffset())) { + r_max = this.getRadialOffset(); + } + } + addBound(bounds, x_min, r_max); + addBound(bounds, x_max, r_max); + + return bounds; + } + + /** + * Check whether the given type can be added to this component. A Stage allows + * only BodyComponents to be added. + * + * @param type The RocketComponent class type to add. + * + * @return Whether such a component can be added. + */ + @Override + public boolean isCompatible(Class type) { + if (type.equals(PodSet.class)) { + return true; + } else { + return BodyComponent.class.isAssignableFrom(type); + } + } + + @Override + public void cloneFlightConfiguration(String oldConfigId, String newConfigId) { + separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId); + } + + @Override + protected RocketComponent copyWithOriginalID() { + PodSet copy = (PodSet) super.copyWithOriginalID(); + copy.separationConfigurations = new FlightConfigurationImpl(separationConfigurations, + copy, ComponentChangeEvent.EVENT_CHANGE); + return copy; + } + + @Override + public Coordinate[] getLocation() { + if (null == this.parent) { + throw new BugException(" Attempted to get absolute position Vector of a Stage without a parent. "); + } + + if (this.isCenterline()) { + return super.getLocation(); + } else { + Coordinate[] parentInstances = this.parent.getLocation(); + if (1 != parentInstances.length) { + throw new BugException(" OpenRocket does not (yet) support external stages attached to external stages. " + + "(assumed reason for getting multiple parent locations into an external stage.)"); + } + + Coordinate[] toReturn = this.shiftCoordinates(parentInstances); + + return toReturn; + } + + } + + @Override + public boolean getOutside() { + return !isCenterline(); + } + + /** + * Detects if this Stage is attached directly to the Rocket (and is thus centerline) + * Or if this stage is a parallel (external) stage. + * + * @return whether this Stage is along the center line of the Rocket. + */ + @Override + public boolean isCenterline() { + if (this.parent instanceof Rocket) { + this.centerline = true; + } else { + this.centerline = false; + } + return this.centerline; + } + + /** + * Stub. + * The actual value is set via 'isCenterline()' + */ + @Override + public void setOutside(final boolean _outside) { + } + + @Override + public int getInstanceCount() { + if (this.isCenterline()) { + return 1; + } else { + return this.count; + } + } + + @Override + public void setInstanceCount(final int _count) { + mutex.verify(); + if (this.centerline) { + return; + } + if (_count < 1) { + // there must be at least one instance.... + return; + } + + this.count = _count; + this.angularSeparation = Math.PI * 2 / this.count; + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); + } + + @Override + public double getAngularOffset() { + if (this.centerline) { + return 0.; + } else { + return this.angularPosition_rad; + } + } + + @Override + public void setAngularOffset(final double angle_rad) { + if (this.centerline) { + return; + } + + this.angularPosition_rad = angle_rad; + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); + } + + @Override + public double getRadialOffset() { + if (this.centerline) { + return 0.; + } else { + return this.radialPosition_m; + } + } + + @Override + public void setRadialOffset(final double radius) { + // log.error(" set radial position for: " + this.getName() + " to: " + this.radialPosition_m + " ... in meters?"); + if (false == this.centerline) { + 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! "); + } + if (this.isCenterline()) { + // Centerline stages must be set via AFTER-- regardless of what was requested: + super.setRelativePosition(Position.AFTER); + } else if (this.parent instanceof PodSet) { + if (Position.AFTER == _newPosition) { + log.warn("Stages cannot be relative to other stages via AFTER! Ignoring."); + super.setRelativePosition(Position.TOP); + } else { + super.setRelativePosition(_newPosition); + } + } + fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); + } + + @Override + public double getPositionValue() { + mutex.verify(); + + return this.getAxialOffset(); + } + + /* + * @deprecated remove when the file is fixed.... + */ + public void setRelativeToStage(final int _relToStage) { + // no-op + } + + /** + * Stages may be positioned relative to other stages. In that case, this will set the stage number + * against which this stage is positioned. + * + * @return the stage number which this stage is positioned relative to + */ + public int getRelativeToStage() { + if (null == this.parent) { + return -1; + } else if (this.parent instanceof PodSet) { + return this.parent.parent.getChildPosition(this.parent); + } else if (this.isCenterline()) { + if (0 < this.stageNumber) { + return --this.stageNumber; + } + } + + return -1; + } + + public static void resetStageCount() { + PodSet.stageCount = 0; + } + + @Override + public int getStageNumber() { + return this.stageNumber; + } + + @Override + public double getAxialOffset() { + double returnValue = Double.NaN; + + if ((this.isCenterline() && (Position.AFTER != this.relativePosition))) { + // 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.getRelativePosition().name()); + } else { + returnValue = super.asPositionValue(this.relativePosition); + } + + if (0.000001 > Math.abs(returnValue)) { + returnValue = 0.0; + } + + return returnValue; + } + + @Override + public void setAxialOffset(final double _pos) { + this.updateBounds(); + super.setAxialOffset(this.relativePosition, _pos); + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); + } + + @Override + public Coordinate[] shiftCoordinates(Coordinate[] c) { + checkState(); + + if (this.isCenterline()) { + return c; + } + + if (1 < c.length) { + throw new BugException("implementation of 'shiftCoordinates' assumes the coordinate array has len == 1; this is not true, and may produce unexpected behavior! "); + } + + double radius = this.radialPosition_m; + double angle0 = this.angularPosition_rad; + double angleIncr = this.angularSeparation; + Coordinate center = this.position; + Coordinate[] toReturn = new Coordinate[this.count]; + Coordinate thisOffset; + double thisAngle = angle0; + for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) { + thisOffset = center.add(0, radius * Math.cos(thisAngle), radius * Math.sin(thisAngle)); + + toReturn[instanceNumber] = thisOffset.add(c[0]); + thisAngle += angleIncr; + } + + return toReturn; + } + + @Override + protected StringBuilder toDebugDetail() { + StringBuilder buf = super.toDebugDetail(); + // if (-1 == this.getRelativeToStage()) { + // System.err.println(" >>refStageName: " + null + "\n"); + // } else { + // Stage refStage = (Stage) this.parent; + // System.err.println(" >>refStageName: " + refStage.getName() + "\n"); + // System.err.println(" ..refCenterX: " + refStage.position.x + "\n"); + // System.err.println(" ..refLength: " + refStage.getLength() + "\n"); + // } + return buf; + } + + @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(" %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 + public void updateBounds() { + // currently only updates the length + this.length = 0; + Iterator childIterator = this.getChildren().iterator(); + while (childIterator.hasNext()) { + RocketComponent curChild = childIterator.next(); + if (curChild.isCenterline()) { + this.length += curChild.getLength(); + } + } + + } + + @Override + protected void update() { + if (null == this.parent) { + return; + } + + this.updateBounds(); + if (this.parent instanceof Rocket) { + // stages which are directly children of the rocket are inline, and positioned + int childNumber = this.parent.getChildPosition(this); + if (0 == childNumber) { + this.setAfter(this.parent); + } else { + RocketComponent prevStage = this.parent.getChild(childNumber - 1); + this.setAfter(prevStage); + } + } else if (this.parent instanceof PodSet) { + this.updateBounds(); + // because if parent is instanceof Stage, that means 'this' is positioned externally + super.update(); + } + + // updates the internal 'previousComponent' field. + this.updateChildSequence(); + + return; + } + + protected void updateChildSequence() { + Iterator childIterator = this.getChildren().iterator(); + RocketComponent prevComp = null; + while (childIterator.hasNext()) { + RocketComponent curChild = childIterator.next(); + if (curChild.isCenterline()) { + //curChild.previousComponent = prevComp; + curChild.setAfter(prevComp); + prevComp = curChild; + // } else { + // curChild.previousComponent = null; + } + } + } + + + +} diff --git a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java index 68fb6d07c..8fe99a322 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java @@ -93,7 +93,7 @@ public class Rocket extends RocketComponent { functionalModID = modID; defaultConfiguration = new Configuration(this); - Stage.resetStageCount(); + AxialStage.resetStageCount(); } @@ -130,7 +130,7 @@ public class Rocket extends RocketComponent { */ public int getStageCount() { checkState(); - return Stage.getStageCount(); + return AxialStage.getStageCount(); } @@ -196,22 +196,22 @@ public class Rocket extends RocketComponent { return functionalModID; } - public ArrayList getStageList() { - ArrayList toReturn = new ArrayList(); + public ArrayList getStageList() { + ArrayList toReturn = new ArrayList(); toReturn = Rocket.getStages(toReturn, this); return toReturn; } - private static ArrayList getStages(ArrayList accumulator, final RocketComponent parent) { + private static ArrayList getStages(ArrayList accumulator, final RocketComponent parent) { if ((null == accumulator) || (null == parent)) { - return new ArrayList(); + return new ArrayList(); } for (RocketComponent curChild : parent.getChildren()) { - if (curChild instanceof Stage) { - Stage curStage = (Stage) curChild; + if (curChild instanceof AxialStage) { + AxialStage curStage = (AxialStage) curChild; accumulator.add(curStage); } getStages(accumulator, curChild); @@ -707,7 +707,7 @@ public class Rocket extends RocketComponent { */ @Override public boolean isCompatible(Class type) { - return (Stage.class.isAssignableFrom(type)); + return (AxialStage.class.isAssignableFrom(type)); } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index fd2e5c8c0..8203825d1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -1024,7 +1024,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab // if this is the root of a hierarchy, constrain the position to zero. if (null == this.parent) { return; - } else if ((this.isCenterline()) && (this instanceof Stage)) { + } else if ((this.isCenterline()) && (this instanceof AxialStage)) { // enforce AFTER positionMethod = Position.AFTER; } @@ -1506,12 +1506,12 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab * @return The Stage component this component belongs to. * @throws IllegalStateException if a Stage component is not in the parentage. */ - public final Stage getStage() { + public final AxialStage getStage() { checkState(); RocketComponent c = this; while (c != null) { - if (c instanceof Stage) - return (Stage) c; + if (c instanceof AxialStage) + return (AxialStage) c; c = c.getParent(); } throw new IllegalStateException("getStage() called without Stage as a parent."); @@ -1530,14 +1530,14 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab } RocketComponent curComponent = this; - while (!(curComponent instanceof Stage)) { + while (!(curComponent instanceof AxialStage)) { curComponent = curComponent.parent; if (curComponent == null || curComponent.parent == null) { throw new IllegalStateException("getStageNumber() could not find parent " + "stage."); } } - Stage stage = (Stage) curComponent; + AxialStage stage = (AxialStage) curComponent; return stage.getStageNumber(); } diff --git a/core/src/net/sf/openrocket/rocketcomponent/StageSeparationConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/StageSeparationConfiguration.java index a7a2a13d9..4a167f1f0 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/StageSeparationConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/StageSeparationConfiguration.java @@ -16,7 +16,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter //// Upper stage motor ignition UPPER_IGNITION(trans.get("Stage.SeparationEvent.UPPER_IGNITION")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { if (e.getType() != FlightEvent.Type.IGNITION) return false; @@ -28,7 +28,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter //// Current stage motor ignition IGNITION(trans.get("Stage.SeparationEvent.IGNITION")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { if (e.getType() != FlightEvent.Type.IGNITION) return false; @@ -40,7 +40,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter //// Current stage motor burnout BURNOUT(trans.get("Stage.SeparationEvent.BURNOUT")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { if (e.getType() != FlightEvent.Type.BURNOUT) return false; @@ -52,7 +52,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter //// Current stage ejection charge EJECTION(trans.get("Stage.SeparationEvent.EJECTION")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { if (e.getType() != FlightEvent.Type.EJECTION_CHARGE) return false; @@ -64,14 +64,14 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter //// Launch LAUNCH(trans.get("Stage.SeparationEvent.LAUNCH")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { return e.getType() == FlightEvent.Type.LAUNCH; } }, //// Never NEVER(trans.get("Stage.SeparationEvent.NEVER")) { @Override - public boolean isSeparationEvent(FlightEvent e, Stage stage) { + public boolean isSeparationEvent(FlightEvent e, AxialStage stage) { return false; } }, @@ -87,7 +87,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter /** * Test whether a specific event is a stage separation event. */ - public abstract boolean isSeparationEvent(FlightEvent e, Stage stage); + public abstract boolean isSeparationEvent(FlightEvent e, AxialStage stage); @Override public String toString() { diff --git a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java index 7b455fa85..a8bb2cf61 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java @@ -570,7 +570,7 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial if (c instanceof SymmetricComponent) { return (SymmetricComponent) c; } - if (!(c instanceof Stage) && + if (!(c instanceof AxialStage) && (c.relativePosition == RocketComponent.Position.AFTER)) return null; // Bad component type as "parent" } @@ -590,7 +590,7 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial if (c instanceof SymmetricComponent) { return (SymmetricComponent) c; } - if (!(c instanceof Stage) && + if (!(c instanceof AxialStage) && (c.relativePosition == RocketComponent.Position.AFTER)) return null; // Bad component type as "parent" } diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index afadf26c2..67dd57093 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -15,7 +15,7 @@ import net.sf.openrocket.rocketcomponent.MotorConfiguration; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.simulation.exception.MotorIgnitionException; import net.sf.openrocket.simulation.exception.SimulationException; @@ -358,7 +358,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { if (stageNo == 0) continue; - Stage stage = (Stage) status.getConfiguration().getRocket().getChild(stageNo); + AxialStage stage = (AxialStage) status.getConfiguration().getRocket().getChild(stageNo); StageSeparationConfiguration separationConfig = stage.getStageSeparationConfiguration().get(flightConfigurationId); if (separationConfig.getSeparationEvent().isSeparationEvent(event, stage)) { addEvent(new FlightEvent(FlightEvent.Type.STAGE_SEPARATION, diff --git a/core/src/net/sf/openrocket/util/TestRockets.java b/core/src/net/sf/openrocket/util/TestRockets.java index f4fff0762..c8f6ff12f 100644 --- a/core/src/net/sf/openrocket/util/TestRockets.java +++ b/core/src/net/sf/openrocket/util/TestRockets.java @@ -39,7 +39,7 @@ import net.sf.openrocket.rocketcomponent.ReferenceType; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent.Position; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.rocketcomponent.Transition.Shape; @@ -104,7 +104,7 @@ public class TestRockets { rocket.setRevision("Rocket revision " + key); rocket.setName(key); - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); setBasics(stage); rocket.addChild(stage); @@ -251,13 +251,13 @@ public class TestRockets { double finRootChord = 0.04, finTipChord = 0.05, finSweep = 0.01, finThickness = 0.003, finHeight = 0.03; Rocket rocket; - Stage stage; + AxialStage stage; NoseCone nosecone; BodyTube bodytube; TrapezoidFinSet finset; rocket = new Rocket(); - stage = new Stage(); + stage = new AxialStage(); stage.setName("Stage1"); nosecone = new NoseCone(Transition.Shape.ELLIPSOID, noseconeLength, noseconeRadius); @@ -299,14 +299,14 @@ public class TestRockets { public static Rocket makeBigBlue() { Rocket rocket; - Stage stage; + AxialStage stage; NoseCone nosecone; BodyTube bodytube; FreeformFinSet finset; MassComponent mcomp; rocket = new Rocket(); - stage = new Stage(); + stage = new AxialStage(); stage.setName("Stage1"); nosecone = new NoseCone(Transition.Shape.ELLIPSOID, 0.105, 0.033); @@ -368,7 +368,7 @@ public class TestRockets { public static Rocket makeIsoHaisu() { Rocket rocket; - Stage stage; + AxialStage stage; NoseCone nosecone; BodyTube tube1, tube2, tube3; TrapezoidFinSet finset; @@ -379,7 +379,7 @@ public class TestRockets { final double R = 0.07; rocket = new Rocket(); - stage = new Stage(); + stage = new AxialStage(); stage.setName("Stage1"); nosecone = new NoseCone(Transition.Shape.OGIVE, 0.53, R); @@ -557,7 +557,7 @@ public class TestRockets { rocket.setName("v100"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); // make body tube @@ -578,7 +578,7 @@ public class TestRockets { rocket.setName("v101_withFinTabs"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -607,7 +607,7 @@ public class TestRockets { rocket.setName("v101_withTubeCouplerChild"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -633,7 +633,7 @@ public class TestRockets { rocket.setName("v104_withMotorConfig"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -671,7 +671,7 @@ public class TestRockets { rocket.setName("v104_withSimulationData"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -719,7 +719,7 @@ public class TestRockets { rocket.setName("v105_withCustomExpression"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -743,7 +743,7 @@ public class TestRockets { rocket.setName("v105_withComponentPreset"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -779,7 +779,7 @@ public class TestRockets { rocket.setName("v105_withLowerStageRecoveryDevice"); // make 1st stage - Stage stage1 = new Stage(); + AxialStage stage1 = new AxialStage(); stage1.setName("Stage1"); rocket.addChild(stage1); @@ -795,7 +795,7 @@ public class TestRockets { bodyTube1.addChild(parachute); // make 2nd stage - Stage stage2 = new Stage(); + AxialStage stage2 = new AxialStage(); stage2.setName("Stage2"); rocket.addChild(stage2); @@ -810,7 +810,7 @@ public class TestRockets { rocket.setName("v106_withAppearance"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -831,7 +831,7 @@ public class TestRockets { rocket.setName("v106_withwithMotorMountIgnitionConfig"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -860,7 +860,7 @@ public class TestRockets { rocket.setName("v106_withRecoveryDeviceDeploymentConfig"); // make stage - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Stage1"); rocket.addChild(stage); @@ -886,7 +886,7 @@ public class TestRockets { rocket.setName("v106_withStageSeparationConfig"); // make 1st stage - Stage stage1 = new Stage(); + AxialStage stage1 = new AxialStage(); stage1.setName("Stage1"); rocket.addChild(stage1); @@ -904,7 +904,7 @@ public class TestRockets { stage1.getStageSeparationConfiguration().set("3SecondDelay", stageSepConfig); // make 2nd stage - Stage stage2 = new Stage(); + AxialStage stage2 = new AxialStage(); stage2.setName("Stage2"); rocket.addChild(stage2); @@ -937,7 +937,7 @@ public class TestRockets { rocket.setName("for_estimateFileSize"); // make 1st stage - Stage stage1 = new Stage(); + AxialStage stage1 = new AxialStage(); stage1.setName("Stage1"); rocket.addChild(stage1); @@ -959,7 +959,7 @@ public class TestRockets { bodyTube1.addChild(parachute); // make 2nd stage - Stage stage2 = new Stage(); + AxialStage stage2 = new AxialStage(); stage2.setName("Stage2"); rocket.addChild(stage2); 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 0c7b19469..66e551581 100644 --- a/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java +++ b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java @@ -9,7 +9,7 @@ import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.ExternalComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import org.junit.Assert; import org.junit.Test; @@ -37,7 +37,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { //success } - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); BodyTubeHandler handler = new BodyTubeHandler(null, stage, new WarningSet()); BodyTube component = (BodyTube) getField(handler, "bodyTube"); assertContains(component, stage.getChildren()); @@ -50,8 +50,8 @@ public class BodyTubeHandlerTest extends RocksimTestBase { */ @Test public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(null, new Stage(), new WarningSet()).openElement(null, null, null)); - Assert.assertNotNull(new BodyTubeHandler(null, new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); + Assert.assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(null, new AxialStage(), new WarningSet()).openElement(null, null, null)); + Assert.assertNotNull(new BodyTubeHandler(null, new AxialStage(), new WarningSet()).openElement("AttachedParts", null, null)); } /** @@ -62,7 +62,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { */ @Test public void testCloseElement() throws Exception { - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); BodyTubeHandler handler = new BodyTubeHandler(null, stage, new WarningSet()); BodyTube component = (BodyTube) getField(handler, "bodyTube"); HashMap attributes = new HashMap(); @@ -134,7 +134,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { */ @Test public void testGetComponent() throws Exception { - Assert.assertTrue(new BodyTubeHandler(null, new Stage(), new WarningSet()).getComponent() instanceof BodyTube); + Assert.assertTrue(new BodyTubeHandler(null, new AxialStage(), new WarningSet()).getComponent() instanceof BodyTube); } /** @@ -144,7 +144,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { */ @Test public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new BodyTubeHandler(null, new Stage(), new WarningSet()).getMaterialType()); + Assert.assertEquals(Material.Type.BULK, new BodyTubeHandler(null, new AxialStage(), new WarningSet()).getMaterialType()); } } diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java index 6b88cb82f..e9650da7b 100644 --- a/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java +++ b/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java @@ -10,7 +10,7 @@ import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.ExternalComponent; import net.sf.openrocket.rocketcomponent.NoseCone; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.Transition; import org.junit.Assert; import org.junit.Test; @@ -39,7 +39,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { //success } - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); NoseConeHandler handler = new NoseConeHandler(null, stage, new WarningSet()); NoseCone component = (NoseCone) getField(handler, "noseCone"); assertContains(component, stage.getChildren()); @@ -52,8 +52,8 @@ public class NoseConeHandlerTest extends RocksimTestBase { */ @Test public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(null, new Stage(), new WarningSet()).openElement(null, null, null)); - Assert.assertNotNull(new NoseConeHandler(null, new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); + Assert.assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(null, new AxialStage(), new WarningSet()).openElement(null, null, null)); + Assert.assertNotNull(new NoseConeHandler(null, new AxialStage(), new WarningSet()).openElement("AttachedParts", null, null)); } /** @@ -65,7 +65,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { @Test public void testCloseElement() throws Exception { - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -188,7 +188,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { */ @Test public void testGetComponent() throws Exception { - Assert.assertTrue(new NoseConeHandler(null, new Stage(), new WarningSet()).getComponent() instanceof NoseCone); + Assert.assertTrue(new NoseConeHandler(null, new AxialStage(), new WarningSet()).getComponent() instanceof NoseCone); } /** @@ -198,6 +198,6 @@ public class NoseConeHandlerTest extends RocksimTestBase { */ @Test public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new NoseConeHandler(null, new Stage(), new WarningSet()).getMaterialType()); + Assert.assertEquals(Material.Type.BULK, new NoseConeHandler(null, new AxialStage(), new WarningSet()).getMaterialType()); } } diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java index 72d8be26c..14feee5df 100644 --- a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java @@ -12,7 +12,7 @@ import net.sf.openrocket.file.RocketLoadException; import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.LaunchLug; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.util.BaseTestCase.BaseTestCase; import org.junit.Assert; @@ -85,13 +85,13 @@ public class RocksimLoaderTest extends BaseTestCase { Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName()); Assert.assertEquals(0, loader.getWarnings().size()); Assert.assertEquals(3, rocket.getStageCount()); - Stage stage1 = (Stage) rocket.getChild(0); + AxialStage stage1 = (AxialStage) rocket.getChild(0); Assert.assertFalse(stage1.isMassOverridden()); Assert.assertFalse(stage1.isCGOverridden()); - Stage stage2 = (Stage) rocket.getChild(1); + AxialStage stage2 = (AxialStage) rocket.getChild(1); Assert.assertFalse(stage2.isMassOverridden()); Assert.assertFalse(stage2.isCGOverridden()); - Stage stage3 = (Stage) rocket.getChild(2); + AxialStage stage3 = (AxialStage) rocket.getChild(2); Assert.assertFalse(stage3.isMassOverridden()); Assert.assertFalse(stage3.isCGOverridden()); @@ -109,9 +109,9 @@ public class RocksimLoaderTest extends BaseTestCase { Assert.assertNotNull(rocket); Assert.assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName()); Assert.assertEquals(3, rocket.getStageCount()); - stage1 = (Stage) rocket.getChild(0); - stage2 = (Stage) rocket.getChild(1); - stage3 = (Stage) rocket.getChild(2); + stage1 = (AxialStage) rocket.getChild(0); + stage2 = (AxialStage) rocket.getChild(1); + stage3 = (AxialStage) rocket.getChild(2); //Do some 1st level and simple asserts; the idea here is to not do a deep validation as that //should have been covered elsewhere. Assert that the stage overrides are correct. @@ -170,7 +170,7 @@ public class RocksimLoaderTest extends BaseTestCase { rocket = doc.getRocket(); Assert.assertNotNull(rocket); Assert.assertEquals(1, rocket.getStageCount()); - Stage stage1 = (Stage) rocket.getChild(0); + AxialStage stage1 = (AxialStage) rocket.getChild(0); Assert.assertEquals("Nose cone", stage1.getChild(0).getName()); Assert.assertEquals("Forward Body tube", stage1.getChild(1).getName()); Assert.assertEquals("Aft Body tube", stage1.getChild(2).getName()); diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java index a2298e8f5..fe7d43c28 100644 --- a/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java +++ b/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java @@ -9,7 +9,7 @@ import net.sf.openrocket.file.rocksim.RocksimNoseConeCode; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.ExternalComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.Transition; import org.junit.Assert; @@ -36,7 +36,7 @@ public class TransitionHandlerTest extends RocksimTestBase { //success } - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); TransitionHandler handler = new TransitionHandler(null, stage, new WarningSet()); Transition component = (Transition) getField(handler, "transition"); assertContains(component, stage.getChildren()); @@ -49,7 +49,7 @@ public class TransitionHandlerTest extends RocksimTestBase { */ @org.junit.Test public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(null, new Stage(), new WarningSet()).openElement(null, null, null)); + Assert.assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(null, new AxialStage(), new WarningSet()).openElement(null, null, null)); } /** @@ -60,7 +60,7 @@ public class TransitionHandlerTest extends RocksimTestBase { @org.junit.Test public void testCloseElement() throws Exception { - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -214,7 +214,7 @@ public class TransitionHandlerTest extends RocksimTestBase { */ @org.junit.Test public void testGetComponent() throws Exception { - Assert.assertTrue(new TransitionHandler(null, new Stage(), new WarningSet()).getComponent() instanceof Transition); + Assert.assertTrue(new TransitionHandler(null, new AxialStage(), new WarningSet()).getComponent() instanceof Transition); } /** @@ -224,7 +224,7 @@ public class TransitionHandlerTest extends RocksimTestBase { */ @org.junit.Test public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new TransitionHandler(null, new Stage(), new WarningSet()).getMaterialType()); + Assert.assertEquals(Material.Type.BULK, new TransitionHandler(null, new AxialStage(), new WarningSet()).getMaterialType()); } diff --git a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java index 7c1d52de9..64284700a 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java @@ -356,7 +356,7 @@ public class ConfigurationTest extends BaseTestCase { // TODO: get units correct, these units are prob wrong, are lengths are CM, mass are grams Rocket rocket; - Stage stage; + AxialStage stage; NoseCone nosecone; BodyTube tube1; TrapezoidFinSet finset; @@ -370,7 +370,7 @@ public class ConfigurationTest extends BaseTestCase { final double R2 = 2.3 / 2; rocket = new Rocket(); - stage = new Stage(); + stage = new AxialStage(); stage.setName("Stage1"); nosecone = new NoseCone(Transition.Shape.OGIVE, 10.0, R); @@ -498,7 +498,7 @@ public class ConfigurationTest extends BaseTestCase { Rocket rocket = makeSingleStageTestRocket(); - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); stage.setName("Booster"); BodyTube boosterTube = new BodyTube(9.0, R, BT_T); diff --git a/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java index 58dc0a440..b568dc32e 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java @@ -251,7 +251,7 @@ public class FinSetTest extends BaseTestCase { // Create test rocket Rocket rocket = new Rocket(); - Stage stage = new Stage(); + AxialStage stage = new AxialStage(); BodyTube body = new BodyTube(); rocket.addChild(stage); diff --git a/core/test/net/sf/openrocket/rocketcomponent/StageTest.java b/core/test/net/sf/openrocket/rocketcomponent/StageTest.java index 1e18a2705..3130b1b72 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/StageTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/StageTest.java @@ -27,7 +27,7 @@ public class StageTest extends BaseTestCase { Rocket rocket = new Rocket(); rocket.setName("Rocket"); - Stage sustainer = new Stage(); + AxialStage sustainer = new AxialStage(); sustainer.setName("Sustainer stage"); RocketComponent sustainerNose = new NoseCone(Transition.Shape.CONICAL, 2.0, tubeRadius); sustainerNose.setName("Sustainer Nosecone"); @@ -37,7 +37,7 @@ public class StageTest extends BaseTestCase { sustainer.addChild(sustainerBody); rocket.addChild(sustainer); - Stage core = new Stage(); + AxialStage core = new AxialStage(); core.setName("Core stage"); rocket.addChild(core); BodyTube coreUpperBody = new BodyTube(1.8, tubeRadius, 0.01); @@ -52,10 +52,10 @@ public class StageTest extends BaseTestCase { return rocket; } - public Stage createBooster() { + public AxialStage createBooster() { double tubeRadius = 0.8; - Stage booster = new Stage(); + AxialStage booster = new AxialStage(); booster.setName("Booster Stage"); booster.setOutside(true); RocketComponent boosterNose = new NoseCone(Transition.Shape.CONICAL, 2.0, tubeRadius); @@ -108,7 +108,7 @@ public class StageTest extends BaseTestCase { RocketComponent rocket = createTestRocket(); // Sustainer Stage - Stage sustainer = (Stage) rocket.getChild(0); + AxialStage sustainer = (AxialStage) rocket.getChild(0); RocketComponent sustainerNose = sustainer.getChild(0); RocketComponent sustainerBody = sustainer.getChild(1); assertThat(" createTestRocket failed: is sustainer stage an ancestor of the sustainer stage? ", sustainer.isAncestor(sustainer), equalTo(false)); @@ -156,7 +156,7 @@ public class StageTest extends BaseTestCase { String rocketTree = rocket.toDebugTree(); // Core Stage - Stage core = (Stage) rocket.getChild(1); + AxialStage core = (AxialStage) rocket.getChild(1); double expectedCoreLength = 6.0; assertThat(" createTestRocket failed: Core size: ", core.getLength(), equalTo(expectedCoreLength)); double expectedCoreX = 5; @@ -205,7 +205,7 @@ public class StageTest extends BaseTestCase { public void testSetStagePosition_topOfStack() { // setup RocketComponent rocket = createTestRocket(); - Stage sustainer = (Stage) rocket.getChild(0); + AxialStage sustainer = (AxialStage) rocket.getChild(0); Coordinate expectedPosition = new Coordinate(0, 0., 0.); // i.e. half the tube length Coordinate targetPosition = new Coordinate(+4.0, 0., 0.); @@ -232,8 +232,8 @@ public class StageTest extends BaseTestCase { public void testBoosterInitialization() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage boosterSet = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage boosterSet = createBooster(); core.addChild(boosterSet); double targetOffset = 0; @@ -268,8 +268,8 @@ public class StageTest extends BaseTestCase { public void testBoosterInstanceLocation_BOTTOM() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage boosterSet = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage boosterSet = createBooster(); core.addChild(boosterSet); double targetOffset = 0; @@ -313,8 +313,8 @@ public class StageTest extends BaseTestCase { public void testSetStagePosition_outsideABSOLUTE() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetX = +17.0; @@ -344,7 +344,7 @@ public class StageTest extends BaseTestCase { public void testSetStagePosition_outsideTopOfStack() { // setup RocketComponent rocket = createTestRocket(); - Stage sustainer = (Stage) rocket.getChild(0); + AxialStage sustainer = (AxialStage) rocket.getChild(0); Coordinate targetPosition = new Coordinate(+4.0, 0., 0.); Coordinate expectedPosition = targetPosition; @@ -376,8 +376,8 @@ public class StageTest extends BaseTestCase { @Test public void testSetStagePosition_outsideTOP() { Rocket rocket = this.createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetOffset = +2.0; @@ -406,8 +406,8 @@ public class StageTest extends BaseTestCase { public void testSetStagePosition_outsideMIDDLE() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); // when 'external' the stage should be freely movable @@ -436,8 +436,8 @@ public class StageTest extends BaseTestCase { public void testSetStagePosition_outsideBOTTOM() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); // vv function under test @@ -465,8 +465,8 @@ public class StageTest extends BaseTestCase { public void testAxial_setTOP_getABSOLUTE() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetOffset = +4.50; @@ -489,8 +489,8 @@ public class StageTest extends BaseTestCase { public void testAxial_setTOP_getAFTER() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetOffset = +4.50; @@ -513,8 +513,8 @@ public class StageTest extends BaseTestCase { public void testAxial_setTOP_getMIDDLE() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetOffset = +4.50; @@ -538,8 +538,8 @@ public class StageTest extends BaseTestCase { public void testAxial_setTOP_getBOTTOM() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); @@ -563,8 +563,8 @@ public class StageTest extends BaseTestCase { public void testAxial_setBOTTOM_getTOP() { // setup RocketComponent rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage booster = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage booster = createBooster(); core.addChild(booster); double targetOffset = +4.50; @@ -586,9 +586,9 @@ public class StageTest extends BaseTestCase { public void testOutsideStageRepositionTOPAfterAdd() { final double boosterRadius = 0.8; Rocket rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); + AxialStage core = (AxialStage) rocket.getChild(1); - Stage booster = new Stage(); + AxialStage booster = new AxialStage(); booster.setName("Booster Stage"); core.addChild(booster); final double targetOffset = +2.50; @@ -623,11 +623,11 @@ public class StageTest extends BaseTestCase { @Test public void testStageInitializationMethodValueOrder() { Rocket rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); - Stage boosterA = createBooster(); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage boosterA = createBooster(); boosterA.setName("Booster A Stage"); core.addChild(boosterA); - Stage boosterB = createBooster(); + AxialStage boosterB = createBooster(); boosterB.setName("Booster B Stage"); core.addChild(boosterB); @@ -653,13 +653,13 @@ public class StageTest extends BaseTestCase { @Test public void testStageNumbering() { Rocket rocket = createTestRocket(); - Stage sustainer = (Stage) rocket.getChild(0); - Stage core = (Stage) rocket.getChild(1); - Stage boosterA = createBooster(); + AxialStage sustainer = (AxialStage) rocket.getChild(0); + AxialStage core = (AxialStage) rocket.getChild(1); + AxialStage boosterA = createBooster(); boosterA.setName("Booster A Stage"); core.addChild(boosterA); boosterA.setAxialOffset(Position.BOTTOM, 0.0); - Stage boosterB = createBooster(); + AxialStage boosterB = createBooster(); boosterB.setName("Booster B Stage"); core.addChild(boosterB); boosterB.setAxialOffset(Position.BOTTOM, 0); @@ -687,7 +687,7 @@ public class StageTest extends BaseTestCase { @Test public void testToAbsolute() { Rocket rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); + AxialStage core = (AxialStage) rocket.getChild(1); String treeDump = rocket.toDebugTree(); Coordinate input = new Coordinate(3, 0, 0); @@ -700,7 +700,7 @@ public class StageTest extends BaseTestCase { @Test public void testToRelative() { Rocket rocket = createTestRocket(); - Stage core = (Stage) rocket.getChild(1); + AxialStage core = (AxialStage) rocket.getChild(1); RocketComponent ubody = core.getChild(0); RocketComponent lbody = core.getChild(1); diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index 166644dc8..ce5a925be 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -48,7 +48,7 @@ import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.rocketcomponent.ComponentAssembly; import net.sf.openrocket.rocketcomponent.ExternalComponent; import net.sf.openrocket.rocketcomponent.OutsideComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.RocketComponent; diff --git a/swing/src/net/sf/openrocket/gui/configdialog/StageConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/StageConfig.java index 4622c76a1..08a2f5a4d 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/StageConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/StageConfig.java @@ -16,7 +16,7 @@ import net.sf.openrocket.gui.components.UnitSelector; import net.sf.openrocket.gui.components.StyledLabel.Style; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; @@ -30,18 +30,18 @@ public class StageConfig extends RocketComponentConfig { // Stage separation config (for non-first stage) if (component.getStageNumber() > 0) { - JPanel tab = separationTab((Stage) component); + JPanel tab = separationTab((AxialStage) component); tabbedPane.insertTab(trans.get("tab.Separation"), null, tab, trans.get("tab.Separation.ttip"), 1); } // only stages which are actually off-centerline will get the dialog here: if( ! component.isCenterline()){ - tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Parallel"), null, parallelTab( (Stage) component ), trans.get("RocketCompCfg.tab.ParallelComment"), 2); + tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Parallel"), null, parallelTab( (AxialStage) component ), trans.get("RocketCompCfg.tab.ParallelComment"), 2); } } - private JPanel parallelTab( final Stage stage ){ + private JPanel parallelTab( final AxialStage stage ){ JPanel motherPanel = new JPanel( new MigLayout("fill")); // set radial distance @@ -107,7 +107,7 @@ public class StageConfig extends RocketComponentConfig { return motherPanel; } - private JPanel separationTab(Stage stage) { + private JPanel separationTab(AxialStage stage) { JPanel panel = new JPanel(new MigLayout("fill")); // Select separation event diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java index 2456d1694..0dc8da4bc 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java @@ -22,7 +22,7 @@ import net.sf.openrocket.gui.adaptors.EnumModel; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration.SeparationEvent; import net.sf.openrocket.startup.Application; @@ -36,7 +36,7 @@ public class SeparationSelectionDialog extends JDialog { private StageSeparationConfiguration newConfiguration; - public SeparationSelectionDialog(Window parent, final Rocket rocket, final Stage component) { + public SeparationSelectionDialog(Window parent, final Rocket rocket, final AxialStage component) { super(parent, trans.get("edtmotorconfdlg.title.Selectseparationconf"), Dialog.ModalityType.APPLICATION_MODAL); final String id = rocket.getDefaultConfiguration().getFlightConfigurationID(); diff --git a/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java b/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java index 279bee359..eb49e69a3 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java @@ -44,7 +44,7 @@ import net.sf.openrocket.motor.Motor; import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Preferences; import net.sf.openrocket.util.Color; @@ -417,7 +417,7 @@ public class PhotoPanel extends JPanel implements GLEventListener { //Figure out the lowest stage shown final int currentStageNumber = configuration.getActiveStages()[configuration.getActiveStages().length-1]; - final Stage currentStage = (Stage)configuration.getRocket().getChild(currentStageNumber); + final AxialStage currentStage = (AxialStage)configuration.getRocket().getChild(currentStageNumber); final String motorID = configuration.getFlightConfigurationID(); final Iterator iterator = configuration.motorIterator(); @@ -427,7 +427,7 @@ public class PhotoPanel extends JPanel implements GLEventListener { //If this mount is not in currentStage continue on to the next one. RocketComponent parent = ((RocketComponent)mount); while ( null != (parent = parent.getParent()) ){ - if ( parent instanceof Stage ){ + if ( parent instanceof AxialStage ){ if ( parent != currentStage ) continue motor; break; diff --git a/swing/src/net/sf/openrocket/gui/main/ComponentAddButtons.java b/swing/src/net/sf/openrocket/gui/main/ComponentAddButtons.java index 447b7e4c8..ea3e2fa6f 100644 --- a/swing/src/net/sf/openrocket/gui/main/ComponentAddButtons.java +++ b/swing/src/net/sf/openrocket/gui/main/ComponentAddButtons.java @@ -34,6 +34,7 @@ import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.logging.Markers; import net.sf.openrocket.rocketcomponent.BodyComponent; import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.BoosterSet; import net.sf.openrocket.rocketcomponent.Bulkhead; import net.sf.openrocket.rocketcomponent.CenteringRing; import net.sf.openrocket.rocketcomponent.EllipticalFinSet; @@ -44,10 +45,12 @@ import net.sf.openrocket.rocketcomponent.LaunchLug; import net.sf.openrocket.rocketcomponent.MassComponent; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.Parachute; +import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.ShockCord; import net.sf.openrocket.rocketcomponent.Streamer; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.rocketcomponent.TubeCoupler; @@ -70,6 +73,8 @@ import org.slf4j.LoggerFactory; */ public class ComponentAddButtons extends JPanel implements Scrollable { + private static final long serialVersionUID = 4315680855765544950L; + private static final Logger log = LoggerFactory.getLogger(ComponentAddButtons.class); private static final Translator trans = Application.getTranslator(); @@ -105,12 +110,16 @@ public class ComponentAddButtons extends JPanel implements Scrollable { this.viewport = viewport; buttons = new ComponentButton[ROWS][]; + for( int rowCur = 0; rowCur < ROWS; rowCur++){ + buttons[rowCur]=null; + } int row = 0; - + int col = 0; //////////////////////////////////////////// //// Body components and fin sets - addButtonRow(trans.get("compaddbuttons.Bodycompandfinsets"), row, + add(new JLabel(trans.get("compaddbuttons.Bodycompandfinsets")), "span, gaptop 0, wrap"); + addButtonGroup(row, //// Nose cone new BodyComponentButton(NoseCone.class, trans.get("compaddbuttons.Nosecone")), //// Body tube @@ -127,14 +136,13 @@ public class ComponentAddButtons extends JPanel implements Scrollable { new FinButton(TubeFinSet.class, trans.get("compaddbuttons.Tubefin")), //// Launch lug new FinButton(LaunchLug.class, trans.get("compaddbuttons.Launchlug"))); - row++; - ///////////////////////////////////////////// //// Inner component - addButtonRow(trans.get("compaddbuttons.Innercomponent"), row, + add(new JLabel(trans.get("compaddbuttons.Innercomponent")), "span, gaptop unrel, wrap"); + addButtonGroup(row, //// Inner tube new ComponentButton(InnerTube.class, trans.get("compaddbuttons.Innertube")), //// Coupler @@ -149,9 +157,23 @@ public class ComponentAddButtons extends JPanel implements Scrollable { row++; //////////////////////////////////////////// + add(new JLabel(trans.get("compaddbuttons.assembly")), "span 3"); + add(new JLabel(trans.get("compaddbuttons.Massobjects")), "span, gaptop unrel, wrap"); + +// RocketActions.NewStageAct.ttip.Newstage = Add a new stage to the rocket design. +// RocketActions.NewStageAct.ttip.newBooster = Add a new set booster stage to the rocket design. +// RocketActions.NewStageAct.ttip.newPods = Add a new set of pods to the rocket design. + + //// Component Assembly Components: + ComponentButton[] buttonsToAdd = { + new ComponentButton(AxialStage.class, trans.get("RocketActions.NewStageAct.Newstage")), + new ComponentButton(BoosterSet.class, trans.get("compaddbuttons.newBooster.lbl")), + new ComponentButton(PodSet.class, trans.get("compaddbuttons.newPods.lbl"))}; + addButtonGroup(row, buttonsToAdd); //// Mass objects - addButtonRow(trans.get("compaddbuttons.Massobjects"), row, + // NOTE: These are on the same line as the assemblies above + addButtonGroup(row, //// Parachute new ComponentButton(Parachute.class, trans.get("compaddbuttons.Parachute")), //// Streamer @@ -160,7 +182,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable { new ComponentButton(ShockCord.class, trans.get("compaddbuttons.Shockcord")), // new ComponentButton("Motor clip"), // new ComponentButton("Payload"), - //// Mass\ncomponent + //// Mass component new ComponentButton(MassComponent.class, trans.get("compaddbuttons.Masscomponent"))); @@ -168,7 +190,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable { int w = 0, h = 0; for (row = 0; row < buttons.length; row++) { - for (int col = 0; col < buttons[row].length; col++) { + for (col = 0; col < buttons[row].length; col++) { Dimension d = buttons[row][col].getPreferredSize(); if (d.width > w) w = d.width; @@ -182,7 +204,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable { height = h; Dimension d = new Dimension(width, height); for (row = 0; row < buttons.length; row++) { - for (int col = 0; col < buttons[row].length; col++) { + for (col = 0; col < buttons[row].length; col++) { buttons[row][col].setMinimumSize(d); buttons[row][col].setPreferredSize(d); buttons[row][col].getComponent(0).validate(); @@ -210,27 +232,32 @@ public class ComponentAddButtons extends JPanel implements Scrollable { /** - * Adds a row of buttons to the panel. + * Adds a buttons to the panel in a row. Assumes. + * * @param label Label placed before the row * @param row Row number * @param b List of ComponentButtons to place on the row */ - private void addButtonRow(String label, int row, ComponentButton... b) { - if (row > 0) - add(new JLabel(label), "span, gaptop unrel, wrap"); - else - add(new JLabel(label), "span, gaptop 0, wrap"); + private void addButtonGroup(int row, ComponentButton... b) { - int col = 0; - buttons[row] = new ComponentButton[b.length]; + int oldLen=0; + if( null == buttons[row] ){ + buttons[row] = new ComponentButton[b.length]; + }else{ + ComponentButton[] oldArr = buttons[row]; + oldLen = oldArr.length; + ComponentButton[] newArr = new ComponentButton[oldLen + b.length]; + System.arraycopy(oldArr, 0, newArr, 0, oldLen); + buttons[row] = newArr; + } - for (int i = 0; i < b.length; i++) { - buttons[row][col] = b[i]; - if (i < b.length - 1) - add(b[i], BUTTONPARAM); - else - add(b[i], BUTTONPARAM + ", wrap"); - col++; + int dstCol = oldLen; + int srcCol=0; + while( srcCol < b.length) { + buttons[row][dstCol] = b[srcCol]; + add(b[srcCol], BUTTONPARAM); + dstCol++; + srcCol++; } } @@ -272,6 +299,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable { * Class for a component button. */ private class ComponentButton extends JButton implements TreeSelectionListener { + private static final long serialVersionUID = 4510127994205259083L; protected Class componentClass = null; private Constructor constructor = null; @@ -466,7 +494,8 @@ public class ComponentAddButtons extends JPanel implements Scrollable { * A class suitable for BodyComponents. Addition is allowed ... */ private class BodyComponentButton extends ComponentButton { - + private static final long serialVersionUID = 1574998068156786363L; + public BodyComponentButton(Class c, String text) { super(c, text); } @@ -599,6 +628,11 @@ public class ComponentAddButtons extends JPanel implements Scrollable { * Class for fin sets, that attach only to BodyTubes. */ private class FinButton extends ComponentButton { + /** + * + */ + private static final long serialVersionUID = -219204844803871258L; + public FinButton(Class c, String text) { super(c, text); } diff --git a/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java b/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java index 168b61133..cb6e0d4bf 100644 --- a/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java +++ b/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java @@ -11,6 +11,7 @@ import javax.swing.ImageIcon; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.BoosterSet; import net.sf.openrocket.rocketcomponent.Bulkhead; import net.sf.openrocket.rocketcomponent.CenteringRing; import net.sf.openrocket.rocketcomponent.EllipticalFinSet; @@ -22,6 +23,7 @@ import net.sf.openrocket.rocketcomponent.MassComponent; import net.sf.openrocket.rocketcomponent.MassComponent.MassComponentType; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.Parachute; +import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.ShockCord; import net.sf.openrocket.rocketcomponent.Streamer; import net.sf.openrocket.rocketcomponent.Transition; @@ -79,6 +81,10 @@ public class ComponentIcons { ShockCord.class); load("mass", trans.get("ComponentIcons.Masscomponent"), MassComponent.class); + load("boosters", trans.get("ComponentIcons.Boosters"), + BoosterSet.class); + load("pods", trans.get("ComponentIcons.Pods"), + PodSet.class); // // Mass components loadMassTypeIcon("mass", trans.get("ComponentIcons.Masscomponent"), MassComponentType.MASSCOMPONENT); diff --git a/swing/src/net/sf/openrocket/gui/main/RocketActions.java b/swing/src/net/sf/openrocket/gui/main/RocketActions.java index a702c2839..9cd01f0de 100644 --- a/swing/src/net/sf/openrocket/gui/main/RocketActions.java +++ b/swing/src/net/sf/openrocket/gui/main/RocketActions.java @@ -24,7 +24,7 @@ import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.ComponentChangeListener; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Preferences; import net.sf.openrocket.util.Pair; @@ -174,7 +174,7 @@ public class RocketActions { return false; // Cannot remove last stage - if ((c instanceof Stage) && (c.getParent().getChildCount() == 1)) { + if ((c instanceof AxialStage) && (c.getParent().getChildCount() == 1)) { return false; } @@ -597,7 +597,7 @@ public class RocketActions { ComponentConfigDialog.hideDialog(); - RocketComponent stage = new Stage(); + RocketComponent stage = new AxialStage(); //// Booster stage stage.setName(trans.get("RocketActions.ActBoosterstage")); //// Add stage diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/SeparationConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/SeparationConfigurationPanel.java index 9f6ed064b..640fdd7da 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/SeparationConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/SeparationConfigurationPanel.java @@ -17,17 +17,17 @@ import net.sf.openrocket.formatting.RocketDescriptor; import net.sf.openrocket.gui.dialogs.flightconfiguration.SeparationSelectionDialog; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; -public class SeparationConfigurationPanel extends FlightConfigurablePanel { +public class SeparationConfigurationPanel extends FlightConfigurablePanel { static final Translator trans = Application.getTranslator(); private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class); - private FlightConfigurableTableModel separationTableModel; + private FlightConfigurableTableModel separationTableModel; private final JButton selectSeparationButton; private final JButton resetDeploymentButton; @@ -65,9 +65,9 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel @Override protected JTable initializeTable() { //// Separation selection - separationTableModel = new FlightConfigurableTableModel(Stage.class, rocket) { + separationTableModel = new FlightConfigurableTableModel(AxialStage.class, rocket) { @Override - protected boolean includeComponent(Stage component) { + protected boolean includeComponent(AxialStage component) { return component.getStageNumber() > 0; } @@ -92,7 +92,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel } private void selectDeployment() { - Stage stage = getSelectedComponent(); + AxialStage stage = getSelectedComponent(); if (stage == null) { return; } @@ -102,7 +102,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel } private void resetDeployment() { - Stage stage = getSelectedComponent(); + AxialStage stage = getSelectedComponent(); if (stage == null) { return; } @@ -116,10 +116,10 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel resetDeploymentButton.setEnabled(componentSelected); } - private class SeparationTableCellRenderer extends FlightConfigurablePanel.FlightConfigurableCellRenderer { + private class SeparationTableCellRenderer extends FlightConfigurablePanel.FlightConfigurableCellRenderer { @Override - protected JLabel format(Stage stage, String configId, JLabel label) { + protected JLabel format(AxialStage stage, String configId, JLabel label) { StageSeparationConfiguration sepConfig = stage.getStageSeparationConfiguration().get(configId); String spec = getSeparationSpecification(sepConfig); label.setText(spec); diff --git a/swing/src/net/sf/openrocket/gui/print/DesignReport.java b/swing/src/net/sf/openrocket/gui/print/DesignReport.java index 550381a1c..ed7c98c36 100644 --- a/swing/src/net/sf/openrocket/gui/print/DesignReport.java +++ b/swing/src/net/sf/openrocket/gui/print/DesignReport.java @@ -21,7 +21,7 @@ import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.simulation.FlightData; import net.sf.openrocket.simulation.exception.SimulationException; import net.sf.openrocket.startup.Application; @@ -341,7 +341,7 @@ public class DesignReport { boolean topBorder = false; for (RocketComponent c : rocket) { - if (c instanceof Stage) { + if (c instanceof AxialStage) { config.setToStage(stage); stage++; stageMass = massCalc.getCG(config, MassCalcType.LAUNCH_MASS).weight; diff --git a/swing/src/net/sf/openrocket/gui/print/components/RocketPrintTree.java b/swing/src/net/sf/openrocket/gui/print/components/RocketPrintTree.java index 5296ea478..346a6bb46 100644 --- a/swing/src/net/sf/openrocket/gui/print/components/RocketPrintTree.java +++ b/swing/src/net/sf/openrocket/gui/print/components/RocketPrintTree.java @@ -6,7 +6,7 @@ package net.sf.openrocket.gui.print.components; import net.sf.openrocket.gui.print.OpenRocketPrintable; import net.sf.openrocket.gui.print.PrintableContext; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import javax.swing.*; import javax.swing.event.TreeExpansionEvent; @@ -70,7 +70,7 @@ public class RocketPrintTree extends JTree { toAddTo = parent; } for (RocketComponent stage : stages) { - if (stage instanceof Stage) { + if (stage instanceof AxialStage) { toAddTo.add(createNamedVector(stage.getName(), createPrintTreeNode(true), stage.getStageNumber())); } } diff --git a/swing/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java b/swing/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java index 08df0cc55..fbc56feb6 100644 --- a/swing/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java +++ b/swing/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java @@ -33,7 +33,7 @@ import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.RingComponent; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.ShockCord; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.Streamer; import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.unit.Unit; @@ -150,7 +150,7 @@ public class PartsDetailVisitorStrategy { private void handle (RocketComponent component) { //This ugly if-then-else construct is not object oriented. Originally it was an elegant, and very OO savy, design //using the Visitor pattern. Unfortunately, it was misunderstood and was removed. - if (component instanceof Stage) { + if (component instanceof AxialStage) { try { if (grid != null) { document.add(grid); diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 87a381fb5..358419aed 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -32,7 +32,7 @@ import net.sf.openrocket.rocketcomponent.MotorConfiguration; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.Stage; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.gui.rocketfigure.RocketComponentShape; import net.sf.openrocket.gui.scalefigure.RocketPanel; import net.sf.openrocket.startup.Application; @@ -453,7 +453,7 @@ public class RocketFigure extends AbstractScaleFigure { // generate shapes: if( comp instanceof Rocket){ // no-op. no shapes - }else if( comp instanceof Stage ){ + }else if( comp instanceof AxialStage ){ // no-op; no shapes here, either. }else{ // get all shapes for this component, add to return list.