lt.monarch.chart.plugins
Class ChartProjectorZoomer

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

public class ChartProjectorZoomer
extends AbstractChartPlugin<Chart2D>
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Plug-in for zooming and monivng 2D chart projector.

See Also:
Serialized Form

Constructor Summary
Constructor and Description
ChartProjectorZoomer()
          Constructs Chart2D projector 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.
 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

ChartProjectorZoomer

public ChartProjectorZoomer()
Constructs Chart2D projector zoomer plug-in. Plug-in performs zooming on chart, when activated.

Method Detail

activate

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

Specified by:
activate in class AbstractChartPlugin<Chart2D>

deactivate

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

Specified by:
deactivate in class AbstractChartPlugin<Chart2D>

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 or the modifiers flag for the event equals to a "scrollModifiers" flag in the chart stylesheet prepares to move zoomed chart.

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 or moves chart.

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<Chart2D>
Overrides:
paint in class AbstractChartPlugin<Chart2D>
Parameters:
g - the Graphics context in which to paint zoom frame
See Also:
ChartPlugin.paint(lt.monarch.chart.engine.AbstractGraphics)