Java 类javafx.event.EventType 实例源码

项目:jmonkeybuilder    文件:FXEventManager.java   
/**
 * The process of handling a new event.
 */
@FXThread
private void notifyImpl(@NotNull final Event event) {

    final ObjectDictionary<EventType<? extends Event>, Array<EventHandler<? super Event>>> eventHandlers = getEventHandlers();

    for (EventType<? extends Event> eventType = event.getEventType();
         eventType != null; eventType = eventType.getSuperType()) {

        final Array<EventHandler<? super Event>> handlers = eventHandlers.get(eventType);
        if (handlers == null || handlers.isEmpty()) continue;

        handlers.forEach(event, EventHandler::handle);
    }

    if (event instanceof ConsumableEvent && !event.isConsumed()) {
        final ExecutorManager executorManager = ExecutorManager.getInstance();
        executorManager.addFXTask(() -> notifyImpl(event));
    }
}
项目:tilesfx    文件:Section.java   
public void fireSectionEvent(final SectionEvent EVENT) {
    final EventHandler<SectionEvent> HANDLER;
    final EventType                  TYPE = EVENT.getEventType();
    if (SectionEvent.TILES_FX_SECTION_ENTERED == TYPE) {
        HANDLER = getOnSectionEntered();
    } else if (SectionEvent.TILES_FX_SECTION_LEFT == TYPE) {
        HANDLER = getOnSectionLeft();
    } else if (SectionEvent.TILES_FX_SECTION_UPDATE == TYPE) {
        HANDLER = getOnSectionUpdate();
    } else {
        HANDLER = null;
    }

    if (null == HANDLER) return;

    HANDLER.handle(EVENT);
}
项目:Percussion-Packer    文件:ColumnSeparator.java   
@Override
public void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_ENTERED) {
        this.getScene().setCursor(Cursor.E_RESIZE);
    } else if (type == MouseEvent.MOUSE_EXITED) {
        if (!this.isDragging) {
            this.getScene().setCursor(Cursor.DEFAULT);
        }
    } else if (type == MouseEvent.MOUSE_PRESSED) {
        this.startMouseDrag(event.getSceneX());
    } else if (type == MouseEvent.MOUSE_DRAGGED) {
        this.handleMouseDrag(event.getSceneX());
    } else if (type == MouseEvent.MOUSE_RELEASED) {
        if (this.isDragging) {
            this.finishMouseDrag();
        }
    }
}
项目:Percussion-Packer    文件:WorkspaceScene.java   
@Override
public void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_PRESSED) {
        Node focusedObject = this.getFocusOwner();
        if (focusedObject instanceof UnfocusableTextField) {
            Region textField = (Region) focusedObject;
            Point2D textFieldPos = GraphicsUtil.getScenePosition(textField);
            double mouseX = event.getSceneX();
            double mouseY = event.getSceneY();
            if (!(textFieldPos.getX() <= mouseX
                    && mouseX < textFieldPos.getX() + textField.getWidth()
                    && textFieldPos.getY() <= mouseY
                    && mouseY < textFieldPos.getY() + textField.getHeight())) {
                this.rootPane.requestFocus();
            }
        }
    }
}
项目:Percussion-Packer    文件:ClickEditableText.java   
@Override
public void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_PRESSED) {
        this.isDragging = false;
        this.lastMouseX = event.getSceneX();
        this.lastMouseY = event.getSceneY();
    } else if (type == MouseEvent.MOUSE_DRAGGED) {
        double dx = event.getSceneX() - this.lastMouseX;
        double dy = event.getSceneY() - this.lastMouseY;
        if (ClickEditableText.isClickOverThreshold(dx, dy)) {
            this.isDragging = true;
        }
    } else if (type == MouseEvent.MOUSE_RELEASED) {
        if (this.isEditable && !this.isDragging) {
            this.startRenaming();
        }
    }
}
项目:FxEditor    文件:FxEditor.java   
protected void handleKeyEvent(KeyEvent ev)
{
    if(!ev.isConsumed())
    {
        Runnable a = keymap.getActionForKeyEvent(ev);
        if(a != null)
        {
            a.run();
            return;
        }

        EventType<KeyEvent> t = ev.getEventType();
        if(t == KeyEvent.KEY_PRESSED)
        {
            handleKeyPressed(ev);
        }
        else if(t == KeyEvent.KEY_RELEASED)
        {
            handleKeyReleased(ev);
        }
        else if(t == KeyEvent.KEY_TYPED)
        {
            handleKeyTyped(ev);
        }
    }
}
项目:Gargoyle    文件:GoogleTrendChartEvent.java   
/**
 * @param source
 * @param target
 * @param eventType
 * @param x
 * @param y
 * @param screenX
 * @param screenY
 * @param pickResult
 * @param clickCount
 * @param contents
 */
