Package gov.nih.mipav.model.algorithms
Class ContourPlot.CoordSysPanning
- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- gov.nih.mipav.model.algorithms.ContourPlot.CoordSysPanning
-
- All Implemented Interfaces:
ContourPlot.InteractionConstants
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.event.MouseWheelListener
,java.util.EventListener
- Enclosing class:
- ContourPlot
public class ContourPlot.CoordSysPanning extends java.awt.event.MouseAdapter implements ContourPlot.InteractionConstants
The CoordSysPanning class implements aMouseListener
andMouseMotionListener
that realize panning functionality for the coordinate view of theContourPlot.CoordSysRenderer
. When registering this with anContourPlot.JPlotterCanvas
and CoordSysRenderer dragging with the left mouse button over the Canvas while holding down CTRL will set the coordinate view accordingly.Intended use:
CoordSysPanning pan = new CoordSysPanning(canvas, coordsys).register();
Per default the extended modifier mask for a dragging mouse event to trigger panning is
InputEvent.CTRL_DOWN_MASK
. If this is undesired theextModifierMask
has to be overridden.
For example to not need to press any key:new CoordSysPanning(canvas){{extModifierMask=0;}}.register();
- Author:
- hageldave
-
-
Field Summary
Fields Modifier and Type Field Description protected int
axes
protected java.awt.Component
canvas
protected ContourPlot.CoordSysRenderer
coordsys
protected int
extModifierMask
protected java.awt.Point
startPoint
-
Fields inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.InteractionConstants
X_AXIS, Y_AXIS
-
-
Constructor Summary
Constructors Constructor Description CoordSysPanning(ContourPlot.JPlotterCanvas canvas, ContourPlot.CoordSysRenderer coordsys)
Creates a newContourPlot.CoordSysPanning
for the specified canvas and corresponding coordinate system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.CoordSysPanning
deRegister()
Removes thisContourPlot.CoordSysPanning
from the associated canvas' mouse and mouse motion listeners.int
getPannedAxes()
protected boolean
isTriggerMouseEvent(java.awt.event.MouseEvent e, int method)
void
mouseDragged(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
ContourPlot.CoordSysPanning
register()
Adds thisContourPlot.CoordSysPanning
asMouseListener
andMouseMotionListener
to the associated canvas.ContourPlot.CoordSysPanning
setPannedAxes(int axes)
Sets the axes to which this panning is applied.
-
-
-
Field Detail
-
startPoint
protected java.awt.Point startPoint
-
canvas
protected java.awt.Component canvas
-
coordsys
protected ContourPlot.CoordSysRenderer coordsys
-
extModifierMask
protected int extModifierMask
-
axes
protected int axes
-
-
Constructor Detail
-
CoordSysPanning
public CoordSysPanning(ContourPlot.JPlotterCanvas canvas, ContourPlot.CoordSysRenderer coordsys)
Creates a newContourPlot.CoordSysPanning
for the specified canvas and corresponding coordinate system.- Parameters:
canvas
- displaying the coordsyscoordsys
- the coordinate system to apply the panning in
-
-
Method Detail
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classjava.awt.event.MouseAdapter
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseDragged
in classjava.awt.event.MouseAdapter
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classjava.awt.event.MouseAdapter
-
isTriggerMouseEvent
protected boolean isTriggerMouseEvent(java.awt.event.MouseEvent e, int method)
-
setPannedAxes
public ContourPlot.CoordSysPanning setPannedAxes(int axes)
Sets the axes to which this panning is applied. Default are both x and y axis.- Parameters:
axes
-ContourPlot.InteractionConstants.X_AXIS
,ContourPlot.InteractionConstants.Y_AXIS
orX_AXIS|Y_AXIS
- Returns:
- this for chaining
-
getPannedAxes
public int getPannedAxes()
- Returns:
- the axes this panning applies to, i.e.
ContourPlot.InteractionConstants.X_AXIS
,ContourPlot.InteractionConstants.Y_AXIS
orX_AXIS|Y_AXIS
-
register
public ContourPlot.CoordSysPanning register()
Adds thisContourPlot.CoordSysPanning
asMouseListener
andMouseMotionListener
to the associated canvas.- Returns:
- this for chaining
-
deRegister
public ContourPlot.CoordSysPanning deRegister()
Removes thisContourPlot.CoordSysPanning
from the associated canvas' mouse and mouse motion listeners.- Returns:
- this for chaining
-
-