use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class GaugeSkin method registerListeners.
private void registerListeners() {
getSkinnable().widthProperty().addListener(observable -> handleControlPropertyChanged("RESIZE"));
getSkinnable().heightProperty().addListener(observable -> handleControlPropertyChanged("RESIZE"));
getSkinnable().minMeasuredValueProperty().addListener(observable -> handleControlPropertyChanged("MIN_MEASURED_VALUE"));
getSkinnable().minMeasuredValueVisibleProperty().addListener(observable -> handleControlPropertyChanged("MIN_MEASURED_VALUE_VISIBLE"));
getSkinnable().maxMeasuredValueProperty().addListener(observable -> handleControlPropertyChanged("MAX_MEASURED_VALUE"));
getSkinnable().maxMeasuredValueVisibleProperty().addListener(observable -> handleControlPropertyChanged("MAX_MEASURED_VALUE_VISIBLE"));
getSkinnable().tickLabelOrientationProperty().addListener(observable -> handleControlPropertyChanged("RESIZE"));
getSkinnable().needleTypeProperty().addListener(observable -> handleControlPropertyChanged("NEEDLE_TYPE"));
getSkinnable().needleColorProperty().addListener(observable -> handleControlPropertyChanged("NEEDLE_COLOR"));
getSkinnable().animatedProperty().addListener(observable -> handleControlPropertyChanged("ANIMATED"));
getSkinnable().thresholdProperty().addListener(observable -> handleControlPropertyChanged("THRESHOLD"));
getSkinnable().thresholdVisibleProperty().addListener(observable -> handleControlPropertyChanged("THRESHOLD_VISIBLE"));
getSkinnable().angleRangeProperty().addListener(observable -> handleControlPropertyChanged("ANGLE_RANGE"));
getSkinnable().numberFormatProperty().addListener(observable -> handleControlPropertyChanged("RECALC"));
getSkinnable().plainValueProperty().addListener(observable -> handleControlPropertyChanged("PLAIN_VALUE"));
getSkinnable().histogramEnabledProperty().addListener(observable -> handleControlPropertyChanged("HISTOGRAM"));
getSkinnable().dropShadowEnabledProperty().addListener(observable -> handleControlPropertyChanged("DROP_SHADOW"));
getSkinnable().interactiveProperty().addListener(observable -> handleControlPropertyChanged("INTERACTIVE"));
getSkinnable().getSections().addListener((ListChangeListener<Section>) change -> handleControlPropertyChanged("CANVAS_REFRESH"));
getSkinnable().getAreas().addListener((ListChangeListener<Section>) change -> handleControlPropertyChanged("CANVAS_REFRESH"));
getSkinnable().getMarkers().addListener((MapChangeListener<Marker, Rotate>) change -> handleControlPropertyChanged("MARKER"));
getSkinnable().markersVisibleProperty().addListener(observable -> handleControlPropertyChanged("MARKER"));
getSkinnable().sectionsVisibleProperty().addListener(observable -> handleControlPropertyChanged("CANVAS_REFRESH"));
getSkinnable().areasVisibleProperty().addListener(observable -> handleControlPropertyChanged("CANVAS_REFRESH"));
getSkinnable().customKnobClickHandlerProperty().addListener(observable -> handleControlPropertyChanged("CUSTOM_KNOB_CLICK_HANDLER"));
getSkinnable().valueProperty().addListener((OV, OLD_VALUE, NEW_VALUE) -> {
withinSpeedLimit = !(Instant.now().minusMillis((long) getSkinnable().getAnimationDuration()).isBefore(lastCall));
lastCall = Instant.now();
oldValue = OLD_VALUE.doubleValue();
rotateNeedle();
});
getSkinnable().minValueProperty().addListener((OV, OLD_VALUE, NEW_VALUE) -> {
angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - NEW_VALUE.doubleValue());
needleRotate.setAngle((180 - getSkinnable().getStartAngle()) + (getSkinnable().getValue() - NEW_VALUE.doubleValue()) * angleStep);
if (getSkinnable().getValue() < NEW_VALUE.doubleValue()) {
getSkinnable().setValue(NEW_VALUE.doubleValue());
oldValue = NEW_VALUE.doubleValue();
}
});
getSkinnable().maxValueProperty().addListener((OV, OLD_VALUE, NEW_VALUE) -> {
angleStep = getSkinnable().getAngleRange() / (NEW_VALUE.doubleValue() - getSkinnable().getMinValue());
needleRotate.setAngle((180 - getSkinnable().getStartAngle()) + (getSkinnable().getValue() - getSkinnable().getMinValue()) * angleStep);
if (getSkinnable().getValue() > NEW_VALUE.doubleValue()) {
getSkinnable().setValue(NEW_VALUE.doubleValue());
oldValue = NEW_VALUE.doubleValue();
}
});
getSkinnable().limitProperty().addListener(observable -> handleControlPropertyChanged("LIMIT"));
needleRotate.angleProperty().addListener(observable -> handleControlPropertyChanged("ANGLE"));
if (null == getSkinnable().getCustomKnobClickHandler()) {
knob.setOnMousePressed(event -> {
timeline.stop();
needleRotate.setAngle(180 - getSkinnable().getStartAngle() + (getSkinnable().getValue() - getSkinnable().getMinValue()) * angleStep);
getSkinnable().setInteractive(!getSkinnable().isInteractive());
});
} else {
knob.setOnMousePressed(getSkinnable().getCustomKnobClickHandler());
}
minMeasuredValue.setOnMousePressed(mouseEventHandler);
minMeasuredValue.setOnMouseReleased(mouseEventHandler);
maxMeasuredValue.setOnMousePressed(mouseEventHandler);
maxMeasuredValue.setOnMouseReleased(mouseEventHandler);
threshold.setOnMousePressed(mouseEventHandler);
threshold.setOnMouseDragged(mouseEventHandler);
threshold.setOnMouseReleased(mouseEventHandler);
for (Marker marker : getSkinnable().getMarkers().keySet()) {
marker.setOnMousePressed(mouseEventHandler);
marker.setOnMouseDragged(mouseEventHandler);
marker.setOnMouseReleased(mouseEventHandler);
}
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class RadialBargraphSkin method registerListeners.
private void registerListeners() {
getSkinnable().widthProperty().addListener(observable -> handleControlPropertyChanged("RESIZE"));
getSkinnable().heightProperty().addListener(observable -> handleControlPropertyChanged("RESIZE"));
getSkinnable().valueProperty().addListener(observable -> handleControlPropertyChanged("VALUE"));
getSkinnable().minValueProperty().addListener(observable -> handleControlPropertyChanged("RECALC"));
getSkinnable().maxValueProperty().addListener(observable -> handleControlPropertyChanged("RECALC"));
getSkinnable().minMeasuredValueProperty().addListener(observable -> handleControlPropertyChanged("MIN_MEASURED_VALUE"));
getSkinnable().minMeasuredValueVisibleProperty().addListener(observable -> handleControlPropertyChanged("MIN_MEASURED_VALUE_VISIBLE"));
getSkinnable().maxMeasuredValueProperty().addListener(observable -> handleControlPropertyChanged("MAX_MEASURED_VALUE"));
getSkinnable().maxMeasuredValueVisibleProperty().addListener(observable -> handleControlPropertyChanged("MAX_MEASURED_VALUE_VISIBLE"));
getSkinnable().barColorProperty().addListener(observable -> handleControlPropertyChanged("BAR_COLOR"));
getSkinnable().animatedProperty().addListener(observable -> handleControlPropertyChanged("ANIMATED"));
getSkinnable().thresholdProperty().addListener(observable -> handleControlPropertyChanged("THRESHOLD"));
getSkinnable().thresholdVisibleProperty().addListener(observable -> handleControlPropertyChanged("THRESHOLD_VISIBLE"));
getSkinnable().angleRangeProperty().addListener(observable -> handleControlPropertyChanged("ANGLE_RANGE"));
getSkinnable().numberFormatProperty().addListener(observable -> handleControlPropertyChanged("RECALC"));
getSkinnable().plainValueProperty().addListener(observable -> handleControlPropertyChanged("PLAIN_VALUE"));
getSkinnable().interactiveProperty().addListener(observable -> handleControlPropertyChanged("INTERACTIVE"));
getSkinnable().getSections().addListener((ListChangeListener<Section>) change -> handleControlPropertyChanged("CANVAS_REFRESH"));
getSkinnable().getMarkers().addListener((MapChangeListener<Marker, Rotate>) change -> handleControlPropertyChanged("MARKER"));
getSkinnable().barGradientProperty().addListener((ListChangeListener<Stop>) change -> handleControlPropertyChanged("BAR_GRADIENT"));
getSkinnable().barGradientEnabledProperty().addListener(observable -> handleControlPropertyChanged("BAR_COLOR"));
angle.addListener(observable -> handleControlPropertyChanged("ANGLE"));
knob.setOnMousePressed(event -> getSkinnable().setInteractive(!getSkinnable().isInteractive()));
minMeasuredValue.setOnMousePressed(mouseEventHandler);
minMeasuredValue.setOnMouseReleased(mouseEventHandler);
minMeasuredValue.setOnTouchPressed(touchEventHandler);
minMeasuredValue.setOnTouchReleased(touchEventHandler);
maxMeasuredValue.setOnMousePressed(mouseEventHandler);
maxMeasuredValue.setOnMouseReleased(mouseEventHandler);
maxMeasuredValue.setOnTouchPressed(touchEventHandler);
maxMeasuredValue.setOnTouchReleased(touchEventHandler);
threshold.setOnMousePressed(mouseEventHandler);
threshold.setOnMouseDragged(mouseEventHandler);
threshold.setOnMouseReleased(mouseEventHandler);
threshold.setOnTouchPressed(touchEventHandler);
threshold.setOnTouchMoved(touchEventHandler);
threshold.setOnTouchReleased(touchEventHandler);
for (Marker marker : getSkinnable().getMarkers().keySet()) {
marker.setOnMousePressed(mouseEventHandler);
marker.setOnMouseDragged(mouseEventHandler);
marker.setOnMouseReleased(mouseEventHandler);
marker.setOnTouchPressed(touchEventHandler);
marker.setOnTouchMoved(touchEventHandler);
marker.setOnTouchReleased(touchEventHandler);
}
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class RadialBargraphSkin method drawSections.
private final void drawSections(final GraphicsContext CTX) {
final double xy = (size - 0.87 * size) * 0.5;
final double wh = size * 0.87;
final double MIN_VALUE = getSkinnable().getMinValue();
final double MAX_VALUE = getSkinnable().getMaxValue();
final double OFFSET = 90 - getSkinnable().getStartAngle();
IntStream.range(0, getSkinnable().getSections().size()).parallel().forEachOrdered(i -> {
final Section SECTION = getSkinnable().getSections().get(i);
final double SECTION_START_ANGLE;
if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
SECTION_START_ANGLE = MIN_VALUE * angleStep;
} else {
SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
}
final double SECTION_ANGLE_EXTEND;
if (SECTION.getStop() > MAX_VALUE) {
SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
} else {
SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
}
CTX.save();
switch(i) {
case 0:
CTX.setStroke(getSkinnable().getSectionFill0());
break;
case 1:
CTX.setStroke(getSkinnable().getSectionFill1());
break;
case 2:
CTX.setStroke(getSkinnable().getSectionFill2());
break;
case 3:
CTX.setStroke(getSkinnable().getSectionFill3());
break;
case 4:
CTX.setStroke(getSkinnable().getSectionFill4());
break;
case 5:
CTX.setStroke(getSkinnable().getSectionFill5());
break;
case 6:
CTX.setStroke(getSkinnable().getSectionFill6());
break;
case 7:
CTX.setStroke(getSkinnable().getSectionFill7());
break;
case 8:
CTX.setStroke(getSkinnable().getSectionFill8());
break;
case 9:
CTX.setStroke(getSkinnable().getSectionFill9());
break;
}
CTX.setLineWidth(size * 0.1);
CTX.setLineCap(StrokeLineCap.BUTT);
CTX.strokeArc(xy, xy, wh, wh, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
CTX.restore();
}
});
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class RadialGaugeSkin method drawAreas.
private final void drawAreas(final GraphicsContext CTX) {
final double xy = (size - 0.7925 * size) / 2;
final double wh = size * 0.7925;
final double MIN_VALUE = getSkinnable().getMinValue();
final double MAX_VALUE = getSkinnable().getMaxValue();
final double OFFSET = 90 - getSkinnable().getStartAngle();
IntStream.range(0, getSkinnable().getAreas().size()).parallel().forEachOrdered(i -> {
final Section AREA = getSkinnable().getAreas().get(i);
final double AREA_START_ANGLE;
if (Double.compare(AREA.getStart(), MAX_VALUE) <= 0 && Double.compare(AREA.getStop(), MIN_VALUE) >= 0) {
if (AREA.getStart() < MIN_VALUE && AREA.getStop() < MAX_VALUE) {
AREA_START_ANGLE = MIN_VALUE * angleStep;
} else {
AREA_START_ANGLE = (AREA.getStart() - MIN_VALUE) * angleStep;
}
final double AREA_ANGLE_EXTEND;
if (AREA.getStop() > MAX_VALUE) {
AREA_ANGLE_EXTEND = (MAX_VALUE - AREA.getStart()) * angleStep;
} else {
AREA_ANGLE_EXTEND = (AREA.getStop() - AREA.getStart()) * angleStep;
}
CTX.save();
switch(i) {
case 0:
CTX.setFill(getSkinnable().getAreaFill0());
break;
case 1:
CTX.setFill(getSkinnable().getAreaFill1());
break;
case 2:
CTX.setFill(getSkinnable().getAreaFill2());
break;
case 3:
CTX.setFill(getSkinnable().getAreaFill3());
break;
case 4:
CTX.setFill(getSkinnable().getAreaFill4());
break;
case 5:
CTX.setFill(getSkinnable().getAreaFill5());
break;
case 6:
CTX.setFill(getSkinnable().getAreaFill6());
break;
case 7:
CTX.setFill(getSkinnable().getAreaFill7());
break;
case 8:
CTX.setFill(getSkinnable().getAreaFill8());
break;
case 9:
CTX.setFill(getSkinnable().getAreaFill9());
break;
}
CTX.fillArc(xy, xy, wh, wh, -(OFFSET + AREA_START_ANGLE), -AREA_ANGLE_EXTEND, ArcType.ROUND);
CTX.restore();
}
});
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class RectangularGaugeSkin method drawSections.
private final void drawSections(final GraphicsContext CTX) {
final double x = width * 0.06;
final double y = width * 0.21;
final double w = width * 0.88;
final double h = height * 1.05;
final double MIN_VALUE = getSkinnable().getMinValue();
final double MAX_VALUE = getSkinnable().getMaxValue();
final double OFFSET = 90 - getSkinnable().getStartAngle();
IntStream.range(0, getSkinnable().getSections().size()).parallel().forEachOrdered(i -> {
final Section SECTION = getSkinnable().getSections().get(i);
final double SECTION_START_ANGLE;
if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
SECTION_START_ANGLE = MIN_VALUE * angleStep;
} else {
SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
}
final double SECTION_ANGLE_EXTEND;
if (SECTION.getStop() > MAX_VALUE) {
SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
} else {
SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
}
CTX.save();
switch(i) {
case 0:
CTX.setStroke(getSkinnable().getSectionFill0());
break;
case 1:
CTX.setStroke(getSkinnable().getSectionFill1());
break;
case 2:
CTX.setStroke(getSkinnable().getSectionFill2());
break;
case 3:
CTX.setStroke(getSkinnable().getSectionFill3());
break;
case 4:
CTX.setStroke(getSkinnable().getSectionFill4());
break;
case 5:
CTX.setStroke(getSkinnable().getSectionFill5());
break;
case 6:
CTX.setStroke(getSkinnable().getSectionFill6());
break;
case 7:
CTX.setStroke(getSkinnable().getSectionFill7());
break;
case 8:
CTX.setStroke(getSkinnable().getSectionFill8());
break;
case 9:
CTX.setStroke(getSkinnable().getSectionFill9());
break;
}
CTX.setLineWidth(height * 0.0415);
CTX.setLineCap(StrokeLineCap.BUTT);
CTX.strokeArc(x, y, w, h, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
CTX.restore();
}
});
}
Aggregations