public GoogleTrendChartEvent(Object source, EventTarget target, EventType<? extends GoogleTrendChartEvent> eventType, double x,
        double y, double screenX, double screenY, PickResult pickResult, int clickCount, List<Node> contents) {
    super(source, target, eventType);
    this.x = x;
    this.y = y;
    this.screenX = screenX;
    this.screenY = screenY;
    this.sceneX = x;
    this.sceneY = y;
    this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
    final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
    this.x = p.getX();
    this.y = p.getY();
    this.z = p.getZ();
    this.clickCount = clickCount;
    this.contents = contents;
}
项目:Gargoyle    文件:DockEvent.java   
/**
 * Constructs new DockEvent event..
 * 
 * @param source the source of the event. Can be null.
 * @param target the target of the event. Can be null.
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 * @param contents The contents being dragged during this event.
 */
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
    double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
  super(source, target, eventType);
  this.x = x;
  this.y = y;
  this.screenX = screenX;
  this.screenY = screenY;
  this.sceneX = x;
  this.sceneY = y;
  this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
  final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
  this.x = p.getX();
  this.y = p.getY();
  this.z = p.getZ();
  this.contents = contents;
}
项目:javaone2016    文件:Section.java   
public void fireSectionEvent(final SectionEvent EVENT) {
    final EventHandler<SectionEvent> HANDLER;
    final EventType                  TYPE = EVENT.getEventType();
    if (SectionEvent.SECTION_ENTERED == TYPE) {
        HANDLER = getOnSectionEntered();
    } else if (SectionEvent.SECTION_LEFT == TYPE) {
        HANDLER = getOnSectionLeft();
    } else if (SectionEvent.SECTION_UPDATE == TYPE) {
        HANDLER = getOnSectionUpdate();
    } else {
        HANDLER = null;
    }

    if (null == HANDLER) return;

    HANDLER.handle(EVENT);
}
项目:openjfx-8u-dev-tests    文件:InputSampleBase.java   
protected void checkMouseEvent(final Color color, final EventType type, final MouseButton btn, final int x, final int y, final int times) {

        Root.ROOT.getEnvironment().getWaiter(Wrap.WAIT_STATE_TIMEOUT).ensureValue(true, () -> {
            synchronized (InputApp.events) {
                if (InputApp.events.size() > 0) {
                    for (Event e : InputApp.events.toArray(new Event[0])) {
                        if (e instanceof MouseEvent) {
                            if (e.getEventType().equals(type)
                                    && ((Rectangle) e.getSource()).getFill().equals(color)
                                    && ((MouseEvent) e).getButton().equals(btn)
                                    && ((MouseEvent) e).getX() == x
                                    && ((MouseEvent) e).getY() == y
                                    && ((MouseEvent) e).getClickCount() == times) {
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        });
    }
项目:openjfx-8u-dev-tests    文件:InputSampleBase.java   
protected void checkKeyboardEvent(final EventType type, final KeyCode btn, final String character) {

        Root.ROOT.getEnvironment().getWaiter(Wrap.WAIT_STATE_TIMEOUT).ensureValue(true, () -> {
            synchronized (InputApp.events) {
                for (Event e : InputApp.events.toArray(new Event[0])) {
                    if (e instanceof KeyEvent) {
                        if (e.getEventType().equals(type)
                                && ((KeyEvent) e).getCode().equals(btn)
                                && (!e.getEventType().equals(KeyEvent.KEY_TYPED) || ((KeyEvent) e).getCharacter().equals(character))) {
                            return true;
                        }
                    }
                }
                return false;
            }
        });
    }
项目:Medusa    文件:Section.java   
public void fireSectionEvent(final SectionEvent EVENT) {
    final EventHandler<SectionEvent> HANDLER;
    final EventType                  TYPE = EVENT.getEventType();
    if (SectionEvent.SECTION_ENTERED == TYPE) {
        HANDLER = getOnSectionEntered();
    } else if (SectionEvent.SECTION_LEFT == TYPE) {
        HANDLER = getOnSectionLeft();
    } else if (SectionEvent.SECTION_UPDATE == TYPE) {
        HANDLER = getOnSectionUpdate();
    } else {
        HANDLER = null;
    }

    if (null == HANDLER) return;

    HANDLER.handle(EVENT);
}
项目:Medusa    文件:ModernSkin.java   
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(31, 31, 31)),
                                              new Stop(1.0, Color.rgb(69, 70, 73))));
        valueText.setTranslateY(size * 0.501);
        subTitleText.setTranslateY(size * 0.3525);
        unitText.setTranslateY(size * 0.6675);
    } else if (MouseEvent.MOUSE_RELEASED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(69, 70, 73)),
                                              new Stop(1.0, Color.rgb(31, 31, 31))));
        valueText.setTranslateY(size * 0.5);
        subTitleText.setTranslateY(size * 0.35);
        unitText.setTranslateY(size * 0.67);
    }
}
项目:Medusa    文件:Marker.java   
public void fireMarkerEvent(final MarkerEvent EVENT) {
    final EventHandler<MarkerEvent> HANDLER;
    final EventType                 TYPE = EVENT.getEventType();

    if (MarkerEvent.MARKER_PRESSED == TYPE) {
        HANDLER = getOnMarkerPressed();
    } else if (MarkerEvent.MARKER_RELEASED == TYPE) {
        HANDLER = getOnMarkerReleased();
    } else if (MarkerEvent.VALUE_CHANGED == TYPE) {
        HANDLER = getOnValueChanged();
    } else if (MarkerEvent.COLOR_CHANGED == TYPE) {
        HANDLER = getOnColorChanged();
    } else if (MarkerEvent.TEXT_CHANGED == TYPE) {
        HANDLER = getOnTextChanged();
    } else if (MarkerEvent.TYPE_CHANGED == TYPE) {
        HANDLER = getOnTypeChanged();
    } else if (MarkerEvent.MARKER_EXCEEDED == TYPE) {
        HANDLER = getOnMarkerExceeded();
    } else if (MarkerEvent.MARKER_UNDERRUN == TYPE) {
        HANDLER = getOnMarkerUnderrun();
    } else {
        HANDLER = null;
    }
    if (null == HANDLER) return;
    Platform.runLater(() -> HANDLER.handle(EVENT));
}
项目:dialplate    文件:DialPlate.java   
private void handleDial(final MouseEvent EVENT, final double MAX_ANGLE, final int NUMBER) {
    final EventType TYPE = EVENT.getEventType();

    if (MouseEvent.MOUSE_DRAGGED == TYPE) {
        Point2D point = sceneToLocal(EVENT.getSceneX(), EVENT.getSceneY());
        touchRotate(point.getX(), point.getY(), MAX_ANGLE);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        KeyValue kv0 = new KeyValue(plateRotate.angleProperty(), currentAngle, Interpolator.EASE_BOTH);
        KeyValue kv1 = new KeyValue(plateRotate.angleProperty(), 0, Interpolator.EASE_BOTH);
        KeyFrame kf0 = new KeyFrame(Duration.ZERO, kv0);
        KeyFrame kf1 = new KeyFrame(Duration.millis(2 * MAX_ANGLE), kv1);
        timeline.getKeyFrames().setAll(kf0, kf1);
        timeline.play();
        timeline.setOnFinished(e -> {
            currentAngle = 0;
            plateRotate.setAngle(currentAngle);
            fireEvent(new DialEvent(DialEvent.NUMBER_DIALED, NUMBER));
        });
    }
}
项目:horizon    文件:HorizonChart.java   
public HorizonChart(final int BANDS, final Series<T> SERIES, final boolean SMOOTHED) {
    series        = SERIES;
    scaleX        = 1;
    scaleY        = 1;
    smoothed      = SMOOTHED;
    referenceZero = true;
    noOfBands     = clamp(1, MAX_NO_OF_BANDS, BANDS);
    noOfItems     = SERIES.getNoOfItems();
    minY          = SERIES.getItems().stream().mapToDouble(Data::getY).min().getAsDouble();
    maxY          = SERIES.getItems().stream().mapToDouble(Data::getY).max().getAsDouble();
    bandWidth     = (maxY - minY) / noOfBands;
    tooltip       = new Tooltip();
    tooltip.setAnchorLocation(AnchorLocation.CONTENT_BOTTOM_LEFT);

    adjustColors();

    // Create list of points
    points = new ArrayList<>(noOfItems);
    prepareData();

    mouseListener           = mouseEvent -> {
        final EventType<? extends MouseEvent> TYPE = mouseEvent.getEventType();
        if (MouseEvent.MOUSE_CLICKED == TYPE) {
            Data<T> data = selectDataAt(mouseEvent.getX());
            tooltip.setText(createTooltipText(data));
            tooltip.setX(mouseEvent.getScreenX());
            tooltip.setY(mouseEvent.getScreenY());
            tooltip.show(getScene().getWindow());
            getSeries().fireSeriesEvent(new SeriesEvent(getSeries(), data, SeriesEventType.SELECT_DATA));
        } else if (MouseEvent.MOUSE_MOVED == TYPE) {
            tooltip.hide();
        } else if (MouseEvent.MOUSE_EXITED == TYPE) {
            tooltip.hide();
        }
    };
    seriesListener          = seriesEvent -> redraw();

    initGraphics();
    registerListeners();
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@SuppressWarnings("deprecation") private void dispatchKeyEvent(final Node node, JavaAgentKeys keyToPress,
        EventType<KeyEvent> eventType, char c) {
    ensureVisible(node);
    if (keyToPress == null) {
        KeyboardMap kbMap = new KeyboardMap(c);
        KeyCode keyCode = KeyCode.getKeyCode((kbMap.getChar() + "").toUpperCase());
        if (eventType.getName().equals("KEY_TYPED")) {
            keyCode = KeyCode.UNDEFINED;
        }
        int modifiersEx = deviceState.getModifierEx();
        char char1 = kbMap.getChar();
        if (modifiersEx == 0) {
            modifiersEx = kbMap.getModifiersEx();
            dispatchEvent(new KeyEvent(eventType, char1 + "", char1 + "", keyCode, deviceState.isShiftPressed(),
                    deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node);
        } else {
            dispatchEvent(new KeyEvent(eventType, char1 + "", char1 + "", keyCode, deviceState.isShiftPressed(),
                    deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node);
        }
        return;
    }
    final KeysMap keysMap = KeysMap.findMap(keyToPress);
    if (keysMap == null) {
        return;
    }
    deviceState.toggleKeyState(keyToPress);
    dispatchEvent(new KeyEvent(eventType, KeyCode.UNDEFINED.impl_getChar(), KeyCode.UNDEFINED.impl_getChar(), keysMap.getCode(),
            deviceState.isShiftPressed(), deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()),
            node);
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@Override public void moveto(Node node, double xoffset, double yoffset) {
    MouseButton buttons = deviceState.getButtons();
    if (node != deviceState.getNode()) {
        if (deviceState.getNode() != null) {
            dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, null, null, xoffset, yoffset, 0, 0, buttons, 0,
                    deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                    buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                    false, false, node));
        }
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_ENTERED, null, null, xoffset, yoffset, 0, 0, buttons, 0,
                deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false, false,
                false, node));
    }
    Node source = node;
    EventType<MouseEvent> id = MouseEvent.MOUSE_MOVED;
    if (buttons != MouseButton.NONE) {
        id = MouseEvent.MOUSE_DRAGGED;
        source = deviceState.getDragSource();
    }
    MouseButton modifierEx = deviceState.getButtonMask();
    dispatchEvent(createMouseEvent(id, null, null, xoffset, yoffset, 0, 0, buttons, 0, deviceState.shiftPressed,
            deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed, modifierEx == MouseButton.PRIMARY,
            modifierEx == MouseButton.MIDDLE, modifierEx == MouseButton.SECONDARY, false, false, false, source));
    deviceState.setNode(node);
    deviceState.setMousePosition(xoffset, yoffset);
}
项目:CalendarFX    文件:CalendarEvent.java   
/**
 * Constructs a new event for subclass.
 *
 * @param eventType the event type
 * @param calendar  the calendar where the event occurred.
 */
