當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。