javafx.event.EventType Java Examples

The following examples show how to use javafx.event.EventType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSilhouette.java    From jsilhouette with Apache License 2.0 6 votes vote down vote up
public final <T extends Event> void removeEventHandler(
    final EventType<T> eventType,
    final EventHandler<? super T> eventHandler) {
    if (eventType == null) {
        throw new NullPointerException("Argument 'eventType' is null");
    }
    if (eventHandler == null) {
        throw new NullPointerException("Argument 'eventHandler' is null");
    }

    if (shape == null) {
        EventHandlerRegistration<T> registration = new EventHandlerRegistration<>(eventType, eventHandler);
        eventHandlers.remove(registration);
    } else {
        shape.get().removeEventHandler(eventType, eventHandler);
    }
}
 
Example #2
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void sendScrollEventToFX(final EventType<ScrollEvent> eventType,
		double scrollX, double scrollY, int x, int y, int stateMask) {
	// granularity for mouse wheel scroll events is more
	// coarse-grained than for pan gesture events
	final double multiplier = 40.0;
	final Point los = toDisplay(x, y);
	scheduleSceneRunnable(new ISceneRunnable() {
		@Override
		public void run(TKSceneListenerWrapper sceneListener) {
			sceneListener.scrollEvent(eventType, scrollX, scrollY,
					scrollX, scrollY, multiplier, multiplier, 0, 0, 0,
					0, 0, x, y, los.x, los.y,
					(stateMask & SWT.SHIFT) != 0,
					(stateMask & SWT.CONTROL) != 0,
					(stateMask & SWT.ALT) != 0,
					(stateMask & SWT.COMMAND) != 0, false, false);
		}
	});
}
 
Example #3
Source File: ParetoPanel.java    From charts with Apache License 2.0 6 votes vote down vote up
/**
 * Handles the clicks on DataDots and ParetoBars
 * @param EVT
 */
private void handleMouseEvents(final MouseEvent EVT) {
    final EventType<? extends MouseEvent> TYPE = EVT.getEventType();
    double                                X    = EVT.getX();
    double                                Y    = EVT.getY();

    if(MouseEvent.MOUSE_PRESSED.equals(TYPE)) {
        for (DataDot dot: dataDots) {
            if(insideDataDot(X,Y,dot)) {
                showPopup(EVT.getScreenX(),EVT.getScreenY(),dot);
                return;
            }
        }
        for(ParetoBar bar: paretoModel.getData()) {
            if(insideBar(X,Y,bar)) {
                if(EVT.isShiftDown()){
                    filterChartByBar(bar);
                }else {
                    cascadeIntoBar(bar);
                }
                break;
            }
        }

    }
}
 
Example #4
Source File: TimeSection.java    From OEE-Designer with MIT License 6 votes vote down vote up
@SuppressWarnings("rawtypes")
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);
   }
 
Example #5
Source File: Section.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: MapPane.java    From BlockMap with MIT License 6 votes vote down vote up
public MapPane(WorldRendererCanvas renderer) {
	this.renderer = Objects.requireNonNull(renderer);
	catchEvents = new Region();
	ListChangeListener<Node> l = c -> {
		getChildren().clear();
		getChildren().addAll(decorationLayers);
		getChildren().add(catchEvents);
		getChildren().addAll(pinLayers);
		getChildren().addAll(settingsLayers);
	};
	settingsLayers.addListener(l);
	pinLayers.addListener(l);
	decorationLayers.addListener(l);

	catchEvents.setPickOnBounds(true);
	EventHandler<? super Event> refireEvent = event -> decorationLayers.forEach(l1 -> l1.fireEvent(event));
	catchEvents.addEventFilter(EventType.ROOT, refireEvent);
	pinLayers.addListener((ListChangeListener<Node>) e -> {
		while (e.next()) {
			e.getRemoved().forEach(n -> n.removeEventFilter(EventType.ROOT, refireEvent));
			e.getAddedSubList().forEach(n -> n.addEventFilter(EventType.ROOT, refireEvent));
		}
	});

	decorationLayers.add(renderer);
}
 
Example #7
Source File: TimelineTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void handleMouseEvents(final MouseEvent e) {
    EventType type = e.getEventType();
    Circle    dot  = (Circle) e.getSource();
    ChartData data = dots.entrySet().stream().filter(entry -> entry.getValue().equals(dot)).map(entry -> entry.getKey()).findAny().orElse(null);
    if (MouseEvent.MOUSE_ENTERED.equals(type)) {
        if (null != data) {
            dotTooltip.setX(e.getScreenX());
            dotTooltip.setY(e.getScreenY());
            LocalDateTime localDateTime = LocalDateTime.ofInstant(data.getTimestamp(), tile.getZoneId());
            dotTooltip.setText(String.join("\n", DTF.format(localDateTime), String.format(tile.getLocale(), String.join(" ", formatString, tile.getUnit()), data.getValue())));
            dotTooltip.show(tile.getScene().getWindow());
        }
    } else if (MouseEvent.MOUSE_EXITED.equals(type)) {
        dotTooltip.hide();
    }
}
 