protected CalendarEvent(EventType<? extends CalendarEvent> eventType,
                        Calendar calendar) {
    super(calendar, calendar, eventType);

    this.calendar = requireNonNull(calendar);
}
项目:CalendarFX    文件:CalendarEvent.java   
/**
 * Constructs a new event.
 *
 * @param eventType the event type
 * @param calendar  the calendar where the event occured
 * @param entry     the affected entry
 */
public CalendarEvent(EventType<? extends CalendarEvent> eventType,
                     Calendar calendar, Entry<?> entry) {
    super(calendar, calendar, eventType);

    this.calendar = calendar;
    this.entry = requireNonNull(entry);
}
项目:CalendarFX    文件:DateControlSkin.java   
private void calendarChanged(CalendarEvent evt) {

        if (LoggingDomain.EVENTS.isLoggable(Level.FINE) && !(evt.getEntry() instanceof DraggedEntry)) {
            LoggingDomain.EVENTS.fine("calendar event in " + getSkinnable().getClass().getSimpleName() + ": " + evt.getEventType() + ", details: " + evt.toString());
        }

        if (getSkinnable().isSuspendUpdates()) {
            return;
        }

        if (evt.getEventType().getSuperType().equals(CalendarEvent.ENTRY_CHANGED) && evt.getEntry().isRecurrence()) {
            return;
        }

        Util.runInFXThread(() -> {
            EventType<? extends Event> eventType = evt.getEventType();
            if (eventType.equals(CalendarEvent.ENTRY_INTERVAL_CHANGED)) {
                entryIntervalChanged(evt);
            } else if (eventType.equals(CalendarEvent.ENTRY_FULL_DAY_CHANGED)) {
                entryFullDayChanged(evt);
            } else if (eventType.equals(CalendarEvent.ENTRY_RECURRENCE_RULE_CHANGED)) {
                entryRecurrenceRuleChanged(evt);
            } else if (eventType.equals(CalendarEvent.ENTRY_CALENDAR_CHANGED)) {
                entryCalendarChanged(evt);
            } else if (eventType.equals(CALENDAR_CHANGED)) {
                calendarChanged(evt.getCalendar());
            }
        });
    }
