本文整理汇总了Java中javafx.scene.input.ZoomEvent类的典型用法代码示例。如果您正苦于以下问题:Java ZoomEvent类的具体用法?Java ZoomEvent怎么用?Java ZoomEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZoomEvent类属于javafx.scene.input包,在下文中一共展示了ZoomEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendZoomEvent
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
private void sendZoomEvent(EventType<ZoomEvent> fxEventType,
final GestureEvent event,
TKSceneListener sceneListener) {
Point screenPosition = canvas.toDisplay(event.x, event.y);
double magnification = (fxEventType == ZoomEvent.ZOOM_FINISHED)
? currentState.lastZoomFactor
: event.magnification;
// System.out.println(fxEventType + " " + magnification);
sceneListener.zoomEvent(fxEventType,
magnification / currentState.lastZoomFactor, // zoom factor
magnification, // totalZoomFactor
event.x, event.y, // x, y
screenPosition.x, screenPosition.y, // screenX, screenY
isShift(event), isControl(event), isAlt(event), isMeta(event),
false, // direct
false); // inertia
currentState.lastZoomFactor = magnification;
}
示例2: testScaleByTouch
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
@Test
public void testScaleByTouch() throws Exception {
double factor = 4.2;
pane.fireEvent(new ZoomEvent(ZoomEvent.ZOOM, 0, 0, 0, 0, false, false, false, false,
false, false, factor, factor, null));
assertThat(pane.getCurrentXScale()).isEqualTo(factor);
}
示例3: addListeners
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
private void addListeners() {
imageView.addEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
imageView.addEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
imageView.addEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);
if (Platform.isDesktop()) {
imageView.addEventHandler(ScrollEvent.ANY, scrollHandler);
} else {
imageView.addEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
imageView.addEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
imageView.addEventHandler(ZoomEvent.ZOOM, zoomHandler);
}
imageView.addEventHandler(MouseEvent.MOUSE_CLICKED, clickedHandler);
}
示例4: removeListeners
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
private void removeListeners() {
imageView.removeEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
imageView.removeEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
imageView.removeEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);
if (Platform.isDesktop()) {
imageView.removeEventHandler(ScrollEvent.ANY, scrollHandler);
} else {
imageView.removeEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
imageView.removeEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
imageView.removeEventHandler(ZoomEvent.ZOOM, zoomHandler);
}
imageView.removeEventHandler(MouseEvent.MOUSE_CLICKED, clickedHandler);
}
示例5: scrollPaneOnZoom
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
@FXML
void scrollPaneOnZoom(ZoomEvent event) {
FOKLogger.fine(MainWindow.class.getName(), "Zooming in view, new Zoom level: " + event.getZoomFactor());
drawing.setScaleX(drawing.getScaleX() * event.getZoomFactor());
drawing.setScaleY(drawing.getScaleY() * event.getZoomFactor());
// TODO: Update the actual size in the scrollpane (so that scrollbars appear when zooming in
// TODO: Add Keyboard and touchpad zoom
// TODO: do the zoom with the right zoom center
}
示例6: onZoom
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
/**
* On zoom event.
*
* @param e The zoom event.
*/
@FXML
private void onZoom(final ZoomEvent e) {
this.chart.zoom(
e.getZoomFactor(),
this.initialMouseScrollX,
this.initialMouseScrollY
);
}
示例7: compositeTokenPane_OnZoom
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
@FXML
void compositeTokenPane_OnZoom(ZoomEvent event) {
Double scale = portraitImageView.getScaleY() * event.getZoomFactor();
portraitImageView.setScaleX(scale);
portraitImageView.setScaleY(scale);
}
示例8: initialize
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
public static void initialize(ViewPort view, InputHandler input, RenderHandler render, Stage primaryStage) throws Exception
{
final ResizeableLayeredCanvasPane canvasPane = new ResizeableLayeredCanvasPane(
render.getNumOfLayers(), 640, 480);
canvasPane.setFocusTraversable(true);
canvasPane.addEventHandler(MouseEvent.MOUSE_MOVED, event ->
view.setCursorPosition(event.getX(), event.getY()));
canvasPane.addEventHandler(MouseEvent.MOUSE_DRAGGED, event ->
view.setCursorPosition(event.getX(), event.getY()));
canvasPane.addEventHandler(MouseEvent.MOUSE_PRESSED, event ->
view.setCursorDown(true));
canvasPane.addEventHandler(MouseEvent.MOUSE_RELEASED, event ->
view.setCursorDown(false));
canvasPane.addEventHandler(ScrollEvent.SCROLL, event ->
view.move(event.getDeltaX(), event.getDeltaY()));
canvasPane.addEventHandler(ZoomEvent.ZOOM, event ->
view.zoom(event.getZoomFactor()));
canvasPane.addEventFilter(KeyEvent.KEY_PRESSED, event ->
input.onInput(event.getCode()));
final BorderPane root = new BorderPane(canvasPane);
final AnimationTimer timer = new AnimationTimer()
{
@Override
public void handle(long now)
{
render.onDraw(primaryStage, canvasPane, view);
}
};
Scene scene = new Scene(root);
scene.setFill(Color.WHITE);
primaryStage.setScene(scene);
primaryStage.setTitle("Application");
primaryStage.show();
render.onLoad(primaryStage, canvasPane, view);
timer.start();
}
示例9: zoom
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
public static void zoom(Node node, ZoomEvent event) {
zoom(node, event.getZoomFactor(), event.getSceneX(), event.getSceneY());
}
示例10: zooming
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
public void zooming(ZoomEvent ze) {
zoom(ze.getTotalZoomFactor(), ze.getX(), ze.getY());
}
示例11: changeState
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
protected boolean changeState(StateType newStateType, GestureEvent event, TKSceneListener sceneListener) {
if(newStateType != currentState.type) {
switch (currentState.type) {
case SCROLLING:
sendScrollEvent(ScrollEvent.SCROLL_FINISHED, event, sceneListener);
break;
case ROTATING:
sendRotateEvent(RotateEvent.ROTATION_FINISHED, event, sceneListener);
break;
case ZOOMING:
sendZoomEvent(ZoomEvent.ZOOM_FINISHED, event, sceneListener);
break;
default:
// do nothing
}
switch (newStateType) {
case SCROLLING:
sendScrollEvent(ScrollEvent.SCROLL_STARTED, event, sceneListener);
break;
case ROTATING:
sendRotateEvent(RotateEvent.ROTATION_STARTED, event, sceneListener);
break;
case ZOOMING:
sendZoomEvent(ZoomEvent.ZOOM_STARTED, event, sceneListener);
break;
case IDLE:
if(event.detail == SWT.GESTURE_SWIPE)
sendSwipeEvent(event, sceneListener);
break;
default:
// do nothing
}
currentState = new State(newStateType);
return true;
}
switch (newStateType) {
case SCROLLING:
sendScrollEvent(ScrollEvent.SCROLL, event, sceneListener);
break;
case ROTATING:
sendRotateEvent(RotateEvent.ROTATE, event, sceneListener);
break;
case ZOOMING:
sendZoomEvent(ZoomEvent.ZOOM, event, sceneListener);
break;
case IDLE:
if(event.detail == SWT.GESTURE_SWIPE)
sendSwipeEvent(event, sceneListener);
default:
// do nothing
}
return false;
}
示例12: handleZoomEvent
import javafx.scene.input.ZoomEvent; //导入依赖的package包/类
/**
* Handle a zoom event.
*
* @param event
* The zoom event.
*/
private void handleZoomEvent(final ZoomEvent event) {
if (!Double.isNaN(event.getZoomFactor())) {
zoomImage(event.getZoomFactor());
}
}