Java Code Examples for java.awt.event.MouseWheelEvent#getUnitsToScroll()
The following examples show how to use
java.awt.event.MouseWheelEvent#getUnitsToScroll() .
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: InteractiveCanvasComponent.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void mouseWheelMoved(MouseWheelEvent e) { // Mouse wheel zooming takes precedence over scrolling if (isMouseZoomingEnabled() && e.getSource() == InteractiveCanvasComponent.this) return; // Change the ScrollBar value 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 2
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 3
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 4
Source File: DrawingArea.java From VanetSim with GNU General Public License v3.0 | 6 votes |
/** * Listener for mouse scrolls. * * @param e the <code>MouseWheelEvent</code> * * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent) */ public void mouseWheelMoved(MouseWheelEvent e){ if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL && e.getUnitsToScroll() != 0){ int scrollValue = e.getUnitsToScroll(); double newzoom = renderer_.getMapZoom(); if(scrollValue > 0){ for(int i= 0; i < scrollValue; i+=3){ newzoom -= newzoom/ZOOM_VALUE; } } else { for(int i= 0; i > scrollValue; i-=3){ newzoom += newzoom/ZOOM_VALUE; } } renderer_.setMapZoom(newzoom); VanetSimStart.getMainControlPanel().getSimulatePanel().setZoomValue((int)Math.round(Math.log(renderer_.getMapZoom()*1000)*50)); ReRenderManager.getInstance().doReRender(); } }
Example 5
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 6
Source File: ScrollPaneWheelScroller.java From openjdk-jdk8u 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 7
Source File: ScrollPaneWheelScroller.java From jdk8u-dev-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: 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 9
Source File: ListHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static boolean doWheelScroll(XVerticalScrollbar vsb, XHorizontalScrollbar hsb, MouseWheelEvent e) { XScrollbar scroll = null; int wheelRotation; // Determine which, if any, sb to scroll if (vsb != null) { scroll = vsb; } else if (hsb != null) { scroll = hsb; } else { // Neither scrollbar is showing return false; } wheelRotation = e.getWheelRotation(); // Check if scroll is necessary if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) || (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) || wheelRotation != 0) { int type = e.getScrollType(); int incr; if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { incr = wheelRotation * scroll.getBlockIncrement(); } else { // type is WHEEL_UNIT_SCROLL incr = e.getUnitsToScroll() * scroll.getUnitIncrement(); } scroll.setValue(scroll.getValue() + incr); return true; } return false; }
Example 10
Source File: Panel3D.java From orson-charts with GNU General Public License v3.0 | 5 votes |
/** * Receives notification of a mouse wheel movement and responds by moving * the viewpoint in or out (zooming). * * @param mwe the mouse wheel event. */ @Override public void mouseWheelMoved(MouseWheelEvent mwe) { float units = mwe.getUnitsToScroll(); double maxViewingDistance = this.maxViewingDistanceMultiplier * this.minViewingDistance; double valRho = Math.max(this.minViewingDistance, Math.min(maxViewingDistance, this.drawable.getViewPoint().getRho() + units)); this.drawable.getViewPoint().setRho(valRho); repaint(); }
Example 11
Source File: CCSystem.java From FCMFrame with Apache License 2.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { int units = e.getUnitsToScroll(); double zoomx = distX / 100.0 * units; double zoomy = distY / 100.0 * units; zoom(zoomx, zoomy); repaint(); }
Example 12
Source File: ListHelper.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static boolean doWheelScroll(XVerticalScrollbar vsb, XHorizontalScrollbar hsb, MouseWheelEvent e) { XScrollbar scroll = null; int wheelRotation; // Determine which, if any, sb to scroll if (vsb != null) { scroll = vsb; } else if (hsb != null) { scroll = hsb; } else { // Neither scrollbar is showing return false; } wheelRotation = e.getWheelRotation(); // Check if scroll is necessary if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) || (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) || wheelRotation != 0) { int type = e.getScrollType(); int incr; if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { incr = wheelRotation * scroll.getBlockIncrement(); } else { // type is WHEEL_UNIT_SCROLL incr = e.getUnitsToScroll() * scroll.getUnitIncrement(); } scroll.setValue(scroll.getValue() + incr); return true; } return false; }
Example 13
Source File: GroundContainer.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (User.isNull()) { return; } /* * Turning with mouse wheel. Ignore all but the first to avoid flooding * the server with turn commands. */ logger.debug(e.getClickCount() + " click count and " + e.getScrollType() + " scroll type and wheel rotation " + e.getWheelRotation()); if (e.getClickCount() <= 1) { final User user = User.get(); Direction currentDirection = user.getDirection(); Direction newDirection = null; if (e.getUnitsToScroll() > 0) { // Turn right newDirection = currentDirection.nextDirection(); } else { // Turn left newDirection = currentDirection.nextDirection().oppositeDirection(); } if (newDirection != null && newDirection != currentDirection) { final RPAction turnAction = new RPAction(); turnAction.put(TYPE, FACE); turnAction.put(DIR, newDirection.get()); client.send(turnAction); } } }
Example 14
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 15
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 16
Source File: ZyEditModeMouseWheelListener.java From binnavi with Apache License 2.0 | 5 votes |
private void handleInMoveMode(final MouseWheelEvent event) { final boolean scrollDirection = event.getUnitsToScroll() > 0; if (event.isAltDown()) { moveVertical(scrollDirection); } else { moveHorizontal(scrollDirection); } }
Example 17
Source File: ListHelper.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static boolean doWheelScroll(XVerticalScrollbar vsb, XHorizontalScrollbar hsb, MouseWheelEvent e) { XScrollbar scroll = null; int wheelRotation; // Determine which, if any, sb to scroll if (vsb != null) { scroll = vsb; } else if (hsb != null) { scroll = hsb; } else { // Neither scrollbar is showing return false; } wheelRotation = e.getWheelRotation(); // Check if scroll is necessary if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) || (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) || wheelRotation != 0) { int type = e.getScrollType(); int incr; if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { incr = wheelRotation * scroll.getBlockIncrement(); } else { // type is WHEEL_UNIT_SCROLL incr = e.getUnitsToScroll() * scroll.getUnitIncrement(); } scroll.setValue(scroll.getValue() + incr); return true; } return false; }
Example 18
Source File: ListHelper.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static boolean doWheelScroll(XVerticalScrollbar vsb, XHorizontalScrollbar hsb, MouseWheelEvent e) { XScrollbar scroll = null; int wheelRotation; // Determine which, if any, sb to scroll if (vsb != null) { scroll = vsb; } else if (hsb != null) { scroll = hsb; } else { // Neither scrollbar is showing return false; } wheelRotation = e.getWheelRotation(); // Check if scroll is necessary if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) || (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) || wheelRotation != 0) { int type = e.getScrollType(); int incr; if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { incr = wheelRotation * scroll.getBlockIncrement(); } else { // type is WHEEL_UNIT_SCROLL incr = e.getUnitsToScroll() * scroll.getUnitIncrement(); } scroll.setValue(scroll.getValue() + incr); return true; } return false; }
Example 19
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 20
Source File: ListHelper.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static boolean doWheelScroll(XVerticalScrollbar vsb, XHorizontalScrollbar hsb, MouseWheelEvent e) { XScrollbar scroll = null; int wheelRotation; // Determine which, if any, sb to scroll if (vsb != null) { scroll = vsb; } else if (hsb != null) { scroll = hsb; } else { // Neither scrollbar is showing return false; } wheelRotation = e.getWheelRotation(); // Check if scroll is necessary if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) || (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) || wheelRotation != 0) { int type = e.getScrollType(); int incr; if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) { incr = wheelRotation * scroll.getBlockIncrement(); } else { // type is WHEEL_UNIT_SCROLL incr = e.getUnitsToScroll() * scroll.getUnitIncrement(); } scroll.setValue(scroll.getValue() + incr); return true; } return false; }