javafx.scene.input.ScrollEvent#getDeltaY ( )源码实例Demo

下面列出了javafx.scene.input.ScrollEvent#getDeltaY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openstock   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码2 项目: mzmine3   文件: Fx3DStageController.java
/**
 * @param event Zooms in and out when the mouse is scrolled.
 */
public void onScrollHandler(ScrollEvent event) {
  double delta = 1.2;
  double scale = (plot.getScaleX());

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

  scale = clamp(scale, MIN_SCALE, MAX_SCALE);

  plot.setScaleX(scale);
  plot.setScaleY(scale);

  event.consume();
}
 
源代码3 项目: chart-fx   文件: Zoomer.java
private static void zoomOnAxis(final Axis axis, final ScrollEvent event) {
    if (hasBoundedRange(axis)) {
        return;
    }
    final boolean isZoomIn = event.getDeltaY() > 0;
    final boolean isHorizontal = axis.getSide().isHorizontal();

    final double mousePos = isHorizontal ? event.getX() : event.getY();
    final double posOnAxis = axis.getValueForDisplay(mousePos);
    final double max = axis.getMax();
    final double min = axis.getMin();
    final double scaling = isZoomIn ? 0.9 : 1 / 0.9;
    final double diffHalf1 = scaling * Math.abs(posOnAxis - min);
    final double diffHalf2 = scaling * Math.abs(max - posOnAxis);

    axis.set(posOnAxis - diffHalf1, posOnAxis + diffHalf2);

    axis.forceRedraw();
}
 
源代码4 项目: phoebus   文件: PlotCanvasBase.java
/** 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();
}
 
源代码5 项目: TAcharting   文件: TaScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(TaChartCanvas canvas, Zoomable zoomable,
                            ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's org.sjwimmer.tacharting.data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    }
}
 
源代码6 项目: ccu-historian   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码7 项目: buffer_bci   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码8 项目: SIMVA-SoS   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码9 项目: mzmine2   文件: Fx3DStageController.java
/**
 * @param event
 *            Zooms in and out when the mouse is scrolled.
 */
public void onScrollHandler(ScrollEvent event) {
    double delta = 1.2;
    double scale = (plot.getScaleX());

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

    scale = clamp(scale, MIN_SCALE, MAX_SCALE);

    plot.setScaleX(scale);
    plot.setScaleY(scale);

    event.consume();
}
 
源代码10 项目: ECG-Viewer   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码11 项目: buffer_bci   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码12 项目: constellation   文件: TimelineChart.java
public void performZoom(final ScrollEvent se, final double mouseX) {
    final double range = upperTimeExtent - lowerTimeExtent;
    final double width = parent.getWidth();
    // Register the event as a ScrollEvent:

    // Zoom on scrolling events:
    if (se.getEventType() == ScrollEvent.SCROLL) {
        // Determine the scale here:
        final double quantum = range / 10.0;
        final double msMouse = lowerTimeExtent + ((mouseX * (upperTimeExtent - lowerTimeExtent)) / width);

        // We are zooming in:
        if (se.getDeltaY() > 0d) {
            // Only zoom in if we haven't reached the minimum size:
            if (quantum >= 0.5) {
                lowerTimeExtent = (msMouse - ((msMouse - lowerTimeExtent) * 0.9)); // Zoom in by 10%
                upperTimeExtent = (msMouse + ((upperTimeExtent - msMouse) * 0.9));

                // update the scope window:
                parent.coordinator.setExtents(lowerTimeExtent, upperTimeExtent);
            }
        } else { // We are zooming out:
            if (quantum <= YEAR * 10d) {
                lowerTimeExtent = (long) (msMouse - ((msMouse - lowerTimeExtent) * 1.1)); // Zoom out by 10%
                upperTimeExtent = (long) (msMouse + ((upperTimeExtent - msMouse) * 1.1));

                // update the scope window:
                parent.coordinator.setExtents((long) lowerTimeExtent, (long) upperTimeExtent);
            }
        }
    }
}
 
源代码13 项目: oim-fx   文件: WebViewEventDispatcher.java
private void processScrollEvent(ScrollEvent ev) {
    if (page == null) {
        return;
    }
    double dx = - ev.getDeltaX() * webView.getFontScale() * webView.getScaleX();
    double dy = - ev.getDeltaY() * webView.getFontScale() * webView.getScaleY();
    WCMouseWheelEvent wheelEvent =
            new WCMouseWheelEvent((int)ev.getX(), (int)ev.getY(),
                (int)ev.getScreenX(), (int)ev.getScreenY(),
                System.currentTimeMillis(),
                ev.isShiftDown(), ev.isControlDown(), ev.isAltDown(),
                ev.isMetaDown(), (float)dx, (float)dy);
    page.dispatchMouseWheelEvent(wheelEvent);
    ev.consume();
}
 