项目:Clipcon-Client    文件:Notification.java   
public void fireNotificationEvent(final NotificationEvent event) {
    EventType<?> TYPE = event.getEventType();
    EventHandler<NotificationEvent> handelr;
    if (NotificationEvent.NOTIFICATION_PRESSED == TYPE) {
        handelr = getOnNotificationPressed();
    } else if (NotificationEvent.SHOW_NOTIFICATION == TYPE) {
        handelr = getOnShowNotification();
    } else {
        handelr = null;
    }
    if (null == handelr)
        return;
    handelr.handle(event);
}
项目:Lyrebird    文件:EventUtils.java   
@Contract(pure = true)
public static KeyEvent dummyKeyEvent(final EventType<KeyEvent> eventType) {
    return new KeyEvent(
            eventType,
            KeyEvent.CHAR_UNDEFINED,
            "dummy character",
            KeyCode.UNDEFINED,
            false,
            false,
            false,
            false
    );
}
项目:GestureFX    文件:AffineEvent.java   
public AffineEvent(EventType<? extends Event> eventType,
                   Affine affine,
                   Affine previous,
                   Dimension2D targetDimension) {
    super(eventType);
    this.affine = affine;
    this.previous = previous;
    this.targetDimension = targetDimension;
}
项目:jmonkeybuilder    文件:EventRedirector.java   
private void redirect(@NotNull final InputEvent event) {

        final EventTarget target = event.getTarget();
        if (target == destination) {
            return;
        } else if (target instanceof TextInputControl) {
            if (event instanceof KeyEvent && UIUtils.isNotHotKey((KeyEvent) event)) {
                if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
                    LOGGER.debug(this, target, ev -> "Key event was skipped because it was from " + ev);
                }
                return;
            }
        }

        final EventType<? extends InputEvent> eventType = event.getEventType();
        final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();

        if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
            LOGGER.debug(this, event, notNull(currentEditor), (red, ev, editor) -> "Key event " + ev.getEventType() +
                    " is inside " + editor.isInside(red.getSceneX(), red.getSceneY(), ev.getClass()));
        }

        if (currentEditor == null || eventType != KeyEvent.KEY_RELEASED && !currentEditor.isInside(getSceneX(), getSceneY(), event.getClass())) {
            return;
        }

        if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
            LOGGER.debug(this, event, ev -> "Redirect event " + ev);
        }

        Event.fireEvent(destination, event.copyFor(event.getSource(), destination));
    }
