当前位置: 首页>>代码示例>>Java>>正文


Java ScrollEvent.consume方法代码示例

本文整理汇总了Java中javafx.scene.input.ScrollEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollEvent.consume方法的具体用法?Java ScrollEvent.consume怎么用?Java ScrollEvent.consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.ScrollEvent的用法示例。


在下文中一共展示了ScrollEvent.consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * Zooms the canvas to the mouse pointer
 * @param event
 */
@Override
public void handle(ScrollEvent event) {
    double delta = 1.2;
    double scale = canvas.getScale(); // currently we only use Y, same value is used for X
    double oldScale = scale;

    if (event.getDeltaY() < 0) {
        scale /= delta;
    } else {
        scale *= delta;
    }
    scale = clamp(scale, MIN_SCALE, MAX_SCALE);

    double f = (scale / oldScale) - 1;
    double dx = (event.getSceneX() - (canvas.getBoundsInParent().getWidth() / 2 + canvas.getBoundsInParent().getMinX()));
    double dy = (event.getSceneY() - (canvas.getBoundsInParent().getHeight() / 2 + canvas.getBoundsInParent().getMinY()));

    canvas.setScale(scale);
    canvas.setPivot(f * dx, f * dy);
    canvas.setTranslateX(clamp(canvas.getTranslateX(), minX(), maxX()));
    canvas.setTranslateY(clamp(canvas.getTranslateX(), minY(), maxY()));

    event.consume();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:29,代码来源:SceneGestures.java

示例2: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
	event.consume();

	double deltaY = event.getDeltaY();
	double deltaX = event.getDeltaX();

	if (deltaY < 0) {
		scrollPane.setHvalue(Math.min(1, scrollPane.getHvalue() + 0.0007));
	} else if (deltaY > 0) {
		scrollPane.setHvalue(Math.max(0, scrollPane.getHvalue() - 0.0007));
	}
	if (deltaX < 0) {
		scrollPane.setVvalue(Math.min(1, scrollPane.getVvalue() + 0.05));
	} else if (deltaX > 0) {
		scrollPane.setVvalue(Math.max(0, scrollPane.getVvalue() - 0.05));
	}
	
}
 
开发者ID:ProgrammingLife2016,项目名称:PL3-2016,代码行数:20,代码来源:AnnotationController.java

示例3: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
    if (scrollEvent.isControlDown()) {

        Point2D mousePos = new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY());
        Point2D scenePositionToCentreZoomAround = m_root.sceneToLocal(new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY()));

        final double scale = calculateScale(scrollEvent);
        m_root.setScaleX(scale);
        m_root.setScaleY(scale);

        scrollTo(mousePos, scenePositionToCentreZoomAround);

        scrollEvent.consume();
    }
}
 
开发者ID:quiram,项目名称:build-hotspots,代码行数:17,代码来源:BuildHotspotsApplicationBase.java

示例4: wheelZoom

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/** Zoom in/out triggered by mouse wheel
 *  @param event Scroll event
 */
