java.awt.event.MouseWheelEvent Java Examples

The following examples show how to use java.awt.event.MouseWheelEvent. 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: MapCanvas.java    From scelight with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link MapCanvas}.
 * 
 * @param repProc replay processor
 * @param zoomComboBox combo box which tells how to zoom the map image
 */
public MapCanvas( final RepProcessor repProc, final XComboBox< Zoom > zoomComboBox ) {
	this.repProc = repProc;
	this.zoomComboBox = zoomComboBox;
	
	ricon = MapImageCache.getMapImage( repProc );
	
	GuiUtils.makeComponentDragScrollable( this );
	
	// Zoom in and out with CTRL+wheel scroll:
	addMouseWheelListener( new MouseWheelListener() {
		@Override
		public void mouseWheelMoved( final MouseWheelEvent event ) {
			if ( event.isControlDown() ) {
				final int newZoomIdx = zoomComboBox.getSelectedIndex() - event.getWheelRotation();
				zoomComboBox.setSelectedIndex( Math.max( 0, Math.min( zoomComboBox.getItemCount() - 1, newZoomIdx ) ) );
				// An event will be fired which will cause reconfigureZoom() to be called...
			}
		}
	} );
}
 
Example #2
Source File: MouseWheelHandler.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #3
Source File: GuiUtil.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
public void mouseWheelMoved(MouseWheelEvent e) {
	JScrollPane parent = getParentScrollPane();
	if (parent != null) {
		/*
		 * Only dispatch if we have reached top/bottom on previous scroll
		 */
		if (e.getWheelRotation() < 0) {
			if (bar.getValue() == 0 && previousValue == 0) {
				parent.dispatchEvent(cloneEvent(e));
			}
		} else {
			if (bar.getValue() == getMax() && previousValue == getMax()) {
				parent.dispatchEvent(cloneEvent(e));
			}
		}
		previousValue = bar.getValue();
	}
	/*
	 * If parent scrollpane doesn't exist, remove this as a listener. We have to
	 * defer this till now (vs doing it in constructor) because in the constructor
	 * this item has no parent yet.
	 */
	else {
		PDControlScrollPane.this.removeMouseWheelListener(this);
	}
}
 
Example #4
Source File: JCarosel.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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 #5
Source File: EquationDisplay.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void mouseWheelMoved(MouseWheelEvent e) {
    double distanceX = maxX - minX;
    double distanceY = maxY - minY;
    
    double cursorX = minX + distanceX / 2.0;
    double cursorY = minY + distanceY / 2.0;
    
    int rotation = e.getWheelRotation();
    if (rotation < 0) {
        distanceX /= COEFF_ZOOM;
        distanceY /= COEFF_ZOOM;
    } else {
        distanceX *= COEFF_ZOOM;
        distanceY *= COEFF_ZOOM;
    }
    
    minX = cursorX - distanceX / 2.0;
    maxX = cursorX + distanceX / 2.0;
    minY = cursorY - distanceY / 2.0;
    maxY = cursorY + distanceY / 2.0;

    repaint();
}
 
Example #6
Source File: NavigableImagePanel.java    From Ngram-Graphs with Apache License 2.0 6 votes vote down vote up
public void mouseWheelMoved(MouseWheelEvent e) {
	Point p = e.getPoint();
	boolean zoomIn = (e.getWheelRotation() < 0);
	if (isInNavigationImage(p)) {
		if (zoomIn) {
			navZoomFactor = 1.0 + zoomIncrement;
		} else {
			navZoomFactor = 1.0 - zoomIncrement;
		}
		zoomNavigationImage();
	} else if (isInImage(p)) {
		if (zoomIn) {
			zoomFactor = 1.0 + zoomIncrement;
		} else {
			zoomFactor = 1.0 - zoomIncrement;
		}
		zoomImage();
	}
}
 
Example #7
Source File: ChartGestureMouseAdapter.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOUSE_WHEEL))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.MOUSE_WHEEL, button)));
  }
}
 
