Java Code Examples for java.awt.event.MouseWheelEvent

The following examples show how to use java.awt.event.MouseWheelEvent. These examples are extracted from open source projects. 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 Project: openstock   Source File: MouseWheelHandler.java    License: 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 2
Source Project: CQL   Source File: GuiUtil.java    License: 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 3
Source Project: openAGV   Source File: ViewDragScrollListener.java    License: 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 4
Source Project: AMIDST   Source File: MapViewer.java    License: 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 5
Source Project: zap-extensions   Source File: JScrollPopupMenu.java    License: 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 6
Source Project: Course_Generator   Source File: CgSpinner.java    License: 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 7
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 8
Source Project: Spade   Source File: PaintCanvas.java    License: 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 9
Source Project: scelight   Source File: MapCanvas.java    License: 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 10
Source Project: jdk8u-jdk   Source File: bug7170657.java    License: 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 11
Source Project: dragonwell8_jdk   Source File: bug7170657.java    License: 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 12
Source Project: Cafebabe   Source File: CFGraph.java    License: 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 13
Source Project: ECG-Viewer   Source File: MouseWheelHandler.java    License: 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 14
Source Project: TencentKona-8   Source File: bug7170657.java    License: 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
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
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 17
@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 18
Source Project: Ngram-Graphs   Source File: NavigableImagePanel.java    License: 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 19
Source Project: radiance   Source File: JCarosel.java    License: 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 20
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 21
Source Project: jdk8u-jdk   Source File: CPlatformResponder.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void dispatchScrollEvent(final int x, final int y,
                                 final int modifiers, final double delta) {
    final long when = System.currentTimeMillis();
    final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL;
    final int scrollAmount = 1;
    int wheelRotation = (int) delta;
    int signum = (int) Math.signum(delta);
    if (signum * delta < 1) {
        wheelRotation = signum;
    }
    // invert the wheelRotation for the peer
    eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType,
            scrollAmount, -wheelRotation, -delta, null);
}
 
Example 22
Source Project: gcs   Source File: DirectScrollPanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@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 23
Source Project: stendhal   Source File: GroundContainer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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 24
Source Project: jdk8u-jdk   Source File: LWScrollPanePeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handleEvent(AWTEvent e) {
    if (e instanceof MouseWheelEvent) {
        MouseWheelEvent wheelEvent = (MouseWheelEvent) e;
        //java.awt.ScrollPane consumes the event
        // in case isWheelScrollingEnabled() is true,
        // forcibly send the consumed event to the delegate
        if (getTarget().isWheelScrollingEnabled() && wheelEvent.isConsumed()) {
            sendEventToDelegate(wheelEvent);
        }
    } else {
        super.handleEvent(e);
    }
}
 
Example 25
Source Project: constellation   Source File: HistogramDisplay.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    final JViewport scrollpane = (JViewport) getParent();
    final Point pos = scrollpane.getViewPosition();
    final int y;
    final int SCROLL_HEIGHT = 50;
    if (e.getWheelRotation() < 0) {
        y = pos.y - (e.getScrollAmount() * SCROLL_HEIGHT);
    } else {
        y = pos.y + (e.getScrollAmount() * SCROLL_HEIGHT);
    }

    scrollpane.setViewPosition(new Point(0, Math.max(0, y)));
}
 
Example 26
Source Project: openstock   Source File: MouseWheelHandler.java    License: 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 27
Source Project: openjdk-8   Source File: WComponentPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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 Project: pumpernickel   Source File: JEyeDropper.java    License: MIT License 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	if (e.getWheelRotation() < 0) {
		getZoomInAction().actionPerformed(
				new ActionEvent(ContentButton.this, 0,
						ACTION_MAP_KEY_ZOOM_IN));
	} else if (e.getWheelRotation() > 0) {
		getZoomOutAction().actionPerformed(
				new ActionEvent(ContentButton.this, 0,
						ACTION_MAP_KEY_ZOOM_OUT));
	}
}
 
Example 29
Source Project: buffer_bci   Source File: MouseWheelHandler.java    License: 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 Project: zxpoly   Source File: MainFrame.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void mainEditorPanelMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
  if (this.selectAreaMode) {
    this.selectAreaMode = false;
    this.mainEditor.resetSelectArea();
  } else if (evt.getModifiersEx() == MouseWheelEvent.CTRL_DOWN_MASK) {
    if (evt.getWheelRotation() < 0) {
      this.mainEditor.zoomIn();
    } else {
      this.mainEditor.zoomOut();
    }
  }
  updateBottomBar();
}