Commit ead09516 authored by Nico Mack's avatar Nico Mack

Added initialValue property to NumericalVariable

Fixed bug with textColour property of ArcGraph
parent 728e74b1
......@@ -42,6 +42,7 @@ public class VariableBootstrapper {
String unit = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.UNIT_ATTRIBUTE, BootstrappingUtils.OPTIONAL, EquationSystemBundle.EMPTY_STRING, context);
double minValue = BootstrappingUtils.getContentAsDouble(variableNode, EquationSystemBundle.MINIMUM_ATTRIBUTE, BootstrappingUtils.OPTIONAL, -Double.MAX_VALUE, context);
double maxValue = BootstrappingUtils.getContentAsDouble(variableNode, EquationSystemBundle.MAXIMUM_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Double.MAX_VALUE, context);
double initialValue = BootstrappingUtils.getContentAsDouble(variableNode, EquationSystemBundle.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Double.NaN, context);
double scale = BootstrappingUtils.getContentAsDouble(variableNode, EquationSystemBundle.SCALE_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 1.0, context);
double numericValue = BootstrappingUtils.getContentAsDouble(variableNode, EquationSystemBundle.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 0.0, context);
int decimals = BootstrappingUtils.getContentAsInteger(variableNode, EquationSystemBundle.DECIMALS_ATTRIBUTE, BootstrappingUtils.OPTIONAL, -1, context);
......@@ -49,6 +50,7 @@ public class VariableBootstrapper {
NumericalVariable numerical = new NumericalVariable(name, unit, numericValue);
numerical.setMinValue(minValue);
numerical.setMaxValue(maxValue);
numerical.setInitialValue(initialValue);
numerical.setScale(scale);
if (decimals >= 0) {
numerical.setNumberOfDecimals(decimals);
......
......@@ -349,11 +349,11 @@ public class EquationSystemBuilder {
if (!Strings.isNullOrEmpty(attributes.get(EquationSystemBundle.MAXIMUM_ATTRIBUTE)))
numericVariable.setMaxValue(StringUtils.getDoubleValue(attributes.get(EquationSystemBundle.MAXIMUM_ATTRIBUTE)));
if (!Strings.isNullOrEmpty(attributes.get(EquationSystemBundle.INITIAL_ATTRIBUTE)))
numericVariable.setInitialValue(StringUtils.getDoubleValue(attributes.get(EquationSystemBundle.INITIAL_ATTRIBUTE)));
if (!Strings.isNullOrEmpty(attributes.get(EquationSystemBundle.EPSILON_ATTRIBUTE)))
numericVariable.setEpsilon(StringUtils.getDoubleValue(attributes.get(EquationSystemBundle.EPSILON_ATTRIBUTE)));
//
// if (!Strings.isNullOrEmpty(attributes.get(EquationSystemBundle.EQUATE_ATTRIBUTE)))
// numericVariable.setEquate(attributes.get(EquationSystemBundle.EQUATE_ATTRIBUTE));
if (!Strings.isNullOrEmpty(attributes.get(EquationSystemBundle.DECIMALS_ATTRIBUTE)))
numericVariable.setNumberOfDecimals(StringUtils.getIntegerValue(attributes.get(EquationSystemBundle.DECIMALS_ATTRIBUTE)));
......
......@@ -50,6 +50,7 @@ import java.util.Vector;
public class NumericalVariable extends Variable<Double> {
protected double minValue;
protected double maxValue;
protected double initialValue;
protected double scale;
protected double valueRange;
......@@ -102,6 +103,7 @@ public class NumericalVariable extends Variable<Double> {
minValue = -Double.MAX_VALUE;
maxValue = Double.MAX_VALUE;
initialValue = Double.NaN;
valueRange = getValueRange(minValue, maxValue);
epsilon = DEFAULT_EPSILON;
scale = 1;
......@@ -341,6 +343,31 @@ public class NumericalVariable extends Variable<Double> {
return this.maxValue;
}
// ---------------------------------------------------------------------------
/**
* Specifies the smallest difference between a given number and the next different number.
*
* @param value
* specifies the smallest acceptable difference between subsequent values.
*/
// ---------------------------------------------------------------------------
public void setInitialValue(double value) {
this.initialValue = Math.max(value, this.minValue);
this.initialValue = Math.min(value, this.maxValue);
}
// ---------------------------------------------------------------------------
/**
*
* @return the smallest difference between a given number and the next different number.
*/
// ---------------------------------------------------------------------------
public double getInitialValue() {
return this.initialValue;
}
// ---------------------------------------------------------------------------
/**
......
......@@ -109,7 +109,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
rampingTime = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.RAMPING_TIME_NODE, BootstrappingUtils.OPTIONAL, 500, context);
fillColour = buildColorPair(rootElement.getChild(Externalization.FILL_COLOUR_ELEMENT), BootstrappingUtils.MANDATORY, context);
textColour = buildColorPair(rootElement.getChild(Externalization.TEXT_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, null);
textColour = buildColorPair(rootElement.getChild(Externalization.TEXT_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
strokeColour = buildColorPair(rootElement.getChild(Externalization.STROKE_COLOUR_ELEMENT), BootstrappingUtils.MANDATORY, context);
labelColour = buildColorPair(rootElement.getChild(Externalization.LABEL_COLOUR_ELEMENT), BootstrappingUtils.MANDATORY, context);
faceColour = buildColorPair(rootElement.getChild(Externalization.FACE_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment