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
protected boolean constrainted;
/**
* Field holding the current angular position of the constrainted (lowerStopAngle |
* upperStopAngle) angle.
* Field holding the current angular position of the constrainted (lowerStopAngle | upperStopAngle)
* angle.
*/
protected double dialAngle;
private double stepAngle;
......@@ -211,6 +211,28 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
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
// ---------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public void paint(Graphics2D canvas) {
for (Corona corona : coronas.values()) {
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;
}
}
}
}
this.updateInformationReceivers();
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