Java Code Examples for java.awt.event.MouseWheelEvent#getScrollAmount()
The following examples show how to use
java.awt.event.MouseWheelEvent#getScrollAmount() .
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: ScrollPaneWheelScroller.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 2
Source File: ScrollPaneWheelScroller.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 3
Source File: ScrollPaneWheelScroller.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 4
Source File: DarkScrollableTabSupport.java From darklaf with MIT License | 6 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent e) { if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0) return; int tabPosition = ui.tabPane.getTabPlacement(); int scrollAmount = -1 * e.getUnitsToScroll() * e.getScrollAmount(); int scrolled; if (tabPosition == SwingConstants.LEFT || tabPosition == SwingConstants.RIGHT) { if (e.isShiftDown() || !moreTabsButton.isVisible()) return; timer.stop(); scrolled = scroll(scrollAmount, false); } else { if (!e.isShiftDown() || !moreTabsButton.isVisible()) return; timer.stop(); scrolled = scroll(scrollAmount, true); } if (scrolled != 0) { showMoreTabsButton(); updateRollover(); viewport.repaint(); } timer.start(); }
Example 5
Source File: ScrollPaneWheelScroller.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 6
Source File: ScrollPaneWheelScroller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 7
Source File: ScrollPaneWheelScroller.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 8
Source File: ScrollPaneWheelScroller.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 9
Source File: ScrollPaneWheelScroller.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource()); } int increment = 0; if (sp != null && e.getScrollAmount() != 0) { Adjustable adj = getAdjustableToScroll(sp); if (adj != null) { increment = getIncrementFromAdjustable(adj, e); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment); } scrollAdjustable(adj, increment); } } }
Example 10
Source File: UIUtilities.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Clones a {@link MouseEvent}. * * @param event The event to clone. * @param refreshTime Pass in {@code true} to generate a new time stamp. * @return The new {@link MouseEvent}. */ public static final MouseEvent cloneMouseEvent(MouseEvent event, boolean refreshTime) { if (event instanceof MouseWheelEvent) { MouseWheelEvent old = (MouseWheelEvent) event; return new MouseWheelEvent((Component) old.getSource(), old.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), old.getModifiersEx(), old.getX(), old.getY(), old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation()); } return new MouseEvent((Component) event.getSource(), event.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), event.getModifiersEx(), event.getX(), event.getY(), event.getClickCount(), event.isPopupTrigger()); }
Example 11
Source File: UIUtilities.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Clones a {@link MouseEvent}. * * @param event The event to clone. * @return The new {@link MouseEvent}. */ public static final MouseEvent cloneMouseEvent(MouseEvent event) { if (event instanceof MouseWheelEvent) { MouseWheelEvent old = (MouseWheelEvent) event; return new MouseWheelEvent((Component) old.getSource(), old.getID(), System.currentTimeMillis(), old.getModifiersEx(), old.getX(), old.getY(), old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation()); } return new MouseEvent((Component) event.getSource(), event.getID(), System.currentTimeMillis(), event.getModifiersEx(), event.getX(), event.getY(), event.getClickCount(), event.isPopupTrigger()); }
Example 12
Source File: JEditTextArea.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) { if (mouseWheelEvent.getScrollAmount() == 0) { return; } vertical.setValue(vertical.getValue() + 3 * mouseWheelEvent.getWheelRotation()); }
Example 13
Source File: MouseWheelTest.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void mouseWheelMoved (MouseWheelEvent e) { /* * java.awt.event.MouseWheelEvent * [MOUSE_WHEEL,(628,24),absolute(0,0),button=0,modifiers=Ctrl,extModifiers=Ctrl,clickCount=0,scrollType=WHEEL_UNIT_SCROLL,scrollAmount=3,wheelRotation=-1] * on javax.swing.JPanel[,0,0,800x30,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=] */ //System.out.println("e: " + e); int scrollAmount = e.getScrollAmount(); int scrollType = e.getScrollType(); int unitsToScroll = e.getUnitsToScroll(); int wheelRotation = e.getWheelRotation(); boolean ctrl = e.isControlDown(); // System.out.println( // "CTRL:" + ctrl + " amount:" + scrollAmount + " type:" + scrollType + // " units:" + unitsToScroll + " rotation:" + wheelRotation); if (ctrl) { double val = slider.getDoubleValue(); System.out.println("val:" + val); if (wheelRotation > 0) { val /= factor; } else { val *= factor; } System.out.println(" val:" + val); slider.setDoubleValue(val); } }
Example 14
Source File: ProfilerTableContainer.java From netbeans with Apache License 2.0 | 5 votes |
private static void scroll(JScrollBar scroller, MouseWheelEvent event) { if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int direction = event.getUnitsToScroll() < 0 ? -1 : 1; int increment = scroller.getUnitIncrement(direction); int amount = event.getScrollAmount(); int oldValue = scroller.getValue(); int newValue = oldValue + increment * amount * direction; if (oldValue != newValue) scroller.setValue(newValue); event.consume(); } }
Example 15
Source File: SmoothScrollPaneUI.java From netbeans with Apache License 2.0 | 5 votes |
private void mouseWheelMoved(MouseWheelEvent e) { /* The code in this method is taken directly from Pavel Fatin's original IntelliJ patch. Some formatting changes have been applied. */ /* The shift modifier will be enabled for horizontal touchbar scroll events, even when the actual shift key is not pressed, on both Windows and MacOS (though not on Java 8 on Windows). */ JScrollBar scrollbar = e.isShiftDown() ? scrollpane.getHorizontalScrollBar() : scrollpane.getVerticalScrollBar(); int orientation = scrollbar.getOrientation(); JViewport viewport = scrollpane.getViewport(); if (viewport == null || !(viewport.getView() instanceof Scrollable)) { return; } Scrollable view = (Scrollable) viewport.getView(); double rotation = e.getPreciseWheelRotation(); /* Use (0, 0) view position to obtain constant unit increment (which might otherwise be variable on smaller-than-unit scrolling). */ Rectangle r = new Rectangle(new Point(0, 0), viewport.getViewSize()); int unitIncrement = view.getScrollableUnitIncrement(r, orientation, 1); double delta = rotation * e.getScrollAmount() * unitIncrement; boolean limitDelta = Math.abs(rotation) < 1.0d + EPSILON; int blockIncrement = view.getScrollableBlockIncrement(r, orientation, 1); double adjustedDelta = limitDelta ? Math.max(-(double) blockIncrement, Math.min(delta, (double) blockIncrement)) : delta; int value = scrollbar.getValue(); int newValue = Math.max(scrollbar.getMinimum(), Math.min((int) Math.round(value + adjustedDelta), scrollbar.getMaximum())); if (newValue != value) { scrollbar.setValue(newValue); } }
Example 16
Source File: MouseEventUI.java From darklaf with MIT License | 5 votes |
private MouseWheelEvent createMouseWheelEvent(final MouseWheelEvent mouseWheelEvent, final Point point, final Component target) { return new MouseWheelEvent(target, mouseWheelEvent.getID(), mouseWheelEvent.getWhen(), mouseWheelEvent.getModifiersEx(), point.x, point.y, mouseWheelEvent.getClickCount(), mouseWheelEvent.isPopupTrigger(), mouseWheelEvent.getScrollType(), mouseWheelEvent.getScrollAmount(), mouseWheelEvent.getWheelRotation()); }
Example 17
Source File: VisualGraphScrollWheelPanningPlugin.java From ghidra with Apache License 2.0 | 4 votes |
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 18
Source File: DesktopEditorMarkupModelImpl.java From consulo with Apache License 2.0 | 4 votes |
public void mouseWheelMoved(MouseWheelEvent e) { if (myEditorPreviewHint == null) return; myWheelAccumulator += (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL ? e.getUnitsToScroll() * e.getScrollAmount() : e.getWheelRotation() < 0 ? -e.getScrollAmount() : e.getScrollAmount()); myRowAdjuster = myWheelAccumulator / myEditor.getLineHeight(); showToolTipByMouseMove(e); }
Example 19
Source File: CustomScrollPane.java From PacketProxy with Apache License 2.0 | 4 votes |
private MouseWheelEvent cloneEvent(MouseWheelEvent e) { return new MouseWheelEvent(getParentScrollPane(), e.getID(), e .getWhen(), e.getModifiers(), 1, 1, e .getClickCount(), false, e.getScrollType(), e .getScrollAmount(), e.getWheelRotation()); }
Example 20
Source File: UIUtilities.java From gcs with Mozilla Public License 2.0 | 3 votes |
/** * Clones a {@link MouseEvent}. * * @param event The event to clone. * @param source Pass in a new source. * @param where Pass in a new location. * @param refreshTime Pass in {@code true} to generate a new time stamp. * @return The new {@link MouseEvent}. */ public static final MouseEvent cloneMouseEvent(MouseEvent event, Component source, Point where, boolean refreshTime) { if (event instanceof MouseWheelEvent) { MouseWheelEvent old = (MouseWheelEvent) event; return new MouseWheelEvent(source, old.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), old.getModifiersEx(), where.x, where.y, old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation()); } return new MouseEvent(source, event.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), event.getModifiersEx(), where.x, where.y, event.getClickCount(), event.isPopupTrigger()); }