Commit 9bec379f authored by Nico Mack's avatar Nico Mack

Implemented Templating to CPS module

parent 13665e57
*.metadata *.metadata
*.classpath *.classpath
CPS/target CPS/target
/.DS_Store
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<dependency> <dependency>
<groupId>lu.list.itis.dkd.tui</groupId> <groupId>lu.list.itis.dkd.tui</groupId>
<artifactId>tulip</artifactId> <artifactId>tulip</artifactId>
<version>2.3.1</version> <version>2.4.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>maven2.dk.ange</groupId> <groupId>maven2.dk.ange</groupId>
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package lu.list.itis.dkd.tui.bootstrapping;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.cps.variable.BooleanVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.exception.BuildException;
import org.jdom2.Element;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
public class VariableBootstrapper {
public static Variable buildVariableFromElement(Element variableNode, BootstrapContext context, BootstrapCallback callback) throws BuildException {
Variable variable = null;
if (variableNode == null)
return null;
String name = BootstrappingUtils.getContentAsString(variableNode, Externalization.NAME_ATTRIBUTE, BootstrappingUtils.MANDATORY, null, context);
String type = BootstrappingUtils.getContentAsString(variableNode, Externalization.TYPE_NODE, BootstrappingUtils.MANDATORY, null, context);
switch (type) {
case Externalization.NUMERIC_TYPE:
String unit = BootstrappingUtils.getContentAsString(variableNode, Externalization.UNIT_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING, context);
double minValue = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.MINIMUM_ATTRIBUTE, BootstrappingUtils.OPTIONAL, -Double.MAX_VALUE, context);
double maxValue = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.MAXIMUM_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Double.MAX_VALUE, context);
double scale = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.SCALE_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 1.0, context);
double numericValue = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 0.0, context);
TangibleNumericalVariable tangibleVariable = new TangibleNumericalVariable(name, unit, numericValue);
tangibleVariable.setMinValue(minValue);
tangibleVariable.setMaxValue(maxValue);
tangibleVariable.setScale(scale);
variable = tangibleVariable;
break;
case Externalization.LOGIC_TYPE:
boolean booleanValue = BootstrappingUtils.getContentAsBoolean(variableNode, Externalization.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, false, context);
BooleanVariable booleanVariable = new BooleanVariable(name, booleanValue);
variable = booleanVariable;
break;
default:
throw new BuildException("Don't know how to build a Variable of type " + type);
}
return variable;
}
}
...@@ -59,10 +59,13 @@ public class Externalization extends NLS { ...@@ -59,10 +59,13 @@ public class Externalization extends NLS {
public static String MAXIMUM_ATTRIBUTE; public static String MAXIMUM_ATTRIBUTE;
public static String SCALE_ATTRIBUTE; public static String SCALE_ATTRIBUTE;
public static String DECIMALS_ATTRIBUTE; public static String DECIMALS_ATTRIBUTE;
public static String TYPE_NODE;
public static final String EMPTY_STRING = "";
public static final String LOGIC_TYPE = "logic"; public static final String LOGIC_TYPE = "logic";
public static final String NUMERIC_TYPE = "numeric"; public static final String NUMERIC_TYPE = "numeric";
static { static {
// initialize resource bundle // initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Externalization.class); NLS.initializeMessages(BUNDLE_NAME, Externalization.class);
......
...@@ -26,3 +26,4 @@ FUNCTION_ATTRIBUTE=function ...@@ -26,3 +26,4 @@ FUNCTION_ATTRIBUTE=function
FROM_ATTRIBUTE=from FROM_ATTRIBUTE=from
SYSTEM_ELEMENT=system SYSTEM_ELEMENT=system
UNIT_ATTRIBUTE=unit UNIT_ATTRIBUTE=unit
TYPE_NODE=type
\ No newline at end of file
...@@ -26,7 +26,6 @@ import lu.list.itis.dkd.tui.cps.InputChangeListener; ...@@ -26,7 +26,6 @@ import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent; import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.utility.Externalization; import lu.list.itis.dkd.tui.cps.utility.Externalization;
import org.jdom2.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -71,7 +70,7 @@ public class NumericalVariable extends Variable { ...@@ -71,7 +70,7 @@ public class NumericalVariable extends Variable {
format.setDecimalSeparatorAlwaysShown(false); format.setDecimalSeparatorAlwaysShown(false);
format.setGroupingUsed(false); format.setGroupingUsed(false);
minValue = Double.MIN_VALUE; minValue = -Double.MAX_VALUE;
maxValue = Double.MAX_VALUE; maxValue = Double.MAX_VALUE;
scale = 1; scale = 1;
} }
...@@ -84,15 +83,17 @@ public class NumericalVariable extends Variable { ...@@ -84,15 +83,17 @@ public class NumericalVariable extends Variable {
* The root element of the variable containing, as text on child elements, all the * The root element of the variable containing, as text on child elements, all the
* necessary information to initialize the variable. * necessary information to initialize the variable.
*/ */
public NumericalVariable(Element rootElement) { // public NumericalVariable(Element rootElement) {
super(Externalization.NUMERIC_TYPE, rootElement.getChildText("name"), rootElement.getChildText("unit")); //$NON-NLS-1$ //$NON-NLS-2$ // super(Externalization.NUMERIC_TYPE, rootElement.getChildText("name"),
this.value = Double.parseDouble(rootElement.getChildText("value")); //$NON-NLS-1$ // rootElement.getChildText("unit")); //$NON-NLS-1$ //$NON-NLS-2$
// String valueContent = Strings.nullToEmpty(rootElement.getChildText("value")); //$NON-NLS-1$
format = new DecimalFormat(); // this.value = (valueContent.length() > 0) ? Double.parseDouble(valueContent) : 0.0;
format.setDecimalSeparatorAlwaysShown(false); //
format.setGroupingUsed(false); // format = new DecimalFormat();
// format.setDecimalSeparatorAlwaysShown(false);
} // format.setGroupingUsed(false);
//
// }
/** /**
* {@inheritDoc}<br> * {@inheritDoc}<br>
...@@ -104,7 +105,7 @@ public class NumericalVariable extends Variable { ...@@ -104,7 +105,7 @@ public class NumericalVariable extends Variable {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(format.format(value)); StringBuilder builder = new StringBuilder(format.format(value));
if ((unit != null) && (unit.length() > 0)) { if ((unit != null) && (unit.length() > 0)) {
builder.append(" [").append(unit).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ builder.append(" ").append(unit); //$NON-NLS-1$
} }
return builder.toString(); return builder.toString();
} }
......
...@@ -29,8 +29,6 @@ import lu.list.itis.dkd.tui.event.ContextEventListener; ...@@ -29,8 +29,6 @@ import lu.list.itis.dkd.tui.event.ContextEventListener;
import lu.list.itis.dkd.tui.exception.UnsupportedInformationException; import lu.list.itis.dkd.tui.exception.UnsupportedInformationException;
import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.utility.Point;
import org.jdom2.Element;
/** /**
* Class extending the {@link NumericalVariable} by implementing an interface, * Class extending the {@link NumericalVariable} by implementing an interface,
* {@link ContextEventListener} which enables the variable to directly listen to changes pushed by a * {@link ContextEventListener} which enables the variable to directly listen to changes pushed by a
...@@ -65,9 +63,9 @@ public class TangibleNumericalVariable extends NumericalVariable implements Cont ...@@ -65,9 +63,9 @@ public class TangibleNumericalVariable extends NumericalVariable implements Cont
* The root element of the variable containing, as text on child elements, all the * The root element of the variable containing, as text on child elements, all the
* necessary information to initialize the variable. * necessary information to initialize the variable.
*/ */
public TangibleNumericalVariable(Element rootElement) { // public TangibleNumericalVariable(Element rootElement) {
super(rootElement); // super(rootElement);
} // }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
......
package lu.list.itis.dkd.tui.widget;
import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.widget.builder.GaugeWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.Gauge;
import lu.list.itis.dkd.tui.widget.tether.Tetherable;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author nmack
* @date 27 Apr 2015
*
* <br>
* $Log: GaugeWidget.java,v $
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class GaugeWidget extends TetherableWidget implements InputChangeListener, InformationReceiver<Double> {
private TangibleNumericalVariable variable;
// ***************************************************************************
// * Constants *
// ***************************************************************************
private static Logger LOGGER = LoggerFactory.getLogger(GaugeWidget.class.getSimpleName());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public GaugeWidget(GaugeWidgetBuilder builder) {
super(builder);
Preconditions.checkState(builder.variable != null, "The variable may not be null!"); //$NON-NLS-1$
this.variable = builder.variable;
this.variable.addListener(this);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public void inputChanged(InputEvent input) {
if (!this.isTethered()) {
Variable source = (Variable) input.getSource();
double value = (Double) source.getValue();
LOGGER.trace("{} = {}", source.getName(), value); //$NON-NLS-1$
this.setInformation((Double) source.getValue());
}
}
// ---------------------------------------------------------------------------
@Override
public void separateFrom(Tetherable tethered) {
super.separateFrom(tethered);
if (!this.isTethered()) {
InputEvent event = new InputEvent(this.variable);
this.inputChanged(event);
}
}
// ---------------------------------------------------------------------------
@Override
public void setInformation(Double information) {
getCoronas(Gauge.class).forEach(corona -> ((InformationReceiver<Double>) corona).setInformation(information));
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
package lu.list.itis.dkd.tui.widget;
import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.widget.builder.SelectorWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.FadingCorona;
import lu.list.itis.dkd.tui.widget.corona.SelectableCorona;
import lu.list.itis.dkd.tui.widget.state.StateManager;
import com.google.common.base.Preconditions;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class SelectorWidget extends ValueWidget {
/** Total number of positions to chose from */
protected int numberOfPositions;
/** The currently selected position */
protected int currentPosition = NONE;
// ***************************************************************************
// * Constants *
// ***************************************************************************
public static int NONE = -1;
private static double TWO_PI = 2 * Math.PI;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Constructor setting the {@link Map} instance that manages all layers.
*
* @param map
* The map that manages all layers.
*/
// ---------------------------------------------------------------------------
public SelectorWidget(SelectorWidgetBuilder<?> builder) {
super(builder);
this.numberOfPositions = this.getNumberOfPositions();
if (builder.preselect != NONE) {
this.selectPosition(builder.preselect);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
private int getNumberOfPositions() {
List<SelectableCorona> selectableCoronas = getCoronas(SelectableCorona.class);
HashSet<Integer> alreadySeen = new HashSet<>();
for (SelectableCorona corona : selectableCoronas) {
Integer index = corona.getIndex();
Preconditions.checkArgument(!alreadySeen.contains(index), "Duplicate Index detected for selectable Corona!"); //$NON-NLS-1$
alreadySeen.add(index);
}
return selectableCoronas.size();
}
// ---------------------------------------------------------------------------
private int getCurrentPosition(float angle) {
double segment = TWO_PI / numberOfPositions;
int current = 0;
// detect in which segment the current rotation is
for (int position = 0; position < numberOfPositions; position++) {
double minrot = (position - 0.5) * segment;
double maxrot = (position + 0.5) * segment;
if ((angle >= minrot) && (angle < maxrot)) {
current = position;
break;
}
}
return current;
}
// ---------------------------------------------------------------------------
private void selectPosition(int position) {
if (position != currentPosition) {
this.getCoronas(SelectableCorona.class).forEach(selectable -> selectable.setSelected(selectable.getIndex() == position));
if (variable != null) {
variable.setValue(position);
}
currentPosition = position;
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
public void setSelectedPosition(int position) {
currentPosition = position;
}
// ---------------------------------------------------------------------------
public int getSelectedPosition() {
return currentPosition;
}
// ---------------------------------------------------------------------------
/**
* Method invoked when a handle of the widget was moved. This default implementation will set
* the position and angle fields to the corresponding values.
*
* @param tuioObject
* The TuioObject that was triggering the move
*/
// ---------------------------------------------------------------------------
@Override
public void actionMove(TangibleObject tuioObject) {
super.actionMove(tuioObject);
int position = getCurrentPosition(tuioObject.getAngle());
int widgetId = tuioObject.getObjectId();
this.getCoronas(FadingCorona.class).forEach(corona -> corona.fadeIn());
StateManager manager = states.get(widgetId);
if (manager.isRotating()) {
if (position != currentPosition) {
this.selectPosition(position);
}
}
}
// ---------------------------------------------------------------------------
/**
* Method invoked when the tangible is detected on the table surface for the first time. The
* {@link TangibleWidget} instance is set to be active.
*
* @param tuioObject
* The TuioObject that was triggering the drop action.
*/
// ---------------------------------------------------------------------------
@Override
public void actionDrop(TangibleObject tuioObject) {
super.actionDrop(tuioObject);
this.selectPosition(currentPosition);
}
// ---------------------------------------------------------------------------
/**
* Method invoked when the tangible is removed from the table surface. The
* {@link TangibleWidget} instance will be set to no longer be active.
*
* @param tuioObject
* The TuioObject that was triggering the drop action.
*/
// ---------------------------------------------------------------------------
@Override
public void actionLift(TangibleObject tuioObject) {
super.actionLift(tuioObject);
if (!this.isPersistent(tuioObject.getObjectId())) {
this.selectPosition(NONE);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
\ No newline at end of file
...@@ -25,16 +25,21 @@ import lu.list.itis.dkd.dbc.annotation.Nullable; ...@@ -25,16 +25,21 @@ import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.adapter.TangibleObject; import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.content.InformationProvider; import lu.list.itis.dkd.tui.content.InformationProvider;
import lu.list.itis.dkd.tui.content.InformationReceiver; import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable; import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder; import lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder;
import lu.list.itis.dkd.tui.widget.builder.ValueWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona; import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona;
import lu.list.itis.dkd.tui.widget.corona.Corona; import lu.list.itis.dkd.tui.widget.corona.Corona;
import lu.list.itis.dkd.tui.widget.tether.DataFeed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List;
/** /**
* A simple widget that holds an integer value and may modify the value base on a rotation. * A simple widget that holds an integer value and may modify the value base on a rotation.
...@@ -44,29 +49,37 @@ import java.lang.reflect.Type; ...@@ -44,29 +49,37 @@ import java.lang.reflect.Type;
* @version 1.3.0 * @version 1.3.0
*/ */
@NonNullByDefault @NonNullByDefault
public final class ValueWidget extends BaseWidget implements InformationProvider<String> { public class ValueWidget extends TetherableWidget implements InformationProvider<String> {
/** The minimum value to be stored by the widget. */ /** The minimum value to be stored by the widget. */
private double lowerBound; protected double lowerBound;
/** The maximum value to be stored by the widget. */ /** The maximum value to be stored by the widget. */
private double upperBound; protected double upperBound;
/** The lower bound of the angle the widget can be turned to. */ /** The lower bound of the angle the widget can be turned to. */
private double lowerStopAngle; protected double lowerStopAngle;
/** The upper bound of the angle the widget can be turned to. */ /** The upper bound of the angle the widget can be turned to. */
private double upperStopAngle; protected double upperStopAngle;
/** The value of the angle that is considered as one step. */ /** The value of the angle that is considered as one step. */
private double stepSize; protected double stepSize;
/** The variable holding the value to be stored and manipulated by the widget. */ /** The variable holding the value to be stored and manipulated by the widget. */
private TangibleNumericalVariable variable; protected TangibleNumericalVariable variable;
/** The base value to be set for the variable. */ /** The base value to be set for the variable. */
private final double baseValue; protected double initialValue;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */ /** Whether the value held by the widget is to be modified on a rotation of a handle. */
private boolean modifyValueOnRotation = false; protected boolean modifyValueOnRotation = false;
/** Internal flag specifying whether this widgets rotation is constrainted or not! */
protected boolean constrainted;
/**
* Field holding the current angular position of the constrainted (lowerStopAngle |
* upperStopAngle) angle.
*/
protected double dialAngle;
private double stepAngle; private double stepAngle;
private double steps; private double steps;
// private double delta;
private double dialAngle; public static final String DEFAULT_VARIABLE = "Value"; //$NON-NLS-1$
private static Logger LOGGER = LoggerFactory.getLogger(ValueWidget.class.getSimpleName());
/** /**
* Constructor setting all fields by calling the super constructor. * Constructor setting all fields by calling the super constructor.
...@@ -74,7 +87,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider ...@@ -74,7 +87,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
* @param builder * @param builder
* The builder instance defining all parameters. * The builder instance defining all parameters.
*/ */
public ValueWidget(BaseValueWidgetBuilder<ValueWidgetBuilder> builder) { public ValueWidget(BaseValueWidgetBuilder<?> builder) {
super(builder); super(builder);
this.lowerBound = builder.lowerBound; this.lowerBound = builder.lowerBound;
...@@ -82,26 +95,38 @@ public final class ValueWidget extends BaseWidget implements InformationProvider ...@@ -82,26 +95,38 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
this.lowerStopAngle = builder.lowerStopAngle; this.lowerStopAngle = builder.lowerStopAngle;
this.upperStopAngle = builder.upperStopAngle; this.upperStopAngle = builder.upperStopAngle;
this.stepSize = builder.stepSize; this.stepSize = builder.stepSize;
this.variable = builder.variable;
this.modifyValueOnRotation = builder.modifyValueOnRotation; this.modifyValueOnRotation = builder.modifyValueOnRotation;
/** if (builder.variable == null) {
* Remember the base value of the variable and then set it to 0d as the value should be nill String variableName = ((this.name != null) && (this.name.length() > 0)) ? this.name : DEFAULT_VARIABLE;
* if the widget is not on the table (active). This should only be the case for non-dynamic this.variable = new TangibleNumericalVariable(variableName, Externalization.EMPTY_STRING, 0);
* value widgets } else {
*/ this.variable = builder.variable;
}
if (!modifyValueOnRotation) { if (!modifyValueOnRotation) {
this.baseValue = getVariable().getInformation(); this.initialValue = getVariable().getInformation();
getVariable().setValue(0d); getVariable().setValue(0d);
} else { } else {
// this.baseValue = Double.NaN; // this.baseValue = Double.NaN;
this.baseValue = getVariable().getInformation(); this.initialValue = getVariable().getInformation();
} }
constrainted = !(Double.isNaN(lowerStopAngle) || Double.isNaN(upperStopAngle));
if (constrainted) {
dialAngle = lowerStopAngle; dialAngle = lowerStopAngle;
steps = (upperBound - lowerBound + 1) / stepSize; steps = (upperBound - lowerBound + 1) / stepSize;
stepAngle = (upperStopAngle - lowerStopAngle) / steps; stepAngle = (upperStopAngle - lowerStopAngle) / steps;
// delta = Double.NaN; }
}
@SuppressWarnings("unchecked")
private void updateTethers(Double value) {
@SuppressWarnings("rawtypes")
List<DataFeed> dataFeeds = this.getTethers(DataFeed.class);
for (DataFeed<Double> tether : dataFeeds) {
tether.setInformation(value);
}
} }
@Override @Override
...@@ -109,7 +134,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider ...@@ -109,7 +134,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
super.actionDrop(tangibleObject); super.actionDrop(tangibleObject);
if (!modifyValueOnRotation) { if (!modifyValueOnRotation) {
getVariable().setValue(baseValue); getVariable().setValue(initialValue);
} }
} }
...@@ -125,7 +150,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider ...@@ -125,7 +150,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
else { else {
getVariable().setValue(baseValue); getVariable().setValue(initialValue);
} }
} }
...@@ -134,32 +159,32 @@ public final class ValueWidget extends BaseWidget implements InformationProvider ...@@ -134,32 +159,32 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
public void actionMove(TangibleObject tangibleObject) { public void actionMove(TangibleObject tangibleObject) {
super.actionMove(tangibleObject); super.actionMove(tangibleObject);