Search in sources :

Example 1 with Marker

use of eu.hansolo.enzo.common.Marker in project Board-Instrumentation-Framework by intel.

the class GaugeSkin method checkForRemovedMarkers.

// ******************** Private Methods ***********************************
private void checkForRemovedMarkers() {
    markersToRemove.clear();
    for (Node node : pane.getChildren()) {
        if (node instanceof Marker) {
            if (getSkinnable().getMarkers().keySet().contains(node))
                continue;
            node.setManaged(false);
            node.removeEventHandler(MouseEvent.MOUSE_PRESSED, mouseEventHandler);
            node.removeEventHandler(MouseEvent.MOUSE_DRAGGED, mouseEventHandler);
            node.removeEventHandler(MouseEvent.MOUSE_RELEASED, mouseEventHandler);
            markersToRemove.add(node);
        }
    }
    for (Node node : markersToRemove) pane.getChildren().remove(node);
}
Also used : Node(javafx.scene.Node) Marker(eu.hansolo.enzo.common.Marker)

Example 2 with Marker

use of eu.hansolo.enzo.common.Marker in project Board-Instrumentation-Framework by intel.

the class GaugeSkin method handleTouchEvent.

private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object SRC = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(threshold)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unitText.setText("Threshold");
            valueText.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            Point2D point = getSkinnable().sceneToLocal(TOUCH_EVENT.getTouchPoint().getSceneX(), TOUCH_EVENT.getTouchPoint().getSceneY());
            touchRotate(point.getX(), point.getY(), thresholdRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(valueText.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC instanceof Marker) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unitText.setText(((Marker) SRC).getText());
            valueText.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            Point2D point = getSkinnable().sceneToLocal(TOUCH_EVENT.getTouchPoint().getSceneX(), TOUCH_EVENT.getTouchPoint().getSceneY());
            touchRotate(point.getX(), point.getY(), getSkinnable().getMarkers().get(SRC));
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(valueText.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC.equals(minMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unitText.setText("Min");
            valueText.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (SRC.equals(maxMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unitText.setText("Max");
            valueText.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
Also used : EventType(javafx.event.EventType) Point2D(javafx.geometry.Point2D) Marker(eu.hansolo.enzo.common.Marker)

Example 3 with Marker

use of eu.hansolo.enzo.common.Marker in project Board-Instrumentation-Framework by intel.

the class GaugeSkin method drawMarkers.

private final void drawMarkers() {
    for (Marker marker : getSkinnable().getMarkers().keySet()) {
        marker.setPrefSize(0.0325 * size, 0.0325 * size);
        marker.relocate((size - marker.getPrefWidth()) * 0.5, size * 0.04);
        getSkinnable().getMarkers().get(marker).setPivotX(marker.getPrefWidth() * 0.5);
        getSkinnable().getMarkers().get(marker).setPivotY(size * 0.46);
        getSkinnable().getMarkers().get(marker).setAngle(marker.getValue() * angleStep - 180 - getSkinnable().getStartAngle() - getSkinnable().getMinValue() * angleStep);
    }
}
Also used : Marker(eu.hansolo.enzo.common.Marker)

Example 4 with Marker

use of eu.hansolo.enzo.common.Marker in project Board-Instrumentation-Framework by intel.

the class RadialBargraphSkin method drawMarkers.

private final void drawMarkers() {
    for (Marker marker : getSkinnable().getMarkers().keySet()) {
        marker.setPrefSize(0.05 * size, 0.05 * size);
        marker.relocate((size - marker.getPrefWidth()) * 0.5, size * 0.04);
        getSkinnable().getMarkers().get(marker).setPivotX(marker.getPrefWidth() * 0.5);
        getSkinnable().getMarkers().get(marker).setPivotY(size * 0.46);
        getSkinnable().getMarkers().get(marker).setAngle(marker.getValue() * angleStep - 180 - getSkinnable().getStartAngle());
    }
}
Also used : Marker(eu.hansolo.enzo.common.Marker)

Example 5 with Marker

use of eu.hansolo.enzo.common.Marker in project Board-Instrumentation-Framework by intel.

the class RadialBargraphSkin method handleMouseEvent.

private void handleMouseEvent(final MouseEvent MOUSE_EVENT) {
    final Object SRC = MOUSE_EVENT.getSource();
    final EventType TYPE = MOUSE_EVENT.getEventType();
    if (getSkinnable().isInteractive() && SRC.equals(threshold)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            Point2D point = getSkinnable().sceneToLocal(MOUSE_EVENT.getSceneX(), MOUSE_EVENT.getSceneY());
            touchRotate(point.getX(), point.getY(), thresholdRotate);
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC instanceof Marker) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            Point2D point = getSkinnable().sceneToLocal(MOUSE_EVENT.getSceneX(), MOUSE_EVENT.getSceneY());
            touchRotate(point.getX(), point.getY(), getSkinnable().getMarkers().get(SRC));
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(minMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(maxMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
Also used : EventType(javafx.event.EventType) Point2D(javafx.geometry.Point2D) Marker(eu.hansolo.enzo.common.Marker)

Aggregations

Marker (eu.hansolo.enzo.common.Marker)15 EventType (javafx.event.EventType)6 Point2D (javafx.geometry.Point2D)6 Section (eu.hansolo.enzo.common.Section)5 Node (javafx.scene.Node)4 Rotate (javafx.scene.transform.Rotate)4 ArrayList (java.util.ArrayList)3 Color (javafx.scene.paint.Color)3 ValueEvent (eu.hansolo.enzo.common.ValueEvent)2 Fonts (eu.hansolo.enzo.fonts.Fonts)2 Instant (java.time.Instant)2 List (java.util.List)2 Locale (java.util.Locale)2 IntStream (java.util.stream.IntStream)2 AnimationTimer (javafx.animation.AnimationTimer)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