Java Code Examples for java.awt.event.MouseWheelEvent#SHIFT_MASK
The following examples show how to use
java.awt.event.MouseWheelEvent#SHIFT_MASK .
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: CsvTableEditorMouseWheelListenerTest.java From intellij-csv-validator with Apache License 2.0 | 6 votes |
public void testHorizontalScrollingOnCsvTable() { CsvTableEditorSwing fileEditor = Mockito.spy(this.fileEditor); MouseWheelEvent wheelEvent = new MouseWheelEvent(fileEditor.getTable(), MouseWheelEvent.MOUSE_WHEEL,JComponent.WHEN_FOCUSED, MouseWheelEvent.SHIFT_MASK,0,0,0,false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1,1); CsvTableEditorMouseWheelListener spiedMouseWheelListener = fileEditor.tableEditorMouseWheelListener; int hScrollValue = fileEditor.getTableScrollPane().getVerticalScrollBar().getValue(); int vScrollValue = fileEditor.getTableScrollPane().getHorizontalScrollBar().getValue(); assertEquals(0, hScrollValue); assertEquals(0, vScrollValue); spiedMouseWheelListener.mouseWheelMoved(wheelEvent); hScrollValue = fileEditor.getTableScrollPane().getVerticalScrollBar().getValue(); vScrollValue = fileEditor.getTableScrollPane().getHorizontalScrollBar().getValue(); // 90 is max in this case assertEquals(0, hScrollValue); assertEquals(90, vScrollValue); }
Example 2
Source File: JavaOverviewSummary.java From visualvm with GNU General Public License v2.0 | 6 votes |
HorizontalScroller(JComponent view) { super(view, VERTICAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_AS_NEEDED); setBorder(BorderFactory.createEmptyBorder()); setViewportBorder(BorderFactory.createEmptyBorder()); getViewport().setOpaque(false); setOpaque(false); super.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getModifiers() == MouseWheelEvent.SHIFT_MASK) { scroll(getHorizontalScrollBar(), e); } else { getParent().dispatchEvent(e); } } }); }
Example 3
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 4
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(); } }