java.awt.event.MouseWheelEvent#isAltDown()源码实例Demo

下面列出了java.awt.event.MouseWheelEvent#isAltDown() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	int eventModifiers = e.getModifiers();
	boolean controlKeyDown = (eventModifiers & DockingUtils.CONTROL_KEY_MODIFIER_MASK) != 0;
	if (!controlKeyDown) {
		return;
	}

	int wheelRotation = -e.getWheelRotation();
	int offset = wheelRotation * 10;

	Point newPoint = new Point(0, offset);

	if (e.isAltDown()) {
		// control-alt is a horizontal pan
		newPoint.setLocation(offset, 0);
	}

	VisualGraphViewUpdater<V, E> updater = getViewUpdater(e);
	updater.moveViewerLocationWithoutAnimation(newPoint);
}
 
源代码2 项目: binnavi   文件: ZyEditModeMouseWheelListener.java
private void handleInMoveMode(final MouseWheelEvent event) {
  final boolean scrollDirection = event.getUnitsToScroll() > 0;

  if (event.isAltDown()) {
    moveVertical(scrollDirection);
  } else {
    moveHorizontal(scrollDirection);
  }
}
 
源代码3 项目: snap-desktop   文件: ProductSceneView.java
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.isAltDown() || e.isAltGraphDown() || e.isControlDown() || e.isShiftDown()) {
        return;
    }
    Viewport viewport = layerCanvas.getViewport();
    int wheelRotation = e.getWheelRotation();
    if (invertZooming) {
        wheelRotation *= -1;
    }
    double oldZoomFactor = viewport.getZoomFactor();
    double newZoomFactor = oldZoomFactor * Math.pow(1.1, wheelRotation);
    viewport.setZoomFactor(newZoomFactor);
}
 
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.isAltDown()) {
        Band nextBand = getNextBand(matrixModel.getBand(), e.getWheelRotation());
        if (nextBand != null) {
            matrixModel.setBand(nextBand);
            updateDateLabel(nextBand);
        }
    }
}
 
private void pan(MouseWheelEvent e) {
	GraphViewer<V, E> viewer = getGraphViewer(e);

	//
	// Number of 'units' by which to scroll.  This is defined by the OS and is usually
	// something like 'lines of text'.
	//
	int scrollAmount = 1;
	if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
		scrollAmount = e.getScrollAmount();
	}

	//
	// The amount the mouse wheel has been rotated.  By default this is usually 1, but 
	// users can change how the OS accelerates mouse scrolling.
	//
	int wheelRotation = -e.getWheelRotation();

	//
	// A magic magnification amount.  This was chosen by testing on a few platforms.
	//
	int arbitraryAcceleration = 10;

	//
	// The scale of the current graph.  We need to change the scroll amount when scaled out
	// so that we don't end up with tiny scrolling when zoomed out.
	//		
	Double scale = GraphViewerUtils.getGraphScale(viewer);
	int unscaledOffset = wheelRotation * scrollAmount * arbitraryAcceleration;
	int offset = (int) (unscaledOffset * (1 / scale));

	Point newPoint = new Point(0, offset);

	if (e.isAltDown()) {
		// control-alt is a horizontal pan
		newPoint.setLocation(offset, 0);
	}

	VisualGraphViewUpdater<V, E> updater = viewer.getViewUpdater();
	updater.moveViewerLocationWithoutAnimation(newPoint);
}
 
源代码6 项目: consulo   文件: EditorUtil.java
public static boolean isChangeFontSize(@Nonnull MouseWheelEvent e) {
  if (e.getWheelRotation() == 0) return false;
  return SystemInfo.isMac ? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown() : e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown();
}