Added boolean preference to toggle if the motor filter automatically

limits the length to the motor mount length.
This commit is contained in:
kruland2607 2013-10-10 20:53:48 -05:00
parent 30b89a54cf
commit 42e70d3552
2 changed files with 38 additions and 2 deletions

View File

@ -1085,6 +1085,7 @@ StorageOptChooser.lbl.Saveopt = Save options
TCMotorSelPan.lbl.Selrocketmotor = Select rocket motor: TCMotorSelPan.lbl.Selrocketmotor = Select rocket motor:
TCMotorSelPan.checkbox.hideSimilar = Hide very similar thrust curves TCMotorSelPan.checkbox.hideSimilar = Hide very similar thrust curves
TCMotorSelPan.checkbox.hideUsed = Hide motors already used in the mount TCMotorSelPan.checkbox.hideUsed = Hide motors already used in the mount
TCMotorSelPan.checkbox.limitlength = Limit motor length to mount length
TCMotorSelPan.btn.details = Show Details TCMotorSelPan.btn.details = Show Details
TCMotorSelPan.btn.filter = Filter Motors TCMotorSelPan.btn.filter = Filter Motors
TCMotorSelPan.MotorSize = Motor Dimensions TCMotorSelPan.MotorSize = Motor Dimensions

View File

@ -79,6 +79,10 @@ public abstract class MotorFilterPanel extends JPanel {
private final MotorRowFilter filter; private final MotorRowFilter filter;
private final JCheckBox limitLengthCheckBox;
private boolean limitLength = false;
private Double mountLength = null;
// Things we change the label on based on the MotorMount. // Things we change the label on based on the MotorMount.
private final JLabel motorMountDimension; private final JLabel motorMountDimension;
private final MultiSlider lengthSlider; private final MultiSlider lengthSlider;
@ -91,6 +95,8 @@ public abstract class MotorFilterPanel extends JPanel {
List<Manufacturer> unselectedManusFromPreferences = ((SwingPreferences) Application.getPreferences()).getExcludedMotorManufacturers(); List<Manufacturer> unselectedManusFromPreferences = ((SwingPreferences) Application.getPreferences()).getExcludedMotorManufacturers();
filter.setExcludedManufacturers(unselectedManusFromPreferences); filter.setExcludedManufacturers(unselectedManusFromPreferences);
limitLength = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitLength", false);
//// Hide used motor files //// Hide used motor files
{ {
final JCheckBox hideUsedBox = new JCheckBox(trans.get("TCMotorSelPan.checkbox.hideUsed")); final JCheckBox hideUsedBox = new JCheckBox(trans.get("TCMotorSelPan.checkbox.hideUsed"));
@ -237,6 +243,20 @@ public abstract class MotorFilterPanel extends JPanel {
{ {
sub.add( new JLabel(trans.get("TCMotorSelPan.Length")), "split 2, wrap"); sub.add( new JLabel(trans.get("TCMotorSelPan.Length")), "split 2, wrap");
limitLengthCheckBox = new JCheckBox( trans.get("TCMotorSelPan.checkbox.limitlength"));
GUIUtil.changeFontSize(limitLengthCheckBox, -1);
limitLengthCheckBox.setSelected(limitLength);
limitLengthCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MotorFilterPanel.this.setLimitLength( limitLengthCheckBox.isSelected());
onSelectionChanged();
}
});
sub.add( limitLengthCheckBox, "gapleft para, spanx, growx, wrap" );
final DoubleModel minimumLength = new DoubleModel(filter, "MinimumLength", UnitGroup.UNITS_MOTOR_DIMENSIONS, 0); final DoubleModel minimumLength = new DoubleModel(filter, "MinimumLength", UnitGroup.UNITS_MOTOR_DIMENSIONS, 0);
final DoubleModel maximumLength = new DoubleModel(filter, "MaximumLength", UnitGroup.UNITS_MOTOR_DIMENSIONS, 0); final DoubleModel maximumLength = new DoubleModel(filter, "MaximumLength", UnitGroup.UNITS_MOTOR_DIMENSIONS, 0);
@ -288,11 +308,16 @@ public abstract class MotorFilterPanel extends JPanel {
onSelectionChanged(); onSelectionChanged();
if ( mount == null ) { if ( mount == null ) {
// Disable diameter controls? // Disable diameter controls?
mountLength = null;
lengthSlider.setValueAt(1, 1000); lengthSlider.setValueAt(1, 1000);
motorMountDimension.setText(""); motorMountDimension.setText("");
} else { } else {
double mountLength = ((RocketComponent)mount).getLength(); mountLength = ((RocketComponent)mount).getLength();
if ( limitLength ) {
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength))); lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
} else {
lengthSlider.setValueAt(1, 1000);
}
double mountDiameter = mount.getMotorMountDiameter(); double mountDiameter = mount.getMotorMountDiameter();
// find the next largest diameter // find the next largest diameter
@ -312,6 +337,16 @@ public abstract class MotorFilterPanel extends JPanel {
} }
} }
private void setLimitLength( boolean limitLength ) {
this.limitLength = limitLength;
((SwingPreferences) Application.getPreferences()).putBoolean("motorFilterLimitLength", limitLength);
if ( mountLength != null & limitLength ) {
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
} else {
lengthSlider.setValueAt(1, 1000);
}
}
public abstract void onSelectionChanged(); public abstract void onSelectionChanged();
} }