use of eu.hansolo.enzo.common.ValueEvent in project Board-Instrumentation-Framework by intel.
the class HeatControlSkin method handleControlPropertyChanged.
// ******************** Methods *******************************************
protected void handleControlPropertyChanged(final String PROPERTY) {
if ("RESIZE".equals(PROPERTY)) {
resize();
} else if ("INFO_TEXT".equals(PROPERTY)) {
infoText.setText(getSkinnable().getInfoText().toUpperCase());
resize();
} else if ("VALUE".equals(PROPERTY)) {
rotateNeedle();
adjustBackgroundColor();
} else if ("RECALC".equals(PROPERTY)) {
if (getSkinnable().getMinValue() < 0) {
angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
valueIndicatorRotate.setAngle(180 - getSkinnable().getStartAngle() - (getSkinnable().getMinValue()) * angleStep);
} else {
angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() + getSkinnable().getMinValue());
valueIndicatorRotate.setAngle(180 - getSkinnable().getStartAngle() * angleStep);
}
resize();
} else if ("ANGLE".equals(PROPERTY)) {
double currentValue = (valueIndicatorRotate.getAngle() + getSkinnable().getStartAngle() - 180) / angleStep + getSkinnable().getMinValue();
if (!userAction) {
value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue));
value.setTranslateX((size - value.getLayoutBounds().getWidth()) * 0.5);
}
// Check targetIndicator
if (targetExceeded) {
if (currentValue < getSkinnable().getTarget()) {
getSkinnable().fireEvent(new ValueEvent(this, null, ValueEvent.VALUE_UNDERRUN));
targetExceeded = false;
}
} else {
if (currentValue > getSkinnable().getTarget()) {
getSkinnable().fireEvent(new ValueEvent(this, null, ValueEvent.VALUE_EXCEEDED));
targetExceeded = true;
}
}
} else if ("TARGET".equals(PROPERTY)) {
targetIndicatorRotate.setAngle(getSkinnable().getTarget() * angleStep - 180 - getSkinnable().getStartAngle());
} else if ("TARGET_ENABLED".equals(PROPERTY)) {
targetIndicator.setVisible(getSkinnable().isTargetEnabled());
}
}
use of eu.hansolo.enzo.common.ValueEvent in project Board-Instrumentation-Framework by intel.
the class Lcd method init.
// ******************** Initialization ************************************
private void init() {
valueProperty().addListener((ov, oldValue, newValue) -> {
formerValue.set(oldValue.doubleValue());
if (toValueAnimation.getStatus() != Animation.Status.STOPPED) {
toValueAnimation.stop();
}
if (getAnimated()) {
toValueAnimation.setInterpolator(Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
toValueAnimation.play();
toValueAnimation.setOnFinished(EVENT -> {
if (firstTime) {
resetMinMaxMeasuredValue();
firstTime = false;
}
});
} else {
currentValue.set(newValue.doubleValue());
}
});
currentValueProperty().addListener(observable -> {
if (Double.compare(currentValue.get(), getMinMeasuredValue()) < 0 && !firstTime) {
setMinMeasuredValue(currentValue.get());
}
if (Double.compare(currentValue.get(), getMaxMeasuredValue()) > 0 && !firstTime) {
setMaxMeasuredValue(currentValue.get());
}
// Check threshold
if (thresholdExceeded) {
if (currentValue.get() < getThreshold()) {
fireEvent(new ValueEvent(this, this, ValueEvent.VALUE_UNDERRUN));
thresholdExceeded = false;
}
} else {
if (currentValue.get() > getThreshold()) {
fireEvent(new ValueEvent(this, this, ValueEvent.VALUE_EXCEEDED));
thresholdExceeded = true;
}
}
});
}
Aggregations