Added limit diameter checkbox and preference. Refactored some code in
MotorFilterPanel to make it nicer.
This commit is contained in:
parent
42e70d3552
commit
858291de7c
@ -1086,6 +1086,7 @@ 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.checkbox.limitlength = Limit motor length to mount length
|
||||||
|
TCMotorSelPan.checkbox.limitdiameter = Limit motor diameter to mount diameter
|
||||||
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
|
||||||
|
@ -83,6 +83,10 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
private boolean limitLength = false;
|
private boolean limitLength = false;
|
||||||
private Double mountLength = null;
|
private Double mountLength = null;
|
||||||
|
|
||||||
|
private final JCheckBox limitDiameterCheckBox;
|
||||||
|
private boolean limitDiameter = false;
|
||||||
|
private Double mountDiameter = 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;
|
||||||
@ -96,6 +100,7 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
filter.setExcludedManufacturers(unselectedManusFromPreferences);
|
filter.setExcludedManufacturers(unselectedManusFromPreferences);
|
||||||
|
|
||||||
limitLength = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitLength", false);
|
limitLength = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitLength", false);
|
||||||
|
limitDiameter = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitDiameter", false);
|
||||||
|
|
||||||
//// Hide used motor files
|
//// Hide used motor files
|
||||||
{
|
{
|
||||||
@ -111,7 +116,6 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
this.add(hideUsedBox, "gapleft para, spanx, growx, wrap");
|
this.add(hideUsedBox, "gapleft para, spanx, growx, wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Manufacturer selection
|
// Manufacturer selection
|
||||||
JPanel sub = new JPanel(new MigLayout("fill"));
|
JPanel sub = new JPanel(new MigLayout("fill"));
|
||||||
TitledBorder border = BorderFactory.createTitledBorder(trans.get("TCurveMotorCol.MANUFACTURER"));
|
TitledBorder border = BorderFactory.createTitledBorder(trans.get("TCurveMotorCol.MANUFACTURER"));
|
||||||
@ -206,7 +210,7 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
this.add(sub,"grow, wrap");
|
this.add(sub,"grow, wrap");
|
||||||
|
|
||||||
|
|
||||||
// Diameter selection
|
// Motor Dimensions
|
||||||
sub = new JPanel(new MigLayout("fill"));
|
sub = new JPanel(new MigLayout("fill"));
|
||||||
TitledBorder diameterTitleBorder = BorderFactory.createTitledBorder(trans.get("TCMotorSelPan.MotorSize"));
|
TitledBorder diameterTitleBorder = BorderFactory.createTitledBorder(trans.get("TCMotorSelPan.MotorSize"));
|
||||||
GUIUtil.changeFontStyle(diameterTitleBorder, Font.BOLD);
|
GUIUtil.changeFontStyle(diameterTitleBorder, Font.BOLD);
|
||||||
@ -215,8 +219,23 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
motorMountDimension = new JLabel();
|
motorMountDimension = new JLabel();
|
||||||
GUIUtil.changeFontSize(motorMountDimension, -1);
|
GUIUtil.changeFontSize(motorMountDimension, -1);
|
||||||
sub.add(motorMountDimension,"growx,wrap");
|
sub.add(motorMountDimension,"growx,wrap");
|
||||||
|
|
||||||
|
// Diameter selection
|
||||||
{
|
{
|
||||||
sub.add( new JLabel("Diameter"), "split 2, wrap");
|
sub.add( new JLabel(trans.get("TCMotorSelPan.Diameter")), "split 2, wrap");
|
||||||
|
limitDiameterCheckBox = new JCheckBox( trans.get("TCMotorSelPan.checkbox.limitdiameter"));
|
||||||
|
GUIUtil.changeFontSize(limitDiameterCheckBox, -1);
|
||||||
|
limitDiameterCheckBox.setSelected(limitDiameter);
|
||||||
|
limitDiameterCheckBox.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
limitDiameter = limitDiameterCheckBox.isSelected();
|
||||||
|
MotorFilterPanel.this.setLimitDiameter();
|
||||||
|
onSelectionChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sub.add( limitDiameterCheckBox, "gapleft para, spanx, growx, wrap" );
|
||||||
|
|
||||||
diameterSlider = new MultiSlider(MultiSlider.HORIZONTAL,0, diameterValues.length-1, 0, diameterValues.length-1);
|
diameterSlider = new MultiSlider(MultiSlider.HORIZONTAL,0, diameterValues.length-1, 0, diameterValues.length-1);
|
||||||
diameterSlider.setBounded(true); // thumbs cannot cross
|
diameterSlider.setBounded(true); // thumbs cannot cross
|
||||||
diameterSlider.setMajorTickSpacing(1);
|
diameterSlider.setMajorTickSpacing(1);
|
||||||
@ -242,14 +261,14 @@ 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"));
|
limitLengthCheckBox = new JCheckBox( trans.get("TCMotorSelPan.checkbox.limitlength"));
|
||||||
GUIUtil.changeFontSize(limitLengthCheckBox, -1);
|
GUIUtil.changeFontSize(limitLengthCheckBox, -1);
|
||||||
limitLengthCheckBox.setSelected(limitLength);
|
limitLengthCheckBox.setSelected(limitLength);
|
||||||
limitLengthCheckBox.addActionListener(new ActionListener() {
|
limitLengthCheckBox.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
MotorFilterPanel.this.setLimitLength( limitLengthCheckBox.isSelected());
|
limitLength = limitLengthCheckBox.isSelected();
|
||||||
|
MotorFilterPanel.this.setLimitLength();
|
||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -309,17 +328,30 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
if ( mount == null ) {
|
if ( mount == null ) {
|
||||||
// Disable diameter controls?
|
// Disable diameter controls?
|
||||||
mountLength = null;
|
mountLength = null;
|
||||||
lengthSlider.setValueAt(1, 1000);
|
mountDiameter = null;
|
||||||
motorMountDimension.setText("");
|
motorMountDimension.setText("");
|
||||||
} else {
|
} else {
|
||||||
mountLength = ((RocketComponent)mount).getLength();
|
mountLength = ((RocketComponent)mount).getLength();
|
||||||
if ( limitLength ) {
|
mountDiameter = mount.getMotorMountDiameter();
|
||||||
|
motorMountDimension.setText( trans.get("TCMotorSelPan.MotorMountDimensions") + " " +
|
||||||
|
UnitGroup.UNITS_MOTOR_DIMENSIONS.toStringUnit(mountDiameter)+ " x " + UnitGroup.UNITS_MOTOR_DIMENSIONS.toStringUnit(mountLength));
|
||||||
|
}
|
||||||
|
setLimitLength();
|
||||||
|
setLimitDiameter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLimitLength( ) {
|
||||||
|
((SwingPreferences) Application.getPreferences()).putBoolean("motorFilterLimitLength", limitLength);
|
||||||
|
if ( mountLength != null & limitLength ) {
|
||||||
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
|
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
|
||||||
} else {
|
} else {
|
||||||
lengthSlider.setValueAt(1, 1000);
|
lengthSlider.setValueAt(1, 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double mountDiameter = mount.getMotorMountDiameter();
|
private void setLimitDiameter( ) {
|
||||||
|
((SwingPreferences) Application.getPreferences()).putBoolean("motorFilterLimitDiameter", limitDiameter);
|
||||||
|
if ( limitDiameter && mountDiameter != null) {
|
||||||
// find the next largest diameter
|
// find the next largest diameter
|
||||||
int i;
|
int i;
|
||||||
for( i =0; i< diameterValues.length; i++ ) {
|
for( i =0; i< diameterValues.length; i++ ) {
|
||||||
@ -331,19 +363,8 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
diameterSlider.setValueAt(1, i-1);
|
diameterSlider.setValueAt(1, i-1);
|
||||||
|
|
||||||
motorMountDimension.setText( trans.get("TCMotorSelPan.MotorMountDimensions") + " " +
|
|
||||||
UnitGroup.UNITS_MOTOR_DIMENSIONS.toStringUnit(mountDiameter)+ " x " + UnitGroup.UNITS_MOTOR_DIMENSIONS.toStringUnit(mountLength));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
lengthSlider.setValueAt(1, 1000);
|
diameterSlider.setValueAt(1, diameterValues.length-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user