commit
1c287b90be
@ -197,7 +197,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
|||||||
if( 1 == getInstanceCount()){
|
if( 1 == getInstanceCount()){
|
||||||
buffer.append(String.format("%-40s| %5.3f; %24s; %24s;", indent+this.getName()+" (# "+this.getStageNumber()+")",
|
buffer.append(String.format("%-40s| %5.3f; %24s; %24s;", indent+this.getName()+" (# "+this.getStageNumber()+")",
|
||||||
this.getLength(), this.getPosition(), this.getComponentLocations()[0]));
|
this.getLength(), this.getPosition(), this.getComponentLocations()[0]));
|
||||||
buffer.append(String.format("len: %6.4f )(offset: %4.1f via: %s )\n", this.getLength(), this.getAxialOffset(), this.axialMethod.name ));
|
buffer.append(String.format("len: %6.4f )(offset: %4.1f via: %s )\n", this.getLength(), this.getAxialOffset(), this.axialMethod.name() ));
|
||||||
}else{
|
}else{
|
||||||
buffer.append(String.format("%-40s|(len: %6.4f )(offset: %4.1f via: %s)\n", (indent+this.getName()+"(# "+this.getStageNumber()+")"), this.getLength(), this.getAxialOffset(), this.axialMethod.name() ));
|
buffer.append(String.format("%-40s|(len: %6.4f )(offset: %4.1f via: %s)\n", (indent+this.getName()+"(# "+this.getStageNumber()+")"), this.getLength(), this.getAxialOffset(), this.axialMethod.name() ));
|
||||||
for (int instanceNumber = 0; instanceNumber < this.getInstanceCount(); instanceNumber++) {
|
for (int instanceNumber = 0; instanceNumber < this.getInstanceCount(); instanceNumber++) {
|
||||||
|
@ -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:
|
||||||
|
@ -22,7 +22,7 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
|||||||
protected double angleSeparation = Math.PI;
|
protected double angleSeparation = Math.PI;
|
||||||
protected double angleOffset_rad = 0;
|
protected double angleOffset_rad = 0;
|
||||||
|
|
||||||
protected RadiusMethod radiusMethod = RadiusMethod.SURFACE;
|
protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE;
|
||||||
protected double radiusOffset_m = 0;
|
protected double radiusOffset_m = 0;
|
||||||
|
|
||||||
public ParallelStage() {
|
public ParallelStage() {
|
||||||
|
@ -25,7 +25,7 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
|||||||
// angle to the first pod
|
// angle to the first pod
|
||||||
protected double angleOffset_rad = 0;
|
protected double angleOffset_rad = 0;
|
||||||
|
|
||||||
protected RadiusMethod radiusMethod = RadiusMethod.SURFACE;
|
protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE;
|
||||||
protected double radiusOffset_m = 0;
|
protected double radiusOffset_m = 0;
|
||||||
|
|
||||||
public PodSet() {
|
public PodSet() {
|
||||||
@ -155,7 +155,7 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
|||||||
|
|
||||||
if (this.isAfter()){
|
if (this.isAfter()){
|
||||||
// remember the implicit (this instanceof Stage)
|
// remember the implicit (this instanceof Stage)
|
||||||
throw new BugException("found a Stage on centerline, but not positioned as AFTER. Please fix this! " + this.getName() + " is " + this.getAxialMethod().name );
|
throw new BugException("found a pod positioned via: AFTER, but is not on the centerline?!: " + this.getName() + " is " + this.getAxialMethod().name() );
|
||||||
} else {
|
} else {
|
||||||
returnValue = super.asPositionValue(this.axialMethod);
|
returnValue = super.asPositionValue(this.axialMethod);
|
||||||
}
|
}
|
||||||
|
@ -967,7 +967,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
}else if( AxialMethod.BOTTOM == asMethod) {
|
}else if( AxialMethod.BOTTOM == asMethod) {
|
||||||
result = this.position.x + ( this.length - parentLength);
|
result = this.position.x + ( this.length - parentLength);
|
||||||
}else {
|
}else {
|
||||||
throw new BugException("Unknown position type: " + asMethod.name);
|
throw new BugException("Unknown position type: " + asMethod.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -2176,7 +2176,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
StackTraceElement[] stackTrace = (new Exception()).getStackTrace();
|
StackTraceElement[] stackTrace = (new Exception()).getStackTrace();
|
||||||
buf.append(" >> Dumping Detailed Information from: " + stackTrace[1].getMethodName() + "\n");
|
buf.append(" >> Dumping Detailed Information from: " + stackTrace[1].getMethodName() + "\n");
|
||||||
buf.append(" current Component: " + this.getName() + " ofClass: " + this.getClass().getSimpleName() + "\n");
|
buf.append(" current Component: " + this.getName() + " ofClass: " + this.getClass().getSimpleName() + "\n");
|
||||||
buf.append(" offset: " + this.axialOffset + " via: " + this.axialMethod.name + " => " + this.getAxialOffset() + "\n");
|
buf.append(" offset: " + this.axialOffset + " via: " + this.axialMethod.name() + " => " + this.getAxialOffset() + "\n");
|
||||||
buf.append(" thisCenterX: " + this.position.x + "\n");
|
buf.append(" thisCenterX: " + this.position.x + "\n");
|
||||||
buf.append(" this length: " + this.length + "\n");
|
buf.append(" this length: " + this.length + "\n");
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -46,13 +46,18 @@ public enum AngleMethod implements DistanceMethod {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static final AngleMethod[] choices(){
|
public static final AngleMethod[] choices(){
|
||||||
return new AngleMethod[]{ AngleMethod.RELATIVE, AngleMethod.FIXED };
|
return new AngleMethod[]{ AngleMethod.RELATIVE };
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String name;
|
public final String description;
|
||||||
|
|
||||||
private AngleMethod( final String _name ) {
|
private AngleMethod( final String descr ) {
|
||||||
this.name= _name;
|
this.description= descr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,13 +35,18 @@ public enum AxialMethod implements DistanceMethod {
|
|||||||
|
|
||||||
public static final AxialMethod[] axialOffsetMethods = { TOP, MIDDLE, BOTTOM };
|
public static final AxialMethod[] axialOffsetMethods = { TOP, MIDDLE, BOTTOM };
|
||||||
|
|
||||||
public final String name;
|
public final String description;
|
||||||
|
|
||||||
private AxialMethod( final String _name ) {
|
private AxialMethod( final String newDescription ) {
|
||||||
this.name=_name;
|
this.description=newDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return true; }
|
public boolean clampToZero() { return true; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,20 @@ public enum RadiusMethod implements DistanceMethod {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static final RadiusMethod[] choices(){
|
public static final RadiusMethod[] choices(){
|
||||||
return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE, RadiusMethod.SURFACE };
|
return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE };
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String name;
|
public final String description;
|
||||||
|
|
||||||
// =============
|
// =============
|
||||||
|
|
||||||
private RadiusMethod( final String _name ) {
|
private RadiusMethod( final String descr ) {
|
||||||
this.name = _name;
|
this.description = descr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
|
|||||||
motherPanel.add(radiusUnitSelector, "growx 1, wrap");
|
motherPanel.add(radiusUnitSelector, "growx 1, wrap");
|
||||||
// autoRadOffsModel.addEnableComponent(radiusUnitSelector, false);
|
// autoRadOffsModel.addEnableComponent(radiusUnitSelector, false);
|
||||||
|
|
||||||
// set location angle around the primary stage
|
// // set location angle around the primary stage
|
||||||
JLabel angleMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Angle.Label"));
|
// JLabel angleMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Angle.Label"));
|
||||||
motherPanel.add( angleMethodLabel, "align left");
|
// motherPanel.add( angleMethodLabel, "align left");
|
||||||
EnumModel<AngleMethod> angleMethodModel = new EnumModel<AngleMethod>( boosters, "AngleMethod", AngleMethod.choices() );
|
// EnumModel<AngleMethod> angleMethodModel = new EnumModel<AngleMethod>( boosters, "AngleMethod", AngleMethod.choices() );
|
||||||
final JComboBox<AngleMethod> angleMethodCombo = new JComboBox<AngleMethod>( angleMethodModel );
|
// final JComboBox<AngleMethod> angleMethodCombo = new JComboBox<AngleMethod>( angleMethodModel );
|
||||||
motherPanel.add( angleMethodCombo, "align left, wrap");
|
// motherPanel.add( angleMethodCombo, "align left, wrap");
|
||||||
|
|
||||||
JLabel angleLabel = new JLabel(trans.get("StageConfig.parallel.angle"));
|
JLabel angleLabel = new JLabel(trans.get("StageConfig.parallel.angle"));
|
||||||
motherPanel.add( angleLabel, "align left");
|
motherPanel.add( angleLabel, "align left");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user