JIDE 3.5.15

com.jidesoft.chart.event
Class MouseDragPanner

java.lang.Object
  extended by com.jidesoft.chart.event.MouseDragPanner
All Implemented Interfaces:
MouseHandler, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class MouseDragPanner
extends Object
implements MouseHandler

A MouseListener and MouseMotionListener that effects a pan by changing the ranges of the supplied Chart's axes when the mouse is dragged.

As a user of this class, you can find out when a pan has occurred by registering as a PanListener

This class also supports continuous panning, which means that the chart continues to move even after you have finished with the drag. A friction coefficient is applied to slow it down and eventually stop it. It gives the user the impression that the chart has momentum when you drag it.


Field Summary
static String PROPERTY_HORIZONTAL_PAN
           
static String PROPERTY_VERTICAL_PAN
           
static String PROPERTY_X_LIMITS
           
static String PROPERTY_Y_LIMITS
           
 
Constructor Summary
MouseDragPanner(Chart chart)
          Create a MouseDragPanner on the supplied chart that pans in both directions.
MouseDragPanner(Chart chart, boolean panHorizontally, boolean panVertically)
          Create a MouseDragPanner on the supplied chart that pans in the specified directions.
 
Method Summary
 void addPanListener(PanListener listener)
          Register an object's interest in pan events
 void addPropertyChangeListener(PropertyChangeListener listener)
          Register interest in the properties of this class
 Cursor getDragCursor()
          Returns the Cursor that is shown while the chart canvas is being dragged
 double getFrictionCoefficient()
          Returns the current friction coefficient, used with the continuous panning feature
 Range<?> getXLimits()
          Returns the current limits for panning in the x direction
 Range<?> getYLimits()
          Returns the current limits for panning in the y direction
 boolean isChangeCursorWhileDragging()
          Returns a boolean to indicate whether the cursor is to change while the chart canvas is being dragged
 boolean isContinuous()
          Returns a boolean to indicate whether the pan is continuous.
 boolean isHandled()
          If this returns true, the handler has consumed the event.
 boolean isHorizontalPan()
          Is panning allowed in the horizontal direction?
 boolean isVerticalPan()
          Is panning allowed in the vertical direction?
 void mouseClicked(MouseEvent event)
          One of the methods of the MouseHandler interface
 void mouseDragged(MouseEvent e)
          Receive a mouseDrag gesture and interpret it as a pan
 void mouseEntered(MouseEvent event)
          One of the methods of the MouseHandler interface
 void mouseExited(MouseEvent event)
          One of the methods of the MouseHandler interface
 void mouseMoved(MouseEvent event)
          One of the methods of the MouseHandler interface
 void mousePressed(MouseEvent e)
          One of the methods of the MouseHandler interface
 void mouseReleased(MouseEvent e)
          One of the methods of the MouseHandler interface
 void mouseWheelMoved(MouseWheelEvent e)
          One of the methods of the MouseHandler interface
 void removePanListener(PanListener listener)
          De-register an object's interest in pan events
 void removePropertyChangeListener(PropertyChangeListener listener)
          De-register interest in the properties of this class
 void setChangeCursorWhileDragging(boolean changeCursorWhileDragging)
          Specify whether the cursor should change while the chart canvas is being dragged.
 void setContinuous(boolean continuous)
          Specify whether the pan is continuous.
 void setDragCursor(Cursor dragCursor)
          Provide the facility to customise the cursor that is shown while the chart canvas is being dragged
 void setFrictionCoefficient(double friction)
          Specify the friction coefficient used with the continuous panning feature.
 void setHandled(boolean handled)
          Specify whether the handler has handled the event
 void setHorizontalPan(boolean horizontalPan)
          Specify whether to allow horizontal panning
 void setVerticalPan(boolean verticalPan)
          Specify whether to allow vertical panning
 void setXLimits(Range<?> xPanLimits)
          Specify the limits in the x direction beyond which panning is not allowed
 void setYLimits(Range<?> yPanLimits)
          Specify the limits in the y direction beyond which panning is not allowed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_HORIZONTAL_PAN

public static final String PROPERTY_HORIZONTAL_PAN
See Also:
Constant Field Values

PROPERTY_VERTICAL_PAN

public static final String PROPERTY_VERTICAL_PAN
See Also:
Constant Field Values

PROPERTY_X_LIMITS

public static final String PROPERTY_X_LIMITS
See Also:
Constant Field Values

PROPERTY_Y_LIMITS

public static final String PROPERTY_Y_LIMITS
See Also:
Constant Field Values
Constructor Detail

MouseDragPanner

public MouseDragPanner(Chart chart)
Create a MouseDragPanner on the supplied chart that pans in both directions.

Parameters:
chart - the chart we want to pan

MouseDragPanner

public MouseDragPanner(Chart chart,
                       boolean panHorizontally,
                       boolean panVertically)
