Search this API

y.view
Class Graph2DViewMouseWheelScrollListener

java.lang.Object
  extended by y.view.Graph2DViewMouseWheelScrollListener
All Implemented Interfaces:
java.awt.event.MouseWheelListener, java.util.EventListener

public class Graph2DViewMouseWheelScrollListener
extends java.lang.Object
implements java.awt.event.MouseWheelListener

Scrolls a Graph2DView's view port in vertical or horizontal direction in response to mouse wheel events.

Instances of this class should be registered as a listener for mouse wheel events using method addToCanvas(Graph2DView).

See Also:
Graph2DViewMouseWheelZoomListener
 

Constructor Summary
Graph2DViewMouseWheelScrollListener()
          Initializes a new Graph2DViewMouseWheelScrollListener instance.
 
Method Summary
 void addToCanvas(Graph2DView view)
          Adds this listener to the set of listeners that are notified of mouse wheel events for the specified view.
 int getHorizontalScrollingModifierMask()
          Returns the modifier mask that switches from vertical scrolling to horizontal scrolling.
 boolean isSmartScrollingEnabled()
          Determines whether or not smart scrolling should be used.
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
          Scrolls the view port of the Graph2DView associated to the specified mouse wheel event in an appropriate direction.
 void removeFromCanvas(Graph2DView view)
          Removes this listener from the set of listeners that are notified of mouse wheel events for the specified view.
 void setHorizontalScrollingModifierMask(int mask)
          Specifies the modifier mask that switches from vertical scrolling to horizontal scrolling.
 void setSmartScrollingEnabled(boolean enabled)
          Specifies whether or not smart scrolling should be used.
protected  boolean shouldScrollHorizontally(java.awt.event.MouseWheelEvent e)
          Determines if the specified mouse wheel event should result in horizontal scrolling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph2DViewMouseWheelScrollListener

public Graph2DViewMouseWheelScrollListener()
Initializes a new Graph2DViewMouseWheelScrollListener instance.

Method Detail

addToCanvas

public void addToCanvas(Graph2DView view)
Adds this listener to the set of listeners that are notified of mouse wheel events for the specified view. Invoking this method is equivalent to:
view.getCanvasComponent().addMouseWheelListener(this);

Parameters:
view - the Graph2DView instance whose mouse wheel events should be handled by this listener.
See Also:
removeFromCanvas(Graph2DView)

removeFromCanvas

public void removeFromCanvas(Graph2DView view)
Removes this listener from the set of listeners that are notified of mouse wheel events for the specified view. Invoking this method is equivalent to:
view.getCanvasComponent().removeMouseWheelListener(this);

Parameters:
view - the Graph2DView instance whose mouse wheel events were handled by this listener.
See Also:
addToCanvas(Graph2DView)

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Scrolls the view port of the Graph2DView associated to the specified mouse wheel event in an appropriate direction.

Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
Parameters:
e - the mouse wheel event that triggers scrolling.
See Also:
shouldScrollHorizontally(java.awt.event.MouseWheelEvent), isSmartScrollingEnabled()

isSmartScrollingEnabled

public boolean isSmartScrollingEnabled()
Determines whether or not smart scrolling should be used. If this feature is enabled and there is only one visible scroll bar, mouse wheel events will scroll in the direction of the visible scroll bar no matter if or what modifier keys are pressed during mouse wheel usage. If this feature is disabled, unmodified mouse wheel events will scroll vertically (if and only if a vertical scroll bar is visible) and modified mouse wheel events will scroll horizontally (if and only if a horizontal scroll bar is visible).

By default, this feature is disabled.

Returns:
true is smart scrolling is enabled; false otherwise.
See Also:
setSmartScrollingEnabled(boolean)

setSmartScrollingEnabled

public void setSmartScrollingEnabled(boolean enabled)
Specifies whether or not smart scrolling should be used. If this feature is enabled and there is only one visible scroll bar, mouse wheel events will scroll in the direction of the visible scroll bar no matter if or what modifier keys are pressed during mouse wheel usage. If this feature is disabled, unmodified mouse wheel events will scroll vertically (if and only if a vertical scroll bar is visible) and modified mouse wheel events will scroll horizontally (if and only if a horizontal scroll bar is visible).

By default, this feature is disabled.

Parameters:
enabled - if true smart scrolling will be used.
See Also:
isSmartScrollingEnabled()

getHorizontalScrollingModifierMask

public int getHorizontalScrollingModifierMask()
Returns the modifier mask that switches from vertical scrolling to horizontal scrolling.

Defaults to InputEvent.SHIFT_MASK.

Returns:
the modifier mask that switches from vertical scrolling to horizontal scrolling.
See Also:
setHorizontalScrollingModifierMask(int), shouldScrollHorizontally(java.awt.event.MouseWheelEvent), isSmartScrollingEnabled()

setHorizontalScrollingModifierMask

public void setHorizontalScrollingModifierMask(int mask)
Specifies the modifier mask that switches from vertical scrolling to horizontal scrolling.

Defaults to InputEvent.SHIFT_MASK.

Parameters:
mask - the modifier mask used to switch from vertical scrolling to horizontal scrolling.
See Also:
getHorizontalScrollingModifierMask(), shouldScrollHorizontally(java.awt.event.MouseWheelEvent), isSmartScrollingEnabled()

shouldScrollHorizontally

protected boolean shouldScrollHorizontally(java.awt.event.MouseWheelEvent e)
Determines if the specified mouse wheel event should result in horizontal scrolling. Ignored if smart scrolling is enabled and there is only a vertical scroll bar.

Parameters:
e - the mouse wheel event that triggers scrolling.
Returns:
true if the specified mouse wheel event should result in horizontal scrolling; false otherwise.
See Also:
isSmartScrollingEnabled(), getHorizontalScrollingModifierMask()

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.