Merge pull request #2073 from SiboVG/issue-2072
[#2072] Apply designation/common name choice to other parts
This commit is contained in:
commit
7c65d71cfd
@ -1375,6 +1375,7 @@ TCMotorSelPan.lbl.Ejectionchargedelay = Ejection charge delay:
|
|||||||
TCMotorSelPan.equalsIgnoreCase.None = None
|
TCMotorSelPan.equalsIgnoreCase.None = None
|
||||||
TCMotorSelPan.lbl.NumberofsecondsorNone = (Number of seconds or \"None\")
|
TCMotorSelPan.lbl.NumberofsecondsorNone = (Number of seconds or \"None\")
|
||||||
TCMotorSelPan.lbl.Designation = Designation:
|
TCMotorSelPan.lbl.Designation = Designation:
|
||||||
|
TCMotorSelPan.lbl.CommonName = Common name:
|
||||||
TCMotorSelPan.lbl.Totalimpulse = Total impulse:
|
TCMotorSelPan.lbl.Totalimpulse = Total impulse:
|
||||||
TCMotorSelPan.lbl.Avgthrust = Avg. thrust:
|
TCMotorSelPan.lbl.Avgthrust = Avg. thrust:
|
||||||
TCMotorSelPan.lbl.Maxthrust = Max. thrust:
|
TCMotorSelPan.lbl.Maxthrust = Max. thrust:
|
||||||
|
@ -12,6 +12,7 @@ import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
|||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.ArrayList;
|
import net.sf.openrocket.util.ArrayList;
|
||||||
import net.sf.openrocket.util.Chars;
|
import net.sf.openrocket.util.Chars;
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ public class MotorConfigurationSubstitutor implements RocketSubstitutor {
|
|||||||
Motor motor = inst.getMotor();
|
Motor motor = inst.getMotor();
|
||||||
|
|
||||||
if (mount.isMotorMount() && config.isComponentActive(mount) && (motor != null)) {
|
if (mount.isMotorMount() && config.isComponentActive(mount) && (motor != null)) {
|
||||||
String motorDesignation = motor.getDesignation(inst.getEjectionDelay());
|
String motorDesignation = motor.getMotorName(inst.getEjectionDelay());
|
||||||
String manufacturer = "";
|
String manufacturer = "";
|
||||||
if (motor instanceof ThrustCurveMotor) {
|
if (motor instanceof ThrustCurveMotor) {
|
||||||
manufacturer = ((ThrustCurveMotor) motor).getManufacturer().getDisplayName();
|
manufacturer = ((ThrustCurveMotor) motor).getManufacturer().getDisplayName();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.sf.openrocket.motor;
|
package net.sf.openrocket.motor;
|
||||||
|
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
public interface Motor {
|
public interface Motor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,6 +112,24 @@ public interface Motor {
|
|||||||
* @return designation with delay.
|
* @return designation with delay.
|
||||||
*/
|
*/
|
||||||
public String getDesignation(double delay);
|
public String getDesignation(double delay);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the motor name, based on whether the preference is to use the designation or common name.
|
||||||
|
* @return the motor designation, if the preference is to use the designation, otherwise the common name.
|
||||||
|
*/
|
||||||
|
public default String getMotorName() {
|
||||||
|
boolean useDesignation = Application.getPreferences().getMotorNameColumn();
|
||||||
|
return useDesignation ? getDesignation() : getCommonName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the motor name, including a delay, based on whether the preference is to use the designation or common name.
|
||||||
|
* @return the motor designation, including a delay, if the preference is to use the designation, otherwise the common name.
|
||||||
|
*/
|
||||||
|
public default String getMotorName(double delay) {
|
||||||
|
boolean useDesignation = Application.getPreferences().getMotorNameColumn();
|
||||||
|
return useDesignation ? getDesignation(delay) : getCommonName(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,6 @@ import net.sf.openrocket.rocketcomponent.InnerTube;
|
|||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.ArrayList;
|
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.Inertia;
|
import net.sf.openrocket.util.Inertia;
|
||||||
|
|
||||||
@ -68,11 +67,11 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
return ignitionOveride;
|
return ignitionOveride;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toMotorCommonName(){
|
public String toMotorName(){
|
||||||
if( motor == null ){
|
if( motor == null ){
|
||||||
return trans.get("empty");
|
return trans.get("empty");
|
||||||
}else{
|
}else{
|
||||||
return this.motor.getCommonName(this.getEjectionDelay());
|
return this.motor.getMotorName(this.getEjectionDelay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +272,7 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toDescription(){
|
public String toDescription(){
|
||||||
return ( this.toMotorCommonName()+
|
return ( this.toMotorName()+
|
||||||
" in: "+mount.getDebugName()+
|
" in: "+mount.getDebugName()+
|
||||||
" ign@: "+this.toIgnitionDescription() );
|
" ign@: "+this.toIgnitionDescription() );
|
||||||
}
|
}
|
||||||
@ -289,7 +288,7 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
mount.getDebugName(),
|
mount.getDebugName(),
|
||||||
fcid.toShortKey(),
|
fcid.toShortKey(),
|
||||||
mid.toDebug(),
|
mid.toDebug(),
|
||||||
toMotorCommonName(),
|
toMotorName(),
|
||||||
toIgnitionDescription() ));
|
toIgnitionDescription() ));
|
||||||
|
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
@ -58,7 +58,7 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
loopFCID.toShortKey(),
|
loopFCID.toShortKey(),
|
||||||
curConfig.getFCID().toShortKey(),
|
curConfig.getFCID().toShortKey(),
|
||||||
curConfig.getMID().toShortKey(),
|
curConfig.getMID().toShortKey(),
|
||||||
curConfig.toMotorCommonName(),
|
curConfig.toMotorName(),
|
||||||
curConfig.toIgnitionDescription() ));
|
curConfig.toIgnitionDescription() ));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -589,6 +589,22 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
return this.getBoolean(MATCH_AFT_DIAMETER, true);
|
return this.getBoolean(MATCH_AFT_DIAMETER, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether to display the common name (false), or designation (true) in the motor selection table "Name" column
|
||||||
|
* @return true to display designation, false to display common name
|
||||||
|
*/
|
||||||
|
public boolean getMotorNameColumn() {
|
||||||
|
return getBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to display the common name, or designation in the motor selection table "Name" column
|
||||||
|
* @param value if true, display designation, if false, display common name
|
||||||
|
*/
|
||||||
|
public void setMotorNameColumn(boolean value) {
|
||||||
|
putBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OpenRocket unique ID.
|
* Return the OpenRocket unique ID.
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@ class MotorHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return motor.getCommonName();
|
return motor.getMotorName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +52,7 @@ class MotorInformationPanel extends JPanel {
|
|||||||
private ThrustCurveMotor selectedMotor;
|
private ThrustCurveMotor selectedMotor;
|
||||||
|
|
||||||
private final JLabel designationLabel;
|
private final JLabel designationLabel;
|
||||||
|
private final JLabel commonNameLabel;
|
||||||
private final JLabel totalImpulseLabel;
|
private final JLabel totalImpulseLabel;
|
||||||
private final JLabel classificationLabel;
|
private final JLabel classificationLabel;
|
||||||
private final JLabel avgThrustLabel;
|
private final JLabel avgThrustLabel;
|
||||||
@ -82,6 +83,11 @@ class MotorInformationPanel extends JPanel {
|
|||||||
this.add(new JLabel(trans.get("TCMotorSelPan.lbl.Designation")));
|
this.add(new JLabel(trans.get("TCMotorSelPan.lbl.Designation")));
|
||||||
designationLabel = new JLabel();
|
designationLabel = new JLabel();
|
||||||
this.add(designationLabel, "wrap");
|
this.add(designationLabel, "wrap");
|
||||||
|
|
||||||
|
//// Common name
|
||||||
|
this.add(new JLabel(trans.get("TCMotorSelPan.lbl.CommonName")));
|
||||||
|
commonNameLabel = new JLabel();
|
||||||
|
this.add(commonNameLabel, "wrap");
|
||||||
|
|
||||||
//// Total impulse:
|
//// Total impulse:
|
||||||
this.add(new JLabel(trans.get("TCMotorSelPan.lbl.Totalimpulse")));
|
this.add(new JLabel(trans.get("TCMotorSelPan.lbl.Totalimpulse")));
|
||||||
@ -230,6 +236,7 @@ class MotorInformationPanel extends JPanel {
|
|||||||
selectedMotor = null;
|
selectedMotor = null;
|
||||||
selectedMotorSet = null;
|
selectedMotorSet = null;
|
||||||
designationLabel.setText("");
|
designationLabel.setText("");
|
||||||
|
commonNameLabel.setText("");
|
||||||
totalImpulseLabel.setText("");
|
totalImpulseLabel.setText("");
|
||||||
totalImpulseLabel.setToolTipText(null);
|
totalImpulseLabel.setToolTipText(null);
|
||||||
classificationLabel.setText("");
|
classificationLabel.setText("");
|
||||||
@ -262,6 +269,7 @@ class MotorInformationPanel extends JPanel {
|
|||||||
|
|
||||||
// Update thrust curve data
|
// Update thrust curve data
|
||||||
designationLabel.setText(selectedMotor.getDesignation());
|
designationLabel.setText(selectedMotor.getDesignation());
|
||||||
|
commonNameLabel.setText(selectedMotor.getCommonName());
|
||||||
double impulse = selectedMotor.getTotalImpulseEstimate();
|
double impulse = selectedMotor.getTotalImpulseEstimate();
|
||||||
MotorClass mc = MotorClass.getMotorClass(impulse);
|
MotorClass mc = MotorClass.getMotorClass(impulse);
|
||||||
totalImpulseLabel.setText(UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(impulse));
|
totalImpulseLabel.setText(UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(impulse));
|
||||||
|
@ -248,6 +248,8 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
if (selectedRow >= 0) {
|
if (selectedRow >= 0) {
|
||||||
table.setRowSelectionInterval(selectedRow, selectedRow);
|
table.setRowSelectionInterval(selectedRow, selectedRow);
|
||||||
}
|
}
|
||||||
|
curveSelectionBox.revalidate();
|
||||||
|
curveSelectionBox.repaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
designation.addActionListener(new ActionListener() {
|
designation.addActionListener(new ActionListener() {
|
||||||
@ -259,6 +261,8 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
if (selectedRow >= 0) {
|
if (selectedRow >= 0) {
|
||||||
table.setRowSelectionInterval(selectedRow, selectedRow);
|
table.setRowSelectionInterval(selectedRow, selectedRow);
|
||||||
}
|
}
|
||||||
|
curveSelectionBox.revalidate();
|
||||||
|
curveSelectionBox.repaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
throw new NullPointerException("Motor has a null mount... this should never happen: "+curMotorInstance.getID());
|
throw new NullPointerException("Motor has a null mount... this should never happen: "+curMotorInstance.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
String str = motor.getCommonName(curMotorInstance.getEjectionDelay());
|
String str = motor.getMotorName(curMotorInstance.getEjectionDelay());
|
||||||
int count = mount.getInstanceCount();
|
int count = mount.getInstanceCount();
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
str = "" + count + Chars.TIMES + " " + str;
|
str = "" + count + Chars.TIMES + " " + str;
|
||||||
|
@ -362,23 +362,6 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
// TODO: MEDIUM: Motor fill color (settable?)
|
// TODO: MEDIUM: Motor fill color (settable?)
|
||||||
return new Color(0, 0, 0, 100);
|
return new Color(0, 0, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether to display the common name (false), or designation (true) in the motor selection table "Name" column
|
|
||||||
* @return true to display designation, false to display common name
|
|
||||||
*/
|
|
||||||
public boolean getMotorNameColumn() {
|
|
||||||
return getBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether to display the common name, or designation in the motor selection table "Name" column
|
|
||||||
* @param value if true, display designation, if false, display common name
|
|
||||||
*/
|
|
||||||
public void setMotorNameColumn(boolean value) {
|
|
||||||
putBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int getMaxThreadCount() {
|
public static int getMaxThreadCount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user