Create a MouseDragPanner on the supplied chart that pans in the specified directions.

Parameters:
chart - the chart we want to be able to pan
panHorizontally - whether the user is able to pan in the horizontal direction
panVertically - whether the user is able to pan in the vertical direction
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Register interest in the properties of this class

Parameters:
listener - the object to be notified of property changes

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
De-register interest in the properties of this class

Parameters:
listener - the object to removed as a property change listener

isHorizontalPan

public boolean isHorizontalPan()
Is panning allowed in the horizontal direction?

Returns:
a boolean to indicate whether horizontal panning is allowed

setHorizontalPan

public void setHorizontalPan(boolean horizontalPan)
Specify whether to allow horizontal panning

Parameters:
horizontalPan - the new value for the horizontalPan property

isVerticalPan

public boolean isVerticalPan()
Is panning allowed in the vertical direction?

Returns:
a boolean to indicate whether vertical panning is allowed

setVerticalPan

public void setVerticalPan(boolean verticalPan)
Specify whether to allow vertical panning

Parameters:
verticalPan - the new value for the verticalPan property

getDragCursor

public Cursor getDragCursor()
Returns the Cursor that is shown while the chart canvas is being dragged

Returns:
the Cursor that is shown while the chart canvas is being dragged

setDragCursor

public void setDragCursor(Cursor dragCursor)
Provide the facility to customise the cursor that is shown while the chart canvas is being dragged

Parameters:
dragCursor - the Cursor to show while the chart canvas is being dragged

isChangeCursorWhileDragging

public boolean isChangeCursorWhileDragging()
Returns a boolean to indicate whether the cursor is to change while the chart canvas is being dragged

Returns:
a boolean to indicate whether the cursor is to change

setChangeCursorWhileDragging

public void setChangeCursorWhileDragging(boolean changeCursorWhileDragging)
Specify whether the cursor should change while the chart canvas is being dragged. Default is true.

Parameters:
changeCursorWhileDragging - whether to change the canvas while dragging the chart

isContinuous

public boolean isContinuous()
Returns a boolean to indicate whether the pan is continuous.

Returns:
a boolean to indicate whether the pan is continuous.

setContinuous

public void setContinuous(boolean continuous)
Specify whether the pan is continuous. A continuous pan is one where the chart continues to pan after you have released the mouse. It gives the effect of momentum to the drag, and is subject to a friction coefficient.

Parameters:
continuous - whether the pan should be continuous

getFrictionCoefficient

public double getFrictionCoefficient()
Returns the current friction coefficient, used with the continuous panning feature

Returns:
the current friction coefficient

setFrictionCoefficient

public void setFrictionCoefficient(double friction)
Specify the friction coefficient used with the continuous panning feature. The friction coefficient is a number between 0 and 1 (default 0.1). The higher the value, the more friction and the quicker the chart will come to a halt when panned.

Parameters:
friction - the friction coefficient

getXLimits

public Range<?> getXLimits()
Returns the current limits for panning in the x direction

Returns:
the limits for panning in the x direction

setXLimits

public void setXLimits(Range<?> xPanLimits)
Specify the limits in the x direction beyond which panning is not allowed

Parameters:
xPanLimits - the minimum and maximum possible x value under panning

getYLimits

public Range<?> getYLimits()
Returns the current limits for panning in the y direction

Returns:
the limits for panning in the y direction

setYLimits

public void setYLimits(Range<?> yPanLimits)
Specify the limits in the y direction beyond which panning is not allowed

Parameters:
yPanLimits - the minimum and maximum possible y value under panning

addPanListener

public void addPanListener(PanListener listener)
Register an object's interest in pan events

Parameters:
listener - the object interested in pan events

removePanListener

public void removePanListener(PanListener listener)
De-register an object's interest in pan events

Parameters:
listener - the object no longer interested in pan events

mousePressed

public void mousePressed(MouseEvent e)
One of the methods of the MouseHandler interface

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
One of the methods of the MouseHandler interface

Specified by:
mouseReleased in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent event)
One of the methods of the MouseHandler interface

Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent event)
One of the methods of the MouseHandler interface

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent event)
One of the methods of the MouseHandler interface

Specified by:
mouseExited in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Receive a mouseDrag gesture and interpret it as a pan

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent event)
One of the methods of the MouseHandler interface

Specified by:
mouseMoved in interface MouseMotionListener

isHandled

public boolean isHandled()
If this returns true, the handler has consumed the event.

Specified by:
isHandled in interface MouseHandler
Returns:
whether the event was handled

setHandled

public void setHandled(boolean handled)
Specify whether the handler has handled the event

Specified by:
setHandled in interface MouseHandler
Parameters:
handled - whether the event was handled

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
One of the methods of the MouseHandler interface

Specified by:
mouseWheelMoved in interface MouseWheelListener

JIDE 3.5.15