1 package net.sf.openrocket.optimization.rocketoptimization;
3 import net.sf.openrocket.document.Simulation;
4 import net.sf.openrocket.optimization.general.OptimizationException;
5 import net.sf.openrocket.unit.UnitGroup;
6 import net.sf.openrocket.util.ChangeSource;
9 * An interface what modifies a single parameter in a rocket simulation
10 * based on a double value in the range [0...1].
12 * The implementation must fire change events when the minimum and maximum ranges
13 * are modified, NOT when the actual modified value changes.
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 public interface SimulationModifier extends ChangeSource {
20 * Return a name describing this modifier.
21 * @return a name describing this modifier.
23 public String getName();
27 * Return the object this modifier is related to. This is for example the
28 * rocket component this modifier is modifying. This object can be used by a
29 * UI to group related modifiers.
31 * @return the object this modifier is related to, or <code>null</code>.
33 public Object getRelatedObject();
37 * Return the current value of the modifier in SI units.
38 * @return the current value of this parameter in SI units.
39 * @throws OptimizationException if fetching the current value fails
41 public double getCurrentValue(Simulation simulation) throws OptimizationException;
45 * Return the minimum value (corresponding to scaled value 0) in SI units.
46 * @return the value corresponding to scaled value 0.
48 public double getMinValue();
51 * Set the minimum value (corresponding to scaled value 0) in SI units.
52 * @param value the value corresponding to scaled value 0.
54 public void setMinValue(double value);
58 * Return the maximum value (corresponding to scaled value 1) in SI units.
59 * @return the value corresponding to scaled value 1.
61 public double getMaxValue();
64 * Set the maximum value (corresponding to scaled value 1) in SI units.
65 * @param value the value corresponding to scaled value 1.
67 public void setMaxValue(double value);
71 * Return the unit group used for the values returned by {@link #getCurrentValue(Simulation)} etc.
72 * @return the unit group
74 public UnitGroup getUnitGroup();
78 * Return the current scaled value. This is normally within the range [0...1], but
79 * can be outside the range if the current value is outside of the min and max values.
81 * @return the current value of this parameter (normally between [0 ... 1])
82 * @throws OptimizationException if fetching the current value fails
84 public double getCurrentScaledValue(Simulation simulation) throws OptimizationException;
89 * Modify the specified simulation to the corresponding parameter value.
91 * @param simulation the simulation to modify
92 * @param scaledValue the scaled value in the range [0...1]
93 * @throws OptimizationException if the modification fails
95 public void modify(Simulation simulation, double scaledValue) throws OptimizationException;