项目:jmonkeybuilder    文件:FXEventManager.java   
/**
 * Add a new event handler.
 *
 * @param eventType    the event type.
 * @param eventHandler the event handler.
 */
@FXThread
public void addEventHandler(@NotNull final EventType<? extends Event> eventType,
                            @NotNull final EventHandler<? super Event> eventHandler) {

    final Array<EventHandler<? super Event>> handlers = getEventHandlers().get(eventType,
            () -> newArray(EventHandler.class));

    handlers.add(eventHandler);
}
项目:jmonkeybuilder    文件:FXEventManager.java   
/**
 * Remove an old event handler.
 *
 * @param eventType    the event type.
 * @param eventHandler the event handler.
 */
@FXThread
public void removeEventHandler(@NotNull final EventType<? extends Event> eventType,
                               @NotNull final EventHandler<? super Event> eventHandler) {

    final Array<EventHandler<? super Event>> handlers = getEventHandlers().get(eventType);
    if (handlers == null) return;

    handlers.slowRemove(eventHandler);
}
项目:tilesfx    文件:TimeSection.java   
public void fireTimeSectionEvent(final TimeSectionEvent EVENT) {
    final EventHandler<TimeSectionEvent> HANDLER;
    final EventType                      TYPE = EVENT.getEventType();
    if (TimeSectionEvent.TIME_SECTION_ENTERED == TYPE) {
        HANDLER = getOnTimeSectionEntered();
    } else if (TimeSectionEvent.TIME_SECTION_LEFT == TYPE) {
        HANDLER = getOnTimeSectionLeft();
    } else {
        HANDLER = null;
    }

    if (null == HANDLER) return;

    HANDLER.handle(EVENT);
}
项目:tilesfx    文件:Alarm.java   
public void fireAlarmMarkerEvent(final AlarmMarkerEvent EVENT) {
    final EventHandler<AlarmMarkerEvent> HANDLER;
    final EventType                      TYPE = EVENT.getEventType();

    if (AlarmMarkerEvent.ALARM_MARKER_PRESSED == TYPE) {
        HANDLER = getOnMarkerPressed();
    } else if (AlarmMarkerEvent.ALARM_MARKER_RELEASED == TYPE) {
        HANDLER = getOnMarkerReleased();
    } else {
        HANDLER = null;
    }
    if (null == HANDLER) return;
    Platform.runLater(() -> HANDLER.handle(EVENT));
}
项目:Percussion-Packer    文件:CardDragPane.java   
@Override
public void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_PRESSED) {
        this.lastMouseX = event.getSceneX();
        this.lastMouseY = event.getSceneY();
        this.isCardDragging = false;
    } else if (type == MouseEvent.MOUSE_DRAGGED) {
        if (this.draggingCard != null) {
            this.handleMouseDrag(event.getSceneX(), event.getSceneY());
        }
    } else if (type == MouseEvent.MOUSE_RELEASED) {
        this.handleMouseRelease();
    }
}
项目:Percussion-Packer    文件:Card.java   
@Override
public final void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_ENTERED) {
        this.backingButton.arm();
    } else if (type == MouseEvent.MOUSE_EXITED) {
        this.backingButton.disarm();
    }
}
项目:Percussion-Packer    文件:CardList.java   
@Override
public void handleMouse(MouseEvent event, EventType<? extends MouseEvent> type) {
    if (type == MouseEvent.MOUSE_PRESSED) {
        double localY = event.getY();
        for (int i = 0; i < this.cards.size(); i++) {
            CardEntity clickedEntity = this.cards.get(i);
            if (clickedEntity.isDraggable()) {
                double cardPosY = clickedEntity.getLayoutY();
                if (localY >= cardPosY && localY < cardPosY + clickedEntity.getHeight()) {
                    this.handleCardClick(i);
                }
            }
        }
    }
}
项目:Percussion-Packer    文件:PackingStage.java   
@Override
public void handleWindowEvent(WindowEvent event, EventType<? extends WindowEvent> type) {
    if (type == WindowEvent.WINDOW_CLOSE_REQUEST) {
        Platform.exit();
        System.exit(0);
    }
}
项目:Percussion-Packer    文件:UnfocusableTextField.java   
@Override
public void handleKey(KeyEvent event, EventType<KeyEvent> type, KeyCode code) {
    if (event.getEventType() == KeyEvent.KEY_PRESSED) {
        if (code == KeyCode.ENTER || code == KeyCode.ESCAPE) {
            this.getParent().requestFocus();
        }
    }
}
项目:farmsim    文件:KeyPressHandler.java   
@Override
public void handle(KeyEvent event) {
    EventType eventType = event.getEventType();
    if (eventType == KeyEvent.KEY_PRESSED) {
        keyPressed(event.getCode());
    } else if (eventType == KeyEvent.KEY_RELEASED) {
        keyReleased(event.getCode());
    }
}
项目:medusademo    文件:InteractiveGaugeSkin.java   
public void handleMouseEvent(final MouseEvent EVENT) {
    if (getSkinnable().isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        getSkinnable().fireEvent(getSkinnable().BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        getSkinnable().fireEvent(getSkinnable().BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
项目:openjfx-8u-dev-tests    文件:ControlEventsApp.java   
public static EventTypes get(EventType<? extends Event> type) {
    for (EventTypes t : EventTypes.values()) {
        if (t.getType().equals(type)) {
            return t;
        }
    }
    return null;
}
项目:openjfx-8u-dev-tests    文件:SceneEventHandlersApp.java   
public static EventTypes get(EventType<? extends Event> type)
{
    for(EventTypes t: EventTypes.values())
    {
        if(t.type.equals(type))
        {
            return t;
        }
    }
    return null;
}
项目:Medusa    文件:HSkin.java   
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
项目:Medusa    文件:QuarterSkin.java   
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}