public abstract class PlotNavigator extends AbstractNavigator
Abstract base class that can be used to control the zoom and panning of a plot. The navigator translates the interaction to operations on a defined set of axes: Zooming is translated as scaling, panning is done by uniformly changing the minimum and maximum values of the axes.
Additionally, the actions can also be bound to a certain direction by
defining a more restricted set of axes. The methods AbstractNavigator.getDirection()
and AbstractNavigator.setDirection(de.erichseifert.gral.navigation.NavigationDirection)
provide a convenient way for setting predefined sets of axes:
Modifier and Type | Class and Description |
---|---|
protected static class |
PlotNavigator.NavigationInfo
Data class for storing navigational information for an axis.
|
DEFAULT_ZOOM_FACTOR, DEFAULT_ZOOM_MAX, DEFAULT_ZOOM_MIN
Constructor and Description |
---|
PlotNavigator(Plot plot,
java.util.List<java.lang.String> axesNames)
Initializes a new instance that is responsible for zooming and panning
the axes with the specified names of the specified plot.
|
PlotNavigator(Plot plot,
java.lang.String... axesNames)
Initializes a new instance that is responsible for zooming and panning
the axes with the specified names of the specified plot.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.List<java.lang.String> |
getAxes()
Returns the names of all axes handled by this object.
|
PointND<? extends java.lang.Number> |
getCenter()
Returns the current center point.
|
protected abstract int |
getDimensions()
Returns the number dimensions the associated plot can handle.
|
protected abstract java.lang.Number |
getDimensionValue(java.lang.String axisName,
PointND<? extends java.lang.Number> values)
Return the index that can be used to access data for the axis with the
specified name.
|
protected PlotNavigator.NavigationInfo |
getInfo(java.lang.String axisName)
Returns navigational information for the axis with specified name.
|
protected Plot |
getPlot()
Returns the plot stored in this instance.
|
double |
getZoom()
Returns the current zoom level of the associated object.
|
void |
pan(PointND<? extends java.lang.Number> deltas)
Moves the center by the relative values of the specified point.
|
void |
reset()
Sets the object's position and zoom level to the default state.
|
protected void |
setAxes(java.util.List<java.lang.String> axesNames)
Sets the names of the axes that should be handled by this object.
|
protected void |
setAxes(java.lang.String... axesNames)
Sets the names of the axes that should be handled by this object.
|
void |
setCenter(PointND<? extends java.lang.Number> center)
Sets a new center point.
|
void |
setDefaultState()
Sets the current state as the default state of the object.
|
void |
setZoom(double zoomNew)
Sets the zoom level of the associated object to the specified value.
|
addNavigationListener, centerChanged, connect, disconnect, fireCenterChanged, fireZoomChanged, getDirection, getZoomFactor, getZoomMax, getZoomMin, isPannable, isZoomable, removeNavigationListener, setDirection, setPannable, setZoomable, setZoomFactor, setZoomMax, setZoomMin, zoomChanged, zoomIn, zoomOut
public PlotNavigator(Plot plot, java.util.List<java.lang.String> axesNames)
plot
- AbstractPlot to be zoomed and panned.axesNames
- Names of the axes that should be controlled by this
navigator.public PlotNavigator(Plot plot, java.lang.String... axesNames)
plot
- AbstractPlot to be zoomed and panned.axesNames
- Names of the axes that should be controlled by this
navigator.protected Plot getPlot()
public double getZoom()
public void setZoom(double zoomNew)
zoomNew
- New zoom level.public PointND<? extends java.lang.Number> getCenter()
public void setCenter(PointND<? extends java.lang.Number> center)
center
- New center point in world units.Navigator.isPannable()
,
Navigator.setPannable(boolean)
public void pan(PointND<? extends java.lang.Number> deltas)
deltas
- Relative values to use for panning.Navigator.isPannable()
,
Navigator.setPannable(boolean)
public void setDefaultState()
public void reset()
protected PlotNavigator.NavigationInfo getInfo(java.lang.String axisName)
axisName
- Axis name.protected java.util.List<java.lang.String> getAxes()
protected void setAxes(java.util.List<java.lang.String> axesNames)
axesNames
- Names of the axes that should be handled.protected void setAxes(java.lang.String... axesNames)
axesNames
- Names of the axes that should be handled.protected abstract int getDimensions()
PiePlot
this is 1, for a
two-dimensional plot like XYPlot
this is 2, and so on.protected abstract java.lang.Number getDimensionValue(java.lang.String axisName, PointND<? extends java.lang.Number> values)
getDimensions()
.axisName
- Name of the axis.values
- Data values.