Commit be5a940d authored by Nico Mack's avatar Nico Mack

Changes required by encapsulation of coronas property in Widgets

parent 741ebbab
...@@ -80,8 +80,8 @@ public class ValueWidget extends TetherableWidget implements InformationProvider ...@@ -80,8 +80,8 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
protected boolean constrainted; protected boolean constrainted;
/** /**
* Field holding the current angular position of the constrainted (lowerStopAngle | * Field holding the current angular position of the constrainted (lowerStopAngle | upperStopAngle)
* upperStopAngle) angle. * angle.
*/ */
protected double dialAngle; protected double dialAngle;
private double stepAngle; private double stepAngle;
...@@ -211,6 +211,28 @@ public class ValueWidget extends TetherableWidget implements InformationProvider ...@@ -211,6 +211,28 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
LOGGER.trace("{} = {}", variable.getName(), value); //$NON-NLS-1$ LOGGER.trace("{} = {}", variable.getName(), value); //$NON-NLS-1$
} }
} }
// ---------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private void updateInformationReceivers() {
for (Corona corona : this.getAllCoronas()) {
if (corona instanceof InformationReceiver<?>) {
Type[] types = corona.getClass().getGenericInterfaces();
for (Type type : types) {
if (type instanceof ParameterizedType) {
String typeName = ((ParameterizedType) type).getActualTypeArguments()[0].getTypeName();
if (typeName.equals(String.class.getTypeName())) {
String information = (variable.getValue() != null) ? variable.getValue().toString() : null;
((InformationReceiver<String>) corona).setInformation(information);
} else if (typeName.equals(Double.class.getTypeName())) {
((InformationReceiver<Double>) corona).setInformation(variable.getValue());
}
}
}
}
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// *************************************************************************** // ***************************************************************************
...@@ -349,31 +371,9 @@ public class ValueWidget extends TetherableWidget implements InformationProvider ...@@ -349,31 +371,9 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override @Override
public void paint(Graphics2D canvas) { public void paint(Graphics2D canvas) {
for (Corona corona : coronas.values()) { this.updateInformationReceivers();
if (corona instanceof InformationReceiver<?>) {
Type[] types = corona.getClass().getGenericInterfaces();
for (Type type : types) {
if (!(type instanceof ParameterizedType)) {
continue;
}
String typeName = ((ParameterizedType) type).getActualTypeArguments()[0].getTypeName();
if (typeName.equals(String.class.getTypeName())) {
String information = (variable.getValue() != null) ? variable.getValue().toString() : null;
((InformationReceiver<String>) corona).setInformation(information);
continue;
}
if (typeName.equals(Double.class.getTypeName())) {
((InformationReceiver<Double>) corona).setInformation(variable.getValue());
continue;
}
}
}
}
super.paint(canvas); super.paint(canvas);
} }
......
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