源代码14 项目: fxgraph   文件: ViewportGestures.java
@Override
public void handle(ScrollEvent event) {
	double scale = canvas.getScale(); // currently we only use Y, same value is used for X
	final double oldScale = scale;

	if(event.getDeltaY() < 0) {
		scale /= getZoomSpeed();
	} else if (event.getDeltaY() > 0) {
		scale *= getZoomSpeed();
	}

	scale = clamp(scale, minScaleProperty.get(), maxScaleProperty.get());
	final double f = (scale / oldScale) - 1;

	// maxX = right overhang, maxY = lower overhang
	final double maxX = canvas.getBoundsInParent().getMaxX() - canvas.localToParent(canvas.getPrefWidth(), canvas.getPrefHeight()).getX();
	final double maxY = canvas.getBoundsInParent().getMaxY() - canvas.localToParent(canvas.getPrefWidth(), canvas.getPrefHeight()).getY();

	// minX = left overhang, minY = upper overhang
	final double minX = canvas.localToParent(0, 0).getX() - canvas.getBoundsInParent().getMinX();
	final double minY = canvas.localToParent(0, 0).getY() - canvas.getBoundsInParent().getMinY();

	// adding the overhangs together, as we only consider the width of canvas itself
	final double subX = maxX + minX;
	final double subY = maxY + minY;

	// subtracting the overall overhang from the width and only the left and upper overhang from the upper left point
	final double dx = (event.getSceneX() - ((canvas.getBoundsInParent().getWidth() - subX) / 2 + (canvas.getBoundsInParent().getMinX() + minX)));
	final double dy = (event.getSceneY() - ((canvas.getBoundsInParent().getHeight() - subY) / 2 + (canvas.getBoundsInParent().getMinY() + minY)));

	canvas.setScale(scale);

	// note: pivot value must be untransformed, i. e. without scaling
	canvas.setPivot(f * dx, f * dy);

	event.consume();

}
 
源代码15 项目: jfreechart-fx   文件: ScrollHandlerFX.java
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param canvas  the chart canvas.
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
	if (canvas.getChart() == null) {
	    return;
	}
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
源代码16 项目: gef   文件: PanOrZoomOnScrollHandler.java
/**
 * Computes the translation for the given {@link ScrollEvent}. The
 * horizontal and vertical translation is inverted when
 * {@link #isPanDirectionSwapped(ScrollEvent)} returns <code>true</code>.
 *
 * @param event
 *            The original {@link ScrollEvent}.
 * @return A {@link Dimension} storing the horizontal and vertical
 *         translation.
 */
protected Dimension computePanTranslation(ScrollEvent event) {
	double dx = event.getDeltaX();
	double dy = event.getDeltaY();
	if (isPanDirectionSwapped(event)) {
		double t = dx;
		dx = dy;
		dy = t;
	}
	return new Dimension(dx, dy);
}
 
源代码17 项目: DeskChan   文件: MouseEventNotificator.java
/**
 * Use this method to process a scroll event and send a special GUI event by the means of the message system.
 * @param event ScrollEvent
 */
void notifyScrollEvent(ScrollEvent event) {
    int delta = (event.getDeltaY() > 0) ? -1 : 1;
    impl_notifyScrollEvent(delta, event.getScreenX(), event.getScreenY(), event.getX(), event.getY());
}
 
