本文整理汇总了Java中javafx.event.EventType类的典型用法代码示例。如果您正苦于以下问题:Java EventType类的具体用法?Java EventType怎么用?Java EventType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventType类属于javafx.event包,在下文中一共展示了EventType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyImpl
import javafx.event.EventType; //导入依赖的package包/类
/**
* 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));
}
}
示例2: fireSectionEvent
import javafx.event.EventType; //导入依赖的package包/类
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);
}
示例3: handleMouse
import javafx.event.EventType; //导入依赖的package包/类
@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();
}
}
}
示例4: handleMouse
import javafx.event.EventType; //导入依赖的package包/类
@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();
}
}
}
}
示例5: handleMouse
import javafx.event.EventType; //导入依赖的package包/类
@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();
}
}
}
示例6: handleKeyEvent
import javafx.event.EventType; //导入依赖的package包/类
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);
}
}
}
示例7: GoogleTrendChartEvent
import javafx.event.EventType; //导入依赖的package包/类
/**
* @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;
}
示例8: DockEvent
import javafx.event.EventType; //导入依赖的package包/类
/**
* 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;
}
示例9: fireSectionEvent
import javafx.event.EventType; //导入依赖的package包/类
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);
}
示例10: checkMouseEvent
import javafx.event.EventType; //导入依赖的package包/类
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;
});
}
示例11: checkKeyboardEvent
import javafx.event.EventType; //导入依赖的package包/类
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;
}
});
}
示例12: handleMouseEvent
import javafx.event.EventType; //导入依赖的package包/类
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);
}
}
示例13: fireMarkerEvent
import javafx.event.EventType; //导入依赖的package包/类
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));
}
示例14: handleDial
import javafx.event.EventType; //导入依赖的package包/类
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));
});
}
}
示例15: HorizonChart
import javafx.event.EventType; //导入依赖的package包/类
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();
}