Example #8
Source File: Switch.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
public Switch() {
    getStylesheets().add(Switch.class.getResource("switch.css").toExternalForm());
    aspectRatio      = PREFERRED_HEIGHT / PREFERRED_WIDTH;
    _active          = false;
    _activeColor     = Tile.BLUE;
    _foregroundColor = Tile.FOREGROUND;
    _backgroundColor = Tile.BACKGROUND;

    mouseEventHandler = e -> {
        final EventType TYPE = e.getEventType();
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            setActive(!isActive());
            fireEvent(SWITCH_PRESSED);
        } else if(MouseEvent.MOUSE_RELEASED == TYPE) {
            fireEvent(SWITCH_RELEASED);
        }
    };
    selectedListener = o -> moveThumb();

    timeline = new Timeline();

    initGraphics();
    registerListeners();
}
 
Example #9
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void sendSwipeEventToFX(EventType<SwipeEvent> eventType,
		GestureEvent gestureEvent) {
	final Point los = toDisplay(gestureEvent.x, gestureEvent.y);

	scheduleSceneRunnable(new ISceneRunnable() {
		@Override
		public void run(TKSceneListenerWrapper sceneListener) {
			sceneListener.swipeEvent(eventType, 0, gestureEvent.x,
					gestureEvent.y, los.x, los.y,
					(gestureEvent.stateMask & SWT.SHIFT) != 0,
					(gestureEvent.stateMask & SWT.CONTROL) != 0,
					(gestureEvent.stateMask & SWT.ALT) != 0,
					(gestureEvent.stateMask & SWT.COMMAND) != 0, false);
		}
	});
}
 
Example #10
Source File: MouseCoordinateTrackerTest.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static final MouseEvent createEvent(EventType<MouseEvent> type, double x, double y)
{
	return new MouseEvent(
			type,
			x,
			y,
			0.0,
			0.0,
			MouseButton.PRIMARY,
			1,
			false,
			false,
			false,
			false,
			true,
			false,
			false,
			false,
			false,
			false,
			null);
}
 
Example #11
Source File: Marker.java    From Medusa with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #12
Source File: ModernSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #13
Source File: ChartPlugin.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <T extends InputEvent> void addEventHandlers(final Node node) {
    if (node == null) {
        return;
    }
    for (final Pair<EventType<? extends InputEvent>, EventHandler<? extends InputEvent>> pair : mouseEventHandlers) {
        final EventType<T> type = (EventType<T>) pair.getKey();
        final EventHandler<T> handler = (EventHandler<T>) pair.getValue();
        node.addEventHandler(type, handler);
        node.sceneProperty().addListener((ch, o, n) -> {
            if (o == n) {
                return;
            }
            if (o != null) {
                o.removeEventHandler(type, handler);
            }

            if (n != null) {
                n.addEventHandler(type, handler);
            }
        });
    }
}
 
Example #14
Source File: TreeViewApp.java    From oim-fx with MIT License 5 votes vote down vote up
@Override

	public void start(Stage primaryStage) throws Exception {
		primaryStage.initStyle(StageStyle.TRANSPARENT);
		primaryStage.setScene(new Scene(createContent()));
		primaryStage.show();
		EventType<MouseEvent> type = MouseEvent.MOUSE_CLICKED;
		primaryStage.addEventHandler(type,e->{
			System.out.println(e);
		});
	}
 
Example #15
Source File: Alarm.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #16
Source File: PaintClickOrDrag.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public EventHandler<MouseEvent> singleEventHandler() {
	return event -> {
		final EventType<? extends MouseEvent> eventType = event.getEventType();
		if (MouseEvent.MOUSE_PRESSED.equals(eventType)) {
			LOG.debug("Single event handler: Is pressed");
			onPress.handle(event);
		}
		else if (MouseEvent.MOUSE_DRAGGED.equals(eventType) || MouseEvent.MOUSE_MOVED.equals(eventType))
			onDragOrMove.handle(event);
		else if (MouseEvent.MOUSE_RELEASED.equals(eventType))
			onRelease.handle(event);
	};
}
 
Example #17
Source File: ChatWritePane.java    From oim-fx with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public KeyEvent createKeyEvent(
		EventType<? extends KeyEvent> eventType,
		KeyCode code, String character, String text,
		boolean shiftDown, boolean controlDown,
		boolean altDown, boolean metaDown) {
	return new KeyEvent((EventType<KeyEvent>) eventType, character, text, code, shiftDown, controlDown, altDown, metaDown);
}
 
