[Bugfix] Fixed UI issues related to 'Instanceable' implementation.

- Added set/get InstanceCount methods to BoosterSet, PodSets.
- changed order of editing tabs for BoosterSets, PodSets.
- When editing MotorMounts, fixed an incorrect model reference.
This commit is contained in:
Daniel_M_Williams 2015-10-16 19:05:32 -04:00
parent a7b4386358
commit 80c4ef5254
5 changed files with 43 additions and 3 deletions

View File

@ -102,6 +102,20 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return this.count; return this.count;
} }
@Override
public void setInstanceCount( final int newCount ){
mutex.verify();
if ( newCount < 1) {
// there must be at least one instance....
return;
}
this.count = newCount;
this.angularSeparation = Math.PI * 2 / this.count;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override @Override
public double getRadialOffset() { public double getRadialOffset() {
return this.radialPosition_m; return this.radialPosition_m;
@ -164,12 +178,14 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
@Override @Override
public void setRadialOffset(final double radius) { public void setRadialOffset(final double radius) {
mutex.verify();
this.radialPosition_m = radius; this.radialPosition_m = radius;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@Override @Override
public void setAngularOffset(final double angle_rad) { public void setAngularOffset(final double angle_rad) {
mutex.verify();
this.angularPosition_rad = angle_rad; this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }

View File

@ -165,12 +165,33 @@ public class PodSet extends ComponentAssembly implements RingInstanceable, Outsi
return (this.getInstanceCount() + "-ring"); return (this.getInstanceCount() + "-ring");
} }
@Override @Override
public double getRadialOffset() { public double getRadialOffset() {
return this.radialPosition_m; return this.radialPosition_m;
} }
@Override
public int getInstanceCount() {
return this.count;
}
@Override
public void setInstanceCount( final int newCount ){
mutex.verify();
if ( newCount < 1) {
// there must be at least one instance....
return;
}
this.count = newCount;
this.angularSeparation = Math.PI * 2 / this.count;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override @Override
public Coordinate[] shiftCoordinates(Coordinate[] c) { public Coordinate[] shiftCoordinates(Coordinate[] c) {
checkState(); checkState();
@ -212,12 +233,14 @@ public class PodSet extends ComponentAssembly implements RingInstanceable, Outsi
@Override @Override
public void setAngularOffset(double angle_rad) { public void setAngularOffset(double angle_rad) {
mutex.verify();
this.angularPosition_rad = angle_rad; this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@Override @Override
public void setRadialOffset(double radius_m) { public void setRadialOffset(double radius_m) {
mutex.verify();
this.radialPosition_m = radius_m; this.radialPosition_m = radius_m;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }

View File

@ -29,7 +29,7 @@ public class AxialStageConfig extends ComponentAssemblyConfig {
if (component.getStageNumber() > 0) { if (component.getStageNumber() > 0) {
JPanel tab = separationTab((AxialStage) component); JPanel tab = separationTab((AxialStage) component);
tabbedPane.insertTab(trans.get("StageConfig.tab.Separation"), null, tab, tabbedPane.insertTab(trans.get("StageConfig.tab.Separation"), null, tab,
trans.get("StageConfig.tab.Separation.ttip"), 1); trans.get("StageConfig.tab.Separation.ttip"), 2);
} }
} }

View File

@ -5,6 +5,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSpinner; import javax.swing.JSpinner;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.SpinnerEditor;
@ -27,7 +28,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
// only stages which are actually off-centerline will get the dialog here: // only stages which are actually off-centerline will get the dialog here:
if(( component instanceof ComponentAssembly )&&( ! component.isCenterline() )){ if(( component instanceof ComponentAssembly )&&( ! component.isCenterline() )){
tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Parallel"), null, parallelTab( (ComponentAssembly) component ), trans.get("RocketCompCfg.tab.ParallelComment"), 2); tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Parallel"), null, parallelTab( (ComponentAssembly) component ), trans.get("RocketCompCfg.tab.ParallelComment"), 1);
} }
} }

View File

@ -71,7 +71,7 @@ public class MotorConfig extends JPanel {
MotorInstance motorInstance = mount.getDefaultMotorInstance(); MotorInstance motorInstance = mount.getDefaultMotorInstance();
final EnumModel<IgnitionEvent> igEvModel = new EnumModel<IgnitionEvent>(motorMount, "IgnitionEvent", IgnitionEvent.values()); final EnumModel<IgnitionEvent> igEvModel = new EnumModel<IgnitionEvent>(motorInstance, "IgnitionEvent", IgnitionEvent.values());
final JComboBox<IgnitionEvent> eventBox = new JComboBox<IgnitionEvent>( igEvModel); final JComboBox<IgnitionEvent> eventBox = new JComboBox<IgnitionEvent>( igEvModel);
panel.add(eventBox , "growx, wrap"); panel.add(eventBox , "growx, wrap");