Java Code Examples for java.awt.event.MouseWheelEvent#isAltDown()

The following examples show how to use java.awt.event.MouseWheelEvent#isAltDown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VisualGraphScreenPositioningPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: ZyEditModeMouseWheelListener.java    From binnavi with Apache License 2.0 5 votes vote down vote up
private void handleInMoveMode(final MouseWheelEvent event) {
  final boolean scrollDirection = event.getUnitsToScroll() > 0;

  if (event.isAltDown()) {
    moveVertical(scrollDirection);
  } else {
    moveHorizontal(scrollDirection);
  }
}
 
Example 3
Source File: ProductSceneView.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: TimeSeriesMatrixTopComponent.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.isAltDown()) {
        Band nextBand = getNextBand(matrixModel.getBand(), e.getWheelRotation());
        if (nextBand != null) {
            matrixModel.setBand(nextBand);
            updateDateLabel(nextBand);
        }
    }
}
 
Example 5
Source File: VisualGraphScrollWheelPanningPlugin.java    From ghidra with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 6
Source File: EditorUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
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();
}