[fix] file version 108 now correctly loads angle-offsets for all ComponentAssemblies

This commit is contained in:
Daniel_M_Williams 2018-02-03 10:52:44 -05:00
parent 0ef72ec66d
commit 20473dbf82
3 changed files with 10 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.sf.openrocket.rocketcomponent.position.AxialMethod; import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.rocketcomponent.position.AxialPositionable;
import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
@ -21,7 +22,7 @@ import net.sf.openrocket.util.Coordinate;
* *
* @author Sampo Niskanen <sampo.niskanen@iki.fi> * @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/ */
public abstract class ComponentAssembly extends RocketComponent { public abstract class ComponentAssembly extends RocketComponent implements AxialPositionable {
private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class); private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class);
/** /**
@ -132,16 +133,17 @@ public abstract class ComponentAssembly extends RocketComponent {
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
public void setRelativePositionMethod(final AxialMethod _newPosition) { @Override
public void setAxialMethod( final AxialMethod newMethod ) {
if (null == this.parent) { if (null == this.parent) {
throw new NullPointerException(" a Stage requires a parent before any positioning! "); throw new NullPointerException(" a Stage requires a parent before any positioning! ");
} }
if ((this instanceof ParallelStage ) || ( this instanceof PodSet )){ if ((this instanceof ParallelStage ) || ( this instanceof PodSet )){
if (AxialMethod.AFTER == _newPosition) { if (AxialMethod.AFTER == newMethod) {
log.warn("Stages (or Pods) cannot be relative to other stages via AFTER! Ignoring."); log.warn("Stages (or Pods) cannot be relative to other stages via AFTER! Ignoring.");
super.setAxialMethod(AxialMethod.TOP); super.setAxialMethod(AxialMethod.TOP);
} else { } else {
super.setAxialMethod(_newPosition); super.setAxialMethod(newMethod);
} }
}else if( this.getClass().equals( AxialStage.class)){ }else if( this.getClass().equals( AxialStage.class)){
// Centerline stages must be set via AFTER-- regardless of what was requested: // Centerline stages must be set via AFTER-- regardless of what was requested:

View File

@ -173,7 +173,7 @@ public class ParallelStageTest extends BaseTestCase {
// without making the rocket 'external' and the Stage should be restricted to AFTER positioning. // without making the rocket 'external' and the Stage should be restricted to AFTER positioning.
sustainer.setRelativePositionMethod(AxialMethod.ABSOLUTE); sustainer.setAxialMethod(AxialMethod.ABSOLUTE);
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isAfter(), equalTo(true)); assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isAfter(), equalTo(true));
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getAxialMethod(), equalTo(AxialMethod.AFTER)); assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getAxialMethod(), equalTo(AxialMethod.AFTER));
@ -613,7 +613,7 @@ public class ParallelStageTest extends BaseTestCase {
boosterA.setAxialOffset(AxialMethod.TOP, targetOffset); boosterA.setAxialOffset(AxialMethod.TOP, targetOffset);
boosterB.setRelativePositionMethod(AxialMethod.TOP); boosterB.setAxialMethod(AxialMethod.TOP);
boosterB.setAxialOffset(targetOffset); boosterB.setAxialOffset(targetOffset);
String treeDump = rocket.toDebugTree(); String treeDump = rocket.toDebugTree();