Java Code Examples for java.awt.event.MouseWheelListener#mouseWheelMoved()

The following examples show how to use java.awt.event.MouseWheelListener#mouseWheelMoved() . 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: SmoothScrollPaneUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void handleMouseWheelEvent(MouseWheelEvent evt, MouseWheelListener delegate) {
    if (scrollpane.isWheelScrollingEnabled() &&
        evt.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL)
    {
        mouseWheelMoved(evt);
        evt.consume();
    } else {
        delegate.mouseWheelMoved(evt);
    }
}
 
Example 2
Source File: Rubber.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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 3
Source File: MouseWheelController.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Redispatch a {@link MouseWheelEvent} to the real {@link MouseWheelListener MouseWheelListeners}
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	//  Create an altered event to redispatch
	if (scrollAmount != 0) {
		e = createScrollAmountEvent(e);
	}

	//  Redispatch the event to original MouseWheelListener
	for (MouseWheelListener mwl : realListeners) {
		mwl.mouseWheelMoved(e);
	}
}
 
Example 4
Source File: Rubber.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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();
        }
    }
}