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;
|
||||||
@ -22,9 +23,11 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
|
|
||||||
public class FlightConfigurationModel implements ComboBoxModel, StateChangeListener {
|
public class FlightConfigurationModel implements ComboBoxModel, StateChangeListener {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
|
|
||||||
private Map<String, ID> map = new HashMap<String, ID>();
|
private Map<String, ID> map = new HashMap<String, ID>();
|
||||||
|
|
||||||
|
|
||||||
public FlightConfigurationModel(Configuration config) {
|
public FlightConfigurationModel(Configuration config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.rocket = config.getRocket();
|
this.rocket = config.getRocket();
|
||||||
@ -45,7 +48,7 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
String[] ids = rocket.getFlightConfigurationIDs();
|
String[] ids = rocket.getFlightConfigurationIDs();
|
||||||
if (index < 0 || index > ids.length)
|
if (index < 0 || index > ids.length)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (index == ids.length)
|
if (index == ids.length)
|
||||||
@ -53,17 +56,17 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
|
|
||||||
return get(ids[index]);
|
return get(ids[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return rocket.getFlightConfigurationIDs().length + 1;
|
return rocket.getFlightConfigurationIDs().length + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSelectedItem() {
|
public Object getSelectedItem() {
|
||||||
return get(config.getFlightConfigurationID());
|
return get(config.getFlightConfigurationID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedItem(Object item) {
|
public void setSelectedItem(Object item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@ -77,21 +80,21 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
new FlightConfigurationDialog(rocket, BasicFrame.findFrame(rocket))
|
new FlightConfigurationDialog(rocket, BasicFrame.findFrame(rocket))
|
||||||
.setVisible(true);
|
.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
config.setFlightConfigurationID(idObject.getID());
|
config.setFlightConfigurationID(idObject.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////// Event/listener handling ////////////////
|
//////////////// Event/listener handling ////////////////
|
||||||
|
|
||||||
@ -100,31 +103,31 @@ public class FlightConfigurationModel implements ComboBoxModel, StateChangeListe
|
|||||||
public void addListDataListener(ListDataListener l) {
|
public void addListDataListener(ListDataListener l) {
|
||||||
listenerList.add(ListDataListener.class, l);
|
listenerList.add(ListDataListener.class, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeListDataListener(ListDataListener l) {
|
public void removeListDataListener(ListDataListener l) {
|
||||||
listenerList.remove(ListDataListener.class, l);
|
listenerList.remove(ListDataListener.class, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireListDataEvent() {
|
protected void fireListDataEvent() {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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;
|
||||||
@ -47,7 +49,7 @@ import net.sf.openrocket.unit.UnitGroup;
|
|||||||
public class SimulationPanel extends JPanel {
|
public class SimulationPanel extends JPanel {
|
||||||
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();
|
||||||
|
|
||||||
|
|
||||||
private static final Color WARNING_COLOR = Color.RED;
|
private static final Color WARNING_COLOR = Color.RED;
|
||||||
private static final String WARNING_TEXT = "\uFF01"; // Fullwidth exclamation mark
|
private static final String WARNING_TEXT = "\uFF01"; // Fullwidth exclamation mark
|
||||||
@ -55,8 +57,10 @@ public class SimulationPanel extends JPanel {
|
|||||||
private static final Color OK_COLOR = new Color(60, 150, 0);
|
private static final Color OK_COLOR = new Color(60, 150, 0);
|
||||||
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;
|
||||||
|
|
||||||
private final ColumnTableModel simulationTableModel;
|
private final ColumnTableModel simulationTableModel;
|
||||||
@ -68,11 +72,11 @@ public class SimulationPanel extends JPanel {
|
|||||||
|
|
||||||
JButton button;
|
JButton button;
|
||||||
|
|
||||||
|
|
||||||
this.document = doc;
|
this.document = doc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////// The simulation action buttons
|
//////// The simulation action buttons
|
||||||
|
|
||||||
//// New simulation button
|
//// New simulation button
|
||||||
@ -135,7 +139,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
|
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
new SimulationRunDialog(SwingUtilities.getWindowAncestor(
|
new SimulationRunDialog(SwingUtilities.getWindowAncestor(
|
||||||
SimulationPanel.this), document, sims).setVisible(true);
|
SimulationPanel.this), document, sims).setVisible(true);
|
||||||
log.info("Running simulations took " + (System.currentTimeMillis() - t) + " ms");
|
log.info("Running simulations took " + (System.currentTimeMillis() - t) + " ms");
|
||||||
fireMaintainSelection();
|
fireMaintainSelection();
|
||||||
}
|
}
|
||||||
@ -165,17 +169,17 @@ public class SimulationPanel extends JPanel {
|
|||||||
panel.add(new StyledLabel(trans.get("simpanel.lbl.defpref"), -2));
|
panel.add(new StyledLabel(trans.get("simpanel.lbl.defpref"), -2));
|
||||||
|
|
||||||
int ret = JOptionPane.showConfirmDialog(SimulationPanel.this,
|
int ret = JOptionPane.showConfirmDialog(SimulationPanel.this,
|
||||||
new Object[] {
|
new Object[] {
|
||||||
//// Delete the selected simulations?
|
//// Delete the selected simulations?
|
||||||
trans.get("simpanel.dlg.lbl.DeleteSim1"),
|
trans.get("simpanel.dlg.lbl.DeleteSim1"),
|
||||||
//// <html><i>This operation cannot be undone.</i>
|
//// <html><i>This operation cannot be undone.</i>
|
||||||
trans.get("simpanel.dlg.lbl.DeleteSim2"),
|
trans.get("simpanel.dlg.lbl.DeleteSim2"),
|
||||||
"",
|
"",
|
||||||
panel },
|
panel },
|
||||||
//// Delete simulations
|
//// Delete simulations
|
||||||
trans.get("simpanel.dlg.lbl.DeleteSim3"),
|
trans.get("simpanel.dlg.lbl.DeleteSim3"),
|
||||||
JOptionPane.OK_CANCEL_OPTION,
|
JOptionPane.OK_CANCEL_OPTION,
|
||||||
JOptionPane.WARNING_MESSAGE);
|
JOptionPane.WARNING_MESSAGE);
|
||||||
if (ret != JOptionPane.OK_OPTION)
|
if (ret != JOptionPane.OK_OPTION)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -216,14 +220,13 @@ public class SimulationPanel extends JPanel {
|
|||||||
});
|
});
|
||||||
this.add(button, "wrap para");
|
this.add(button, "wrap para");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////// The simulation table
|
//////// The simulation table
|
||||||
|
|
||||||
simulationTableModel = new ColumnTableModel(
|
simulationTableModel = new ColumnTableModel(
|
||||||
|
|
||||||
//// Status and warning column
|
//// Status and warning column
|
||||||
new Column("") {
|
new Column("") {
|
||||||
private JLabel label = null;
|
private JLabel label = null;
|
||||||
|
|
||||||
@ -243,7 +246,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
Simulation.Status status = document.getSimulation(row).getStatus();
|
Simulation.Status status = document.getSimulation(row).getStatus();
|
||||||
label.setIcon(Icons.SIMULATION_STATUS_ICON_MAP.get(status));
|
label.setIcon(Icons.SIMULATION_STATUS_ICON_MAP.get(status));
|
||||||
|
|
||||||
|
|
||||||
// Set warning marker
|
// Set warning marker
|
||||||
if (status == Simulation.Status.NOT_SIMULATED ||
|
if (status == Simulation.Status.NOT_SIMULATED ||
|
||||||
status == Simulation.Status.EXTERNAL) {
|
status == Simulation.Status.EXTERNAL) {
|
||||||
@ -277,7 +280,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
return JLabel.class;
|
return JLabel.class;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Simulation name
|
//// Simulation name
|
||||||
//// Name
|
//// Name
|
||||||
new Column(trans.get("simpanel.col.Name")) {
|
new Column(trans.get("simpanel.col.Name")) {
|
||||||
@ -293,16 +296,15 @@ public class SimulationPanel extends JPanel {
|
|||||||
return 125;
|
return 125;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// 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
|
||||||
@ -310,7 +312,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
return 125;
|
return 125;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Launch rod velocity
|
//// Launch rod velocity
|
||||||
new Column(trans.get("simpanel.col.Velocityoffrod")) {
|
new Column(trans.get("simpanel.col.Velocityoffrod")) {
|
||||||
@Override
|
@Override
|
||||||
@ -326,7 +328,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getLaunchRodVelocity());
|
data.getLaunchRodVelocity());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Apogee
|
//// Apogee
|
||||||
new Column(trans.get("simpanel.col.Apogee")) {
|
new Column(trans.get("simpanel.col.Apogee")) {
|
||||||
@Override
|
@Override
|
||||||
@ -342,7 +344,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getMaxAltitude());
|
data.getMaxAltitude());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Velocity at deployment
|
//// Velocity at deployment
|
||||||
new Column(trans.get("simpanel.col.Velocityatdeploy")) {
|
new Column(trans.get("simpanel.col.Velocityatdeploy")) {
|
||||||
@Override
|
@Override
|
||||||
@ -358,7 +360,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getDeploymentVelocity());
|
data.getDeploymentVelocity());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Maximum velocity
|
//// Maximum velocity
|
||||||
new Column(trans.get("simpanel.col.Maxvelocity")) {
|
new Column(trans.get("simpanel.col.Maxvelocity")) {
|
||||||
@Override
|
@Override
|
||||||
@ -374,7 +376,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getMaxVelocity());
|
data.getMaxVelocity());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Maximum acceleration
|
//// Maximum acceleration
|
||||||
new Column(trans.get("simpanel.col.Maxacceleration")) {
|
new Column(trans.get("simpanel.col.Maxacceleration")) {
|
||||||
@Override
|
@Override
|
||||||
@ -390,7 +392,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getMaxAcceleration());
|
data.getMaxAcceleration());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Time to apogee
|
//// Time to apogee
|
||||||
new Column(trans.get("simpanel.col.Timetoapogee")) {
|
new Column(trans.get("simpanel.col.Timetoapogee")) {
|
||||||
@Override
|
@Override
|
||||||
@ -406,7 +408,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getTimeToApogee());
|
data.getTimeToApogee());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Flight time
|
//// Flight time
|
||||||
new Column(trans.get("simpanel.col.Flighttime")) {
|
new Column(trans.get("simpanel.col.Flighttime")) {
|
||||||
@Override
|
@Override
|
||||||
@ -422,7 +424,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getFlightTime());
|
data.getFlightTime());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//// Ground hit velocity
|
//// Ground hit velocity
|
||||||
new Column(trans.get("simpanel.col.Groundhitvelocity")) {
|
new Column(trans.get("simpanel.col.Groundhitvelocity")) {
|
||||||
@Override
|
@Override
|
||||||
@ -438,13 +440,13 @@ public class SimulationPanel extends JPanel {
|
|||||||
data.getGroundHitVelocity());
|
data.getGroundHitVelocity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
) {
|
) {
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return document.getSimulationCount();
|
return document.getSimulationCount();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Override processKeyBinding so that the JTable does not catch
|
// Override processKeyBinding so that the JTable does not catch
|
||||||
// key bindings used in menu accelerators
|
// key bindings used in menu accelerators
|
||||||
@ -461,7 +463,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
simulationTable.setDefaultRenderer(Object.class, new JLabelRenderer());
|
simulationTable.setDefaultRenderer(Object.class, new JLabelRenderer());
|
||||||
simulationTableModel.setColumnWidths(simulationTable.getColumnModel());
|
simulationTableModel.setColumnWidths(simulationTable.getColumnModel());
|
||||||
|
|
||||||
|
|
||||||
// Mouse listener to act on double-clicks
|
// Mouse listener to act on double-clicks
|
||||||
simulationTable.addMouseListener(new MouseAdapter() {
|
simulationTable.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@ -490,9 +492,9 @@ public class SimulationPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Fire table change event when the rocket changes
|
// Fire table change event when the rocket changes
|
||||||
document.getRocket().addComponentChangeListener(new ComponentChangeListener() {
|
document.getRocket().addComponentChangeListener(new ComponentChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -501,11 +503,11 @@ public class SimulationPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
JScrollPane scrollpane = new JScrollPane(simulationTable);
|
JScrollPane scrollpane = new JScrollPane(simulationTable);
|
||||||
this.add(scrollpane, "spanx, grow, wrap rel");
|
this.add(scrollpane, "spanx, grow, wrap rel");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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;
|
||||||
@ -74,33 +75,36 @@ import com.itextpdf.text.pdf.PdfWriter;
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class DesignReport {
|
public class DesignReport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The logger.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
private OpenRocketDocument rocketDocument;
|
private OpenRocketDocument rocketDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel used for rendering of the design diagram.
|
* A panel used for rendering of the design diagram.
|
||||||
*/
|
*/
|
||||||
final RocketPanel panel;
|
final RocketPanel panel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The iText document.
|
* The iText document.
|
||||||
*/
|
*/
|
||||||
protected Document document;
|
protected Document document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The figure rotation.
|
* The figure rotation.
|
||||||
*/
|
*/
|
||||||
private double rotation = 0d;
|
private double rotation = 0d;
|
||||||
|
|
||||||
/** The displayed strings. */
|
/** The displayed strings. */
|
||||||
private static final String STAGES = "Stages: ";
|
private static final String STAGES = "Stages: ";
|
||||||
private static final String MASS_WITH_MOTORS = "Mass (with motors): ";
|
private static final String MASS_WITH_MOTORS = "Mass (with motors): ";
|
||||||
@ -126,7 +130,7 @@ public class DesignReport {
|
|||||||
private static final String LANDING_VELOCITY = "Landing Velocity";
|
private static final String LANDING_VELOCITY = "Landing Velocity";
|
||||||
private static final String ROCKET_DESIGN = "Rocket Design";
|
private static final String ROCKET_DESIGN = "Rocket Design";
|
||||||
private static final double GRAVITY_CONSTANT = 9.80665d;
|
private static final double GRAVITY_CONSTANT = 9.80665d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -140,7 +144,7 @@ public class DesignReport {
|
|||||||
panel = new RocketPanel(rocketDocument);
|
panel = new RocketPanel(rocketDocument);
|
||||||
rotation = figureRotation;
|
rotation = figureRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point. Prints the rocket drawing and design data.
|
* Main entry point. Prints the rocket drawing and design data.
|
||||||
*
|
*
|
||||||
@ -153,23 +157,23 @@ public class DesignReport {
|
|||||||
com.itextpdf.text.Rectangle pageSize = document.getPageSize();
|
com.itextpdf.text.Rectangle pageSize = document.getPageSize();
|
||||||
int pageImageableWidth = (int) pageSize.getWidth() - (int) pageSize.getBorderWidth() * 2;
|
int pageImageableWidth = (int) pageSize.getWidth() - (int) pageSize.getBorderWidth() * 2;
|
||||||
int pageImageableHeight = (int) pageSize.getHeight() / 2 - (int) pageSize.getBorderWidthTop();
|
int pageImageableHeight = (int) pageSize.getHeight() / 2 - (int) pageSize.getBorderWidthTop();
|
||||||
|
|
||||||
PrintUtilities.addText(document, PrintUtilities.BIG_BOLD, ROCKET_DESIGN);
|
PrintUtilities.addText(document, PrintUtilities.BIG_BOLD, ROCKET_DESIGN);
|
||||||
|
|
||||||
Rocket rocket = rocketDocument.getRocket();
|
Rocket rocket = rocketDocument.getRocket();
|
||||||
final Configuration configuration = rocket.getDefaultConfiguration().clone();
|
final Configuration configuration = rocket.getDefaultConfiguration().clone();
|
||||||
configuration.setAllStages();
|
configuration.setAllStages();
|
||||||
PdfContentByte canvas = writer.getDirectContent();
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
final PrintFigure figure = new PrintFigure(configuration);
|
final PrintFigure figure = new PrintFigure(configuration);
|
||||||
figure.setRotation(rotation);
|
figure.setRotation(rotation);
|
||||||
|
|
||||||
FigureElement cp = panel.getExtraCP();
|
FigureElement cp = panel.getExtraCP();
|
||||||
FigureElement cg = panel.getExtraCG();
|
FigureElement cg = panel.getExtraCG();
|
||||||
RocketInfo text = panel.getExtraText();
|
RocketInfo text = panel.getExtraText();
|
||||||
|
|
||||||
double scale = paintRocketDiagram(pageImageableWidth, pageImageableHeight, canvas, figure, cp, cg);
|
double scale = paintRocketDiagram(pageImageableWidth, pageImageableHeight, canvas, figure, cp, cg);
|
||||||
|
|
||||||
canvas.beginText();
|
canvas.beginText();
|
||||||
canvas.setFontAndSize(ITextHelper.getBaseFont(), PrintUtilities.NORMAL_FONT_SIZE);
|
canvas.setFontAndSize(ITextHelper.getBaseFont(), PrintUtilities.NORMAL_FONT_SIZE);
|
||||||
int figHeightPts = (int) (PrintUnit.METERS.toPoints(figure.getFigureHeight()) * 0.4 * (scale / PrintUnit.METERS
|
int figHeightPts = (int) (PrintUnit.METERS.toPoints(figure.getFigureHeight()) * 0.4 * (scale / PrintUnit.METERS
|
||||||
@ -177,15 +181,15 @@ public class DesignReport {
|
|||||||
final int diagramHeight = pageImageableHeight * 2 - 70 - (figHeightPts);
|
final int diagramHeight = pageImageableHeight * 2 - 70 - (figHeightPts);
|
||||||
canvas.moveText(document.leftMargin() + pageSize.getBorderWidthLeft(), diagramHeight);
|
canvas.moveText(document.leftMargin() + pageSize.getBorderWidthLeft(), diagramHeight);
|
||||||
canvas.moveTextWithLeading(0, -16);
|
canvas.moveTextWithLeading(0, -16);
|
||||||
|
|
||||||
float initialY = canvas.getYTLM();
|
float initialY = canvas.getYTLM();
|
||||||
|
|
||||||
canvas.showText(rocketDocument.getRocket().getName());
|
canvas.showText(rocketDocument.getRocket().getName());
|
||||||
|
|
||||||
canvas.newlineShowText(STAGES);
|
canvas.newlineShowText(STAGES);
|
||||||
canvas.showText("" + rocket.getStageCount());
|
canvas.showText("" + rocket.getStageCount());
|
||||||
|
|
||||||
|
|
||||||
if (configuration.hasMotors()) {
|
if (configuration.hasMotors()) {
|
||||||
if (configuration.getStageCount() > 1) {
|
if (configuration.getStageCount() > 1) {
|
||||||
canvas.newlineShowText(MASS_WITH_MOTORS);
|
canvas.newlineShowText(MASS_WITH_MOTORS);
|
||||||
@ -196,29 +200,29 @@ public class DesignReport {
|
|||||||
canvas.newlineShowText(MASS_EMPTY);
|
canvas.newlineShowText(MASS_EMPTY);
|
||||||
}
|
}
|
||||||
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
||||||
|
|
||||||
canvas.newlineShowText(STABILITY);
|
canvas.newlineShowText(STABILITY);
|
||||||
canvas.showText(text.getStability());
|
canvas.showText(text.getStability());
|
||||||
|
|
||||||
canvas.newlineShowText(CG);
|
canvas.newlineShowText(CG);
|
||||||
canvas.showText(text.getCg());
|
canvas.showText(text.getCg());
|
||||||
|
|
||||||
canvas.newlineShowText(CP);
|
canvas.newlineShowText(CP);
|
||||||
canvas.showText(text.getCp());
|
canvas.showText(text.getCp());
|
||||||
canvas.endText();
|
canvas.endText();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Move the internal pointer of the document below that of what was just written using the direct byte buffer.
|
//Move the internal pointer of the document below that of what was just written using the direct byte buffer.
|
||||||
Paragraph paragraph = new Paragraph();
|
Paragraph paragraph = new Paragraph();
|
||||||
float finalY = canvas.getYTLM();
|
float finalY = canvas.getYTLM();
|
||||||
int heightOfDiagramAndText = (int) (pageSize.getHeight() - (finalY - initialY + diagramHeight));
|
int heightOfDiagramAndText = (int) (pageSize.getHeight() - (finalY - initialY + diagramHeight));
|
||||||
|
|
||||||
paragraph.setSpacingAfter(heightOfDiagramAndText);
|
paragraph.setSpacingAfter(heightOfDiagramAndText);
|
||||||
document.add(paragraph);
|
document.add(paragraph);
|
||||||
|
|
||||||
String[] motorIds = rocket.getFlightConfigurationIDs();
|
String[] motorIds = rocket.getFlightConfigurationIDs();
|
||||||
List<Simulation> simulations = rocketDocument.getSimulations();
|
List<Simulation> simulations = rocketDocument.getSimulations();
|
||||||
|
|
||||||
for (int j = 0; j < motorIds.length; j++) {
|
for (int j = 0; j < motorIds.length; j++) {
|
||||||
String motorId = motorIds[j];
|
String motorId = motorIds[j];
|
||||||
if (motorId != null) {
|
if (motorId != null) {
|
||||||
@ -242,8 +246,8 @@ public class DesignReport {
|
|||||||
log.error("Could not modify document.", e);
|
log.error("Could not modify document.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint a diagram of the rocket into the PDF document.
|
* Paint a diagram of the rocket into the PDF document.
|
||||||
*
|
*
|
||||||
@ -264,7 +268,7 @@ public class DesignReport {
|
|||||||
theFigure.addRelativeExtra(theCp);
|
theFigure.addRelativeExtra(theCp);
|
||||||
theFigure.addRelativeExtra(theCg);
|
theFigure.addRelativeExtra(theCg);
|
||||||
theFigure.updateFigure();
|
theFigure.updateFigure();
|
||||||
|
|
||||||
double scale =
|
double scale =
|
||||||
(thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
|
(thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
|
||||||
theFigure.setScale(scale);
|
theFigure.setScale(scale);
|
||||||
@ -273,7 +277,7 @@ public class DesignReport {
|
|||||||
*/
|
*/
|
||||||
theFigure.setSize(thePageImageableWidth, thePageImageableHeight);
|
theFigure.setSize(thePageImageableWidth, thePageImageableHeight);
|
||||||
theFigure.updateFigure();
|
theFigure.updateFigure();
|
||||||
|
|
||||||
final DefaultFontMapper mapper = new DefaultFontMapper();
|
final DefaultFontMapper mapper = new DefaultFontMapper();
|
||||||
Graphics2D g2d = theCanvas.createGraphics(thePageImageableWidth, thePageImageableHeight * 2, mapper);
|
Graphics2D g2d = theCanvas.createGraphics(thePageImageableWidth, thePageImageableHeight * 2, mapper);
|
||||||
final double halfFigureHeight = SCALE_FUDGE_FACTOR * theFigure.getFigureHeightPx() / 2;
|
final double halfFigureHeight = SCALE_FUDGE_FACTOR * theFigure.getFigureHeightPx() / 2;
|
||||||
@ -284,13 +288,13 @@ public class DesignReport {
|
|||||||
y += (int) halfFigureHeight;
|
y += (int) halfFigureHeight;
|
||||||
}
|
}
|
||||||
g2d.translate(20, y);
|
g2d.translate(20, y);
|
||||||
|
|
||||||
g2d.scale(SCALE_FUDGE_FACTOR, SCALE_FUDGE_FACTOR);
|
g2d.scale(SCALE_FUDGE_FACTOR, SCALE_FUDGE_FACTOR);
|
||||||
theFigure.paint(g2d);
|
theFigure.paint(g2d);
|
||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the motor data for a motor configuration to the table.
|
* Add the motor data for a motor configuration to the table.
|
||||||
*
|
*
|
||||||
@ -299,11 +303,11 @@ public class DesignReport {
|
|||||||
* @param parent the parent to which the motor data will be added
|
* @param parent the parent to which the motor data will be added
|
||||||
*/
|
*/
|
||||||
private void addMotorData(Rocket rocket, String motorId, final PdfPTable parent) {
|
private void addMotorData(Rocket rocket, String motorId, final PdfPTable parent) {
|
||||||
|
|
||||||
PdfPTable motorTable = new PdfPTable(8);
|
PdfPTable motorTable = new PdfPTable(8);
|
||||||
motorTable.setWidthPercentage(68);
|
motorTable.setWidthPercentage(68);
|
||||||
motorTable.setHorizontalAlignment(Element.ALIGN_LEFT);
|
motorTable.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||||
|
|
||||||
final PdfPCell motorCell = ITextHelper.createCell(MOTOR, PdfPCell.BOTTOM, PrintUtilities.SMALL);
|
final PdfPCell motorCell = ITextHelper.createCell(MOTOR, PdfPCell.BOTTOM, PrintUtilities.SMALL);
|
||||||
final int mPad = 10;
|
final int mPad = 10;
|
||||||
motorCell.setPaddingLeft(mPad);
|
motorCell.setPaddingLeft(mPad);
|
||||||
@ -315,25 +319,25 @@ public class DesignReport {
|
|||||||
motorTable.addCell(ITextHelper.createCell(THRUST_TO_WT, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
motorTable.addCell(ITextHelper.createCell(THRUST_TO_WT, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
||||||
motorTable.addCell(ITextHelper.createCell(PROPELLANT_WT, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
motorTable.addCell(ITextHelper.createCell(PROPELLANT_WT, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
||||||
motorTable.addCell(ITextHelper.createCell(SIZE, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
motorTable.addCell(ITextHelper.createCell(SIZE, PdfPCell.BOTTOM, PrintUtilities.SMALL));
|
||||||
|
|
||||||
DecimalFormat ttwFormat = new DecimalFormat("0.00");
|
DecimalFormat ttwFormat = new DecimalFormat("0.00");
|
||||||
|
|
||||||
MassCalculator massCalc = new BasicMassCalculator();
|
MassCalculator massCalc = new BasicMassCalculator();
|
||||||
|
|
||||||
Configuration config = new Configuration(rocket);
|
Configuration config = new Configuration(rocket);
|
||||||
config.setFlightConfigurationID(motorId);
|
config.setFlightConfigurationID(motorId);
|
||||||
|
|
||||||
int totalMotorCount = 0;
|
int totalMotorCount = 0;
|
||||||
double totalPropMass = 0;
|
double totalPropMass = 0;
|
||||||
double totalImpulse = 0;
|
double totalImpulse = 0;
|
||||||
double totalTTW = 0;
|
double totalTTW = 0;
|
||||||
|
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
double stageMass = 0;
|
double stageMass = 0;
|
||||||
|
|
||||||
boolean topBorder = false;
|
boolean topBorder = false;
|
||||||
for (RocketComponent c : rocket) {
|
for (RocketComponent c : rocket) {
|
||||||
|
|
||||||
if (c instanceof Stage) {
|
if (c instanceof Stage) {
|
||||||
config.setToStage(stage);
|
config.setToStage(stage);
|
||||||
stage++;
|
stage++;
|
||||||
@ -342,26 +346,26 @@ public class DesignReport {
|
|||||||
totalTTW = 0;
|
totalTTW = 0;
|
||||||
topBorder = true;
|
topBorder = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
||||||
MotorMount mount = (MotorMount) c;
|
MotorMount mount = (MotorMount) c;
|
||||||
|
|
||||||
if (mount.isMotorMount() && mount.getMotor(motorId) != null) {
|
if (mount.isMotorMount() && mount.getMotor(motorId) != null) {
|
||||||
Motor motor = mount.getMotor(motorId);
|
Motor motor = mount.getMotor(motorId);
|
||||||
int motorCount = c.toAbsolute(Coordinate.NUL).length;
|
int motorCount = c.toAbsolute(Coordinate.NUL).length;
|
||||||
|
|
||||||
|
|
||||||
int border = Rectangle.NO_BORDER;
|
int border = Rectangle.NO_BORDER;
|
||||||
if (topBorder) {
|
if (topBorder) {
|
||||||
border = Rectangle.TOP;
|
border = Rectangle.TOP;
|
||||||
topBorder = false;
|
topBorder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = motor.getDesignation();
|
String name = motor.getDesignation();
|
||||||
if (motorCount > 1) {
|
if (motorCount > 1) {
|
||||||
name += " (" + Chars.TIMES + motorCount + ")";
|
name += " (" + Chars.TIMES + motorCount + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
final PdfPCell motorVCell = ITextHelper.createCell(name, border);
|
final PdfPCell motorVCell = ITextHelper.createCell(name, border);
|
||||||
motorVCell.setPaddingLeft(mPad);
|
motorVCell.setPaddingLeft(mPad);
|
||||||
motorTable.addCell(motorVCell);
|
motorTable.addCell(motorVCell);
|
||||||
@ -373,21 +377,21 @@ public class DesignReport {
|
|||||||
UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(motor.getMaxThrustEstimate()), border));
|
UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(motor.getMaxThrustEstimate()), border));
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(motor.getTotalImpulseEstimate()), border));
|
UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(motor.getTotalImpulseEstimate()), border));
|
||||||
|
|
||||||
double ttw = motor.getAverageThrustEstimate() / (stageMass * GRAVITY_CONSTANT);
|
double ttw = motor.getAverageThrustEstimate() / (stageMass * GRAVITY_CONSTANT);
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
ttwFormat.format(ttw) + ":1", border));
|
ttwFormat.format(ttw) + ":1", border));
|
||||||
|
|
||||||
double propMass = (motor.getLaunchCG().weight - motor.getEmptyCG().weight);
|
double propMass = (motor.getLaunchCG().weight - motor.getEmptyCG().weight);
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(propMass), border));
|
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(propMass), border));
|
||||||
|
|
||||||
final Unit motorUnit = UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit();
|
final Unit motorUnit = UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit();
|
||||||
motorTable.addCell(ITextHelper.createCell(motorUnit.toString(motor.getDiameter()) +
|
motorTable.addCell(ITextHelper.createCell(motorUnit.toString(motor.getDiameter()) +
|
||||||
"/" +
|
"/" +
|
||||||
motorUnit.toString(motor.getLength()) + " " +
|
motorUnit.toString(motor.getLength()) + " " +
|
||||||
motorUnit.toString(), border));
|
motorUnit.toString(), border));
|
||||||
|
|
||||||
// Sum up total count
|
// Sum up total count
|
||||||
totalMotorCount += motorCount;
|
totalMotorCount += motorCount;
|
||||||
totalPropMass += propMass * motorCount;
|
totalPropMass += propMass * motorCount;
|
||||||
@ -396,7 +400,7 @@ public class DesignReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalMotorCount > 1) {
|
if (totalMotorCount > 1) {
|
||||||
int border = Rectangle.TOP;
|
int border = Rectangle.TOP;
|
||||||
final PdfPCell motorVCell = ITextHelper.createCell("Total:", border);
|
final PdfPCell motorVCell = ITextHelper.createCell("Total:", border);
|
||||||
@ -412,17 +416,17 @@ public class DesignReport {
|
|||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(totalPropMass), border));
|
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(totalPropMass), border));
|
||||||
motorTable.addCell(ITextHelper.createCell("", border));
|
motorTable.addCell(ITextHelper.createCell("", border));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfPCell c = new PdfPCell(motorTable);
|
PdfPCell c = new PdfPCell(motorTable);
|
||||||
c.setBorder(PdfPCell.LEFT);
|
c.setBorder(PdfPCell.LEFT);
|
||||||
c.setBorderWidthTop(0f);
|
c.setBorderWidthTop(0f);
|
||||||
parent.addCell(c);
|
parent.addCell(c);
|
||||||
config.release();
|
config.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the flight data for a simulation configuration to the table.
|
* Add the flight data for a simulation configuration to the table.
|
||||||
*
|
*
|
||||||
@ -433,47 +437,47 @@ public class DesignReport {
|
|||||||
* @param leading the number of points for the leading
|
* @param leading the number of points for the leading
|
||||||
*/
|
*/
|
||||||
private void addFlightData(final FlightData flight, final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
private void addFlightData(final FlightData flight, final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
||||||
|
|
||||||
// Output the flight data
|
// Output the flight data
|
||||||
if (flight != null) {
|
if (flight != null) {
|
||||||
try {
|
try {
|
||||||
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
||||||
final Unit velocityUnit = UnitGroup.UNITS_VELOCITY.getDefaultUnit();
|
final Unit velocityUnit = UnitGroup.UNITS_VELOCITY.getDefaultUnit();
|
||||||
final Unit flightTimeUnit = UnitGroup.UNITS_FLIGHT_TIME.getDefaultUnit();
|
final Unit flightTimeUnit = UnitGroup.UNITS_FLIGHT_TIME.getDefaultUnit();
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
document.add(chunk);
|
document.add(chunk);
|
||||||
|
|
||||||
final PdfPCell cell = ITextHelper.createCell(ALTITUDE, 2, 2);
|
final PdfPCell cell = ITextHelper.createCell(ALTITUDE, 2, 2);
|
||||||
cell.setUseBorderPadding(false);
|
cell.setUseBorderPadding(false);
|
||||||
cell.setBorderWidthTop(0f);
|
cell.setBorderWidthTop(0f);
|
||||||
labelTable.addCell(cell);
|
labelTable.addCell(cell);
|
||||||
labelTable.addCell(ITextHelper.createCell(distanceUnit.toStringUnit(flight.getMaxAltitude()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(distanceUnit.toStringUnit(flight.getMaxAltitude()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(FLIGHT_TIME, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(FLIGHT_TIME, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getFlightTime()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getFlightTime()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(TIME_TO_APOGEE, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(TIME_TO_APOGEE, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getTimeToApogee()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getTimeToApogee()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(VELOCITY_OFF_PAD, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(VELOCITY_OFF_PAD, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getLaunchRodVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getLaunchRodVelocity()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(MAX_VELOCITY, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(MAX_VELOCITY, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getMaxVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getMaxVelocity()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(DEPLOYMENT_VELOCITY, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(DEPLOYMENT_VELOCITY, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getDeploymentVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getDeploymentVelocity()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(LANDING_VELOCITY, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(LANDING_VELOCITY, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getGroundHitVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getGroundHitVelocity()), 2, 2));
|
||||||
|
|
||||||
//Add the table to the parent; have to wrap it in a cell
|
//Add the table to the parent; have to wrap it in a cell
|
||||||
PdfPCell c = new PdfPCell(labelTable);
|
PdfPCell c = new PdfPCell(labelTable);
|
||||||
c.setBorder(PdfPCell.RIGHT);
|
c.setBorder(PdfPCell.RIGHT);
|
||||||
@ -485,7 +489,7 @@ public class DesignReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locate the simulation based on the motor id. Copy the simulation and execute it, then return the resulting
|
* Locate the simulation based on the motor id. Copy the simulation and execute it, then return the resulting
|
||||||
* flight data.
|
* flight data.
|
||||||
@ -513,7 +517,7 @@ public class DesignReport {
|
|||||||
}
|
}
|
||||||
return flight;
|
return flight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip [] brackets from a string.
|
* Strip [] brackets from a string.
|
||||||
*
|
*
|
||||||
@ -524,7 +528,7 @@ public class DesignReport {
|
|||||||
private String stripBrackets(String target) {
|
private String stripBrackets(String target) {
|
||||||
return stripLeftBracket(stripRightBracket(target));
|
return stripLeftBracket(stripRightBracket(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip [ from a string.
|
* Strip [ from a string.
|
||||||
*
|
*
|
||||||
@ -535,7 +539,7 @@ public class DesignReport {
|
|||||||
private String stripLeftBracket(String target) {
|
private String stripLeftBracket(String target) {
|
||||||
return target.replace("[", "");
|
return target.replace("[", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip ] from a string.
|
* Strip ] from a string.
|
||||||
*
|
*
|
||||||
@ -546,5 +550,5 @@ public class DesignReport {
|
|||||||
private String stripRightBracket(String target) {
|
private String stripRightBracket(String target) {
|
||||||
return target.replace("]", "");
|
return target.replace("]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
flightConfigurationNames.put(id, name);
|
if (name == null || name.equals("")) {
|
||||||
|
flightConfigurationNames.remove(id);
|
||||||
|
} else {
|
||||||
|
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