Java Code Examples for java.awt.event.MouseWheelEvent#WHEEL_UNIT_SCROLL
The following examples show how to use
java.awt.event.MouseWheelEvent#WHEEL_UNIT_SCROLL .
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: FlatScrollPaneUI.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override protected MouseWheelListener createMouseWheelListener() { return new BasicScrollPaneUI.MouseWheelHandler() { @Override public void mouseWheelMoved( MouseWheelEvent e ) { // Note: Getting UI value "ScrollPane.smoothScrolling" here to allow // applications to turn smooth scrolling on or off at any time // (e.g. in application options dialog). if( UIManager.getBoolean( "ScrollPane.smoothScrolling" ) && scrollpane.isWheelScrollingEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL && e.getPreciseWheelRotation() != 0 && e.getPreciseWheelRotation() != e.getWheelRotation() ) { mouseWheelMovedSmooth( e ); } else super.mouseWheelMoved( e ); } }; }
Example 2
Source File: ScrollPaneWheelScroller.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 3
Source File: ScrollPaneWheelScroller.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 4
Source File: ScrollPaneWheelScroller.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 5
Source File: ScrollPaneWheelScroller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 6
Source File: JCarosel.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * When event received will spin the carousel to select the next object. * Because the wheel can be spun quicker than the carousel animates it keeps * track of the target (so the user may have selected something three * components away, althought the animation has not yet finished moving past * the first comopnent) * * @param mouseWheelEvent * The event object */ public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) { if (mouseWheelEvent.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int amount = mouseWheelEvent.getWheelRotation(); if (lastWheeledTo == null) { lastWheeledTo = getFrontmost(); } int lastPosition = layout.getComponentIndex(lastWheeledTo); int frontMostPosition = layout.getComponentIndex(getComponent(0)); // Don't over spin if (Math.abs(lastPosition - frontMostPosition) > layout .getComponentCount() / 4) { return; } if (amount > 0) { lastWheeledTo = layout.getPreviousComponent(lastWheeledTo); } else { lastWheeledTo = layout.getNextComponent(lastWheeledTo); } bringToFront(lastWheeledTo); } }
Example 7
Source File: ScrollPaneWheelScroller.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 8
Source File: ScrollPaneWheelScroller.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static int getIncrementFromAdjustable(Adjustable adj, MouseWheelEvent e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (adj == null) { log.fine("Assertion (adj != null) failed"); } } int increment = 0; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { increment = e.getUnitsToScroll() * adj.getUnitIncrement(); } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { increment = adj.getBlockIncrement() * e.getWheelRotation(); } return increment; }
Example 9
Source File: DebuggingViewComponent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { JScrollBar scrollBar = mainScrollPane.getVerticalScrollBar(); if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int totalScrollAmount = (int) (e.getPreciseWheelRotation() * e.getScrollAmount() * scrollBar.getUnitIncrement()); scrollBar.setValue(scrollBar.getValue() + totalScrollAmount); } }
Example 10
Source File: JTreeTablePanel.java From netbeans with Apache License 2.0 | 5 votes |
private static void scroll(final JScrollBar scroller, final MouseWheelEvent event) { if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int unitsToScroll = event.getUnitsToScroll(); int direction = unitsToScroll < 0 ? -1 : 1; if (unitsToScroll != 0) { int increment = scroller.getUnitIncrement(direction); int oldValue = scroller.getValue(); int newValue = oldValue + increment * unitsToScroll; newValue = Math.max(Math.min(newValue, scroller.getMaximum() - scroller.getVisibleAmount()), scroller.getMinimum()); if (oldValue != newValue) scroller.setValue(newValue); } event.consume(); } }
Example 11
Source File: ChartPanel.java From netbeans with Apache License 2.0 | 5 votes |
private static void scroll(JScrollBar scrollBar, MouseWheelEvent e) { if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int unitsToScroll = e.getUnitsToScroll(); int direction = unitsToScroll < 0 ? -1 : 1; if (unitsToScroll != 0) { int increment = scrollBar.getUnitIncrement(direction); int oldValue = scrollBar.getValue(); int newValue = oldValue + increment * unitsToScroll; newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() - scrollBar.getVisibleAmount()), scrollBar.getMinimum()); if (oldValue != newValue) scrollBar.setValue(newValue); } } }
Example 12
Source File: CPlatformResponder.java From hottub with GNU General Public License v2.0 | 5 votes |
private void dispatchScrollEvent(final int x, final int y, final int modifiers, final double delta) { final long when = System.currentTimeMillis(); final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL; final int scrollAmount = 1; int wheelRotation = (int) delta; int signum = (int) Math.signum(delta); if (signum * delta < 1) { wheelRotation = signum; } // invert the wheelRotation for the peer eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType, scrollAmount, -wheelRotation, -delta, null); }
Example 13
Source File: DirectScrollPanel.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent event) { if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int amt = event.getUnitsToScroll(); JScrollBar bar = event.isShiftDown() ? mHSB : mVSB; bar.setValue(bar.getValue() + amt * bar.getUnitIncrement()); } }
Example 14
Source File: JBinaryViewer.java From freeinternals with Apache License 2.0 | 5 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent e) { switch (e.getScrollType()) { case MouseWheelEvent.WHEEL_UNIT_SCROLL: JBinaryViewer.this.vBar.setValue( JBinaryViewer.this.vBar.getValue() + e.getUnitsToScroll()); break; case MouseWheelEvent.WHEEL_BLOCK_SCROLL: break; default: break; } }
Example 15
Source File: CPlatformResponder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void dispatchScrollEvent(final int x, final int y, final int modifiers, final double delta) { final long when = System.currentTimeMillis(); final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL; final int scrollAmount = 1; int wheelRotation = (int) delta; int signum = (int) Math.signum(delta); if (signum * delta < 1) { wheelRotation = signum; } // invert the wheelRotation for the peer eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType, scrollAmount, -wheelRotation, -delta, null); }
Example 16
Source File: ChartPanel.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static void scroll(JScrollBar scrollBar, MouseWheelEvent e) { if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int unitsToScroll = e.getUnitsToScroll(); int direction = unitsToScroll < 0 ? -1 : 1; if (unitsToScroll != 0) { int increment = scrollBar.getUnitIncrement(direction); int oldValue = scrollBar.getValue(); int newValue = oldValue + increment * unitsToScroll; newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() - scrollBar.getVisibleAmount()), scrollBar.getMinimum()); if (oldValue != newValue) scrollBar.setValue(newValue); } } }
Example 17
Source File: JavaOverviewSummary.java From visualvm with GNU General Public License v2.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 amount = 1; int oldValue = scroller.getValue(); int newValue = oldValue + increment * amount * direction; if (oldValue != newValue) scroller.setValue(newValue); event.consume(); } }
Example 18
Source File: CPlatformResponder.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void dispatchScrollEvent(final int x, final int y, final int modifiers, final int roundDelta, final double delta) { final long when = System.currentTimeMillis(); final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL; final int scrollAmount = 1; // invert the wheelRotation for the peer eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType, scrollAmount, -roundDelta, -delta, null); }
Example 19
Source File: CPlatformResponder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void dispatchScrollEvent(final int x, final int y, final int modifiers, final double delta) { final long when = System.currentTimeMillis(); final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL; final int scrollAmount = 1; int wheelRotation = (int) delta; int signum = (int) Math.signum(delta); if (signum * delta < 1) { wheelRotation = signum; } // invert the wheelRotation for the peer eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType, scrollAmount, -wheelRotation, -delta, null); }
Example 20
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); }