Refactoring or rocket configuration description
This commit is contained in:
parent
dd5a16802b
commit
525869c3e7
@ -405,6 +405,7 @@ simpanel.dlg.lbl.DeleteSim2 = <html><i>This operation cannot be undone.</i>
|
|||||||
simpanel.dlg.lbl.DeleteSim3 = Delete simulations
|
simpanel.dlg.lbl.DeleteSim3 = Delete simulations
|
||||||
simpanel.col.Name = Name
|
simpanel.col.Name = Name
|
||||||
simpanel.col.Motors = Motors
|
simpanel.col.Motors = Motors
|
||||||
|
simpanel.col.Configuration = Configuration
|
||||||
simpanel.col.Velocityoffrod = Velocity off rod
|
simpanel.col.Velocityoffrod = Velocity off rod
|
||||||
simpanel.col.Velocityatdeploy = Velocity at deployment
|
simpanel.col.Velocityatdeploy = Velocity at deployment
|
||||||
simpanel.col.Apogee = Apogee
|
simpanel.col.Apogee = Apogee
|
||||||
@ -1313,7 +1314,8 @@ Streamer.Streamer = Streamer
|
|||||||
Sleeve.Sleeve = Sleeve
|
Sleeve.Sleeve = Sleeve
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [No motors]
|
Rocket.motorCount.Nomotor = No motors
|
||||||
|
Rocket.motorCount.noStageMotors = None
|
||||||
Rocket.compname.Rocket = Rocket
|
Rocket.compname.Rocket = Rocket
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
@ -1856,3 +1858,4 @@ SeparationSelectionDialog.opt.override = Override for the {0} flight configurati
|
|||||||
|
|
||||||
MotorConfigurationPanel.description = <b>Select the motors and motor ignition events of your rocket.</b><br> <em>Motor mounts:</em> Select which components function as motor mounts.<br> <em>Motor configurations:</em> Select the motor and ignition event for each motor mount.
|
MotorConfigurationPanel.description = <b>Select the motors and motor ignition events of your rocket.</b><br> <em>Motor mounts:</em> Select which components function as motor mounts.<br> <em>Motor configurations:</em> Select the motor and ignition event for each motor mount.
|
||||||
|
|
||||||
|
MotorDescriptionSubstitutor.description = Motors in the configuration
|
||||||
|
@ -1159,7 +1159,7 @@ ShockCord.ShockCord = Poutac
|
|||||||
Bulkhead.Bulkhead = Prepá\u017Eka
|
Bulkhead.Bulkhead = Prepá\u017Eka
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [\u017Dádné motory]
|
Rocket.motorCount.Nomotor = \u017Dádné motory
|
||||||
Rocket.compname.Rocket = Raketa
|
Rocket.compname.Rocket = Raketa
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1216,7 +1216,7 @@ ShockCord.ShockCord = Gummiband
|
|||||||
Bulkhead.Bulkhead = Schott
|
Bulkhead.Bulkhead = Schott
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [Keine Motoren]
|
Rocket.motorCount.Nomotor = Keine Motoren
|
||||||
Rocket.compname.Rocket = Rakete
|
Rocket.compname.Rocket = Rakete
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1227,7 +1227,7 @@ ShockCord.ShockCord = Tirante de suspensi
|
|||||||
Bulkhead.Bulkhead = Disco de enganche
|
Bulkhead.Bulkhead = Disco de enganche
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [Sin motores]
|
Rocket.motorCount.Nomotor = Sin motores
|
||||||
Rocket.compname.Rocket = Cohete
|
Rocket.compname.Rocket = Cohete
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1269,7 +1269,7 @@ Streamer.Streamer = Streamer
|
|||||||
Sleeve.Sleeve = Sleeve
|
Sleeve.Sleeve = Sleeve
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [aucun moteurs]
|
Rocket.motorCount.Nomotor = aucun moteurs
|
||||||
Rocket.compname.Rocket = Fusée
|
Rocket.compname.Rocket = Fusée
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1220,7 +1220,7 @@ ShockCord.ShockCord = Shock cord
|
|||||||
Bulkhead.Bulkhead = Paratia
|
Bulkhead.Bulkhead = Paratia
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [Nessun motore]
|
Rocket.motorCount.Nomotor = Nessun motore
|
||||||
Rocket.compname.Rocket = Razzo
|
Rocket.compname.Rocket = Razzo
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1161,7 +1161,7 @@
|
|||||||
Bulkhead.Bulkhead = Przegroda
|
Bulkhead.Bulkhead = Przegroda
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [bez silników]
|
Rocket.motorCount.Nomotor = bez silników
|
||||||
Rocket.compname.Rocket = Rakieta
|
Rocket.compname.Rocket = Rakieta
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -1274,7 +1274,7 @@ Streamer.Streamer = \u0422\u043e\u0440\u043c\u043e\u0437\u043d\u0430\u044f \u043
|
|||||||
Sleeve.Sleeve = \u0412\u0442\u0443\u043b\u043a\u0430
|
Sleeve.Sleeve = \u0412\u0442\u0443\u043b\u043a\u0430
|
||||||
|
|
||||||
!Rocket
|
!Rocket
|
||||||
Rocket.motorCount.Nomotor = [\u0411\u0435\u0437 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439]
|
Rocket.motorCount.Nomotor = \u0411\u0435\u0437 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439
|
||||||
Rocket.compname.Rocket = \u0420\u0430\u043a\u0435\u0442\u0430
|
Rocket.compname.Rocket = \u0420\u0430\u043a\u0435\u0442\u0430
|
||||||
|
|
||||||
!MotorMount
|
!MotorMount
|
||||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
|
import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
|
||||||
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
||||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.logging.LogHelper;
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
@ -57,6 +58,9 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
NOT_SIMULATED
|
NOT_SIMULATED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
private SafetyMutex mutex = SafetyMutex.newInstance();
|
private SafetyMutex mutex = SafetyMutex.newInstance();
|
||||||
|
|
||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
@ -83,7 +87,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
/** The conditions actually used in the previous simulation, or null */
|
/** The conditions actually used in the previous simulation, or null */
|
||||||
private SimulationOptions simulatedConditions = null;
|
private SimulationOptions simulatedConditions = null;
|
||||||
private String simulatedMotors = null;
|
private String simulatedConfiguration = null;
|
||||||
private FlightData simulatedData = null;
|
private FlightData simulatedData = null;
|
||||||
private int simulatedRocketID = -1;
|
private int simulatedRocketID = -1;
|
||||||
|
|
||||||
@ -305,7 +309,8 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
// Set simulated info after simulation, will not be set in case of exception
|
// Set simulated info after simulation, will not be set in case of exception
|
||||||
simulatedConditions = options.clone();
|
simulatedConditions = options.clone();
|
||||||
final Configuration configuration = getConfiguration();
|
final Configuration configuration = getConfiguration();
|
||||||
simulatedMotors = configuration.getFlightConfigurationDescription();
|
|
||||||
|
simulatedConfiguration = descriptor.format(configuration.getRocket(), configuration.getFlightConfigurationID());
|
||||||
simulatedRocketID = rocket.getFunctionalModID();
|
simulatedRocketID = rocket.getFunctionalModID();
|
||||||
|
|
||||||
status = Status.UPTODATE;
|
status = Status.UPTODATE;
|
||||||
@ -350,11 +355,10 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
*
|
*
|
||||||
* @return a description of the motor configuration of the previous simulation, or
|
* @return a description of the motor configuration of the previous simulation, or
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @see Rocket#getFlightConfigurationNameOrDescription(String)
|
|
||||||
*/
|
*/
|
||||||
public String getSimulatedMotorDescription() {
|
public String getSimulatedConfigurationDescription() {
|
||||||
mutex.verify();
|
mutex.verify();
|
||||||
return simulatedMotors;
|
return simulatedConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,7 +393,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
copy.simulationListeners = this.simulationListeners.clone();
|
copy.simulationListeners = this.simulationListeners.clone();
|
||||||
copy.listeners = new ArrayList<EventListener>();
|
copy.listeners = new ArrayList<EventListener>();
|
||||||
copy.simulatedConditions = null;
|
copy.simulatedConditions = null;
|
||||||
copy.simulatedMotors = null;
|
copy.simulatedConfiguration = null;
|
||||||
copy.simulatedData = null;
|
copy.simulatedData = null;
|
||||||
copy.simulatedRocketID = -1;
|
copy.simulatedRocketID = -1;
|
||||||
|
|
||||||
|
@ -49,7 +49,8 @@ public class RocketSaver extends RocketComponentSaver {
|
|||||||
if (id.equals(defId))
|
if (id.equals(defId))
|
||||||
str += " default=\"true\"";
|
str += " default=\"true\"";
|
||||||
|
|
||||||
if (rocket.getFlightConfigurationName(id) == "") {
|
|
||||||
|
if (rocket.getFlightConfigurationName(id).equals(Rocket.DEFAULT_NAME)) {
|
||||||
str += "/>";
|
str += "/>";
|
||||||
} else {
|
} else {
|
||||||
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(rocket.getFlightConfigurationName(id))
|
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(rocket.getFlightConfigurationName(id))
|
||||||
|
@ -32,20 +32,20 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String substitute(String str, Rocket rocket, String configId) {
|
public String substitute(String str, Rocket rocket, String configId) {
|
||||||
String description = getFlightConfigurationDescription(rocket, configId);
|
String description = getMotorConfigurationDescription(rocket, configId);
|
||||||
return str.replace(SUBSTITUTION, description);
|
return str.replace(SUBSTITUTION, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getDescriptions() {
|
public Map<String, String> getDescriptions() {
|
||||||
Map<String, String> desc = new HashMap<String, String>();
|
Map<String, String> desc = new HashMap<String, String>();
|
||||||
desc.put(SUBSTITUTION, trans.get("description"));
|
desc.put(SUBSTITUTION, trans.get("MotorDescriptionSubstitutor.description"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getFlightConfigurationDescription(Rocket rocket, String id) {
|
public String getMotorConfigurationDescription(Rocket rocket, String id) {
|
||||||
String name;
|
String name;
|
||||||
int motorCount = 0;
|
int motorCount = 0;
|
||||||
|
|
||||||
@ -82,7 +82,6 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (motorCount == 0) {
|
if (motorCount == 0) {
|
||||||
//// [No motors]
|
|
||||||
return trans.get("Rocket.motorCount.Nomotor");
|
return trans.get("Rocket.motorCount.Nomotor");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,17 +137,16 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
|||||||
stages.add(stageName);
|
stages.add(stageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
name = "[";
|
name = "";
|
||||||
for (int i = 0; i < stages.size(); i++) {
|
for (int i = 0; i < stages.size(); i++) {
|
||||||
String s = stages.get(i);
|
String s = stages.get(i);
|
||||||
if (s.equals(""))
|
if (s.equals(""))
|
||||||
s = "None";
|
s = trans.get("Rocket.motorCount.noStageMotors");
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
name = name + s;
|
name = name + s;
|
||||||
else
|
else
|
||||||
name = name + "; " + s;
|
name = name + "; " + s;
|
||||||
}
|
}
|
||||||
name += "]";
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
core/src/net/sf/openrocket/formatting/RocketDescriptor.java
Normal file
25
core/src/net/sf/openrocket/formatting/RocketDescriptor.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package net.sf.openrocket.formatting;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for formatting a flight configuration into a
|
||||||
|
* textual string.
|
||||||
|
*/
|
||||||
|
public interface RocketDescriptor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string describing a particular flight configuration
|
||||||
|
* of the rocket. This uses the default flight configuration name
|
||||||
|
* as the basis.
|
||||||
|
*/
|
||||||
|
public String format(Rocket rocket, String configId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string describing a particular flight configuration
|
||||||
|
* of the rocket. This uses a custom-provided name as the basis.
|
||||||
|
*/
|
||||||
|
public String format(String name, Rocket rocket, String configId);
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,7 @@ import net.sf.openrocket.rocketcomponent.Rocket;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
public class RocketFormatterImpl implements RocketFormatter {
|
public class RocketDescriptorImpl implements RocketDescriptor {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Set<RocketSubstitutor> substitutors;
|
private Set<RocketSubstitutor> substitutors;
|
||||||
@ -14,7 +14,11 @@ public class RocketFormatterImpl implements RocketFormatter {
|
|||||||
@Override
|
@Override
|
||||||
public String format(Rocket rocket, String configId) {
|
public String format(Rocket rocket, String configId) {
|
||||||
String name = rocket.getFlightConfigurationName(configId);
|
String name = rocket.getFlightConfigurationName(configId);
|
||||||
|
return format(name, rocket, configId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(String name, Rocket rocket, String configId) {
|
||||||
for (RocketSubstitutor s : substitutors) {
|
for (RocketSubstitutor s : substitutors) {
|
||||||
while (s.containsSubstitution(name)) {
|
while (s.containsSubstitution(name)) {
|
||||||
name = s.substitute(name, rocket, configId);
|
name = s.substitute(name, rocket, configId);
|
@ -1,17 +0,0 @@
|
|||||||
package net.sf.openrocket.formatting;
|
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for formatting a flight configuration into a
|
|
||||||
* textual string.
|
|
||||||
*/
|
|
||||||
public interface RocketFormatter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a string describing a particular flight configuration
|
|
||||||
* of the rocket.
|
|
||||||
*/
|
|
||||||
public String format(Rocket rocket, String configId);
|
|
||||||
|
|
||||||
}
|
|
@ -11,6 +11,7 @@ import javax.swing.event.EventListenerList;
|
|||||||
import javax.swing.event.ListDataEvent;
|
import javax.swing.event.ListDataEvent;
|
||||||
import javax.swing.event.ListDataListener;
|
import javax.swing.event.ListDataListener;
|
||||||
|
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog;
|
import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog;
|
||||||
import net.sf.openrocket.gui.main.BasicFrame;
|
import net.sf.openrocket.gui.main.BasicFrame;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
@ -25,6 +26,8 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
|
|
||||||
private static final String EDIT = trans.get("MotorCfgModel.Editcfg");
|
private static final String EDIT = trans.get("MotorCfgModel.Editcfg");
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
private EventListenerList listenerList = new EventListenerList();
|
private EventListenerList listenerList = new EventListenerList();
|
||||||
|
|
||||||
@ -84,7 +87,7 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(item instanceof ID)) {
|
if (!(item instanceof ID)) {
|
||||||
throw new IllegalArgumentException("MotorConfigurationModel item="+item);
|
throw new IllegalArgumentException("MotorConfigurationModel item=" + item);
|
||||||
}
|
}
|
||||||
|
|
||||||
ID idObject = (ID) item;
|
ID idObject = (ID) item;
|
||||||
@ -110,11 +113,11 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
Object[] listeners = listenerList.getListenerList();
|
Object[] listeners = listenerList.getListenerList();
|
||||||
ListDataEvent e = null;
|
ListDataEvent e = null;
|
||||||
|
|
||||||
for (int i = listeners.length-2; i>=0; i-=2) {
|
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||||
if (listeners[i] == ListDataListener.class) {
|
if (listeners[i] == ListDataListener.class) {
|
||||||
if (e == null)
|
if (e == null)
|
||||||
e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize());
|
e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize());
|
||||||
((ListDataListener) listeners[i+1]).contentsChanged(e);
|
((ListDataListener) listeners[i + 1]).contentsChanged(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +127,7 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
public void stateChanged(EventObject e) {
|
public void stateChanged(EventObject e) {
|
||||||
if (e instanceof ComponentChangeEvent) {
|
if (e instanceof ComponentChangeEvent) {
|
||||||
// Ignore unnecessary changes
|
// Ignore unnecessary changes
|
||||||
if (!((ComponentChangeEvent)e).isMotorChange())
|
if (!((ComponentChangeEvent) e).isMotorChange())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fireListDataEvent();
|
fireListDataEvent();
|
||||||
@ -162,9 +165,8 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return rocket.getFlightConfigurationNameOrDescription(id);
|
return descriptor.format(rocket, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import javax.swing.JSlider;
|
|||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.SpinnerEditor;
|
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;
|
||||||
@ -33,6 +34,8 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
private final DeploymentConfiguration newConfiguration;
|
private final DeploymentConfiguration newConfiguration;
|
||||||
|
|
||||||
private final JLabel altText;
|
private final JLabel altText;
|
||||||
@ -53,7 +56,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
final JRadioButton defaultButton = new JRadioButton(trans.get("DeploymentSelectionDialog.opt.default"), true);
|
final JRadioButton defaultButton = new JRadioButton(trans.get("DeploymentSelectionDialog.opt.default"), true);
|
||||||
panel.add(defaultButton, "span, gapleft para, wrap rel");
|
panel.add(defaultButton, "span, gapleft para, wrap rel");
|
||||||
String str = trans.get("DeploymentSelectionDialog.opt.override");
|
String str = trans.get("DeploymentSelectionDialog.opt.override");
|
||||||
str = str.replace("{0}", rocket.getFlightConfigurationNameOrDescription(id));
|
str = str.replace("{0}", descriptor.format(rocket, id));
|
||||||
final JRadioButton overrideButton = new JRadioButton(str, false);
|
final JRadioButton overrideButton = new JRadioButton(str, false);
|
||||||
panel.add(overrideButton, "span, gapleft para, wrap para");
|
panel.add(overrideButton, "span, gapleft para, wrap para");
|
||||||
|
|
||||||
@ -134,7 +137,6 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
GUIUtil.setDisposableDialogOptions(this, okButton);
|
GUIUtil.setDisposableDialogOptions(this, okButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
boolean enabled = (newConfiguration.getDeployEvent() == DeployEvent.ALTITUDE);
|
boolean enabled = (newConfiguration.getDeployEvent() == DeployEvent.ALTITUDE);
|
||||||
altText.setEnabled(enabled);
|
altText.setEnabled(enabled);
|
||||||
|
@ -10,6 +10,8 @@ import net.sf.openrocket.rocketcomponent.Rocket;
|
|||||||
|
|
||||||
public class FlightConfigurationModelRemoveMe extends DefaultComboBoxModel {
|
public class FlightConfigurationModelRemoveMe extends DefaultComboBoxModel {
|
||||||
|
|
||||||
|
// FIXME Remove this class
|
||||||
|
|
||||||
private final Configuration config;
|
private final Configuration config;
|
||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ public class FlightConfigurationModelRemoveMe extends DefaultComboBoxModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return rocket.getFlightConfigurationNameOrDescription(id);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import javax.swing.JRadioButton;
|
|||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.SpinnerEditor;
|
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;
|
||||||
@ -30,6 +31,8 @@ public class IgnitionSelectionDialog extends JDialog {
|
|||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
private IgnitionConfiguration newConfiguration;
|
private IgnitionConfiguration newConfiguration;
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ public class IgnitionSelectionDialog extends JDialog {
|
|||||||
final JRadioButton defaultButton = new JRadioButton(trans.get("IgnitionSelectionDialog.opt.default"), isDefault);
|
final JRadioButton defaultButton = new JRadioButton(trans.get("IgnitionSelectionDialog.opt.default"), isDefault);
|
||||||
panel.add(defaultButton, "span, gapleft para, wrap rel");
|
panel.add(defaultButton, "span, gapleft para, wrap rel");
|
||||||
String str = trans.get("IgnitionSelectionDialog.opt.override");
|
String str = trans.get("IgnitionSelectionDialog.opt.override");
|
||||||
str = str.replace("{0}", rocket.getFlightConfigurationNameOrDescription(id));
|
str = str.replace("{0}", descriptor.format(rocket, id));
|
||||||
final JRadioButton overrideButton = new JRadioButton(str, !isDefault);
|
final JRadioButton overrideButton = new JRadioButton(str, !isDefault);
|
||||||
panel.add(overrideButton, "span, gapleft para, wrap para");
|
panel.add(overrideButton, "span, gapleft para, wrap para");
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ import javax.swing.tree.TreePath;
|
|||||||
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.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.SpinnerEditor;
|
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.components.CsvOptionPanel;
|
import net.sf.openrocket.gui.components.CsvOptionPanel;
|
||||||
@ -115,6 +116,9 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
private static final String START_TEXT = trans.get("btn.start");
|
private static final String START_TEXT = trans.get("btn.start");
|
||||||
private static final String STOP_TEXT = trans.get("btn.stop");
|
private static final String STOP_TEXT = trans.get("btn.stop");
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
private final List<OptimizableParameter> optimizationParameters = new ArrayList<OptimizableParameter>();
|
private final List<OptimizableParameter> optimizationParameters = new ArrayList<OptimizableParameter>();
|
||||||
private final Map<Object, List<SimulationModifier>> simulationModifiers =
|
private final Map<Object, List<SimulationModifier>> simulationModifiers =
|
||||||
new HashMap<Object, List<SimulationModifier>>();
|
new HashMap<Object, List<SimulationModifier>>();
|
||||||
@ -933,7 +937,7 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
|
|
||||||
for (Simulation s : documentCopy.getSimulations()) {
|
for (Simulation s : documentCopy.getSimulations()) {
|
||||||
String id = s.getConfiguration().getFlightConfigurationID();
|
String id = s.getConfiguration().getFlightConfigurationID();
|
||||||
String name = createSimulationName(s.getName(), rocket.getFlightConfigurationNameOrDescription(id));
|
String name = createSimulationName(s.getName(), descriptor.format(rocket, id));
|
||||||
simulations.add(new Named<Simulation>(s, name));
|
simulations.add(new Named<Simulation>(s, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,13 +947,13 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
Simulation sim = new Simulation(rocket);
|
Simulation sim = new Simulation(rocket);
|
||||||
sim.getConfiguration().setFlightConfigurationID(id);
|
sim.getConfiguration().setFlightConfigurationID(id);
|
||||||
String name = createSimulationName(trans.get("basicSimulationName"), rocket.getFlightConfigurationNameOrDescription(id));
|
String name = createSimulationName(trans.get("basicSimulationName"), descriptor.format(rocket, id));
|
||||||
simulations.add(new Named<Simulation>(sim, name));
|
simulations.add(new Named<Simulation>(sim, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
Simulation sim = new Simulation(rocket);
|
Simulation sim = new Simulation(rocket);
|
||||||
sim.getConfiguration().setFlightConfigurationID(null);
|
sim.getConfiguration().setFlightConfigurationID(null);
|
||||||
String name = createSimulationName(trans.get("noSimulationName"), rocket.getFlightConfigurationNameOrDescription(null));
|
String name = createSimulationName(trans.get("noSimulationName"), descriptor.format(rocket, null));
|
||||||
simulations.add(new Named<Simulation>(sim, name));
|
simulations.add(new Named<Simulation>(sim, name));
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import net.sf.openrocket.document.Simulation;
|
|||||||
import net.sf.openrocket.document.events.DocumentChangeEvent;
|
import net.sf.openrocket.document.events.DocumentChangeEvent;
|
||||||
import net.sf.openrocket.document.events.DocumentChangeListener;
|
import net.sf.openrocket.document.events.DocumentChangeListener;
|
||||||
import net.sf.openrocket.document.events.SimulationChangeEvent;
|
import net.sf.openrocket.document.events.SimulationChangeEvent;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.adaptors.Column;
|
import net.sf.openrocket.gui.adaptors.Column;
|
||||||
import net.sf.openrocket.gui.adaptors.ColumnTableModel;
|
import net.sf.openrocket.gui.adaptors.ColumnTableModel;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
@ -39,6 +40,7 @@ import net.sf.openrocket.l10n.Translator;
|
|||||||
import net.sf.openrocket.logging.LogHelper;
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Configuration;
|
||||||
import net.sf.openrocket.simulation.FlightData;
|
import net.sf.openrocket.simulation.FlightData;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.startup.Preferences;
|
import net.sf.openrocket.startup.Preferences;
|
||||||
@ -56,6 +58,8 @@ public class SimulationPanel extends JPanel {
|
|||||||
private static final String OK_TEXT = "\u2714"; // Heavy check mark
|
private static final String OK_TEXT = "\u2714"; // Heavy check mark
|
||||||
|
|
||||||
|
|
||||||
|
private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
private final OpenRocketDocument document;
|
private final OpenRocketDocument document;
|
||||||
|
|
||||||
@ -218,7 +222,6 @@ public class SimulationPanel extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////// The simulation table
|
//////// The simulation table
|
||||||
|
|
||||||
simulationTableModel = new ColumnTableModel(
|
simulationTableModel = new ColumnTableModel(
|
||||||
@ -294,15 +297,14 @@ public class SimulationPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Simulation motors
|
//// Simulation configuration
|
||||||
//// Motors
|
new Column(trans.get("simpanel.col.Configuration")) {
|
||||||
new Column(trans.get("simpanel.col.Motors")) {
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row) {
|
public Object getValueAt(int row) {
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
return null;
|
return null;
|
||||||
return document.getSimulation(row).getConfiguration()
|
Configuration c = document.getSimulation(row).getConfiguration();
|
||||||
.getFlightConfigurationDescription();
|
return descriptor.format(c.getRocket(), c.getFlightConfigurationID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -571,38 +573,38 @@ public class SimulationPanel extends JPanel {
|
|||||||
tip = "<html><b>" + sim.getName() + "</b><br>";
|
tip = "<html><b>" + sim.getName() + "</b><br>";
|
||||||
switch (sim.getStatus()) {
|
switch (sim.getStatus()) {
|
||||||
case UPTODATE:
|
case UPTODATE:
|
||||||
tip += trans.get ("simpanel.ttip.uptodate") + "<br>";
|
tip += trans.get("simpanel.ttip.uptodate") + "<br>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOADED:
|
case LOADED:
|
||||||
tip += trans.get ("simpanel.ttip.loaded") + "<br>";
|
tip += trans.get("simpanel.ttip.loaded") + "<br>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTDATED:
|
case OUTDATED:
|
||||||
tip += trans.get ("simpanel.ttip.outdated") + "<br>";
|
tip += trans.get("simpanel.ttip.outdated") + "<br>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXTERNAL:
|
case EXTERNAL:
|
||||||
tip += trans.get ("simpanel.ttip.external") + "<br>";
|
tip += trans.get("simpanel.ttip.external") + "<br>";
|
||||||
return tip;
|
return tip;
|
||||||
|
|
||||||
case NOT_SIMULATED:
|
case NOT_SIMULATED:
|
||||||
tip += trans.get ("simpanel.ttip.notSimulated");
|
tip += trans.get("simpanel.ttip.notSimulated");
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
tip += trans.get ("simpanel.ttip.noData");
|
tip += trans.get("simpanel.ttip.noData");
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
WarningSet warnings = data.getWarningSet();
|
WarningSet warnings = data.getWarningSet();
|
||||||
|
|
||||||
if (warnings.isEmpty()) {
|
if (warnings.isEmpty()) {
|
||||||
tip += trans.get ("simpanel.ttip.noWarnings");
|
tip += trans.get("simpanel.ttip.noWarnings");
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
tip += trans.get ("simpanel.ttip.warnings");
|
tip += trans.get("simpanel.ttip.warnings");
|
||||||
for (Warning w : warnings) {
|
for (Warning w : warnings) {
|
||||||
tip += "<br>" + w.toString();
|
tip += "<br>" + w.toString();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||||
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||||
@ -81,6 +82,9 @@ public class DesignReport {
|
|||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
public static final double SCALE_FUDGE_FACTOR = 0.4d;
|
public static final double SCALE_FUDGE_FACTOR = 0.4d;
|
||||||
|
|
||||||
|
private static final RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The OR Document.
|
* The OR Document.
|
||||||
*/
|
*/
|
||||||
@ -444,7 +448,7 @@ public class DesignReport {
|
|||||||
PdfPTable labelTable = new PdfPTable(2);
|
PdfPTable labelTable = new PdfPTable(2);
|
||||||
labelTable.setWidths(new int[] { 3, 2 });
|
labelTable.setWidths(new int[] { 3, 2 });
|
||||||
final Paragraph chunk = ITextHelper.createParagraph(stripBrackets(
|
final Paragraph chunk = ITextHelper.createParagraph(stripBrackets(
|
||||||
theRocket.getFlightConfigurationNameOrDescription(motorId)), PrintUtilities.BOLD);
|
descriptor.format(theRocket, motorId)), PrintUtilities.BOLD);
|
||||||
chunk.setLeading(leading);
|
chunk.setLeading(leading);
|
||||||
chunk.setSpacingAfter(3f);
|
chunk.setSpacingAfter(3f);
|
||||||
|
|
||||||
|
@ -181,12 +181,6 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi
|
|||||||
fireChangeEvent();
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlightConfigurationDescription() {
|
|
||||||
return rocket.getFlightConfigurationNameOrDescription(flightConfigurationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,10 +11,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.logging.LogHelper;
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
import net.sf.openrocket.motor.Motor;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
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.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
@ -35,6 +33,7 @@ public class Rocket extends RocketComponent {
|
|||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
|
public static final String DEFAULT_NAME = "[{motors}]";
|
||||||
public static final double DEFAULT_REFERENCE_LENGTH = 0.01;
|
public static final double DEFAULT_REFERENCE_LENGTH = 0.01;
|
||||||
|
|
||||||
|
|
||||||
@ -583,7 +582,7 @@ public class Rocket extends RocketComponent {
|
|||||||
MotorMount mount = (MotorMount) c;
|
MotorMount mount = (MotorMount) c;
|
||||||
if (!mount.isMotorMount())
|
if (!mount.isMotorMount())
|
||||||
continue;
|
continue;
|
||||||
if (mount.getMotor(id) != null) {
|
if (mount.getMotorConfiguration().get(id).getMotor() != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,18 +593,19 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the user-set name of the flight configuration. If no name has been set,
|
* Return the user-set name of the flight configuration. If no name has been set,
|
||||||
* returns an empty string (not null).
|
* returns the default name ({@link #DEFAULT_NAME}).
|
||||||
*
|
*
|
||||||
* @param id the flight configuration id
|
* @param id the flight configuration id
|
||||||
* @return the configuration name
|
* @return the configuration name
|
||||||
*/
|
*/
|
||||||
|
// FIXME: Check references to this method adhere to the new returning of DEFAULT_NAME
|
||||||
public String getFlightConfigurationName(String id) {
|
public String getFlightConfigurationName(String id) {
|
||||||
checkState();
|
checkState();
|
||||||
if (!isFlightConfigurationID(id))
|
if (!isFlightConfigurationID(id))
|
||||||
return "";
|
return DEFAULT_NAME;
|
||||||
String s = flightConfigurationNames.get(id);
|
String s = flightConfigurationNames.get(id);
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return "";
|
return DEFAULT_NAME;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,146 +619,15 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public void setFlightConfigurationName(String id, String name) {
|
public void setFlightConfigurationName(String id, String name) {
|
||||||
checkState();
|
checkState();
|
||||||
|
if (name == null || name.equals("")) {
|
||||||
|
flightConfigurationNames.remove(id);
|
||||||
|
} else {
|
||||||
flightConfigurationNames.put(id, name);
|
flightConfigurationNames.put(id, name);
|
||||||
|
}
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return either the flight configuration name (if set) or its description.
|
|
||||||
*
|
|
||||||
* @param id the flight configuration ID.
|
|
||||||
* @return a textual representation of the configuration
|
|
||||||
*/
|
|
||||||
public String getFlightConfigurationNameOrDescription(String id) {
|
|
||||||
checkState();
|
|
||||||
String name;
|
|
||||||
|
|
||||||
name = getFlightConfigurationName(id);
|
|
||||||
if (name != null && !name.equals(""))
|
|
||||||
return name;
|
|
||||||
|
|
||||||
return getFlightConfigurationDescription(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Change to private
|
|
||||||
/**
|
|
||||||
* Return a description for the flight configuration, generated from the motor
|
|
||||||
* designations of the components.
|
|
||||||
*
|
|
||||||
* @param id the flight configuration ID.
|
|
||||||
* @return a textual representation of the configuration
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("null")
|
|
||||||
private String getFlightConfigurationDescription(String id) {
|
|
||||||
checkState();
|
|
||||||
String name;
|
|
||||||
int motorCount = 0;
|
|
||||||
|
|
||||||
// Generate the description
|
|
||||||
|
|
||||||
// First iterate over each stage and store the designations of each motor
|
|
||||||
List<List<String>> list = new ArrayList<List<String>>();
|
|
||||||
List<String> currentList = null;
|
|
||||||
|
|
||||||
Iterator<RocketComponent> iterator = this.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
RocketComponent c = iterator.next();
|
|
||||||
|
|
||||||
if (c instanceof Stage) {
|
|
||||||
|
|
||||||
currentList = new ArrayList<String>();
|
|
||||||
list.add(currentList);
|
|
||||||
|
|
||||||
} else if (c instanceof MotorMount) {
|
|
||||||
|
|
||||||
MotorMount mount = (MotorMount) c;
|
|
||||||
Motor motor = mount.getMotor(id);
|
|
||||||
|
|
||||||
if (mount.isMotorMount() && motor != null) {
|
|
||||||
String designation = motor.getDesignation(mount.getMotorDelay(id));
|
|
||||||
|
|
||||||
for (int i = 0; i < mount.getMotorCount(); i++) {
|
|
||||||
currentList.add(designation);
|
|
||||||
motorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (motorCount == 0) {
|
|
||||||
//// [No motors]
|
|
||||||
return trans.get("Rocket.motorCount.Nomotor");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change multiple occurrences of a motor to n x motor
|
|
||||||
List<String> stages = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (List<String> stage : list) {
|
|
||||||
String stageName = "";
|
|
||||||
String previous = null;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
Collections.sort(stage);
|
|
||||||
for (String current : stage) {
|
|
||||||
if (current.equals(previous)) {
|
|
||||||
|
|
||||||
count++;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (previous != null) {
|
|
||||||
String s = "";
|
|
||||||
if (count > 1) {
|
|
||||||
s = "" + count + Chars.TIMES + previous;
|
|
||||||
} else {
|
|
||||||
s = previous;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stageName.equals(""))
|
|
||||||
stageName = s;
|
|
||||||
else
|
|
||||||
stageName = stageName + "," + s;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
count = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (previous != null) {
|
|
||||||
String s = "";
|
|
||||||
if (count > 1) {
|
|
||||||
s = "" + count + Chars.TIMES + previous;
|
|
||||||
} else {
|
|
||||||
s = previous;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stageName.equals(""))
|
|
||||||
stageName = s;
|
|
||||||
else
|
|
||||||
stageName = stageName + "," + s;
|
|
||||||
}
|
|
||||||
|
|
||||||
stages.add(stageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = "[";
|
|
||||||
for (int i = 0; i < stages.size(); i++) {
|
|
||||||
String s = stages.get(i);
|
|
||||||
if (s.equals(""))
|
|
||||||
s = "None";
|
|
||||||
if (i == 0)
|
|
||||||
name = name + s;
|
|
||||||
else
|
|
||||||
name = name + "; " + s;
|
|
||||||
}
|
|
||||||
name += "]";
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////// Obligatory component information
|
//////// Obligatory component information
|
||||||
|
@ -407,11 +407,11 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
// Try to find a closely matching motor ID
|
// Try to find a closely matching motor ID
|
||||||
MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class);
|
MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class);
|
||||||
|
|
||||||
String motorDesc = formatter.substitute(MotorDescriptionSubstitutor.SUBSTITUTION, src.rocket, src.motorID);
|
String motorDesc = formatter.getMotorConfigurationDescription(src.rocket, src.motorID);
|
||||||
String matchID = null;
|
String matchID = null;
|
||||||
|
|
||||||
for (String id : this.rocket.getFlightConfigurationIDs()) {
|
for (String id : this.rocket.getFlightConfigurationIDs()) {
|
||||||
String motorDesc2 = formatter.substitute(MotorDescriptionSubstitutor.SUBSTITUTION, this.rocket, id);
|
String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, id);
|
||||||
if (motorDesc.equals(motorDesc2)) {
|
if (motorDesc.equals(motorDesc2)) {
|
||||||
matchID = id;
|
matchID = id;
|
||||||
break;
|
break;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.sf.openrocket.startup;
|
package net.sf.openrocket.startup;
|
||||||
|
|
||||||
import net.sf.openrocket.formatting.RocketFormatter;
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.formatting.RocketFormatterImpl;
|
import net.sf.openrocket.formatting.RocketDescriptorImpl;
|
||||||
import net.sf.openrocket.gui.watcher.WatchService;
|
import net.sf.openrocket.gui.watcher.WatchService;
|
||||||
import net.sf.openrocket.gui.watcher.WatchServiceImpl;
|
import net.sf.openrocket.gui.watcher.WatchServiceImpl;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
@ -17,7 +17,7 @@ public class ApplicationModule extends AbstractModule {
|
|||||||
bind(Preferences.class).toInstance(Application.getPreferences());
|
bind(Preferences.class).toInstance(Application.getPreferences());
|
||||||
bind(Translator.class).toInstance(Application.getTranslator());
|
bind(Translator.class).toInstance(Application.getTranslator());
|
||||||
bind(WatchService.class).to(WatchServiceImpl.class);
|
bind(WatchService.class).to(WatchServiceImpl.class);
|
||||||
bind(RocketFormatter.class).to(RocketFormatterImpl.class);
|
bind(RocketDescriptor.class).to(RocketDescriptorImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user