ExpressionBuilderDialog.led.ttip.Name = Name must not have already been used
ExpressionBuilderDialog.led.ttip.Symbol = Symbol must not have already been used
ExpressionBuilderDialog.led.ttip.Expression = Expression must use only known symbols and operators
+ExpressionBuilderDialog.CopyToOtherSimulations = Copy to other simulations
+ExpressionBuilderDialog.CopyToOtherSimulations.ttip = <html>Make a copy of this expression in other simulations in this document.<br>Will not overwrite or modify any existing expressions in other simulations.
! Custom expression variable selector
CustomVariableSelector.title = Variable Selector
! Custom operator selector
CustomOperatorSelector.title = Operator Selector
+! Operators
+Operator.plus = Addition
+Operator.minus = Subtraction
+Operator.star = Multiplication
+Operator.div = Divison
+Operator.mod = Modulo
+Operator.pow = Exponentiation
+Operator.abs = Absolute value
+Operator.ceil = Ceiling (next integer value
+Operator.floor = Floor (previous integer value
+Operator.sqrt = Square root
+Operator.cbrt = Cubic root
+Operator.exp = Euler\'s number raised to the value (e^x)
+Operator.ln = Natural logarithm
+Operator.sin = Sine
+Operator.cos = Cosine
+Operator.tan = Tangent
+Operator.asin = Arc sine
+Operator.acos = Arc cosine
+Operator.atan = Arc tangent
+Operator.hsin = Hyerbolic sine
+Operator.hcos = Hyperbolic cosine
+Operator.htan = Hyperbolic tangent
+
! MotorPlot
MotorPlot.title.Motorplot = Motor plot
MotorPlot.but.Select = Select
private SafetyMutex mutex = SafetyMutex.newInstance();
private final Rocket rocket;
+ private final OpenRocketDocument document;
private String name = "";
/**
- * Create a new simulation for the rocket. The initial motor configuration is
- * taken from the default rocket configuration.
+ * Create a new simulation for the rocket. Parent document should also be provided.
+ * The initial motor configuration is taken from the default rocket configuration.
*
* @param rocket the rocket associated with the simulation.
*/
- public Simulation(Rocket rocket) {
+ public Simulation(OpenRocketDocument doc, Rocket rocket) {
+ // It may seem silly to pass in the document and rocket, since usually when called we
+ // use doc.getRocket, but I guess there is some reason; when cloning a simulation + rocket we don't need
+ // to make a duplicate of the undo data etc stored in the document. --Richard
+ this.document = doc;
this.rocket = rocket;
this.status = Status.NOT_SIMULATED;
}
- public Simulation(Rocket rocket, Status status, String name, SimulationOptions options,
+ public Simulation(OpenRocketDocument doc, Rocket rocket, Status status, String name, SimulationOptions options,
List<String> listeners, FlightData data) {
if (rocket == null)
throw new IllegalArgumentException("options cannot be null");
this.rocket = rocket;
+ this.document = doc;
if (status == Status.UPTODATE) {
this.status = Status.LOADED;
}
+ /*
+ * Return the parent document for this simulation
+ */
+ public OpenRocketDocument getDocument(){
+ return document;
+ }
+
public void addCustomExpression(CustomExpression expression){
this.status = Simulation.Status.OUTDATED;
log.debug("Simulation must be run again to update custom expression.");
public Simulation duplicateSimulation(Rocket newRocket) {
mutex.lock("duplicateSimulation");
try {
- Simulation copy = new Simulation(newRocket);
+ Simulation copy = new Simulation(document, newRocket);
copy.name = this.name;
copy.options.copyFrom(this.options);
else
data = dataHandler.getFlightData();
- Simulation simulation = new Simulation(doc.getRocket(), status, name,
+ Simulation simulation = new Simulation(doc, doc.getRocket(), status, name,
conditions, listeners, data);
// Note : arraylist implementation in simulation different from standard one
}
}
+ // Look in custom expressions
+ for (CustomExpression exp : simHandler.getCustomExpressions()){
+ if (exp.getName().equals(name) ){
+ return exp.getType();
+ }
+ }
+
// Look in custom expressions, meanwhile set priority based on order in file
+ /*
int totalExpressions = simHandler.getCustomExpressions().size();
for (int i=0; i<totalExpressions; i++){
CustomExpression exp = simHandler.getCustomExpressions().get(i);
return exp.getType();
}
}
+ */
log.warn("Could not find the flight data type '"+name+"' used in the XML file. Substituted type with unknown symbol and units.");
return FlightDataType.getType(name, "Unknown", UnitGroup.UNITS_NONE);
private void updateExpressions(){
expressionSelectorPanel.removeAll();
- for (CustomExpression expression : simulation.getCustomExpressions()){
- SingleExpression se = new SingleExpression(expression);
+ int totalExpressions = simulation.getCustomExpressions().size();
+ for (int i=0; i<totalExpressions; i++){
+ SingleExpression se = new SingleExpression(simulation.getCustomExpressions().get(i), i != 0, i != totalExpressions-1);
expressionSelectorPanel.add(se, "wrap");
}
//TODO: High : Find out why repaint method not working properly here.
//expressionSelectorPanel.repaint();
expressionSelectorPanel.updateUI(); // Not the correct method to use but works
-
-
}
private void deleteExpression(CustomExpression expression){
return l;
}
- private SingleExpression(final CustomExpression expression) {
+ private SingleExpression(final CustomExpression expression, boolean showUp, boolean showDown) {
super(new MigLayout("ins 0"));
// name: aName symbol: a Unit: m/s
//super(new MigLayout("","[::100][:200:400][::100][:100:200][::100][:100:200]",""));
JButton upButton = new JButton(Icons.UP);
upButton.setToolTipText(trans.get("customExpression.Units.but.ttip.MoveUp"));
upButton.setBorderPainted(false);
+ upButton.setVisible(showUp);
upButton.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JButton downButton = new JButton(Icons.DOWN);
downButton.setToolTipText(trans.get("customExpression.Units.but.ttip.MoveDown"));
downButton.setBorderPainted(false);
+ downButton.setVisible(showDown);
downButton.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
import javax.swing.ImageIcon;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout;
}
});
+ //// Copy expression check box
+ final JCheckBox copyCheckBox = new JCheckBox(trans.get("ExpressionBuilderDialog.CopyToOtherSimulations"));
+ copyCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
+ copyCheckBox.setToolTipText(trans.get("ExpressionBuilderDialog.CopyToOtherSimulations.ttip"));
//// OK Button
okButton.setEnabled(false);
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
+ // add to this simulation
expression.addToSimulation();
+ if (copyCheckBox.isSelected()){
+ expression.copyToOtherSimulations();
+ }
+
+ // close window
ExpressionBuilderDialog.this.dispose();
}
});
mainPanel.add(expressionCheck, "wrap, center");
mainPanel.add(insertOperatorButton, "span 2, right, split 2");
mainPanel.add(insertVariableButton, "right, wrap");
+ mainPanel.add(copyCheckBox, "span 2, right, wrap");
mainPanel.add(cancelButton, "span 2, right, width :50:100");
mainPanel.add(okButton, "right, width :50:100, wrap");
if (id == null) {
continue;
}
- Simulation sim = new Simulation(rocket);
+ Simulation sim = new Simulation(documentCopy, rocket);
sim.getConfiguration().setMotorConfigurationID(id);
String name = createSimulationName(trans.get("basicSimulationName"), rocket.getMotorConfigurationNameOrDescription(id));
simulations.add(new Named<Simulation>(sim, name));
}
- Simulation sim = new Simulation(rocket);
+ Simulation sim = new Simulation(documentCopy, rocket);
sim.getConfiguration().setMotorConfigurationID(null);
String name = createSimulationName(trans.get("noSimulationName"), rocket.getMotorConfigurationNameOrDescription(null));
simulations.add(new Named<Simulation>(sim, name));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- Simulation sim = new Simulation(document.getRocket());
+ Simulation sim = new Simulation(document, document.getRocket());
sim.setName(document.getNextSimulationName());
int n = document.getSimulationCount();
import java.util.prefs.Preferences;
import net.sf.openrocket.arch.SystemInfo;
+import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.material.Material;
}
public Simulation getBackgroundSimulation(Rocket rocket) {
- Simulation s = new Simulation(rocket);
+ Simulation s = new Simulation(new OpenRocketDocument(rocket), rocket);
SimulationOptions cond = s.getOptions();
cond.setTimeStep(RK4SimulationStepper.RECOMMENDED_TIME_STEP * 2);
Rocket rocket = document.getRocket();
// Simulation is used to calculate default min/max values
- Simulation simulation = new Simulation(rocket);
+ Simulation simulation = new Simulation(document, rocket);
simulation.getConfiguration().setMotorConfigurationID(null);
for (RocketComponent c : rocket) {
import java.util.TreeMap;
import net.sf.openrocket.document.Simulation;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.FixedUnitGroup;
public class CustomExpression implements Cloneable{
private static final LogHelper log = Application.getLogger();
+ private static final Translator trans = Application.getTranslator();
private String name, symbol, unit, expression;
private ExpressionBuilder builder;
// A map of available operator strings (keys) and description of function (value)
public static final SortedMap<String, String> AVAILABLE_OPERATORS = new TreeMap<String, String>() {{
- put("+" , "Addition");
- put("-" , "Subtraction");
- put("*" , "Multiplication");
- put("/" , "Divison");
- put("%" , "Modulo");
- put("^" , "Exponentiation");
- put("abs()" , "Absolute value");
- put("ceil()" , "Ceiling (next integer value");
- put("floor()" , "Floor (previous integer value");
- put("sqrt()" , "Square root");
- put("cbrt()" , "Cubic root");
- put("exp()" , "Euler\'s number raised to the value (e^x)");
- put("log()" , "Natural logarithm");
- put("sin()" , "Sine");
- put("cos()" , "Cosine");
- put("tan()" , "Tangent");
- put("asin()" , "Arc sine");
- put("acos()" , "Arc cosine");
- put("atan()" , "Arc tangent");
- put("sinh()" , "Hyerbolic sine");
- put("cosh()" , "Hyperbolic cosine");
- put("tanh()" , "Hyperbolic tangent");
+ put("+" , trans.get("Operator.plus"));
+ put("-" , trans.get("Operator.minus"));
+ put("*" , trans.get("Operator.star"));
+ put("/" , trans.get("Operator.div"));
+ put("%" , trans.get("Operator.mod"));
+ put("^" , trans.get("Operator.pow"));
+ put("abs()" , trans.get("Operator.abs"));
+ put("ceil()" , trans.get("Operator.ceil"));
+ put("floor()" , trans.get("Operator.floor"));
+ put("sqrt()" , trans.get("Operator.sqrt"));
+ put("cbrt()" , trans.get("Operator.cbrt"));
+ put("exp()" , trans.get("Operator.exp"));
+ put("log()" , trans.get("Operator.ln"));
+ put("sin()" , trans.get("Operator.sin"));
+ put("cos()" , trans.get("Operator.cos"));
+ put("tan()" , trans.get("Operator.tan"));
+ put("asin()" , trans.get("Operator.asin"));
+ put("acos()" , trans.get("Operator.acos"));
+ put("atan()" , trans.get("Operator.atan"));
+ put("sinh()" , trans.get("Operator.hsin"));
+ put("cosh()" , trans.get("Operator.hcos"));
+ put("tanh()" , trans.get("Operator.htan"));
}};
-
public CustomExpression(){
setName("");
setSymbol("");
return new FlightDataBranch();
}
else {
- System.out.println("Using existing branch");
return sim.getSimulatedData().getBranch(0);
}
}
ArrayList<String> names = getAllNames().clone();
if (names.contains(name.trim())){
int index = names.indexOf(name.trim());
- log.user("Symbol "+symbol+" already exists, found "+names.get(index));
+ log.user("Name "+name+" already exists, found "+names.get(index));
return false;
}
FlightDataType type = FlightDataType.getType(name, symbol, ug);
// If in a simulation, figure out priority from order in array so that customs expressions are always at the top
- if (sim != null && sim.getCustomExpressions().contains(this)){
- int totalExpressions = sim.getCustomExpressions().size();
- int p = -1*(totalExpressions-sim.getCustomExpressions().indexOf(this));
- type.setPriority(p);
- }
+ //if (sim != null && sim.getCustomExpressions().contains(this)){
+ // int totalExpressions = sim.getCustomExpressions().size();
+ // int p = -1*(totalExpressions-sim.getCustomExpressions().indexOf(this));
+ // type.setPriority(p);
+ //}
return type;
}
/*
- * Add this expression to the simulation if not already added
+ * Add this expression to the simulation if valid and not already added
*/
public void addToSimulation(){
- if (! sim.getCustomExpressions().contains(this))
- sim.addCustomExpression( this );
+ // Abort if exact expression already in
+ if ( !sim.getCustomExpressions().contains(this) && this.checkAll() )
+ sim.addCustomExpression( this );
}
/*
}
}
+ /*
+ * Add a copy to other simulations in this document if possible
+ * Will not overwrite existing expressions
+ */
+ public void copyToOtherSimulations(){
+ for (Simulation s : this.getSimulation().getDocument().getSimulations()){
+ CustomExpression newExpression = (CustomExpression) this.clone();
+ newExpression.setSimulation(s);
+ newExpression.addToSimulation();
+ }
+ }
+
@Override
public String toString(){
return "Custom expression : "+this.name.toString()+ " " + this.expression.toString();
@Override
/*
- * Clone method makes a deep copy of everything except the simulation
+ * Clone method makes a deep copy of everything except the simulation.
+ * If you want to apply this to another simulation, set simulation manually after cloning.
* @see java.lang.Object#clone()
*/
public Object clone() {
//// Lateral distance
public static final FlightDataType TYPE_POSITION_XY = newType(trans.get("FlightDataType.TYPE_POSITION_XY"), "Pl", UnitGroup.UNITS_DISTANCE, 32);
//// Lateral direction
- public static final FlightDataType TYPE_POSITION_DIRECTION = newType(trans.get("FlightDataType.TYPE_POSITION_DIRECTION"), "θl", UnitGroup.UNITS_ANGLE, 33);
+ public static final FlightDataType TYPE_POSITION_DIRECTION = newType(trans.get("FlightDataType.TYPE_POSITION_DIRECTION"), "\u03b8l", UnitGroup.UNITS_ANGLE, 33);
//// Lateral velocity
public static final FlightDataType TYPE_VELOCITY_XY = newType(trans.get("FlightDataType.TYPE_VELOCITY_XY"), "Vl", UnitGroup.UNITS_VELOCITY, 34);
//// Lateral acceleration
public static final FlightDataType TYPE_ACCELERATION_XY = newType(trans.get("FlightDataType.TYPE_ACCELERATION_XY"), "Al", UnitGroup.UNITS_ACCELERATION, 35);
//// Latitude
- public static final FlightDataType TYPE_LATITUDE = newType(trans.get("FlightDataType.TYPE_LATITUDE"), "φ", UnitGroup.UNITS_ANGLE, 36);
+ public static final FlightDataType TYPE_LATITUDE = newType(trans.get("FlightDataType.TYPE_LATITUDE"), "\u03c6", UnitGroup.UNITS_ANGLE, 36);
//// Longitude
- public static final FlightDataType TYPE_LONGITUDE = newType(trans.get("FlightDataType.TYPE_LONGITUDE"), "λ", UnitGroup.UNITS_ANGLE, 37);
+ public static final FlightDataType TYPE_LONGITUDE = newType(trans.get("FlightDataType.TYPE_LONGITUDE"), "\u03bb", UnitGroup.UNITS_ANGLE, 37);
//// Angular motion
//// Angle of attack
- public static final FlightDataType TYPE_AOA = newType(trans.get("FlightDataType.TYPE_AOA"), "α", UnitGroup.UNITS_ANGLE, 40);
+ public static final FlightDataType TYPE_AOA = newType(trans.get("FlightDataType.TYPE_AOA"), "\u03b1", UnitGroup.UNITS_ANGLE, 40);
//// Roll rate
- public static final FlightDataType TYPE_ROLL_RATE = newType(trans.get("FlightDataType.TYPE_ROLL_RATE"), "dΦ", UnitGroup.UNITS_ROLL, 41);
+ public static final FlightDataType TYPE_ROLL_RATE = newType(trans.get("FlightDataType.TYPE_ROLL_RATE"), "d\u03a6", UnitGroup.UNITS_ROLL, 41);
//// Pitch rate
- public static final FlightDataType TYPE_PITCH_RATE = newType(trans.get("FlightDataType.TYPE_PITCH_RATE"), "dθ", UnitGroup.UNITS_ROLL, 42);
+ public static final FlightDataType TYPE_PITCH_RATE = newType(trans.get("FlightDataType.TYPE_PITCH_RATE"), "d\u03b8", UnitGroup.UNITS_ROLL, 42);
//// Yaw rate
- public static final FlightDataType TYPE_YAW_RATE = newType(trans.get("FlightDataType.TYPE_YAW_RATE"), "dΨ", UnitGroup.UNITS_ROLL, 43);
+ public static final FlightDataType TYPE_YAW_RATE = newType(trans.get("FlightDataType.TYPE_YAW_RATE"), "d\u03a8", UnitGroup.UNITS_ROLL, 43);
//// Stability information
//// Normal force coefficient
public static final FlightDataType TYPE_NORMAL_FORCE_COEFF = newType(trans.get("FlightDataType.TYPE_NORMAL_FORCE_COEFF"), "Cn", UnitGroup.UNITS_COEFFICIENT, 90);
//// Pitch moment coefficient
- public static final FlightDataType TYPE_PITCH_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_PITCH_MOMENT_COEFF"), "Cθ", UnitGroup.UNITS_COEFFICIENT, 91);
+ public static final FlightDataType TYPE_PITCH_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_PITCH_MOMENT_COEFF"), "C\u03b8", UnitGroup.UNITS_COEFFICIENT, 91);
//// Yaw moment coefficient
- public static final FlightDataType TYPE_YAW_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_YAW_MOMENT_COEFF"), "CτΨ", UnitGroup.UNITS_COEFFICIENT, 92);
+ public static final FlightDataType TYPE_YAW_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_YAW_MOMENT_COEFF"), "C\u03c4\u03a8", UnitGroup.UNITS_COEFFICIENT, 92);
//// Side force coefficient
- public static final FlightDataType TYPE_SIDE_FORCE_COEFF = newType(trans.get("FlightDataType.TYPE_SIDE_FORCE_COEFF"), "Cτs", UnitGroup.UNITS_COEFFICIENT, 93);
+ public static final FlightDataType TYPE_SIDE_FORCE_COEFF = newType(trans.get("FlightDataType.TYPE_SIDE_FORCE_COEFF"), "C\u03c4s", UnitGroup.UNITS_COEFFICIENT, 93);
//// Roll moment coefficient
- public static final FlightDataType TYPE_ROLL_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_MOMENT_COEFF"), "CτΦ", UnitGroup.UNITS_COEFFICIENT, 94);
+ public static final FlightDataType TYPE_ROLL_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_MOMENT_COEFF"), "C\u03c4\u03a6", UnitGroup.UNITS_COEFFICIENT, 94);
//// Roll forcing coefficient
- public static final FlightDataType TYPE_ROLL_FORCING_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_FORCING_COEFF"), "CfΦ", UnitGroup.UNITS_COEFFICIENT, 95);
+ public static final FlightDataType TYPE_ROLL_FORCING_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_FORCING_COEFF"), "Cf\u03a6", UnitGroup.UNITS_COEFFICIENT, 95);
//// Roll damping coefficient
- public static final FlightDataType TYPE_ROLL_DAMPING_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_DAMPING_COEFF"), "CζΦ", UnitGroup.UNITS_COEFFICIENT, 96);
+ public static final FlightDataType TYPE_ROLL_DAMPING_COEFF = newType(trans.get("FlightDataType.TYPE_ROLL_DAMPING_COEFF"), "C\u03b6\u03a6", UnitGroup.UNITS_COEFFICIENT, 96);
//// Pitch damping coefficient
- public static final FlightDataType TYPE_PITCH_DAMPING_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF"), "Cζθ", UnitGroup.UNITS_COEFFICIENT, 97);
+ public static final FlightDataType TYPE_PITCH_DAMPING_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF"), "C\u03b6\u03b8", UnitGroup.UNITS_COEFFICIENT, 97);
//// Yaw damping coefficient
- public static final FlightDataType TYPE_YAW_DAMPING_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_YAW_DAMPING_MOMENT_COEFF"), "CζΨ", UnitGroup.UNITS_COEFFICIENT, 98);
+ public static final FlightDataType TYPE_YAW_DAMPING_MOMENT_COEFF = newType(trans.get("FlightDataType.TYPE_YAW_DAMPING_MOMENT_COEFF"), "C\u03b6\u03a8", UnitGroup.UNITS_COEFFICIENT, 98);
//// Coriolis acceleration
public static final FlightDataType TYPE_CORIOLIS_ACCELERATION = newType(trans.get("FlightDataType.TYPE_CORIOLIS_ACCELERATION"), "Ac", UnitGroup.UNITS_ACCELERATION, 99);
//// Orientation
//// Vertical orientation (zenith)
- public static final FlightDataType TYPE_ORIENTATION_THETA = newType(trans.get("FlightDataType.TYPE_ORIENTATION_THETA"), "Θ", UnitGroup.UNITS_ANGLE, 106);
+ public static final FlightDataType TYPE_ORIENTATION_THETA = newType(trans.get("FlightDataType.TYPE_ORIENTATION_THETA"), "\u0398", UnitGroup.UNITS_ANGLE, 106);
//// Lateral orientation (azimuth)
- public static final FlightDataType TYPE_ORIENTATION_PHI = newType(trans.get("FlightDataType.TYPE_ORIENTATION_PHI"), "Φ", UnitGroup.UNITS_ANGLE, 107);
+ public static final FlightDataType TYPE_ORIENTATION_PHI = newType(trans.get("FlightDataType.TYPE_ORIENTATION_PHI"), "\u03a6", UnitGroup.UNITS_ANGLE, 107);
//// Atmospheric conditions
//// Simulation time step
public static final FlightDataType TYPE_TIME_STEP = newType(trans.get("FlightDataType.TYPE_TIME_STEP"), "dt", UnitGroup.UNITS_TIME_STEP, 200);
//// Computation time
- public static final FlightDataType TYPE_COMPUTATION_TIME = newType(trans.get("FlightDataType.TYPE_COMPUTATION_TIME"), "tc", UnitGroup.UNITS_SHORT_TIME, 201);
-
+ public static final FlightDataType TYPE_COMPUTATION_TIME = newType(trans.get("FlightDataType.TYPE_COMPUTATION_TIME"), "tc", UnitGroup.UNITS_SHORT_TIME, 201);
// An array of all the built in types
public static final FlightDataType[] ALL_TYPES = {
private final String name;
private final String symbol;
private final UnitGroup units;
- private int priority;
+ private final int priority;
private final int hashCode;
this.hashCode = this.name.toLowerCase(Locale.ENGLISH).hashCode();
}
-
+ /*
public void setPriority(int p){
this.priority = p;
}
+ */
public String getName() {
return name;
package net.sf.openrocket.optimization.rocketoptimization;
import static org.junit.Assert.*;
+import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.optimization.general.OptimizationException;
import net.sf.openrocket.optimization.general.Point;
@Test
public void testNormalEvaluation() throws InterruptedException, OptimizationException {
final Rocket rocket = new Rocket();
- final Simulation simulation = new Simulation(rocket);
+ final Simulation simulation = new Simulation(new OpenRocketDocument(rocket), rocket);
final double p1 = 0.4;
final double p2 = 0.7;
@Test
public void testNaNValue() throws InterruptedException, OptimizationException {
final Rocket rocket = new Rocket();
- final Simulation simulation = new Simulation(rocket);
+ final Simulation simulation = new Simulation(new OpenRocketDocument(rocket), rocket);
final double p1 = 0.4;
final double p2 = 0.7;
@Test
public void testOutsideDomain() throws InterruptedException, OptimizationException {
final Rocket rocket = new Rocket();
- final Simulation simulation = new Simulation(rocket);
+ final Simulation simulation = new Simulation(new OpenRocketDocument(rocket), rocket);
final double p1 = 0.4;
final double p2 = 0.7;
@Test
public void testOutsideDomain2() throws InterruptedException, OptimizationException {
final Rocket rocket = new Rocket();
- final Simulation simulation = new Simulation(rocket);
+ final Simulation simulation = new Simulation(new OpenRocketDocument(rocket), rocket);
final double p1 = 0.4;
final double p2 = 0.7;
public void testNewSimulationInstance() {
final Rocket rocket = new Rocket();
rocket.setName("Foobar");
- final Simulation simulation = new Simulation(rocket);
+ final Simulation simulation = new Simulation(new OpenRocketDocument(rocket), rocket);
simulation.setName("MySim");
RocketOptimizationFunction function = new RocketOptimizationFunction(simulation,
import static net.sf.openrocket.util.MathUtil.EPSILON;
import static org.junit.Assert.assertEquals;
+import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.optimization.general.OptimizationException;
import net.sf.openrocket.rocketcomponent.Rocket;
@Before
public void setup() {
value = new TestValue();
- sim = new Simulation(new Rocket());
+ Rocket rocket = new Rocket();
+
+ sim = new Simulation(new OpenRocketDocument(rocket), rocket);
Object related = new Object();