JIDE 3.5.15

com.jidesoft.chart.event
Class RubberBandZoomer

java.lang.Object
  extended by com.jidesoft.chart.event.RubberBandZoomer
All Implemented Interfaces:
Drawable, MouseListener, MouseMotionListener, EventListener

public class RubberBandZoomer
extends Object
implements Drawable, MouseMotionListener, MouseListener

This class listens to mouse movements and draws 'rubber band' selections when added to an instance of Chart.

A ChartSelectionEvent is fired when the mouse button is released.

You can use property settings to constrain the shape of the rectangular region used for the zoom. Essentially there are four modes:

Free
The user can drag out any rectangle and the shape is unconstrained. This is the default setting.
Proportional
The shape of the rectangle is constrained to be the same (i.e. similar in the mathematical sense) as the shape of the chart. To use this mode, set keepWidthHeightRatio to true and leave zoomOrientation with its default value of BOTH.
Horizontal
The user can only zoom in horizontally, so the zoom area is a vertical bar. To use this mode, set zoomOrientation to HORIZONTAL.
Vertical
The user can only zoom in vertically, so the zoom area is a horizontal bar. To use this mode, set zoomOrientation to VERTICAL.

Author:
Simon White (swhite@catalysoft.com)

Field Summary
static String PROPERTY_FILL
           
static String PROPERTY_KEEP_RATIO
           
static String PROPERTY_OUTLINE_COLOR
           
static String PROPERTY_OUTLINE_STROKE
           
static String PROPERTY_ZOOM_ORIENTATION
           
 
Constructor Summary
RubberBandZoomer(JComponent component)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a listener that is informed when properties change
 void addZoomListener(ZoomListener listener)
          Add a listener that is informed when the user wishes to zoom in or out
 void draw(Graphics g)
          Draw the object implementing this interface onto the supplied Graphics context
protected  void fireZoomIn(Rectangle selection)
           
protected  void fireZoomOut(Point p)
           
 Paint getFill()
           
 Stroke getOutlineStroke()
           
 ZoomOrientation getZoomOrientation()
           
 boolean isKeepWidthHeightRatio()
           
 void mouseClicked(MouseEvent e)
          
 void mouseDragged(MouseEvent e)
          
 void mouseEntered(MouseEvent e)
          
 void mouseExited(MouseEvent e)
          
 void mouseMoved(MouseEvent e)
          
 void mousePressed(MouseEvent e)
          
 void mouseReleased(MouseEvent e)
          
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a property change that was added previously
 void removeZoomListener(ZoomListener listener)
          Remove a listener that was previously added
 void setFill(Paint fill)
          Specify the fill for the inner region of the rubber band.
 void setKeepWidthHeightRatio(boolean keepWidthHeightRatio)
           
 void setOutlineColor(Color color)
          Specify the color to use for the outline of the rubber band
 void setOutlineStroke(Stroke stroke)
          Specify the outline stroke to use for the rubber band
 void setZoomOrientation(ZoomOrientation zoomOrientation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_OUTLINE_STROKE

public static final String PROPERTY_OUTLINE_STROKE
See Also:
Constant Field Values

PROPERTY_OUTLINE_COLOR

public static final String PROPERTY_OUTLINE_COLOR
See Also:
Constant Field Values

PROPERTY_FILL

public static final String PROPERTY_FILL
See Also:
Constant Field Values

PROPERTY_KEEP_RATIO

public static final String PROPERTY_KEEP_RATIO
See Also:
Constant Field Values

PROPERTY_ZOOM_ORIENTATION

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

RubberBandZoomer

public RubberBandZoomer(JComponent component)
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a listener that is informed when properties change

Parameters:
listener - the property change listener

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change that was added previously

Parameters:
listener - the listener to remove

addZoomListener

public void addZoomListener(ZoomListener listener)
Add a listener that is informed when the user wishes to zoom in or out

Parameters:
listener - the listener to be informed of the zoom

removeZoomListener

public void removeZoomListener(ZoomListener listener)
Remove a listener that was previously added

Parameters:
listener - the listener to be informed of the zoom

setOutlineStroke

public void setOutlineStroke(Stroke stroke)
Specify the outline stroke to use for the rubber band

Parameters:
stroke - the Stroke to use

getOutlineStroke

public Stroke getOutlineStroke()
Returns:
the current outline stroke

setOutlineColor

public void setOutlineColor(Color color)
Specify the color to use for the outline of the rubber band

Parameters:
color - the color to use for the outline

getFill

public Paint getFill()
Returns:
the fill used for the rectangular inner region of the rubber band

setFill

public void setFill(Paint fill)
Specify the fill for the inner region of the rubber band. Set this to null if you don't want any fill at all.

Parameters:
fill - the fill to use

isKeepWidthHeightRatio

public boolean isKeepWidthHeightRatio()

setKeepWidthHeightRatio

public void setKeepWidthHeightRatio(boolean keepWidthHeightRatio)

getZoomOrientation

public ZoomOrientation getZoomOrientation()

setZoomOrientation

public void setZoomOrientation(ZoomOrientation zoomOrientation)

fireZoomIn

protected void fireZoomIn(Rectangle selection)

fireZoomOut

protected void fireZoomOut(Point p)

mouseClicked

public void mouseClicked(MouseEvent e)

Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)

Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)

Specified by:
mouseReleased in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)

Specified by:
mouseMoved in interface MouseMotionListener

draw

public void draw(Graphics g)
Description copied from interface: Drawable
Draw the object implementing this interface onto the supplied Graphics context

Specified by:
draw in interface Drawable
Parameters:
g - the Graphics context

JIDE 3.5.15