jsynoptic.builtin
Class PlotZoom

java.lang.Object
  extended by jsynoptic.builtin.PlotZoom
All Implemented Interfaces:
DiagramComponent.ContextualDrawing, DiagramSelectionListener

public class PlotZoom
extends java.lang.Object
implements DiagramComponent.ContextualDrawing, DiagramSelectionListener

This class performs the additional drawing required to perform some zooms on one or several selected plots Zoom box - Its location and size are defined thanks to mouse events received through the ContextualDrawing interface.When zoom defintion is over, on button 2 release, the rectangle coordinates are used to compute the zoom aplied to the selected plots. If there is one plot selected then the zoom concerns all the axes (even the secondary axes if thy exist). If there is more than a plot selected, the zoom is restricted to the axis with intersection with the zoom rectangle. In that case only one axis is changed but it is done on all the selected plots. - A red dashed rectangle is drawn. Zoom wheel - Its location and direction of rotation are defined thanks to mouse events received through the ContextualDrawing interface. Zoom wheel is performed on the selected plot that contains mouse position. Zoom whell concerns all the axes (even the secondary axes if thy exist). Translation * - The translation vector is defined thanks to mouse events received through the ContextualDrawing interface. The translation concerns all the axes and all the selected plots.


Field Summary
protected static java.awt.BasicStroke dashStroke
          on ZOOM_BOX, a stroke used to display the zoom rectangle
protected  boolean firstTranslation
          on TRANSLATION: During draging operation, , several translation are performed, but a unique event is stored into undo operation stack.
protected  int kindOfZoom
          Kind of zoom
protected  Plot plot1
          the plot on which the zoom definition starts
protected static int TRANSLATION
           
protected  int x1
          Zoom coordinates
protected  int x2
          Zoom coordinates
protected  int y1
          Zoom coordinates
protected  int y2
          Zoom coordinates
protected static int ZOOM_BOX
           
protected static int ZOOM_WHEEL
           
protected  java.awt.Rectangle zoomArea
          on ZOOM_BOX, the zoom area shape
protected static java.awt.Color zoomColor
          on ZOOM_BOX, the zoom area line color
protected static double zoomWheelFactor
          on TRANSLATION: Zoom wheel factor
 
Constructor Summary
PlotZoom(DiagramSelection sel)
          Creates a new PlotZoom for the current selection
 
Method Summary
 void abort()
          Abort the zoom
 boolean consumeKeyEvent(java.awt.event.KeyEvent e)
          During this specific context, the key events can be consumed and thus nt handled as in normal mode
 boolean consumeMouseEvent(java.awt.event.MouseEvent e)
          During this specific context, the mouse events can be consumed and thus nt handled as in normal mode
protected  void displayCrossLocation(int x, int y)
          Display the plot coordinates for this point
 void drag(int x, int y)
          Extends the zoom area according to dragged mouse location
 void draw(java.awt.Graphics2D g2, java.awt.Point pMax)
          Do the additional drawing
protected  Plot getSelectedPlot(double x, double y)
          Get the first plot part of selection which contains this point
 void press(int x, int y)
          Start the zoom at the mouse pressed location
 void release(int x, int y)
          When the mouse is released, do the zoom according to zoom area definition
 void selectionChanged(DiagramSelection sel)
          The selection calls each listener when the selection changes
 void translate()
          When the mouse is released, do the translation according to the vector (x1,y1) (x2,y2)
protected  void wheel(int x, int y, boolean zoomIn)
          make a zoom wheel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kindOfZoom

protected int kindOfZoom
Kind of zoom


ZOOM_BOX

protected static final int ZOOM_BOX
See Also:
Constant Field Values

ZOOM_WHEEL

protected static final int ZOOM_WHEEL
See Also:
Constant Field Values

TRANSLATION

protected static final int TRANSLATION
See Also:
Constant Field Values

x1

protected int x1
Zoom coordinates


y1

protected int y1
Zoom coordinates


x2

protected int x2
Zoom coordinates


y2

protected int y2
Zoom coordinates


plot1

protected Plot plot1
the plot on which the zoom definition starts


zoomWheelFactor

protected static final double zoomWheelFactor
on TRANSLATION: Zoom wheel factor

See Also:
Constant Field Values

zoomColor

protected static java.awt.Color zoomColor
on ZOOM_BOX, the zoom area line color


dashStroke

protected static java.awt.BasicStroke dashStroke
on ZOOM_BOX, a stroke used to display the zoom rectangle


zoomArea

protected java.awt.Rectangle zoomArea
on ZOOM_BOX, the zoom area shape


firstTranslation

protected boolean firstTranslation
on TRANSLATION: During draging operation, , several translation are performed, but a unique event is stored into undo operation stack.

Constructor Detail

PlotZoom

public PlotZoom(DiagramSelection sel)
Creates a new PlotZoom for the current selection

Parameters:
sel - the selection to zoom
Method Detail

consumeKeyEvent

public boolean consumeKeyEvent(java.awt.event.KeyEvent e)
Description copied from interface: DiagramComponent.ContextualDrawing
During this specific context, the key events can be consumed and thus nt handled as in normal mode

Specified by:
consumeKeyEvent in interface DiagramComponent.ContextualDrawing
Parameters:
e - the key event
Returns:
true if it is consumed by the specific key event handler

consumeMouseEvent

public boolean consumeMouseEvent(java.awt.event.MouseEvent e)
Description copied from interface: DiagramComponent.ContextualDrawing
During this specific context, the mouse events can be consumed and thus nt handled as in normal mode

Specified by:
consumeMouseEvent in interface DiagramComponent.ContextualDrawing
Parameters:
e - the mouse event (including motion events)
Returns:
true if it is consumed by the specific mouse event handler

wheel

protected void wheel(int x,
                     int y,
                     boolean zoomIn)
make a zoom wheel

Parameters:
x -
y -
zoomIn -

abort

public void abort()
Abort the zoom


press

public void press(int x,
                  int y)
Start the zoom at the mouse pressed location

Parameters:
x - mouse location X coordinate
y - mouse location Y coordinate

drag

public void drag(int x,
                 int y)
Extends the zoom area according to dragged mouse location

Parameters:
x - mouse location X coordinate
y - mouse location Y coordinate

release

public void release(int x,
                    int y)
When the mouse is released, do the zoom according to zoom area definition

Parameters:
x - mouse location X coordinate
y - mouse location Y coordinate

translate

public void translate()
When the mouse is released, do the translation according to the vector (x1,y1) (x2,y2)

Parameters:
x - mouse location X coordinate
y - mouse location Y coordinate

getSelectedPlot

protected Plot getSelectedPlot(double x,
                               double y)
Get the first plot part of selection which contains this point

Parameters:
x - X coordinate location wrt diagram frame
y - Y coordinate location wrt diagram frame
Returns:
a plot

displayCrossLocation

protected void displayCrossLocation(int x,
                                    int y)
Display the plot coordinates for this point

Parameters:
x - X coordinate location wrt diagram frame
y - Y coordinate location wrt diagram frame

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.Point pMax)
Description copied from interface: DiagramComponent.ContextualDrawing
Do the additional drawing

Specified by:
draw in interface DiagramComponent.ContextualDrawing
Parameters:
g2 - the current graphic
pMax - the max point to compute diagram size

selectionChanged

public void selectionChanged(DiagramSelection sel)
Description copied from interface: DiagramSelectionListener
The selection calls each listener when the selection changes

Specified by:
selectionChanged in interface DiagramSelectionListener
Parameters:
sel - the selection