Example #18
Source File: VSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #19
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void sendScrollEventToFX(EventType<ScrollEvent> eventType,
		double scrollX, double scrollY, int x, int y, int stateMask,
		boolean inertia) {
	// up to and including SWT 4.5, direction was inverted for pan
	// gestures on the Mac
	// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=481331)
	final double multiplier = ("cocoa".equals(SWT.getPlatform())
			&& SWT.getVersion() < 4600) ? -5.0 : 5.0;

	if (eventType == ScrollEvent.SCROLL_STARTED) {
		totalScrollX = 0;
		totalScrollY = 0;
	} else if (inertia) {
		// inertia events do not belong to the gesture,
		// thus total scroll is not accumulated
		totalScrollX = scrollX;
		totalScrollY = scrollY;
	} else {
		// accumulate total scroll as long as the gesture occurs
		totalScrollX += scrollX;
		totalScrollY += scrollY;
	}

	final Point los = toDisplay(x, y);
	scheduleSceneRunnable(new ISceneRunnable() {
		@Override
		public void run(TKSceneListenerWrapper sceneListener) {
			sceneListener.scrollEvent(eventType, scrollX, scrollY,
					totalScrollX, totalScrollY, multiplier, multiplier,
					0, 0, 0, 0, 0, x, y, los.x, los.y,
					(stateMask & SWT.SHIFT) != 0,
					(stateMask & SWT.CONTROL) != 0,
					(stateMask & SWT.ALT) != 0,
					(stateMask & SWT.COMMAND) != 0, false, inertia);
		}
	});
}
 
Example #20
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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, JavaCompatibility.getChar(KeyCode.UNDEFINED),
            JavaCompatibility.getChar(KeyCode.UNDEFINED), keysMap.getCode(), deviceState.isShiftPressed(),
            deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node);
}
 
Example #21
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #22
Source File: FxEventManager.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Add a new event handler.
 *
 * @param eventType    the event type.
 * @param eventHandler the event handler.
 */
@FxThread
public <T extends Event> void addEventHandler(
        @NotNull EventType<T> eventType,
        @NotNull EventHandler<T> eventHandler
) {
    getEventHandlers().get(eventType, () -> newArray(EventHandler.class))
            .add(eventHandler);
}
 
Example #23
Source File: FxEventManager.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an old event handler.
 *
 * @param eventType    the event type.
 * @param eventHandler the event handler.
 */
@FxThread
public void removeEventHandler(
        @NotNull EventType<?> eventType,
        @NotNull EventHandler<?> eventHandler
) {
    getEventHandlers().getOptional(eventType)
            .ifPresent(handlers -> handlers.slowRemove(eventHandler));
}
 
Example #24
Source File: TimeSection.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #25
Source File: TimeSection.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: Alarm.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #27
Source File: GaugeSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source File: InteractiveGaugeSkin.java    From medusademo with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #29
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void sendRotateEventToFX(EventType<RotateEvent> eventType,
		GestureEvent gestureEvent) {
	Point los = toDisplay(gestureEvent.x, gestureEvent.y);

	// XXX: SWT uses negative angle values to indicate clockwise
	// rotation, while JavaFX uses positive ones. We thus have to invert
	// the values here
	double[] totalAngle = { -gestureEvent.rotation };
	if (eventType == RotateEvent.ROTATION_STARTED) {
		totalAngle[0] = lastTotalAngle = 0.0;
	} else if (eventType == RotateEvent.ROTATION_FINISHED) {
		// SWT uses 0.0 for final event, while JavaFX still provides a
		// (total) rotation value
		totalAngle[0] = lastTotalAngle;
	}
	final double angle = eventType == RotateEvent.ROTATION_FINISHED
			? 0.0 : totalAngle[0] - lastTotalAngle;
	lastTotalAngle = totalAngle[0];

	scheduleSceneRunnable(new ISceneRunnable() {
		@Override
		public void run(TKSceneListenerWrapper sceneListener) {
			sceneListener.rotateEvent(eventType, angle, totalAngle[0],
					gestureEvent.x, gestureEvent.y, los.x, los.y,
					(gestureEvent.stateMask & SWT.SHIFT) != 0,
					(gestureEvent.stateMask & SWT.CONTROL) != 0,
					(gestureEvent.stateMask & SWT.ALT) != 0,
					(gestureEvent.stateMask & SWT.COMMAND) != 0, false,
					!gestureActive);
		}
	});
}
 
Example #30
Source File: QuarterSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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);
    }
}