protected void wheelZoom(final ScrollEvent event)
{
    // Invoked by mouse scroll wheel.
    // Only allow zoom (with control), not pan.
    if (! event.isControlDown())
        return;

    if (event.getDeltaY() > 0)
        zoomInOut(event.getX(), event.getY(), 1.0/ZOOM_FACTOR);
    else if (event.getDeltaY() < 0)
        zoomInOut(event.getX(), event.getY(), ZOOM_FACTOR);
    else
        return;
    event.consume();
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:19,代码来源:PlotCanvasBase.java

示例5: onScrollStarted

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * When the user starts scrolling on the graph.
 *
 * @param scrollEvent {@link ScrollEvent} associated with the event
 */
@FXML
void onScrollStarted(final ScrollEvent scrollEvent) {
    ((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.CROSSHAIR);

    scrollEvent.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:12,代码来源:GraphController.java

示例6: onScroll

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * When the user scroll on the graph.
 *
 * @param scrollEvent {@link ScrollEvent} associated with the event
 */
@FXML
void onScroll(final ScrollEvent scrollEvent) {
    graphMovementCalculator.onScroll(-scrollEvent.getDeltaY());

    scrollEvent.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:12,代码来源:GraphController.java

示例7: onScrollFinished

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * When the user finished scrolling.
 *
 * @param scrollEvent {@link ScrollEvent} associated with the event
 */
@FXML
void onScrollFinished(final ScrollEvent scrollEvent) {
    ((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.DEFAULT);

    scrollEvent.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:12,代码来源:GraphController.java

示例8: handleScrollGesture

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
private void handleScrollGesture(ScrollEvent e) {
    // only react to proper panning gestures that not on the touch screen itself
    if ((!e.isDirect()) && !e.isInertia()) {
        if (this.panningAction != null) {
            if (preferences.getBoolean("invertScroll", false)) {
                this.panningAction.accept(-e.getDeltaX(), -e.getDeltaY());
            } else {
                this.panningAction.accept(e.getDeltaX(), e.getDeltaY());
            }
        }
    }
    
    e.consume();
}
 
开发者ID:viskell,项目名称:viskell,代码行数:15,代码来源:TouchContext.java

示例9: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
	if (scrollEvent.isControlDown()) {
		final double scale = calculateScale(scrollEvent);
		nodeToZoom.setScaleX(scale);
		nodeToZoom.setScaleY(scale);
		scrollEvent.consume();
	}
}
 
开发者ID:bdh92123,项目名称:share_all,代码行数:10,代码来源:RoomController.java

示例10: onScroll

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * Invoked if the mouse wheel is rotated.
 * <p>
 * Increments and decrements the value according to the mouse wheel.
 * 
 * @param pScrollEvent the event.
 */
private void onScroll(ScrollEvent pScrollEvent)
{
	if (pScrollEvent.getDeltaY() >= 0)
	{
		getControl().getValueFactory().increment((int)(pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY()));
	}
	else
	{
		// Minus is needed because the decrement step count needs to be positive.
		getControl().getValueFactory().decrement((int)(-pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY()));
	}
	
	pScrollEvent.consume();
}
 
开发者ID:ivartanian,项目名称:JVx.javafx,代码行数:22,代码来源:FXSpinnerBehaviorRT40623.java

示例11: onScroll

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
 * Invoked if the mouse wheel scrolls.
 * 
 * @param pScrollEvent the event.
 */
private void onScroll(ScrollEvent pScrollEvent)
{
	if (pScrollEvent.isControlDown())
	{
		pScrollEvent.consume();
		
		double turns = pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY();
		Point2D mousePoint = sceneToLocal(pScrollEvent.getSceneX(), pScrollEvent.getSceneY());
		
		zoom((int)turns, mousePoint.getX(), mousePoint.getY());
	}
}
 
开发者ID:ivartanian,项目名称:JVx.javafx,代码行数:18,代码来源:FXZoomRegion.java

示例12: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
    event.consume();
    if (event.getDeltaY() != 0) {
        double scaleFactor = (event.getDeltaY() > 0) ? SCALE_DELTA : 1 / SCALE_DELTA;
        node.adjustStaticTransform(new TransformMatrix(scaleFactor));
    }
}
 
开发者ID:kcoolsae,项目名称:Equi,代码行数:9,代码来源:ZoomHandler3D.java

示例13: handle

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
    if (scrollEvent.isControlDown()) {
        final double scale = calculateScale(scrollEvent);
        nodeToZoom.setScaleX(scale);
        nodeToZoom.setScaleY(scale);
        scrollEvent.consume();
    }
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:10,代码来源:ZoomApp.java

示例14: compositeTokenPane_OnScroll

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@FXML
void compositeTokenPane_OnScroll(ScrollEvent event) {
	// if event is touch enabled, skip this as it will be handled by onZoom & onRotate handlers
	if (event.isDirect())
		return;

	if (event.isShiftDown()) {
		// Note: OK, this is stupid but on Windows shift + mousewheel returns X delta but on Ubuntu it returns Y delta...
		double delta = event.getDeltaY();
		if (delta == 0)
			delta = event.getDeltaX();

		Double r = portraitImageView.getRotate() + delta / 20;

		if (r < -360d || r > 360d)
			r = 0d;

		portraitImageView.setRotate(r);
	} else {
		Double scale = portraitImageView.getScaleY() * Math.pow(1.001, event.getDeltaY());

		portraitImageView.setScaleX(scale);
		portraitImageView.setScaleY(scale);
	}

	event.consume();
	updateTokenPreviewImageView();
}
 
开发者ID:RPTools,项目名称:tokentool,代码行数:29,代码来源:TokenTool_Controller.java

示例15: mouseScroll

import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@FXML
  void mouseScroll(ScrollEvent event) {

  	event.consume();
  	final double diff = 0.1;

  	//scroll pane locations
  	final double h = scrollPaneLeft.getHvalue();
  	final double v = scrollPaneLeft.getVvalue();
  	
  	final double min = 400;
  	
  	if(event.getDeltaY()>0&&((imageLeft.getBoundsInParent().getWidth()<min)||
  			imageLeft.getBoundsInParent().getHeight()<min)) {
  		return;
  	}
  	
  	if(event.getDeltaY()<0) {
  		imageLeft.setScaleX(imageLeft.getScaleX()+diff);
  		imageLeft.setScaleY(imageLeft.getScaleY()+diff);
  	} else {
  		imageLeft.setScaleX(imageLeft.getScaleX()-diff);
  		imageLeft.setScaleY(imageLeft.getScaleY()-diff);
  	}
imageRight.setScaleX(imageLeft.getScaleX());
imageRight.setScaleY(imageLeft.getScaleY());

//just set the same ratio of scroll - this should work out mostly ok
     	scrollPaneLeft.setHvalue(h);
     	scrollPaneLeft.setVvalue(v);
     	
  }
 
开发者ID:bl-dpt,项目名称:dissimilar,代码行数:33,代码来源:DissimilarGUIThread.java


注:本文中的javafx.scene.input.ScrollEvent.consume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。