Example #8
Source File: ScrollPaneWheelScroller.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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: ScrollPaneWheelScroller.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #10
Source File: ViewDragScrollListener.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: MapViewer.java    From AMIDST with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	int notches = e.getWheelRotation();
	Point mouse = e.getPoint(); // Don't use getMousePosition() because when computer is swapping/grinding, mouse may have moved out of window before execution reaches here.
	for (Widget widget : widgets) {
		if ((widget.isVisible()) &&
			(mouse.x > widget.getX()) &&
			(mouse.y > widget.getY()) &&
			(mouse.x < widget.getX() + widget.getWidth()) &&
			(mouse.y < widget.getY() + widget.getHeight())) {
			if (widget.onMouseWheelMoved(mouse.x - widget.getX(), mouse.y - widget.getY(), notches))
				return;
		}
	}
	adjustZoom(getMousePosition(), notches);
}
 
Example #12
Source File: MouseWheelHandler.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #13
Source File: PaintCanvas.java    From Spade with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e)
{
	int sign = e.getWheelRotation();
	
	if(sign < 0)
	{
		this.cam_zoom_increase();
		return;
	}
	
	if(sign > 0)
	{
		this.cam_zoom_decrease();
		return;
	}
}
 
Example #14
Source File: bug7170657.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example #15
Source File: ScrollPaneWheelScroller.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #16
Source File: CgSpinner.java    From Course_Generator with GNU General Public License v3.0 6 votes vote down vote up
public CgSpinner(int start, int min, int max, int step) {
	super();
	this.min = min;
	this.max = max;
	this.step = step;

	model = new SpinnerNumberModel(start, // initial value
			min, // min
			max, // max
			step); // step
	setModel(model);

	addMouseWheelListener(new MouseWheelListener() {
		public void mouseWheelMoved(MouseWheelEvent mwe) {
			MouseWheelAction(mwe.getWheelRotation());
		}
	});

	// Center
	JSpinner.DefaultEditor spinnerEditor = (JSpinner.DefaultEditor) this.getEditor();
	spinnerEditor.getTextField().setHorizontalAlignment(JTextField.CENTER);
}
 
Example #17
Source File: bug7170657.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example #18
Source File: CFGraph.java    From Cafebabe with GNU General Public License v3.0 6 votes vote down vote up
public CFGComponent(mxGraph g) {
	super(g);
	this.getViewport().setBackground(Color.WHITE);
	this.setEnabled(false);
	this.setBorder(new EmptyBorder(0, 0, 0, 0));
	this.setZoomFactor(1.1);
	this.getGraphControl().addMouseWheelListener(new MouseWheelListener() {
		@Override
		public void mouseWheelMoved(MouseWheelEvent e) {
			if (e.isControlDown()) {
				if (e.getWheelRotation() < 0) {
					zoomIn();
				} else {
					zoomOut();
				}
				repaint();
				revalidate();
			} else if (scp != null) {
				// do we need this on linux too?
				scp.getVerticalScrollBar().setValue(scp.getVerticalScrollBar().getValue()
						+ e.getUnitsToScroll() * scp.getVerticalScrollBar().getUnitIncrement());
			}
		}
	});
}
 
Example #19
Source File: JScrollPopupMenu.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public JScrollPopupMenu(String label) {
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener() {
        @Override public void mouseWheelMoved(MouseWheelEvent event) {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL)
                         ? event.getUnitsToScroll() * scrollBar.getUnitIncrement()
                         : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
 
Example #20
Source File: bug7170657.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example #21
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Clones a {@link MouseEvent}.
 *
 * @param event       The event to clone.
 * @param refreshTime Pass in {@code true} to generate a new time stamp.
 * @return The new {@link MouseEvent}.
 */
public static final MouseEvent cloneMouseEvent(MouseEvent event, boolean refreshTime) {
    if (event instanceof MouseWheelEvent) {
        MouseWheelEvent old = (MouseWheelEvent) event;
        return new MouseWheelEvent((Component) old.getSource(), old.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), old.getModifiersEx(), old.getX(), old.getY(), old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation());
    }
    return new MouseEvent((Component) event.getSource(), event.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), event.getModifiersEx(), event.getX(), event.getY(), event.getClickCount(), event.isPopupTrigger());
}
 
Example #22
Source File: SessionScroller.java    From tn5250j with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
  if (this.screen != null) {
    int notches = e.getWheelRotation();
    if (notches < 0) {
      screen.sendKeys(PAGE_UP);
    } else {
      screen.sendKeys(PAGE_DOWN);
    }
  }
}
 
Example #23
Source File: SmoothScrollPaneUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected MouseWheelListener createMouseWheelListener() {
    final MouseWheelListener delegate = super.createMouseWheelListener();
    return new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent evt) {
            handleMouseWheelEvent(evt, delegate);
        }
    };
}
 
