[#1422] Add sliders to ComponentAssemblyConfig
This commit is contained in:
parent
0c9cb22660
commit
5365a210fd
@ -12,6 +12,7 @@ import net.sf.openrocket.gui.SpinnerEditor;
|
|||||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||||
import net.sf.openrocket.gui.adaptors.EnumModel;
|
import net.sf.openrocket.gui.adaptors.EnumModel;
|
||||||
import net.sf.openrocket.gui.adaptors.IntegerModel;
|
import net.sf.openrocket.gui.adaptors.IntegerModel;
|
||||||
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
||||||
@ -23,13 +24,21 @@ import net.sf.openrocket.rocketcomponent.position.RadiusMethod;
|
|||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ComponentAssemblyConfig extends RocketComponentConfig {
|
public class ComponentAssemblyConfig extends RocketComponentConfig {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
private final RocketComponent component;
|
||||||
|
|
||||||
public ComponentAssemblyConfig(OpenRocketDocument document, RocketComponent component) {
|
public ComponentAssemblyConfig(OpenRocketDocument document, RocketComponent component) {
|
||||||
super(document, component);
|
super(document, component);
|
||||||
|
this.component = component;
|
||||||
|
|
||||||
// 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( ParallelStage.class.isAssignableFrom( component.getClass()) || PodSet.class.isAssignableFrom( component.getClass())){
|
if( ParallelStage.class.isAssignableFrom( component.getClass()) || PodSet.class.isAssignableFrom( component.getClass())){
|
||||||
@ -45,9 +54,9 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
|
|||||||
// radial distance method
|
// radial distance method
|
||||||
JLabel radiusMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Radius.Label"));
|
JLabel radiusMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Radius.Label"));
|
||||||
motherPanel.add( radiusMethodLabel, "align left");
|
motherPanel.add( radiusMethodLabel, "align left");
|
||||||
final EnumModel<RadiusMethod> radiusMethodModel = new EnumModel<RadiusMethod>( boosters, "RadiusMethod", RadiusMethod.choices());
|
final ComboBoxModel<RadiusMethod> radiusMethodModel = new EnumModel<RadiusMethod>( boosters, "RadiusMethod", RadiusMethod.choices());
|
||||||
final JComboBox<RadiusMethod> radiusMethodCombo = new JComboBox<RadiusMethod>( radiusMethodModel );
|
final JComboBox<RadiusMethod> radiusMethodCombo = new JComboBox<RadiusMethod>( radiusMethodModel );
|
||||||
motherPanel.add( radiusMethodCombo, "align left, wrap");
|
motherPanel.add( radiusMethodCombo, "spanx 3, growx, wrap");
|
||||||
|
|
||||||
// set radial distance
|
// set radial distance
|
||||||
JLabel radiusLabel = new JLabel(trans.get("StageConfig.parallel.radius"));
|
JLabel radiusLabel = new JLabel(trans.get("StageConfig.parallel.radius"));
|
||||||
@ -55,30 +64,33 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
|
|||||||
//radiusMethodModel.addEnableComponent(radiusLabel, false);
|
//radiusMethodModel.addEnableComponent(radiusLabel, false);
|
||||||
DoubleModel radiusModel = new DoubleModel( boosters, "RadiusOffset", UnitGroup.UNITS_LENGTH, 0);
|
DoubleModel radiusModel = new DoubleModel( boosters, "RadiusOffset", UnitGroup.UNITS_LENGTH, 0);
|
||||||
|
|
||||||
JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel());
|
JSpinner radiusSpinner = new JSpinner(radiusModel.getSpinnerModel());
|
||||||
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner ));
|
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner));
|
||||||
motherPanel.add(radiusSpinner , "growx 1, align right");
|
motherPanel.add(radiusSpinner , "wmin 65lp, growx 1, align right");
|
||||||
// autoRadOffsModel.addEnableComponent(radiusSpinner, false);
|
// autoRadOffsModel.addEnableComponent(radiusSpinner, false);
|
||||||
UnitSelector radiusUnitSelector = new UnitSelector(radiusModel);
|
UnitSelector radiusUnitSelector = new UnitSelector(radiusModel);
|
||||||
motherPanel.add(radiusUnitSelector, "growx 1, wrap");
|
motherPanel.add(radiusUnitSelector, "growx 1");
|
||||||
// autoRadOffsModel.addEnableComponent(radiusUnitSelector, false);
|
motherPanel.add(new BasicSlider(radiusModel.getSliderModel(0, new DoubleModel(component.getParent(), "OuterRadius", 4.0, UnitGroup.UNITS_LENGTH))),
|
||||||
|
"gapleft para, growx 2, wrap");
|
||||||
|
|
||||||
// // set location angle around the primary stage
|
radiusMethodCombo.addItemListener(new ItemListener() {
|
||||||
// JLabel angleMethodLabel = new JLabel(trans.get("RocketComponent.Position.Method.Angle.Label"));
|
@Override
|
||||||
// motherPanel.add( angleMethodLabel, "align left");
|
public void itemStateChanged(ItemEvent e) {
|
||||||
// EnumModel<AngleMethod> angleMethodModel = new EnumModel<AngleMethod>( boosters, "AngleMethod", AngleMethod.choices() );
|
radiusModel.stateChanged(new EventObject(e));
|
||||||
// final JComboBox<AngleMethod> angleMethodCombo = new JComboBox<AngleMethod>( angleMethodModel );
|
}
|
||||||
// motherPanel.add( angleMethodCombo, "align left, wrap");
|
});
|
||||||
|
|
||||||
|
// set angle
|
||||||
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");
|
||||||
DoubleModel angleModel = new DoubleModel( boosters, "AngleOffset", 1.0, UnitGroup.UNITS_ANGLE, 0.0, Math.PI*2);
|
DoubleModel angleModel = new DoubleModel( boosters, "AngleOffset", 1.0, UnitGroup.UNITS_ANGLE, 0.0, Math.PI*2);
|
||||||
|
|
||||||
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
|
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
|
||||||
angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
|
angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
|
||||||
motherPanel.add(angleSpinner, "growx 1");
|
motherPanel.add(angleSpinner, "wmin 65lp, growx 1");
|
||||||
UnitSelector angleUnitSelector = new UnitSelector(angleModel);
|
UnitSelector angleUnitSelector = new UnitSelector(angleModel);
|
||||||
motherPanel.add( angleUnitSelector, "growx 1, wrap");
|
motherPanel.add( angleUnitSelector, "growx 1");
|
||||||
|
motherPanel.add(new BasicSlider(angleModel.getSliderModel(-Math.PI, Math.PI)), "gapleft para, growx 2, wrap");
|
||||||
|
|
||||||
// set multiplicity
|
// set multiplicity
|
||||||
JLabel countLabel = new JLabel(trans.get("StageConfig.parallel.count"));
|
JLabel countLabel = new JLabel(trans.get("StageConfig.parallel.count"));
|
||||||
@ -87,7 +99,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
|
|||||||
IntegerModel countModel = new IntegerModel( boosters, "InstanceCount", 1);
|
IntegerModel countModel = new IntegerModel( boosters, "InstanceCount", 1);
|
||||||
JSpinner countSpinner = new JSpinner(countModel.getSpinnerModel());
|
JSpinner countSpinner = new JSpinner(countModel.getSpinnerModel());
|
||||||
countSpinner.setEditor(new SpinnerEditor(countSpinner));
|
countSpinner.setEditor(new SpinnerEditor(countSpinner));
|
||||||
motherPanel.add(countSpinner, "growx 1, wrap");
|
motherPanel.add(countSpinner, "wmin 65lp, growx 1, wrap");
|
||||||
|
|
||||||
// setPositions relative to parent component
|
// setPositions relative to parent component
|
||||||
JLabel positionLabel = new JLabel(trans.get("LaunchLugCfg.lbl.Posrelativeto"));
|
JLabel positionLabel = new JLabel(trans.get("LaunchLugCfg.lbl.Posrelativeto"));
|
||||||
@ -95,21 +107,29 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
|
|||||||
|
|
||||||
ComboBoxModel<AxialMethod> axialPositionMethodModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods );
|
ComboBoxModel<AxialMethod> axialPositionMethodModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods );
|
||||||
JComboBox<?> positionMethodCombo = new JComboBox<AxialMethod>( axialPositionMethodModel );
|
JComboBox<?> positionMethodCombo = new JComboBox<AxialMethod>( axialPositionMethodModel );
|
||||||
motherPanel.add(positionMethodCombo, "spanx 2, growx, wrap");
|
motherPanel.add(positionMethodCombo, "spanx 3, growx, wrap");
|
||||||
|
|
||||||
// relative offset labels
|
// plus
|
||||||
JLabel positionPlusLabel = new JLabel(trans.get("StageConfig.parallel.offset"));
|
motherPanel.add(new JLabel(trans.get("StageConfig.parallel.plus")), "right");
|
||||||
motherPanel.add( positionPlusLabel );
|
|
||||||
DoubleModel axialOffsetModel = new DoubleModel( boosters, "AxialOffset", UnitGroup.UNITS_LENGTH);
|
|
||||||
|
|
||||||
JSpinner axPosSpin= new JSpinner( axialOffsetModel.getSpinnerModel());
|
final DoubleModel axialOffsetModel = new DoubleModel(component, "AxialOffset", UnitGroup.UNITS_LENGTH);
|
||||||
axPosSpin.setEditor(new SpinnerEditor(axPosSpin));
|
final JSpinner axialOffsetSpinner = new JSpinner(axialOffsetModel.getSpinnerModel());
|
||||||
motherPanel.add(axPosSpin, "growx");
|
axialOffsetSpinner.setEditor(new SpinnerEditor(axialOffsetSpinner));
|
||||||
UnitSelector axialOffsetUnitSelector = new UnitSelector(axialOffsetModel);
|
|
||||||
motherPanel.add(axialOffsetUnitSelector, "growx 1, wrap");
|
|
||||||
|
|
||||||
// For DEBUG purposes
|
motherPanel.add(axialOffsetSpinner, "wmin 65lp, growx 1");
|
||||||
//System.err.println(assembly.getRocket().toDebugTree());
|
|
||||||
|
positionMethodCombo.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
axialOffsetModel.stateChanged(new EventObject(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
motherPanel.add(new UnitSelector(axialOffsetModel), "growx");
|
||||||
|
motherPanel.add(new BasicSlider(axialOffsetModel.getSliderModel(
|
||||||
|
new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
|
||||||
|
new DoubleModel(component.getParent(), "Length"))),
|
||||||
|
"gapleft para, growx 2, wrap");
|
||||||
|
|
||||||
return motherPanel;
|
return motherPanel;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user