Search in sources :

Example 16 with EventType

use of javafx.event.EventType in project tilesfx by HanSolo.

the class SliderTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    mouseEventHandler = e -> {
        final EventType TYPE = e.getEventType();
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            dragStart = thumb.localToParent(e.getX(), e.getY());
            formerThumbPos = (tile.getCurrentValue() - minValue) / range;
            tile.fireTileEvent(VALUE_CHANGING);
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            Point2D currentPos = thumb.localToParent(e.getX(), e.getY());
            double dragPos = currentPos.getX() - dragStart.getX();
            thumbDragged((formerThumbPos + dragPos / trackLength));
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            tile.fireTileEvent(VALUE_CHANGED);
        }
    };
    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());
    valueText = new Text(String.format(locale, formatString, (tile.getValue())));
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());
    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());
    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);
    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setWrapText(true);
    description.setTextFill(tile.getTextColor());
    Helper.enableNode(description, !tile.getDescription().isEmpty());
    barBackground = new Rectangle(PREFERRED_WIDTH * 0.795, PREFERRED_HEIGHT * 0.0275);
    bar = new Rectangle(0, PREFERRED_HEIGHT * 0.0275);
    thumb = new Circle(PREFERRED_WIDTH * 0.09);
    thumb.setEffect(shadow);
    getPane().getChildren().addAll(titleText, text, valueUnitFlow, description, barBackground, bar, thumb);
}
Also used : Circle(javafx.scene.shape.Circle) EventType(javafx.event.EventType) Point2D(javafx.geometry.Point2D) Label(javafx.scene.control.Label) Rectangle(javafx.scene.shape.Rectangle) Text(javafx.scene.text.Text) TextFlow(javafx.scene.text.TextFlow)

Example 17 with EventType

use of javafx.event.EventType in project gs-ui-javafx by graphstream.

the class FxDefaultView method addListener.

public <T, U> void addListener(T descriptor, U listener) {
    EventType eventType = (EventType) descriptor;
    EventHandler eventFilter = (EventHandler) listener;
    addEventFilter(eventType, eventFilter);
}
Also used : EventType(javafx.event.EventType) EventHandler(javafx.event.EventHandler)

Example 18 with EventType

use of javafx.event.EventType in project Board-Instrumentation-Framework by intel.

the class Section method fireSectionEvent.

public void fireSectionEvent(final SectionEvent EVENT) {
    final EventHandler<SectionEvent> HANDLER;
    final EventType TYPE = EVENT.getEventType();
    if (SectionEvent.ENTERING_SECTION == TYPE) {
        HANDLER = getOnEnteringSection();
    } else if (SectionEvent.LEAVING_SECTION == TYPE) {
        HANDLER = getOnLeavingSection();
    } else {
        HANDLER = null;
    }
    if (null == HANDLER)
        return;
    HANDLER.handle(EVENT);
}
Also used : EventType(javafx.event.EventType)

Example 19 with EventType

use of javafx.event.EventType in project Board-Instrumentation-Framework by intel.

the class Marker method fireMarkerEvent.

public void fireMarkerEvent(final MarkerEvent EVENT) {
    final EventHandler<MarkerEvent> HANDLER;
    final EventType TYPE = EVENT.getEventType();
    if (MarkerEvent.MARKER_EXCEEDED == TYPE) {
        HANDLER = getOnMarkerExceeded();
    } else if (MarkerEvent.MARKER_UNDERRUN == TYPE) {
        HANDLER = getOnMarkerUnderrun();
    } else {
        HANDLER = null;
    }
    if (null == HANDLER)
        return;
    HANDLER.handle(EVENT);
}
Also used : EventType(javafx.event.EventType)

Example 20 with EventType

use of javafx.event.EventType in project Board-Instrumentation-Framework by intel.

the class PushButton method fireSelectionEvent.

public void fireSelectionEvent(final SelectionEvent EVENT) {
    final EventType TYPE = EVENT.getEventType();
    final EventHandler<SelectionEvent> HANDLER;
    if (SelectionEvent.SELECTED == TYPE) {
        HANDLER = getOnSelect();
    } else if (SelectionEvent.DESELECTED == TYPE) {
        HANDLER = getOnDeselect();
    } else if (SelectionEvent.EMPTY == TYPE) {
        HANDLER = getOnEmpty();
    } else {
        HANDLER = null;
    }
    if (HANDLER != null) {
        HANDLER.handle(EVENT);
    }
}
Also used : EventType(javafx.event.EventType)

Aggregations

EventType (javafx.event.EventType)26 Point2D (javafx.geometry.Point2D)7 Marker (eu.hansolo.enzo.common.Marker)4 Label (javafx.scene.control.Label)4 Text (javafx.scene.text.Text)4 EventHandler (javafx.event.EventHandler)3 Circle (javafx.scene.shape.Circle)3 Rectangle (javafx.scene.shape.Rectangle)3 TextFlow (javafx.scene.text.TextFlow)3 Timeline (javafx.animation.Timeline)2 Node (javafx.scene.Node)2 UnmodifiableListSet (com.sun.javafx.collections.UnmodifiableListSet)1 Direction (com.sun.javafx.scene.traversal.Direction)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 Queue (java.util.Queue)1 Set (java.util.Set)1 BiConsumer (java.util.function.BiConsumer)1