abaac19be757a825cb6a1c1bf477928a072b4340
[debian/openrocket] / src / net / sf / openrocket / optimization / rocketoptimization / SimulationModifier.java
1 package net.sf.openrocket.optimization.rocketoptimization;
2
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;
7
8 /**
9  * An interface what modifies a single parameter in a rocket simulation
10  * based on a double value in the range [0...1].
11  * <p>
12  * The implementation must fire change events when the minimum and maximum ranges
13  * are modified, NOT when the actual modified value changes.
14  * 
15  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
16  */
17 public interface SimulationModifier extends ChangeSource {
18         
19         /**
20          * Return a name describing this modifier.
21          * @return      a name describing this modifier.
22          */
23         public String getName();
24         
25         
26         /**
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.
30          * 
31          * @return      the object this modifier is related to, or <code>null</code>.
32          */
33         public Object getRelatedObject();
34         
35         
36         /**
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
40          */
41         public double getCurrentValue(Simulation simulation) throws OptimizationException;
42         
43         
44         /**
45          * Return the minimum value (corresponding to scaled value 0) in SI units.
46          * @return      the value corresponding to scaled value 0.
47          */
48         public double getMinValue();
49         
50         /**
51          * Set the minimum value (corresponding to scaled value 0) in SI units.
52          * @param value the value corresponding to scaled value 0.
53          */
54         public void setMinValue(double value);
55         
56         
57         /**
58          * Return the maximum value (corresponding to scaled value 1) in SI units.
59          * @return      the value corresponding to scaled value 1.
60          */
61         public double getMaxValue();
62         
63         /**
64          * Set the maximum value (corresponding to scaled value 1) in SI units.
65          * @param value the value corresponding to scaled value 1.
66          */
67         public void setMaxValue(double value);
68         
69         
70         /**
71          * Return the unit group used for the values returned by {@link #getCurrentValue(Simulation)} etc.
72          * @return      the unit group
73          */
74         public UnitGroup getUnitGroup();
75         
76         
77         /**
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.
80          * 
81          * @return      the current value of this parameter (normally between [0 ... 1])
82          * @throws OptimizationException        if fetching the current value fails
83          */
84         public double getCurrentScaledValue(Simulation simulation) throws OptimizationException;
85         
86         
87
88         /**
89          * Modify the specified simulation to the corresponding parameter value.
90          * 
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
94          */
95         public void modify(Simulation simulation, double scaledValue) throws OptimizationException;
96         
97 }