Commit 5860ff6c authored by Nico Mack's avatar Nico Mack

Changes entailed by changes in class hierarchy of Tulip

parent a439fabe
...@@ -141,4 +141,15 @@ public class DisplayWidgetBootstrapper implements BootstrapCallback { ...@@ -141,4 +141,15 @@ public class DisplayWidgetBootstrapper implements BootstrapCallback {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public BootstrapContext reset(BootstrapContext context) {
variableIterator = variables.iterator();
if (variableIterator.hasNext()) {
this.variable = variableIterator.next();
}
return context;
}
// ---------------------------------------------------------------------------
} }
...@@ -291,6 +291,13 @@ public class EquationSystemBuilder { ...@@ -291,6 +291,13 @@ public class EquationSystemBuilder {
attribute = element.getAttributeValue(Externalization.DECIMALS_ATTRIBUTE); attribute = element.getAttributeValue(Externalization.DECIMALS_ATTRIBUTE);
attributes.put(Externalization.DECIMALS_ATTRIBUTE, attribute); attributes.put(Externalization.DECIMALS_ATTRIBUTE, attribute);
attribute = element.getChildText(Externalization.SCALE_ATTRIBUTE);
if (Strings.isNullOrEmpty(attribute))
attribute = element.getAttributeValue(Externalization.SCALE_ATTRIBUTE);
if (Strings.isNullOrEmpty(attribute))
attribute = "1"; //$NON-NLS-1$
attributes.put(Externalization.SCALE_ATTRIBUTE, attribute);
return attributes; return attributes;
} }
...@@ -323,6 +330,9 @@ public class EquationSystemBuilder { ...@@ -323,6 +330,9 @@ public class EquationSystemBuilder {
if (!Strings.isNullOrEmpty(attributes.get(Externalization.DECIMALS_ATTRIBUTE))) if (!Strings.isNullOrEmpty(attributes.get(Externalization.DECIMALS_ATTRIBUTE)))
numericVariable.setNumberOfDecimals(this.getIntegerValue(attributes.get(Externalization.DECIMALS_ATTRIBUTE))); numericVariable.setNumberOfDecimals(this.getIntegerValue(attributes.get(Externalization.DECIMALS_ATTRIBUTE)));
if (!Strings.isNullOrEmpty(attributes.get(Externalization.SCALE_ATTRIBUTE)))
numericVariable.setScale(this.getDoubleValue(attributes.get(Externalization.SCALE_ATTRIBUTE)));
variable = numericVariable; variable = numericVariable;
} }
......
...@@ -4,6 +4,7 @@ import lu.list.itis.dkd.tui.cps.system.Import; ...@@ -4,6 +4,7 @@ import lu.list.itis.dkd.tui.cps.system.Import;
import lu.list.itis.dkd.tui.cps.variable.Variable; import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.VectorVariable; import lu.list.itis.dkd.tui.cps.variable.VectorVariable;
import org.python.core.Py;
import org.python.core.PyArray; import org.python.core.PyArray;
import org.python.core.PyFloat; import org.python.core.PyFloat;
import org.python.core.PyInteger; import org.python.core.PyInteger;
...@@ -61,9 +62,10 @@ public class PythonExecutor extends Executor { ...@@ -61,9 +62,10 @@ public class PythonExecutor extends Executor {
array = new PyArray(Double.class, list.size()); array = new PyArray(Double.class, list.size());
int index = 0; int index = 0;
for (Double value : list) { for (Double value : list) {
if (value == null) // if (value == null)
value = Double.valueOf(0); // value = Double.valueOf(0);
array.set(index++, new PyFloat(value)); // array.set(index++, new PyFloat(value));
array.set(index++, (value != null) ? new PyFloat(value) : Py.None);
} }
engine.set(variable.getName(), array); engine.set(variable.getName(), array);
if (LOGGER.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
...@@ -75,9 +77,10 @@ public class PythonExecutor extends Executor { ...@@ -75,9 +77,10 @@ public class PythonExecutor extends Executor {
array = new PyArray(Integer.class, list.size()); array = new PyArray(Integer.class, list.size());
int index = 0; int index = 0;
for (Integer value : list) { for (Integer value : list) {
if (value == null) // if (value == null)
value = Integer.valueOf(0); // value = Integer.valueOf(0);
array.set(index++, new PyInteger(value)); // array.set(index++, new PyInteger(value));
array.set(index++, (value != null) ? new PyInteger(value) : Py.None);
} }
engine.set(variable.getName(), array); engine.set(variable.getName(), array);
if (LOGGER.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
......
...@@ -101,7 +101,7 @@ public class NumericalVariable extends Variable<Double> { ...@@ -101,7 +101,7 @@ public class NumericalVariable extends Variable<Double> {
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(format.format(value)); StringBuilder builder = new StringBuilder(format.format(value / scale));
if ((unit != null) && (unit.length() > 0)) { if ((unit != null) && (unit.length() > 0)) {
builder.append(" ").append(unit); //$NON-NLS-1$ builder.append(" ").append(unit); //$NON-NLS-1$
} }
......
...@@ -108,7 +108,13 @@ public class DisplayWidget extends BaseWidget implements InputChangeListener { ...@@ -108,7 +108,13 @@ public class DisplayWidget extends BaseWidget implements InputChangeListener {
// } // }
for (String variableName : this.variables.keySet()) { for (String variableName : this.variables.keySet()) {
ValueCorona display = dispatcher.get(variableName); ValueCorona display = dispatcher.get(variableName);
display.setInformation(this.variables.get(variableName).getValue()); NumericalVariable variable = this.variables.get(variableName);
if (variable != null) {
display.setInformation(variable.getValue());
} else {
LOGGER.warn("Corona requires variable {} unkown to display widget!", variableName); //$NON-NLS-1$
}
} }
} }
......
...@@ -3,7 +3,7 @@ package lu.list.itis.dkd.tui.widget; ...@@ -3,7 +3,7 @@ package lu.list.itis.dkd.tui.widget;
import lu.list.itis.dkd.tui.adapter.TangibleObject; import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.widget.builder.SelectorWidgetBuilder; 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.FadingCorona;
import lu.list.itis.dkd.tui.widget.corona.SelectableCorona; import lu.list.itis.dkd.tui.widget.corona.IndexedCorona;
import lu.list.itis.dkd.tui.widget.state.StateManager; import lu.list.itis.dkd.tui.widget.state.StateManager;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
...@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions; ...@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream;
// *************************************************************************** // ***************************************************************************
// * Class Definition and Members * // * Class Definition and Members *
...@@ -61,12 +62,12 @@ public class SelectorWidget extends ValueWidget { ...@@ -61,12 +62,12 @@ public class SelectorWidget extends ValueWidget {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
private int getNumberOfPositions() { private int getNumberOfPositions() {
List<SelectableCorona> selectableCoronas = getCoronas(SelectableCorona.class); List<IndexedCorona> selectableCoronas = getCoronas(IndexedCorona.class);
HashSet<Integer> alreadySeen = new HashSet<>(); HashSet<Integer> alreadySeen = new HashSet<>();
for (SelectableCorona corona : selectableCoronas) { for (IndexedCorona corona : selectableCoronas) {
Integer index = corona.getIndex(); Integer index = corona.getIndex();
Preconditions.checkArgument(!alreadySeen.contains(index), "Duplicate Index detected for selectable Corona!"); //$NON-NLS-1$ Preconditions.checkArgument(!alreadySeen.contains(index), "Duplicate Index detected for indexed Corona!"); //$NON-NLS-1$
alreadySeen.add(index); alreadySeen.add(index);
} }
...@@ -105,7 +106,7 @@ public class SelectorWidget extends ValueWidget { ...@@ -105,7 +106,7 @@ public class SelectorWidget extends ValueWidget {
private void selectPosition(int position) { private void selectPosition(int position) {
if (position != currentPosition) { if (position != currentPosition) {
this.getCoronas(SelectableCorona.class).forEach(selectable -> selectable.setSelected(selectable.getIndex() == position)); this.getCoronas(IndexedCorona.class).forEach(indexed -> indexed.setSelected(indexed.getIndex() == position));
if (variable != null) { if (variable != null) {
variable.setValue((double) position); variable.setValue((double) position);
...@@ -148,7 +149,9 @@ public class SelectorWidget extends ValueWidget { ...@@ -148,7 +149,9 @@ public class SelectorWidget extends ValueWidget {
int position = getCurrentPosition(tuioObject.getAngle()); int position = getCurrentPosition(tuioObject.getAngle());
int widgetId = tuioObject.getObjectId(); int widgetId = tuioObject.getObjectId();
this.getCoronas(FadingCorona.class).forEach(corona -> corona.fadeIn()); Stream<FadingCorona> autoFading = this.getCoronas(FadingCorona.class).stream().filter(corona -> corona.fadesWithHandle());
autoFading.forEach(corona -> corona.fadeIn());
StateManager manager = states.get(widgetId); StateManager manager = states.get(widgetId);
if (manager.isRotating()) { if (manager.isRotating()) {
......
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