Example #24
Source File: JExtendedSpinner.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void configureWheelListener() {
    addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) return;
            Object newValue = (e.getWheelRotation() < 0 ?
                               JExtendedSpinner.this.getNextValue() :
                               JExtendedSpinner.this.getPreviousValue());
            if (newValue != null) JExtendedSpinner.this.setValue(newValue);
        }
    });
}
 
Example #25
Source File: Canvas.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {// zoom mouse wheel
	if (e.getPreciseWheelRotation() < 0) {
		proj.getFrame().getZoomControl().spinnerModel
				.setValue(proj.getFrame().getZoomControl().spinnerModel.getNextValue());
	} else if (e.getPreciseWheelRotation() > 0) {
		proj.getFrame().getZoomControl().spinnerModel
				.setValue(proj.getFrame().getZoomControl().spinnerModel.getPreviousValue());
	}
}
 
Example #26
Source File: WComponentPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
    int id = e.getID();

    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
        ((Component)target).isEnabled())
    {
        if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
            handleJavaMouseEvent((MouseEvent) e);
        } else if (e instanceof KeyEvent) {
            if (handleJavaKeyEvent((KeyEvent)e)) {
                return;
            }
        }
    }

    switch(id) {
        case PaintEvent.PAINT:
            // Got native painting
            paintPending = false;
            // Fallthrough to next statement
        case PaintEvent.UPDATE:
            // Skip all painting while layouting and all UPDATEs
            // while waiting for native paint
            if (!isLayouting && ! paintPending) {
                paintArea.paint(target,shouldClearRectBeforePaint());
            }
            return;
        case FocusEvent.FOCUS_LOST:
        case FocusEvent.FOCUS_GAINED:
            handleJavaFocusEvent((FocusEvent)e);
        default:
        break;
    }

    // Call the native code
    nativeHandleEvent(e);
}
 
Example #27
Source File: WComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
    int id = e.getID();

    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
        ((Component)target).isEnabled())
    {
        if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
            handleJavaMouseEvent((MouseEvent) e);
        } else if (e instanceof KeyEvent) {
            if (handleJavaKeyEvent((KeyEvent)e)) {
                return;
            }
        }
    }

    switch(id) {
        case PaintEvent.PAINT:
            // Got native painting
            paintPending = false;
            // Fallthrough to next statement
        case PaintEvent.UPDATE:
            // Skip all painting while layouting and all UPDATEs
            // while waiting for native paint
            if (!isLayouting && ! paintPending) {
                paintArea.paint(target,shouldClearRectBeforePaint());
            }
            return;
        case FocusEvent.FOCUS_LOST:
        case FocusEvent.FOCUS_GAINED:
            handleJavaFocusEvent((FocusEvent)e);
        default:
        break;
    }

    // Call the native code
    nativeHandleEvent(e);
}
 
Example #28
Source File: VisualGraphScrollWheelPanningPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	if (!isScrollModifiers(e)) {
		return;
	}

	pan(e);
}
 
Example #29
Source File: MouseWheelHandler.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
    if (!pinfo.getDataArea().contains(p)) {
        return;
    }

    Plot plot = (Plot) zoomable;
    // do not notify while zooming each axis
    boolean notifyState = plot.isNotify();
    plot.setNotify(false);
    int clicks = e.getWheelRotation();
    double zf = 1.0 + this.zoomFactor;
    if (clicks < 0) {
        zf = 1.0 / zf;
    }
    if (chartPanel.isDomainZoomable()) {
        zoomable.zoomDomainAxes(zf, pinfo, p, true);
    }
    if (chartPanel.isRangeZoomable()) {
        zoomable.zoomRangeAxes(zf, pinfo, p, true);
    }
    plot.setNotify(notifyState);  // this generates the change event too
}
 
Example #30
Source File: Display.java    From osm-lib with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    int x = e.getX();
    int y = e.getY();
    // TODO metersPerPixel *= (1 + (0.1 * e.getWheelRotation()));
    double scale = 1 + (0.05 * e.getWheelRotation());
    wgsWindow.setRect(wgsWindow.getX(), wgsWindow.getY(),
            wgsWindow.getWidth() * scale, wgsWindow.getHeight() * scale);
    repaint();
}