de.erichseifert.gral.navigation
Class AbstractNavigator
- java.lang.Object
-
- de.erichseifert.gral.navigation.AbstractNavigator
-
- All Implemented Interfaces:
- NavigationListener, Navigator
- Direct Known Subclasses:
- PiePlot.PiePlotNavigator, PlotNavigator
public abstract class AbstractNavigator extends java.lang.Object implements Navigator
Abstract base class that can be used to control the zoom and panning of an object. The navigator translates actions to operations on the object. The class provides implementations for zooming using a zoom factor, management of listeners, getting and setting a main direction for actions, and synchronizing actions with another navigator. Derived classes must use the methodsfireCenterChanged(NavigationEvent)andfireZoomChanged(NavigationEvent)to notify listeners of changes to the center or zoom level. To avoid loop states these methods must only be called if a value has really been changed.
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleDEFAULT_ZOOM_FACTORDefault zoom factor.static doubleDEFAULT_ZOOM_MAXDefault maximum of zoom factor.static doubleDEFAULT_ZOOM_MINDefault minimum of zoom factor.
-
Constructor Summary
Constructors Constructor and Description AbstractNavigator()Initializes a new instance that is responsible for zooming and panning the axes with the specified names of the specified plot.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNavigationListener(NavigationListener l)Adds the specified listener object that gets notified on changes to navigation information like panning or zooming.voidcenterChanged(NavigationEvent<PointND<? extends java.lang.Number>> event)A method that gets called after the center of an object in a connectedPlotNavigatorhas changed.voidconnect(Navigator navigator)Couples the actions of the current and the specified navigator.voiddisconnect(Navigator navigator)Decouples the actions of the current and the connected specified navigator.NavigationDirectiongetDirection()Returns the current direction of the components that will be taken into account for zooming and panning.doublegetZoomFactor()Returns the factor which is used to change the zoom level on zoom in/out actions.doublegetZoomMax()Returns the minimal zoom factor.doublegetZoomMin()Returns the minimal zoom factor.booleanisPannable()Returns whether the associated object can be panned.booleanisZoomable()Returns whether the associated object can be zoomed.voidremoveNavigationListener(NavigationListener l)Removes the specified listener object, i.e.voidsetDirection(NavigationDirection direction)Sets the direction of the components that will be taken into account for zooming and panning.voidsetPannable(boolean pannable)Sets whether the associated object can be panned.voidsetZoomable(boolean zoomable)Sets whether the associated object can be zoomed.voidsetZoomFactor(double factor)Sets the factor which should be used to change the zoom level on zoom in/out actions.voidsetZoomMax(double max)Sets the maximal zoom factor.voidsetZoomMin(double min)Sets the minimal zoom factor.voidzoomAt(double zoom, PointND<? extends java.lang.Number> zoomPoint)Scale the associated object at the specified point.voidzoomChanged(NavigationEvent<java.lang.Double> event)A method that gets called after the zoom level of an object in a connectedPlotNavigatorhas changed.voidzoomIn()Increases the current zoom level by the specified zoom factor.voidzoomInAt(PointND<? extends java.lang.Number> zoomPoint)Increases the current zoom level by the specified zoom factor and scales the associated object at the specified point.voidzoomOut()Decreases the current zoom level by the specified zoom factor.voidzoomOutAt(PointND<? extends java.lang.Number> zoomPoint)Decreases the current zoom level by the specified zoom factor and scales the associated object at the specified point.
-
-
-
Field Detail
-
DEFAULT_ZOOM_FACTOR
public static final double DEFAULT_ZOOM_FACTOR
Default zoom factor.- See Also:
- Constant Field Values
-
DEFAULT_ZOOM_MIN
public static final double DEFAULT_ZOOM_MIN
Default minimum of zoom factor.- See Also:
- Constant Field Values
-
DEFAULT_ZOOM_MAX
public static final double DEFAULT_ZOOM_MAX
Default maximum of zoom factor.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractNavigator
public AbstractNavigator()
Initializes a new instance that is responsible for zooming and panning the axes with the specified names of the specified plot.
-
-
Method Detail
-
isZoomable
public boolean isZoomable()
Returns whether the associated object can be zoomed.- Specified by:
isZoomablein interfaceNavigator- Returns:
trueif the object can be zoomed,falseotherwise.
-
setZoomable
public void setZoomable(boolean zoomable)
Sets whether the associated object can be zoomed.- Specified by:
setZoomablein interfaceNavigator- Parameters:
zoomable- A value that tells whether it should be possible to zoom the associated object.
-
zoomIn
public void zoomIn()
Increases the current zoom level by the specified zoom factor.- Specified by:
zoomInin interfaceNavigator- See Also:
Navigator.isZoomable(),Navigator.setZoomable(boolean)
-
zoomOut
public void zoomOut()
Decreases the current zoom level by the specified zoom factor.- Specified by:
zoomOutin interfaceNavigator- See Also:
Navigator.isZoomable(),Navigator.setZoomable(boolean)
-
zoomAt
public void zoomAt(double zoom, PointND<? extends java.lang.Number> zoomPoint)Description copied from interface:NavigatorScale the associated object at the specified point. If zooming is disabled nothing will be done. If panning is disabled zooming will be applied around the current center.
-
zoomInAt
public void zoomInAt(PointND<? extends java.lang.Number> zoomPoint)
Description copied from interface:NavigatorIncreases the current zoom level by the specified zoom factor and scales the associated object at the specified point.
-
zoomOutAt
public void zoomOutAt(PointND<? extends java.lang.Number> zoomPoint)
Description copied from interface:NavigatorDecreases the current zoom level by the specified zoom factor and scales the associated object at the specified point.
-
isPannable
public boolean isPannable()
Returns whether the associated object can be panned.- Specified by:
isPannablein interfaceNavigator- Returns:
trueif the object can be panned,falseotherwise.
-
setPannable
public void setPannable(boolean pannable)
Sets whether the associated object can be panned.- Specified by:
setPannablein interfaceNavigator- Parameters:
pannable- A value that tells whether it should be possible to pan the associated object.
-
getZoomFactor
public double getZoomFactor()
Returns the factor which is used to change the zoom level on zoom in/out actions.- Specified by:
getZoomFactorin interfaceNavigator- Returns:
- The current zoom factor.
-
setZoomFactor
public void setZoomFactor(double factor)
Sets the factor which should be used to change the zoom level on zoom in/out actions.- Specified by:
setZoomFactorin interfaceNavigator- Parameters:
factor- The new zoom factor.
-
getZoomMin
public double getZoomMin()
Returns the minimal zoom factor.- Specified by:
getZoomMinin interfaceNavigator- Returns:
- Minimal zoom factor.
-
setZoomMin
public void setZoomMin(double min)
Sets the minimal zoom factor.- Specified by:
setZoomMinin interfaceNavigator- Parameters:
min- New minimal zoom factor.
-
getZoomMax
public double getZoomMax()
Returns the minimal zoom factor.- Specified by:
getZoomMaxin interfaceNavigator- Returns:
- Maximal zoom factor.
-
setZoomMax
public void setZoomMax(double max)
Sets the maximal zoom factor.- Specified by:
setZoomMaxin interfaceNavigator- Parameters:
max- New maximal zoom factor.
-
addNavigationListener
public void addNavigationListener(NavigationListener l)
Adds the specified listener object that gets notified on changes to navigation information like panning or zooming.- Specified by:
addNavigationListenerin interfaceNavigator- Parameters:
l- Listener object
-
removeNavigationListener
public void removeNavigationListener(NavigationListener l)
Removes the specified listener object, i.e. it doesn't get notified on changes to navigation information like panning or zooming.- Specified by:
removeNavigationListenerin interfaceNavigator- Parameters:
l- Listener object
-
getDirection
public NavigationDirection getDirection()
Returns the current direction of the components that will be taken into account for zooming and panning.- Specified by:
getDirectionin interfaceNavigator- Returns:
- Direction.
-
setDirection
public void setDirection(NavigationDirection direction)
Sets the direction of the components that will be taken into account for zooming and panning.- Specified by:
setDirectionin interfaceNavigator- Parameters:
direction- Direction.
-
connect
public void connect(Navigator navigator)
Couples the actions of the current and the specified navigator. All actions applied to this navigator will be also applied to the specified navigator and vice versa.
-
disconnect
public void disconnect(Navigator navigator)
Decouples the actions of the current and the connected specified navigator. All actions will be applied separately to each navigator.- Specified by:
disconnectin interfaceNavigator- Parameters:
navigator- Navigator to be bound to this instance.
-
centerChanged
public void centerChanged(NavigationEvent<PointND<? extends java.lang.Number>> event)
A method that gets called after the center of an object in a connectedPlotNavigatorhas changed.- Specified by:
centerChangedin interfaceNavigationListener- Parameters:
event- An object describing the change event.
-
zoomChanged
public void zoomChanged(NavigationEvent<java.lang.Double> event)
A method that gets called after the zoom level of an object in a connectedPlotNavigatorhas changed.- Specified by:
zoomChangedin interfaceNavigationListener- Parameters:
event- An object describing the change event.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG