create changelog entry
[debian/openrocket] / core / 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 short name describing this modifier.
21          * @return      a name describing this modifier.
22          */
23         public String getName();
24         
25         /**
26          * Return a longer description describing this modifiers.
27          * @return      a description of the modifier.
28          */
29         public String getDescription();
30         
31         /**
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.
35          * 
36          * @return      the object this modifier is related to, or <code>null</code>.
37          */
38         public Object getRelatedObject();
39         
40         
41         /**
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
45          */
46         public double getCurrentSIValue(Simulation simulation) throws OptimizationException;
47         
48         
49         /**
50          * Return the minimum value (corresponding to scaled value 0) in SI units.
51          * @return      the value corresponding to scaled value 0.
52          */
53         public double getMinValue();
54         
55         /**
56          * Set the minimum value (corresponding to scaled value 0) in SI units.
57          * @param value the value corresponding to scaled value 0.
58          */
59         public void setMinValue(double value);
60         
61         
62         /**
63          * Return the maximum value (corresponding to scaled value 1) in SI units.
64          * @return      the value corresponding to scaled value 1.
65          */
66         public double getMaxValue();
67         
68         /**
69          * Set the maximum value (corresponding to scaled value 1) in SI units.
70          * @param value the value corresponding to scaled value 1.
71          */
72         public void setMaxValue(double value);
73         
74         
75         /**
76          * Return the unit group used for the values returned by {@link #getCurrentSIValue(Simulation)} etc.
77          * @return      the unit group
78          */
79         public UnitGroup getUnitGroup();
80         
81         
82         /**
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.
85          * 
86          * @return      the current value of this parameter (normally between [0 ... 1])
87          * @throws OptimizationException        if fetching the current value fails
88          */
89         public double getCurrentScaledValue(Simulation simulation) throws OptimizationException;
90         
91         
92
93         /**
94          * Modify the specified simulation to the corresponding parameter value.
95          * 
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
99          */
100         public void modify(Simulation simulation, double scaledValue) throws OptimizationException;
101         
102         
103         /**
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).
108          */
109         public boolean equals(Object obj);
110 }