Java Code Examples for java.awt.event.MouseWheelEvent#isControlDown()
The following examples show how to use
java.awt.event.MouseWheelEvent#isControlDown() .
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: ViewDragScrollListener.java From openAGV with Apache License 2.0 | 6 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isControlDown()) { int zoomLevel = zoomComboBox.getSelectedIndex(); int notches = e.getWheelRotation(); if (zoomLevel != -1) { if (notches < 0) { if (zoomLevel > 0) { zoomLevel--; zoomComboBox.setSelectedIndex(zoomLevel); } } else { if (zoomLevel < zoomComboBox.getItemCount() - 1) { zoomLevel++; zoomComboBox.setSelectedIndex(zoomLevel); } } } } }
Example 2
Source File: ZyEditModeMouseWheelListener.java From binnavi with Apache License 2.0 | 6 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent event) { final int ticks = Math.abs(event.getUnitsToScroll()); // When the user holds down control, we switch between the two modes final boolean changeMode = event.isControlDown(); for (int i = 0; i < ticks; ++i) { if (((m_zyGraph.getSettings().getMouseSettings().getMouseWheelAction() == MouseWheelAction.ZOOM) && !changeMode) || ((m_zyGraph.getSettings().getMouseSettings().getMouseWheelAction() == MouseWheelAction.SCROLL) && changeMode)) { handleInZoomMode(event); } else { handleInMoveMode(event); } } m_zyGraph.updateViews(); }
Example 3
Source File: Java3DEditor.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 5 votes |
private void mouseWheel(MouseWheelEvent e) { if (!e.isControlDown()) { if (e.getWheelRotation() < 0 && currentLayer < maxLayer - 1) { currentLayer++; } if (e.getWheelRotation() > 0 && currentLayer > 0) { currentLayer--; } setCurrentLayer(currentLayer); } else { scaleByAmount(e.getUnitsToScroll() * -0.1); } }
Example 4
Source File: ERDesignerGraphUI.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isControlDown()) { if (e.getWheelRotation() < 0) { erdesigner.commandZoomOneLevelIn(); } else { erdesigner.commandZoomOneLevelOut(); } } }
Example 5
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 6
Source File: Rubber.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Called when the mouse wheel is moved. * If CTRL key is down, modify current zoom ratio accordingly, otherwise * forward the wheel event to proper container (JScrollPane usually). * * @param e the mouse wheel event */ @Override public void mouseWheelMoved (MouseWheelEvent e) { // CTRL is down? if (e.isControlDown()) { double ratio = zoom.getRatio(); if (e.getWheelRotation() > 0) { ratio /= factor; } else { ratio *= factor; } zoom.setRatio(ratio); } else { // Forward event to some container of the component? Container container = component.getParent(); while (container != null) { if (container instanceof JComponent) { JComponent comp = (JComponent) container; MouseWheelListener[] listeners = comp.getMouseWheelListeners(); if (listeners.length > 0) { for (MouseWheelListener listener : listeners) { listener.mouseWheelMoved(e); } return; } } container = container.getParent(); } } }
Example 7
Source File: VideoController.java From zxpoly with GNU General Public License v3.0 | 5 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent e) { if (e.isControlDown()) { final float newzoom; if (e.getPreciseWheelRotation() > 0) { newzoom = Math.max(1.0f, this.zoom - 0.2f); } else { newzoom = Math.min(5.0f, this.zoom + 0.2f); } if (newzoom != this.zoom) { updateZoom(newzoom); } } }
Example 8
Source File: Rubber.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * Called when the mouse wheel is moved. * If CTRL key is down, modify current zoom ratio accordingly, otherwise * forward the wheel event to proper container (JScrollPane usually). * * @param e the mouse wheel event */ @Override public void mouseWheelMoved (MouseWheelEvent e) { // CTRL is down? if (e.isControlDown()) { double ratio = zoom.getRatio(); if (e.getWheelRotation() > 0) { ratio /= factor; } else { ratio *= factor; } zoom.setRatio(ratio); } else { // Forward event to some container of the component? Container container = component.getParent(); while (container != null) { if (container instanceof JComponent) { JComponent comp = (JComponent) container; MouseWheelListener[] listeners = comp.getMouseWheelListeners(); if (listeners.length > 0) { for (MouseWheelListener listener : listeners) { listener.mouseWheelMoved(e); } return; } } container = container.getParent(); } } }
Example 9
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 10
Source File: ProductSceneView.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isAltDown() || e.isAltGraphDown() || e.isControlDown() || e.isShiftDown()) { return; } Viewport viewport = layerCanvas.getViewport(); int wheelRotation = e.getWheelRotation(); if (invertZooming) { wheelRotation *= -1; } double oldZoomFactor = viewport.getZoomFactor(); double newZoomFactor = oldZoomFactor * Math.pow(1.1, wheelRotation); viewport.setZoomFactor(newZoomFactor); }
Example 11
Source File: ProcessPanelScroller.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public void mouseWheelMoved(final MouseWheelEvent e) { if (e.isControlDown() && e.getWheelRotation() != 0) { double oldZoomFactor = rendererView.getModel().getZoomFactor(); if (e.getWheelRotation() < 0) { rendererView.getModel().zoomIn(); } else { rendererView.getModel().zoomOut(); } rendererView.getModel().fireProcessZoomChanged(); // calculate how the scrollbar needs to be adjusted for centered zoom double relativeZoomFactor = rendererView.getModel().getZoomFactor() / oldZoomFactor; double differenceHorizontal = e.getPoint().getX() * (relativeZoomFactor - 1); double differenceVertical = e.getPoint().getY() * (relativeZoomFactor - 1); int newX = Math.max(0, (int) (scrollPane.getHorizontalScrollBar().getValue() + differenceHorizontal)); int newY = Math.max(0, (int) (scrollPane.getVerticalScrollBar().getValue() + differenceVertical)); scrollPane.getHorizontalScrollBar().setValue(newX); scrollPane.getVerticalScrollBar().setValue(newY); // prevent flickering when another adjustment of the scrollbars is needed RepaintManager.currentManager(scrollPane).markCompletelyClean(scrollPane); /** * Setting the value as above does not always work since the scrollbars are not yet * updated to the size changes caused by the zooming. Set flag an values to try * again after the resizing happened. */ zoomed = true; desiredVerticalScrollValue = newY; desiredHorizontalScrollValue = newX; return; } Container p = rendererView.getParent(); if (p != null) { p.dispatchEvent(SwingUtilities.convertMouseEvent(rendererView, e, p)); } }
Example 12
Source File: EditorUtil.java From consulo with Apache License 2.0 | 4 votes |
public static boolean isChangeFontSize(@Nonnull MouseWheelEvent e) { if (e.getWheelRotation() == 0) return false; return SystemInfo.isMac ? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown() : e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown(); }