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 short name describing this modifier.
21 * @return a name describing this modifier.
23 public String getName();
26 * Return a longer description describing this modifiers.
27 * @return a description of the modifier.
29 public String getDescription();
32 * Return the object this modifier is related to. This is for example the
33 * rocket component this modifier is modifying. This object can be used by a
34 * UI to group related modifiers.
36 * @return the object this modifier is related to, or <code>null</code>.
38 public Object getRelatedObject();
42 * Return the current value of the modifier in SI units.
43 * @return the current value of this parameter in SI units.
44 * @throws OptimizationException if fetching the current value fails
46 public double getCurrentSIValue(Simulation simulation) throws OptimizationException;
50 * Return the minimum value (corresponding to scaled value 0) in SI units.
51 * @return the value corresponding to scaled value 0.
53 public double getMinValue();
56 * Set the minimum value (corresponding to scaled value 0) in SI units.
57 * @param value the value corresponding to scaled value 0.
59 public void setMinValue(double value);
63 * Return the maximum value (corresponding to scaled value 1) in SI units.
64 * @return the value corresponding to scaled value 1.
66 public double getMaxValue();
69 * Set the maximum value (corresponding to scaled value 1) in SI units.
70 * @param value the value corresponding to scaled value 1.
72 public void setMaxValue(double value);
76 * Return the unit group used for the values returned by {@link #getCurrentSIValue(Simulation)} etc.
77 * @return the unit group
79 public UnitGroup getUnitGroup();
83 * Return the current scaled value. This is normally within the range [0...1], but
84 * can be outside the range if the current value is outside of the min and max values.
86 * @return the current value of this parameter (normally between [0 ... 1])
87 * @throws OptimizationException if fetching the current value fails
89 public double getCurrentScaledValue(Simulation simulation) throws OptimizationException;
94 * Modify the specified simulation to the corresponding parameter value.
96 * @param simulation the simulation to modify
97 * @param scaledValue the scaled value in the range [0...1]
98 * @throws OptimizationException if the modification fails
100 public void modify(Simulation simulation, double scaledValue) throws OptimizationException;
104 * Compare whether this SimulationModifier is equivalent to another simulation modifier.
105 * "Equivalent" means that the simulation modifier corresponds to the same modification in
106 * another rocket instance (e.g. the same modification on another rocket component that
107 * has the same component ID).
109 public boolean equals(Object obj);