lt.monarch.chart.plugins
Class BoxZoomer

java.lang.Object
  extended by lt.monarch.chart.plugins.AbstractChartPlugin<AbstractChart<?,?>>
      extended by lt.monarch.chart.plugins.BoxZoomer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener, ChartPlugin<AbstractChart<?,?>>

public class BoxZoomer
extends AbstractChartPlugin<AbstractChart<?,?>>
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Plug-in for rubber-band zooming. Performs zooming for both x and y axis.

See Also:
Serialized Form

Constructor Summary
Constructor and Description
BoxZoomer(AbstractAxisMapper xMapper, AbstractAxisMapper yMapper)
          Constructs a box zoomer plug-in.
BoxZoomer(AbstractAxisMapper xMapper, AbstractAxisMapper[] yMappers)
          Constructs a box zoomer plug-in.
BoxZoomer(Axis2D axisX, Axis2D axisY)
          Constructs a box zoomer plug-in.
 
Method Summary
Modifier and Type Method and Description
 void activate()
          Activates the plug-in.
 void deactivate()
          Deactivates the plug-in.
 void drawZoomRectangle(AbstractGraphics g, Point2D from, Point2D to)
          Draws a zoom frame with specified left-top and right-bottom corners in the specified Graphics context.
 void enableDigitization(Axis2D axisX, Axis2D axisY)
          Enables digitization for the specified axis.
 double getZoomMaxScale()
          Returns maximum zoom scale in percents.
 boolean isBoxProportionable()
          Checks if zooming box bounds are kept proportional to chart plotting area.
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a chart.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a chart and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a chart.
 void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a chart.
 void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a chart (with no buttons no down).
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a chart.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a chart.
 void paint(AbstractGraphics g)
          If needed paints zoom frame.
 void setBoxProportionable(boolean proportionable)
          Sets if zooming box bounds should be kept proportional to chart plotting area.
 void setZoomMaxScale(double zoomMaxScale)
          Sets maximum zoom scale in percents.
 
Methods inherited from class lt.monarch.chart.plugins.AbstractChartPlugin
adjustChart, chart, getChart, install, isActivated, uninstall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoxZoomer

public BoxZoomer(Axis2D axisX,
                 Axis2D axisY)
Constructs a box zoomer plug-in. Plug-in performs zooming on the specified axis, when activated. Both axis should have ScrollableAxisMapper mappers installed for the zoomer to work correctly. Zooming digitization is enabled for both axis.

Parameters:
axisX - x axis object
axisY - y axis object

BoxZoomer

public BoxZoomer(AbstractAxisMapper xMapper,
                 AbstractAxisMapper yMapper)
Constructs a box zoomer plug-in. Plug-in performs zooming on the specified axis mappers, when activated.

Parameters:
xMapper - x axis mapper object
yMapper - y axis mapper object

BoxZoomer

public BoxZoomer(AbstractAxisMapper xMapper,
                 AbstractAxisMapper[] yMappers)
Constructs a box zoomer plug-in. Plug-in performs zooming on the specified axis mappers, when activated.

Parameters:
xMapper - x axis mapper object
yMappers - y axis mapper object array
Method Detail

enableDigitization

public void enableDigitization(Axis2D axisX,
                               Axis2D axisY)
Enables digitization for the specified axis. Digitization forces the zoom box to lie on the grid lines, specified by the finest visible scales of each axis.

Parameters:
axisX - x axis object
axisY - y axis object

activate

public void activate()
Activates the plug-in. Registers mouse and mouse motion listeners.

Specified by:
activate in class AbstractChartPlugin<AbstractChart<?,?>>

deactivate

public void deactivate()
Deactivates the plug-in. Unregisters mouse and mouse motion listeners.

Specified by:
deactivate in class AbstractChartPlugin<AbstractChart<?,?>>

setZoomMaxScale

public void setZoomMaxScale(double zoomMaxScale)
Sets maximum zoom scale in percents. Value of 1 represents 100% (no zooming). Value of 0.01 - 1% (zoom works till it's scale reaches 1% of whole axis range). If value is 0.0, then there is no zooming limit.

Parameters:
zoomMaxScale - maximum zoom scale value.

getZoomMaxScale

public double getZoomMaxScale()
Returns maximum zoom scale in percents. Value of 1.0 represents 100% (no zooming). Value of 0.01 - 1% (zoom works till it's scale reaches 1% of whole axis range). If value is 0.0, then there is no zooming limit.

Returns:
maximum zoom scale value.

setBoxProportionable

public void setBoxProportionable(boolean proportionable)
Sets if zooming box bounds should be kept proportional to chart plotting area. Default value is false.

Parameters:
proportionable - true if zooming box bounds should be kept proportional to chart plotting area, false otherwise

isBoxProportionable

public boolean isBoxProportionable()
Checks if zooming box bounds are kept proportional to chart plotting area.

Returns:
true if zooming box bounds are kept proportional to chart plotting area, false otherwise

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a chart. If mouse event isn't consumed and the modifiers flag for the event equals to a "zoomModifiers" flag in the chart stylesheet the chart is unzoomed.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a chart. Does nothing.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a chart. Does nothing.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a chart. If mouse event isn't consumed and the modifiers flag for the event equals to a "zoomModifiers" flag in the chart stylesheet prepares to draw zoom frame.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a chart. If a zoom frame was drawn the chart is zoomed to it.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a chart (with no buttons no down). Does nothing.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a chart and then dragged. If possible draws zoom frame.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

drawZoomRectangle

public void drawZoomRectangle(AbstractGraphics g,
                              Point2D from,
                              Point2D to)
Draws a zoom frame with specified left-top and right-bottom corners in the specified Graphics context.

Parameters:
g - the Graphics context in which to paint zoom frame
from - left-top corner of the frame
to - right-bottom corner of the frame

paint

public void paint(AbstractGraphics g)
If needed paints zoom frame.

Specified by:
paint in interface ChartPlugin<AbstractChart<?,?>>
Overrides:
paint in class AbstractChartPlugin<AbstractChart<?,?>>
Parameters:
g - the Graphics context in which to paint zoom frame
See Also:
ChartPlugin.paint(lt.monarch.chart.engine.AbstractGraphics)