Search in sources :

Example 1 with MapChangeListener

use of javafx.collections.MapChangeListener 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);
    }
}
Also used : EventHandler(javafx.event.EventHandler) CacheHint(javafx.scene.CacheHint) Rotate(javafx.scene.transform.Rotate) ArcTo(javafx.scene.shape.ArcTo) BlendMode(javafx.scene.effect.BlendMode) ListChangeListener(javafx.collections.ListChangeListener) Locale(java.util.Locale) Point2D(javafx.geometry.Point2D) Pane(javafx.scene.layout.Pane) GraphicsContext(javafx.scene.canvas.GraphicsContext) MapChangeListener(javafx.collections.MapChangeListener) Blend(javafx.scene.effect.Blend) Font(javafx.scene.text.Font) Timeline(javafx.animation.Timeline) Canvas(javafx.scene.canvas.Canvas) Group(javafx.scene.Group) Instant(java.time.Instant) ArcType(javafx.scene.shape.ArcType) Text(javafx.scene.text.Text) Marker(eu.hansolo.enzo.common.Marker) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) PauseTransition(javafx.animation.PauseTransition) TouchEvent(javafx.scene.input.TouchEvent) StrokeLineCap(javafx.scene.shape.StrokeLineCap) ObservableList(javafx.collections.ObservableList) Path(javafx.scene.shape.Path) FontWeight(javafx.scene.text.FontWeight) IntStream(java.util.stream.IntStream) SkinBase(javafx.scene.control.SkinBase) Gauge(eu.hansolo.enzo.gauge.Gauge) CubicCurve(javafx.scene.shape.CubicCurve) PathTransition(javafx.animation.PathTransition) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) Skin(javafx.scene.control.Skin) ArrayList(java.util.ArrayList) FadeTransition(javafx.animation.FadeTransition) ValueEvent(eu.hansolo.enzo.common.ValueEvent) VPos(javafx.geometry.VPos) BlurType(javafx.scene.effect.BlurType) TextAlignment(javafx.scene.text.TextAlignment) KeyValue(javafx.animation.KeyValue) InnerShadow(javafx.scene.effect.InnerShadow) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) Section(eu.hansolo.enzo.common.Section) Node(javafx.scene.Node) DropShadow(javafx.scene.effect.DropShadow) Fonts(eu.hansolo.enzo.fonts.Fonts) EventType(javafx.event.EventType) ParallelTransition(javafx.animation.ParallelTransition) SequentialTransition(javafx.animation.SequentialTransition) Arc(javafx.scene.shape.Arc) FillRule(javafx.scene.shape.FillRule) Shape(javafx.scene.shape.Shape) Rotate(javafx.scene.transform.Rotate) Marker(eu.hansolo.enzo.common.Marker) Section(eu.hansolo.enzo.common.Section)

Example 2 with MapChangeListener

use of javafx.collections.MapChangeListener 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);
    }
}
Also used : EventHandler(javafx.event.EventHandler) CacheHint(javafx.scene.CacheHint) Rotate(javafx.scene.transform.Rotate) CycleMethod(javafx.scene.paint.CycleMethod) BlendMode(javafx.scene.effect.BlendMode) ListChangeListener(javafx.collections.ListChangeListener) ConicalGradient(eu.hansolo.enzo.common.ConicalGradient) Locale(java.util.Locale) Point2D(javafx.geometry.Point2D) Pane(javafx.scene.layout.Pane) RadialBargraph(eu.hansolo.enzo.gauge.RadialBargraph) Stop(javafx.scene.paint.Stop) GraphicsContext(javafx.scene.canvas.GraphicsContext) MapChangeListener(javafx.collections.MapChangeListener) Blend(javafx.scene.effect.Blend) Font(javafx.scene.text.Font) Timeline(javafx.animation.Timeline) Canvas(javafx.scene.canvas.Canvas) Instant(java.time.Instant) ArcType(javafx.scene.shape.ArcType) Text(javafx.scene.text.Text) Marker(eu.hansolo.enzo.common.Marker) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) PauseTransition(javafx.animation.PauseTransition) TouchEvent(javafx.scene.input.TouchEvent) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) StrokeLineCap(javafx.scene.shape.StrokeLineCap) IntStream(java.util.stream.IntStream) SkinBase(javafx.scene.control.SkinBase) MouseEvent(javafx.scene.input.MouseEvent) DoubleProperty(javafx.beans.property.DoubleProperty) Skin(javafx.scene.control.Skin) ArrayList(java.util.ArrayList) FadeTransition(javafx.animation.FadeTransition) ValueEvent(eu.hansolo.enzo.common.ValueEvent) VPos(javafx.geometry.VPos) RadialGradient(javafx.scene.paint.RadialGradient) StrokeType(javafx.scene.shape.StrokeType) BlurType(javafx.scene.effect.BlurType) KeyValue(javafx.animation.KeyValue) LinkedList(java.util.LinkedList) InnerShadow(javafx.scene.effect.InnerShadow) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) Section(eu.hansolo.enzo.common.Section) Node(javafx.scene.Node) ImagePattern(javafx.scene.paint.ImagePattern) DropShadow(javafx.scene.effect.DropShadow) Fonts(eu.hansolo.enzo.fonts.Fonts) EventType(javafx.event.EventType) ParallelTransition(javafx.animation.ParallelTransition) SequentialTransition(javafx.animation.SequentialTransition) Arc(javafx.scene.shape.Arc) Image(javafx.scene.image.Image) Rotate(javafx.scene.transform.Rotate) Stop(javafx.scene.paint.Stop) Marker(eu.hansolo.enzo.common.Marker) Section(eu.hansolo.enzo.common.Section)

Aggregations

Marker (eu.hansolo.enzo.common.Marker)2 Section (eu.hansolo.enzo.common.Section)2 ValueEvent (eu.hansolo.enzo.common.ValueEvent)2 Fonts (eu.hansolo.enzo.fonts.Fonts)2 Instant (java.time.Instant)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Locale (java.util.Locale)2 IntStream (java.util.stream.IntStream)2 FadeTransition (javafx.animation.FadeTransition)2 Interpolator (javafx.animation.Interpolator)2 KeyFrame (javafx.animation.KeyFrame)2 KeyValue (javafx.animation.KeyValue)2 ParallelTransition (javafx.animation.ParallelTransition)2 PauseTransition (javafx.animation.PauseTransition)2 SequentialTransition (javafx.animation.SequentialTransition)2 Timeline (javafx.animation.Timeline)2 ListChangeListener (javafx.collections.ListChangeListener)2 MapChangeListener (javafx.collections.MapChangeListener)2 EventHandler (javafx.event.EventHandler)2