Java Code Examples for java.awt.event.MouseWheelEvent#consume()
The following examples show how to use
java.awt.event.MouseWheelEvent#consume() .
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: InstanceMapInputListener.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public MouseWheelEvent mouseWheelMoved(MouseWheelEvent event) { if (!overlay.isMapShown() || isNotWithinOverlay(event.getPoint())) { return event; } int direction = event.getWheelRotation(); if (direction > 0) { plugin.ascendMap(); } else { plugin.descendMap(); } event.consume(); return event; }
Example 2
Source File: InstanceMapInputListener.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public MouseWheelEvent mouseWheelMoved(MouseWheelEvent event) { if (!overlay.isMapShown() || isNotWithinOverlay(event.getPoint())) { return event; } int direction = event.getWheelRotation(); if (direction > 0) { plugin.ascendMap(); } else { plugin.descendMap(); } event.consume(); return event; }
Example 3
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
public void handleWheel(final MouseWheelEvent event) { if (parent == null || !canvasBounds.contains(event.getPoint())) { return; } event.consume(); clientThread.invoke(() -> { if (isHidden()) { return; } scrollTab(event.getWheelRotation()); }); }
Example 4
Source File: ViewPortScrollListener.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public void mouseWheelMoved(MouseWheelEvent e) { if (recognitionFrame == null || recognitionFrame.get() == null) return; if (iFrame == null || iFrame.get() == null) return; if (!acceptTool(recognitionFrame.get().getSelectedTool())) return; iFrame.get().firePropertyChangeExt(ImageFrame.SCALE_EVENT, null, new Double(e.getWheelRotation())); e.consume(); //PropertyChangeEvent event = new PropertyChangeEvent(this, ImageFrame.SCALE_EVENT, null, e.getWheelRotation()); //iFrame.propertyChange(event); /* recognitionFrame.setOldScale(recognitionFrame.getScale()); double newScale = Math.max(1d,recognitionFrame.getScale()+e.getWheelRotation()*10d); recognitionFrame.setScale(newScale); recognitionFrame.scaleImage(newScale, iFrame); iFrame.adjustViewport(); */ /* if (scaleSlider!=null) { scaleSlider.setValue((int)newScale); scaleSlider.repaint(); } */ }
Example 5
Source File: Editor.java From brModelo with GNU General Public License v3.0 | 6 votes |
/** * Recebe o evento de MouseWheel do quadro de edição se não consumido. * * @param e */ public void ScrollMove(MouseWheelEvent e) { int x = parente.getHorizontalScrollBar().getValue(); int y = parente.getVerticalScrollBar().getValue(); int vpw = parente.getViewport().getWidth() - getMargem(); int vph = parente.getViewport().getHeight() - getMargem(); int p1 = e.getX() + getMargem() - x; int p2 = e.getY() + getMargem() - y; boolean ambos = (p2 > vph && p1 > vpw); p1 = vpw - (p1); p2 = vph - (p2); if (p1 < p2 || ambos) { parente.getVerticalScrollBar().setValue(y + 2 * e.getUnitsToScroll()); } if (p2 < p1 || ambos) { parente.getHorizontalScrollBar().setValue(x + 2 * e.getUnitsToScroll()); } e.consume(); }
Example 6
Source File: Tree.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent mwe) { final int modifiers = mwe.getModifiers(); if (0 == (MouseWheelEvent.SHIFT_MASK ^ modifiers)) { final Object source = mwe.getSource(); if (! (source instanceof DisplayCanvas)) return; final DisplayCanvas dc = (DisplayCanvas)source; final Layer la = dc.getDisplay().getLayer(); final int rotation = mwe.getWheelRotation(); final double magnification = dc.getMagnification(); final Rectangle srcRect = dc.getSrcRect(); final float x = (float)((mwe.getX() / magnification) + srcRect.x); final float y = (float)((mwe.getY() / magnification) + srcRect.y); adjustEdgeConfidence(rotation > 0 ? 1 : -1, x, y, la, dc); Display.repaint(this); mwe.consume(); } }
Example 7
Source File: Treeline.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent mwe) { final int modifiers = mwe.getModifiers(); if (0 == ( (MouseWheelEvent.SHIFT_MASK | MouseWheelEvent.ALT_MASK) ^ modifiers)) { final Object source = mwe.getSource(); if (! (source instanceof DisplayCanvas)) return; final DisplayCanvas dc = (DisplayCanvas)source; final Layer la = dc.getDisplay().getLayer(); final int rotation = mwe.getWheelRotation(); final float magnification = (float)dc.getMagnification(); final Rectangle srcRect = dc.getSrcRect(); final float x = ((mwe.getX() / magnification) + srcRect.x); final float y = ((mwe.getY() / magnification) + srcRect.y); final float inc = (rotation > 0 ? 1 : -1) * (1/magnification); if (null != adjustNodeRadius(inc, x, y, la, dc)) { Display.repaint(this); mwe.consume(); return; } } super.mouseWheelMoved(mwe); }
Example 8
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 6 votes |
public void handleWheel(final MouseWheelEvent event) { if (parent == null || !canvasBounds.contains(event.getPoint())) { return; } event.consume(); clientThread.invoke(() -> { if (isHidden()) { return; } scrollTab(event.getWheelRotation()); }); }
Example 9
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 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: SmoothScrollPaneUI.java From netbeans with Apache License 2.0 | 5 votes |
private void handleMouseWheelEvent(MouseWheelEvent evt, MouseWheelListener delegate) { if (scrollpane.isWheelScrollingEnabled() && evt.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { mouseWheelMoved(evt); evt.consume(); } else { delegate.mouseWheelMoved(evt); } }
Example 12
Source File: Diagrama.java From brModelo with GNU General Public License v3.0 | 5 votes |
public void mouseWheelMoved(MouseWheelEvent e) { if (e.isControlDown()) { if (e.getWheelRotation() < 0) { getEditor().ZoomMais(); } else { getEditor().ZoomMenos(); } e.consume(); } }
Example 13
Source File: ShapePainterListener.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
public void mouseWheelMoved(MouseWheelEvent e) { RecognitionFrame recognitionFrame = recognitionFrameRef.get(); if (recognitionFrame == null) return; if (!acceptTool(recognitionFrame.getSelectedTool())) return; if (shapeMode == ClassShape.SHAPETYPE_ARC || (shapeMode == ClassShape.SHAPETYPE_RECTANGLE && fixedRectangle)) { int newSize = Math.max(1, (int) recognitionFrame.getTargetRadius() + e.getWheelRotation()); recognitionFrame.setTargetRadius(newSize); OrbitImageAnalysis.getInstance().getSizeBox().setSelectedItem(new Integer(newSize)); //recognitionFrame.firePropertyChange("circleSizeChange", newSize); e.consume(); recognitionFrame.getForceRepaint().set(true); recognitionFrame.repaint(); } }
Example 14
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 15
Source File: ProfilerTableContainer.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 oldValue = scroller.getValue(); int newValue = oldValue + increment * amount * direction; if (oldValue != newValue) scroller.setValue(newValue); event.consume(); } }
Example 16
Source File: JTreeTablePanel.java From visualvm with GNU General Public License v2.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 17
Source File: MouseEventUI.java From darklaf with MIT License | 5 votes |
/** * Re-dispatches the event to the first component in the hierarchy that has a {@link MouseWheelListener} * registered. */ @Override protected void processMouseWheelEvent(final MouseWheelEvent event, final JXLayer<? extends V> jxlayer) { /* * Only process an event if it is not already consumed. This may be the * case if this LayerUI is contained in a wrapped hierarchy. */ if (!event.isConsumed()) { /* * Since we will create a new event, the argument event must be * consumed. */ event.consume(); /* * Find a target up in the hierarchy that has * MouseWheelEventListeners registered. */ Component target = event.getComponent(); Component newTarget = findWheelListenerComponent(target); if (newTarget == null) { newTarget = jxlayer.getParent(); } /* * Convert the location relative to the new target */ Point point = SwingUtilities.convertPoint(event.getComponent(), event.getPoint(), newTarget); /* * Create a new event and dispatch it. */ newTarget.dispatchEvent(createMouseWheelEvent(event, point, newTarget)); } }
Example 18
Source File: FlatScrollPaneUI.java From FlatLaf with Apache License 2.0 | 4 votes |
private void mouseWheelMovedSmooth( MouseWheelEvent e ) { // return if there is no viewport JViewport viewport = scrollpane.getViewport(); if( viewport == null ) return; // find scrollbar to scroll JScrollBar scrollbar = scrollpane.getVerticalScrollBar(); if( scrollbar == null || !scrollbar.isVisible() || e.isShiftDown() ) { scrollbar = scrollpane.getHorizontalScrollBar(); if( scrollbar == null || !scrollbar.isVisible() ) return; } // consume event e.consume(); // get precise wheel rotation double rotation = e.getPreciseWheelRotation(); // get unit and block increment int unitIncrement; int blockIncrement; int orientation = scrollbar.getOrientation(); Component view = viewport.getView(); if( view instanceof Scrollable ) { Scrollable scrollable = (Scrollable) view; // Use (0, 0) view position to obtain constant unit increment of first item // (which might otherwise be variable on smaller-than-unit scrolling). Rectangle visibleRect = new Rectangle( viewport.getViewSize() ); unitIncrement = scrollable.getScrollableUnitIncrement( visibleRect, orientation, 1 ); blockIncrement = scrollable.getScrollableBlockIncrement( visibleRect, orientation, 1 ); if( unitIncrement > 0 ) { // For the case that the first item (e.g. in a list) is larger // than the other items, get the unit increment of the second item // and use the smaller one. if( orientation == SwingConstants.VERTICAL ) { visibleRect.y += unitIncrement; visibleRect.height -= unitIncrement; } else { visibleRect.x += unitIncrement; visibleRect.width -= unitIncrement; } int unitIncrement2 = scrollable.getScrollableUnitIncrement( visibleRect, orientation, 1 ); if( unitIncrement2 > 0 ) unitIncrement = Math.min( unitIncrement, unitIncrement2 ); } } else { int direction = rotation < 0 ? -1 : 1; unitIncrement = scrollbar.getUnitIncrement( direction ); blockIncrement = scrollbar.getBlockIncrement( direction ); } // limit scroll amount (number of units to scroll) for small viewports // (e.g. vertical scrolling in file chooser) int scrollAmount = e.getScrollAmount(); int viewportWH = (orientation == SwingConstants.VERTICAL) ? viewport.getHeight() : viewport.getWidth(); if( unitIncrement * scrollAmount > viewportWH ) scrollAmount = Math.max( viewportWH / unitIncrement, 1 ); // compute relative delta double delta = rotation * scrollAmount * unitIncrement; boolean adjustDelta = Math.abs( rotation ) < (1.0 + EPSILON); double adjustedDelta = adjustDelta ? Math.max( -blockIncrement, Math.min( delta, blockIncrement ) ) : delta; // compute new value int value = scrollbar.getValue(); double minDelta = scrollbar.getMinimum() - value; double maxDelta = scrollbar.getMaximum() - scrollbar.getModel().getExtent() - value; double boundedDelta = Math.max( minDelta, Math.min( adjustedDelta, maxDelta ) ); int newValue = value + (int) Math.round( boundedDelta ); // set new value if( newValue != value ) scrollbar.setValue( newValue ); /*debug System.out.println( String.format( "%4d %9f / %4d %4d / %12f %5s %12f / %4d %4d %4d / %12f %12f %12f / %4d", e.getWheelRotation(), e.getPreciseWheelRotation(), unitIncrement, blockIncrement, delta, adjustDelta, adjustedDelta, value, scrollbar.getMinimum(), scrollbar.getMaximum(), minDelta, maxDelta, boundedDelta, newValue ) ); */ }
Example 19
Source File: ScrollingMenu.java From pumpernickel with MIT License | 4 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { increment(e.getWheelRotation()); e.consume(); }
Example 20
Source File: MenuScroller.java From jeveassets with GNU General Public License v2.0 | 4 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent mwe) { firstIndex += mwe.getWheelRotation(); mwe.consume(); refreshMenu(); }