源代码18 项目: SONDY   文件: InfluenceAnalysisUI.java
public final VBox createNetworkVisualization(){
    System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
    Viewer viewer = new Viewer(AppParameters.authorNetwork, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    view = viewer.addDefaultView(false); 
    viewer.enableAutoLayout();
    view.resizeFrame(Main.columnWidthLEFT, 290);
    swingNode = new CustomSwingNode();
    swingNode.setContent(view);
    swingNode.resize(Main.columnWidthLEFT, 290);
    EventHandler<MouseEvent> mouseHandlerGraphClick = new EventHandler<MouseEvent>() { 
        @Override 
        public void handle(MouseEvent mouseEvent) { 
            if (mouseEvent.getEventType() == MouseEvent.MOUSE_PRESSED) {
                if(mouseEvent.getButton() == MouseButton.SECONDARY){
                    Node node = (Node) view.findNodeOrSpriteAt(mouseEvent.getX(), mouseEvent.getY());
                    if(node != null){
                        userMessages(node.getId());
                    }
                }
                if(mouseEvent.getButton() == MouseButton.PRIMARY){
                    double translateCoeff = view.getCamera().getViewPercent();
                    Point3 center = view.getCamera().getViewCenter();
                    if(mouseEvent.getY()>175){
                        view.getCamera().setViewCenter(center.x, center.y-5*translateCoeff, center.z);
                    }else{
                        view.getCamera().setViewCenter(center.x, center.y+5*translateCoeff, center.z);
                    }
                    if(mouseEvent.getX()>275){
                        view.getCamera().setViewCenter(center.x+5*translateCoeff, center.y, center.z);
                    }else{
                        view.getCamera().setViewCenter(center.x-5*translateCoeff, center.y, center.z);
                    }
                }
                if(mouseEvent.getButton() == MouseButton.MIDDLE){
                    view.getCamera().setViewPercent(view.getCamera().getViewPercent()/2);
                }
            }
        }
    };   
    EventHandler<ScrollEvent> mouseHandlerGraphScroll = new EventHandler<ScrollEvent>() { 
        @Override
        public void handle(ScrollEvent event) {
            if(event.getDeltaY() < 0){
                view.getCamera().setViewPercent(view.getCamera().getViewPercent()*2);
            }else{
                view.getCamera().setViewPercent(view.getCamera().getViewPercent()/2);
            }
        }
    };   
    swingNode.setOnMousePressed(mouseHandlerGraphClick);
    swingNode.setOnScroll(mouseHandlerGraphScroll);
    VBox graphBox = new VBox();
    graphBox.getChildren().addAll(new Rectangle(Main.columnWidthLEFT,0),swingNode);
    initializeNetworkVisualizationStyle();
    return graphBox;
}
 
源代码19 项目: jfxutils   文件: ChartZoomManager.java
@Override
public void handle( ScrollEvent event ) {
	EventType<? extends Event> eventType = event.getEventType();
	if ( eventType == ScrollEvent.SCROLL_STARTED ) {
		//mouse wheel events never send SCROLL_STARTED
		ignoring = true;
	} else if ( eventType == ScrollEvent.SCROLL_FINISHED ) {
		//end non-mouse wheel event
		ignoring = false;

	} else if ( eventType == ScrollEvent.SCROLL &&
	            //If we are allowing mouse wheel zooming
	            mouseWheelZoomAllowed.get() &&
	            //If we aren't between SCROLL_STARTED and SCROLL_FINISHED
	            !ignoring &&
	            //inertia from non-wheel gestures might have touch count of 0
	            !event.isInertia() &&
	            //Only care about vertical wheel events
	            event.getDeltaY() != 0 &&
	            //mouse wheel always has touch count of 0
	            event.getTouchCount() == 0 ) {

		//Find out which axes to zoom based on the strategy
		double eventX = event.getX();
		double eventY = event.getY();
		DefaultChartInputContext context = new DefaultChartInputContext( chartInfo, eventX, eventY );
		AxisConstraint zoomMode = mouseWheelAxisConstraintStrategy.getConstraint( context );

		if ( zoomMode == AxisConstraint.None )
			return;

		//If we are are doing a zoom animation, stop it. Also of note is that we don't zoom the
		//mouse wheel zooming. Because the mouse wheel can "fly" and generate a lot of events,
		//animation doesn't work well. Plus, as the mouse wheel changes the view a small amount in
		//a predictable way, it "looks like" an animation when you roll it.
		//We might experiment with mouse wheel zoom animation in the future, though.
		zoomAnimation.stop();

		//At this point we are a mouse wheel event, based on everything I've read
		Point2D dataCoords = chartInfo.getDataCoordinates( eventX, eventY );

		//Determine the proportion of change to the lower and upper bounds based on how far the
		//cursor is along the axis.
		double xZoomBalance = getBalance( dataCoords.getX(),
		                                  getXAxisLowerBound(), getXAxisUpperBound() );
		double yZoomBalance = getBalance( dataCoords.getY(),
		                                  getYAxisLowerBound(), getYAxisUpperBound() );

		//Are we zooming in or out, based on the direction of the roll
		double direction = -Math.signum( event.getDeltaY() );

		//TODO: Do we need to handle "continuous" scroll wheels that don't work based on ticks?
		//If so, the 0.2 needs to be modified
		double zoomAmount = 0.2 * direction;

		if ( zoomMode == AxisConstraint.Both || zoomMode == AxisConstraint.Horizontal ) {
			double xZoomDelta = ( getXAxisUpperBound() - getXAxisLowerBound() ) * zoomAmount;
			xAxis.setAutoRanging( false );
			setXAxisLowerBound( getXAxisLowerBound() - xZoomDelta * xZoomBalance );
			setXAxisUpperBound( getXAxisUpperBound() + xZoomDelta * ( 1 - xZoomBalance ) );
		}

		if ( zoomMode == AxisConstraint.Both || zoomMode == AxisConstraint.Vertical ) {
			double yZoomDelta = ( getYAxisUpperBound() - getYAxisLowerBound() ) * zoomAmount;
			yAxis.setAutoRanging( false );
			setYAxisLowerBound( getYAxisLowerBound() - yZoomDelta * yZoomBalance );
			setYAxisUpperBound( getYAxisUpperBound() + yZoomDelta * ( 1 - yZoomBalance ) );
		}
	}
}
 
源代码20 项目: gef   文件: PanOrZoomOnScrollHandler.java
/**
 * Computes the zoom factor from the given {@link ScrollEvent}.
 *
 * @param event
 *            The {@link ScrollEvent} from which to compute the zoom factor.
 * @return The zoom factor according to the given {@link ScrollEvent}.
 */
protected double computeZoomFactor(ScrollEvent event) {
	return event.getDeltaY() > 0 ? 1.05 : 1 / 1.05;
}