java.awt.event.MouseWheelEvent#getUnitsToScroll()源码实例Demo

下面列出了java.awt.event.MouseWheelEvent#getUnitsToScroll() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: darklaf   文件: DarkScrollableTabSupport.java
@Override
public void mouseWheelMoved(final MouseWheelEvent e) {
    if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0) return;
    int tabPosition = ui.tabPane.getTabPlacement();
    int scrollAmount = -1 * e.getUnitsToScroll() * e.getScrollAmount();
    int scrolled;
    if (tabPosition == SwingConstants.LEFT || tabPosition == SwingConstants.RIGHT) {
        if (e.isShiftDown() || !moreTabsButton.isVisible()) return;
        timer.stop();
        scrolled = scroll(scrollAmount, false);
    } else {
        if (!e.isShiftDown() || !moreTabsButton.isVisible()) return;
        timer.stop();
        scrolled = scroll(scrollAmount, true);
    }
    if (scrolled != 0) {
        showMoreTabsButton();
        updateRollover();
        viewport.repaint();
    }
    timer.start();
}
 
源代码2 项目: visualvm   文件: InteractiveCanvasComponent.java
public void mouseWheelMoved(MouseWheelEvent e) {
    // Mouse wheel zooming takes precedence over scrolling
    if (isMouseZoomingEnabled() &&
        e.getSource() == InteractiveCanvasComponent.this) return;

    // Change the ScrollBar value
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        int unitsToScroll = e.getUnitsToScroll();
        int direction = unitsToScroll < 0 ? -1 : 1;
        if (unitsToScroll != 0) {
            int increment = scrollBar.getUnitIncrement(direction);
            int oldValue = scrollBar.getValue();
            int newValue = oldValue + increment * unitsToScroll;
            newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
                    scrollBar.getVisibleAmount()), scrollBar.getMinimum());
            if (oldValue != newValue) scrollBar.setValue(newValue);
        }
    }
}
 
源代码3 项目: VanetSim   文件: DrawingArea.java
/**
 * Listener for mouse scrolls.
 * 
 * @param e	the <code>MouseWheelEvent</code>
 * 
 * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
 */
public void mouseWheelMoved(MouseWheelEvent e){
	if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL && e.getUnitsToScroll() != 0){
		int scrollValue = e.getUnitsToScroll();
		double newzoom = renderer_.getMapZoom();
		if(scrollValue > 0){
			for(int i= 0; i < scrollValue; i+=3){
				newzoom -= newzoom/ZOOM_VALUE;				
			}
		} else {
			for(int i= 0; i > scrollValue; i-=3){
				newzoom += newzoom/ZOOM_VALUE;				
			}
		}
		renderer_.setMapZoom(newzoom);
		VanetSimStart.getMainControlPanel().getSimulatePanel().setZoomValue((int)Math.round(Math.log(renderer_.getMapZoom()*1000)*50));
		ReRenderManager.getInstance().doReRender();
	}
}
 
源代码4 项目: jdk8u-jdk   文件: ScrollPaneWheelScroller.java
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;
}
 
源代码5 项目: openjdk-jdk8u   文件: ScrollPaneWheelScroller.java
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;
}
 
源代码6 项目: jdk8u-dev-jdk   文件: ScrollPaneWheelScroller.java
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;
}
 
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;
}
 
源代码8 项目: dragonwell8_jdk   文件: ListHelper.java
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
源代码9 项目: gcs   文件: DirectScrollPanel.java
@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());
    }
}
 
源代码10 项目: jdk8u60   文件: ListHelper.java
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
源代码11 项目: openjdk-jdk8u   文件: ListHelper.java
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
源代码12 项目: binnavi   文件: ZyEditModeMouseWheelListener.java
private void handleInMoveMode(final MouseWheelEvent event) {
  final boolean scrollDirection = event.getUnitsToScroll() > 0;

  if (event.isAltDown()) {
    moveVertical(scrollDirection);
  } else {
    moveHorizontal(scrollDirection);
  }
}
 
源代码13 项目: netbeans   文件: ProfilerTableContainer.java
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();
    }
}
 
源代码14 项目: netbeans   文件: JTreeTablePanel.java
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();
    }
}
 
源代码15 项目: stendhal   文件: GroundContainer.java
@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);
		}
	}
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: ListHelper.java
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
源代码17 项目: FCMFrame   文件: CCSystem.java
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    int units = e.getUnitsToScroll();

    double zoomx = distX / 100.0 * units;
    double zoomy = distY / 100.0 * units;

    zoom(zoomx, zoomy);

    repaint();
}
 
源代码18 项目: orson-charts   文件: Panel3D.java
/**
 * Receives notification of a mouse wheel movement and responds by moving
 * the viewpoint in or out (zooming).
 * 
 * @param mwe  the mouse wheel event. 
 */
@Override
public void mouseWheelMoved(MouseWheelEvent mwe) {
    float units = mwe.getUnitsToScroll();
    double maxViewingDistance = this.maxViewingDistanceMultiplier 
            * this.minViewingDistance;
    double valRho = Math.max(this.minViewingDistance, 
            Math.min(maxViewingDistance, 
            this.drawable.getViewPoint().getRho() + units));
    this.drawable.getViewPoint().setRho(valRho);
    repaint();
}
 
源代码19 项目: openjdk-jdk9   文件: ListHelper.java
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
源代码20 项目: visualvm   文件: ChartPanel.java
private static void scroll(JScrollBar scrollBar, MouseWheelEvent e) {
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        int unitsToScroll = e.getUnitsToScroll();
        int direction = unitsToScroll < 0 ? -1 : 1;
        if (unitsToScroll != 0) {
            int increment = scrollBar.getUnitIncrement(direction);
            int oldValue = scrollBar.getValue();
            int newValue = oldValue + increment * unitsToScroll;
            newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
                    scrollBar.getVisibleAmount()), scrollBar.getMinimum());
            if (oldValue != newValue) scrollBar.setValue(newValue);
        }
    }
}