From: richardgraham Date: Mon, 11 Jun 2012 04:47:49 +0000 (+0000) Subject: - Implemented copying of custom expressions to other simulations in expression builde... X-Git-Tag: upstream/12.09^2~188 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=109b95aae3323e9c51b58d33d61dfe0a6c5bb7bc;p=debian%2Fopenrocket - Implemented copying of custom expressions to other simulations in expression builder dialog. Note the small changes to various files are to allow simulations access to parent document. - Switched to unicode char escapes - Removed dynamic setting of flightdatatype priority - Now hiding up down arrows in custom expression pane when unusable - Localized custom expression operator discriptions. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@770 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index b783491f..db2b58af 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -469,6 +469,8 @@ ExpressionBuilderDialog.InsertOperator = Insert Operator 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 = Make a copy of this expression in other simulations in this document.
Will not overwrite or modify any existing expressions in other simulations. ! Custom expression variable selector CustomVariableSelector.title = Variable Selector @@ -476,6 +478,30 @@ 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 diff --git a/core/src/net/sf/openrocket/document/Simulation.java b/core/src/net/sf/openrocket/document/Simulation.java index 33a4866e..c947e23d 100644 --- a/core/src/net/sf/openrocket/document/Simulation.java +++ b/core/src/net/sf/openrocket/document/Simulation.java @@ -61,6 +61,7 @@ public class Simulation implements ChangeSource, Cloneable { private SafetyMutex mutex = SafetyMutex.newInstance(); private final Rocket rocket; + private final OpenRocketDocument document; private String name = ""; @@ -90,12 +91,16 @@ public class Simulation implements ChangeSource, Cloneable { /** - * 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; @@ -106,7 +111,7 @@ public class Simulation implements ChangeSource, Cloneable { } - public Simulation(Rocket rocket, Status status, String name, SimulationOptions options, + public Simulation(OpenRocketDocument doc, Rocket rocket, Status status, String name, SimulationOptions options, List listeners, FlightData data) { if (rocket == null) @@ -119,6 +124,7 @@ public class Simulation implements ChangeSource, Cloneable { throw new IllegalArgumentException("options cannot be null"); this.rocket = rocket; + this.document = doc; if (status == Status.UPTODATE) { this.status = Status.LOADED; @@ -148,6 +154,13 @@ public class Simulation implements ChangeSource, Cloneable { } + /* + * 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."); @@ -427,7 +440,7 @@ public class Simulation implements ChangeSource, Cloneable { 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); diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java index 3bc872b9..ca0332c4 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java @@ -1299,7 +1299,7 @@ class SingleSimulationHandler extends AbstractElementHandler { 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 @@ -1704,7 +1704,15 @@ class FlightDataBranchHandler extends AbstractElementHandler { } } + // 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(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(sim, name)); diff --git a/core/src/net/sf/openrocket/gui/main/SimulationPanel.java b/core/src/net/sf/openrocket/gui/main/SimulationPanel.java index 719e1cf6..09751730 100644 --- a/core/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/core/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -82,7 +82,7 @@ public class SimulationPanel extends JPanel { 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(); diff --git a/core/src/net/sf/openrocket/gui/util/SwingPreferences.java b/core/src/net/sf/openrocket/gui/util/SwingPreferences.java index 76407088..ba433217 100644 --- a/core/src/net/sf/openrocket/gui/util/SwingPreferences.java +++ b/core/src/net/sf/openrocket/gui/util/SwingPreferences.java @@ -15,6 +15,7 @@ import java.util.prefs.BackingStoreException; 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; @@ -398,7 +399,7 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences { } 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); diff --git a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java index cf77e3c5..84e6af62 100644 --- a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java +++ b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java @@ -126,7 +126,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi 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) { diff --git a/core/src/net/sf/openrocket/simulation/CustomExpression.java b/core/src/net/sf/openrocket/simulation/CustomExpression.java index 6e829bb1..a383dd87 100644 --- a/core/src/net/sf/openrocket/simulation/CustomExpression.java +++ b/core/src/net/sf/openrocket/simulation/CustomExpression.java @@ -4,6 +4,7 @@ import java.util.SortedMap; 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; @@ -21,6 +22,7 @@ import de.congrace.exp4j.ExpressionBuilder; 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; @@ -28,31 +30,30 @@ public class CustomExpression implements Cloneable{ // A map of available operator strings (keys) and description of function (value) public static final SortedMap AVAILABLE_OPERATORS = new TreeMap() {{ - 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(""); @@ -94,7 +95,6 @@ public class CustomExpression implements Cloneable{ return new FlightDataBranch(); } else { - System.out.println("Using existing branch"); return sim.getSimulatedData().getBranch(0); } } @@ -179,7 +179,7 @@ public class CustomExpression implements Cloneable{ ArrayList 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; } @@ -271,21 +271,22 @@ public class CustomExpression implements Cloneable{ 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 ); } /* @@ -300,6 +301,18 @@ public class CustomExpression implements Cloneable{ } } + /* + * 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(); @@ -307,7 +320,8 @@ public class CustomExpression implements Cloneable{ @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() { diff --git a/core/src/net/sf/openrocket/simulation/FlightDataType.java b/core/src/net/sf/openrocket/simulation/FlightDataType.java index eb8a8d90..2cbe325a 100644 --- a/core/src/net/sf/openrocket/simulation/FlightDataType.java +++ b/core/src/net/sf/openrocket/simulation/FlightDataType.java @@ -59,25 +59,25 @@ public class FlightDataType implements Comparable { //// 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 @@ -126,22 +126,22 @@ public class FlightDataType implements Comparable { //// 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); @@ -156,9 +156,9 @@ public class FlightDataType implements Comparable { //// 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 @@ -175,8 +175,7 @@ public class FlightDataType implements Comparable { //// 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 = { @@ -273,7 +272,7 @@ public class FlightDataType implements Comparable { private final String name; private final String symbol; private final UnitGroup units; - private int priority; + private final int priority; private final int hashCode; @@ -289,10 +288,11 @@ public class FlightDataType implements Comparable { this.hashCode = this.name.toLowerCase(Locale.ENGLISH).hashCode(); } - + /* public void setPriority(int p){ this.priority = p; } + */ public String getName() { return name; diff --git a/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java b/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java index 48cc648b..fe2084f0 100644 --- a/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java +++ b/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java @@ -1,6 +1,7 @@ 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; @@ -39,7 +40,7 @@ public class TestRocketOptimizationFunction { @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; @@ -85,7 +86,7 @@ public class TestRocketOptimizationFunction { @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; @@ -122,7 +123,7 @@ public class TestRocketOptimizationFunction { @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; @@ -163,7 +164,7 @@ public class TestRocketOptimizationFunction { @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; @@ -196,7 +197,7 @@ public class TestRocketOptimizationFunction { 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, diff --git a/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java b/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java index deacacf4..0fb6d13f 100644 --- a/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java +++ b/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java @@ -2,6 +2,7 @@ package net.sf.openrocket.optimization.rocketoptimization.modifiers; 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; @@ -20,7 +21,9 @@ public class TestGenericModifier { @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();