de.erichseifert.gral.navigation
Interface Navigator
-
- All Superinterfaces:
- NavigationListener
- All Known Implementing Classes:
- AbstractNavigator, PiePlot.PiePlotNavigator, PlotNavigator, XYPlot.XYPlotNavigator
public interface Navigator extends NavigationListener
An interface for translating navigational interactions, such as zooming panning to control the associatedNavigableobject. At the moment the only supported operations are zooming and panning. A navigator stores an default state of the object that can be used to reset the object's state after actions have been performed. This must be implemented with the methodssetDefaultState()andreset(). Zooming and panning may be activated and deactivated using the methodssetZoomable(boolean)andsetPannable(boolean). Additionally, the actions can also be bound to a certain direction—like horizontal or vertical—by the convenience methodsgetDirection()andsetDirection(NavigationDirection). The data type, e.g. an enum type, for directions must implement the interfaceNavigationDirection. Sometimes, actions performed on an object should be applied to another object synchronously. The methodsconnect(Navigator)anddisconnect(Navigator)may be implemented to provide functionality for this use case.
-
-
Method Summary
All Methods Instance Methods Abstract 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.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.PointND<? extends java.lang.Number>getCenter()Returns the current center point.NavigationDirectiongetDirection()Returns the current direction of the components that will be taken into account for zooming and panning.doublegetZoom()Returns the current zoom level of the associated object.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.voidpan(PointND<? extends java.lang.Number> deltas)Moves the center by the relative values of the specified point.voidremoveNavigationListener(NavigationListener l)Removes the specified listener object, i.e.voidreset()Sets the object's position and zoom level to the default state.voidsetCenter(PointND<? extends java.lang.Number> center)Sets a new center point.voidsetDefaultState()Sets the current state as the default state of the object.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.voidsetZoom(double zoom)Sets the zoom level of the associated object to the specified value.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.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.-
Methods inherited from interface de.erichseifert.gral.navigation.NavigationListener
centerChanged, zoomChanged
-
-
-
-
Method Detail
-
isZoomable
boolean isZoomable()
Returns whether the associated object can be zoomed.- Returns:
trueif the object can be zoomed,falseotherwise.
-
setZoomable
void setZoomable(boolean zoomable)
Sets whether the associated object can be zoomed.- Parameters:
zoomable- A value that tells whether it should be possible to zoom the associated object.
-
getZoom
double getZoom()
Returns the current zoom level of the associated object.- Returns:
- Current zoom level.
-
setZoom
void setZoom(double zoom)
Sets the zoom level of the associated object to the specified value.- Parameters:
zoom- New zoom level.
-
zoomIn
void zoomIn()
Increases the current zoom level by the specified zoom factor. The zoom will only be changed if the navigator is zoomable.- See Also:
isZoomable(),setZoomable(boolean)
-
zoomOut
void zoomOut()
Decreases the current zoom level by the specified zoom factor. The zoom will only be changed if the navigator is zoomable.- See Also:
isZoomable(),setZoomable(boolean)
-
zoomAt
void zoomAt(double zoom, PointND<? extends java.lang.Number> zoomPoint)Scale 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.- Parameters:
zoom- New zoom level.zoomPoint- Center point for zooming in world units.
-
zoomInAt
void zoomInAt(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.- Parameters:
zoomPoint- Center point for zooming in world units.
-
zoomOutAt
void zoomOutAt(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.- Parameters:
zoomPoint- Center point for zooming in world units.
-
isPannable
boolean isPannable()
Returns whether the associated object can be panned.- Returns:
trueif the object can be panned,falseotherwise.
-
setPannable
void setPannable(boolean pannable)
Sets whether the associated object can be panned.- Parameters:
pannable- A value that tells whether it should be possible to pan the associated object.
-
getCenter
PointND<? extends java.lang.Number> getCenter()
Returns the current center point. The returned point contains value in world units.- Returns:
- Center point in world units.
-
setCenter
void setCenter(PointND<? extends java.lang.Number> center)
Sets a new center point. The values of the point are in world units. The center point will only be changed if the navigator is pannable.- Parameters:
center- New center point in world units.- See Also:
isPannable(),setPannable(boolean)
-
pan
void pan(PointND<? extends java.lang.Number> deltas)
Moves the center by the relative values of the specified point. The values of the point are in screen units. The center point will only be changed if the navigator is pannable.- Parameters:
deltas- Relative values to use for panning.- See Also:
isPannable(),setPannable(boolean)
-
setDefaultState
void setDefaultState()
Sets the current state as the default state of the object. Resetting the navigator will then return to the default state.
-
reset
void reset()
Sets the object's position and zoom level to the default state.
-
getZoomFactor
double getZoomFactor()
Returns the factor which is used to change the zoom level on zoom in/out actions.- Returns:
- The current zoom factor.
-
setZoomFactor
void setZoomFactor(double factor)
Sets the factor which should be used to change the zoom level on zoom in/out actions.- Parameters:
factor- The new zoom factor.
-
getZoomMin
double getZoomMin()
Returns the minimal zoom factor.- Returns:
- Minimal zoom factor.
-
setZoomMin
void setZoomMin(double min)
Sets the minimal zoom factor.- Parameters:
min- New minimal zoom factor.
-
getZoomMax
double getZoomMax()
Returns the minimal zoom factor.- Returns:
- Maximal zoom factor.
-
setZoomMax
void setZoomMax(double max)
Sets the maximal zoom factor.- Parameters:
max- New maximal zoom factor.
-
addNavigationListener
void addNavigationListener(NavigationListener l)
Adds the specified listener object that gets notified on changes to navigation information like panning or zooming.- Parameters:
l- Listener object
-
removeNavigationListener
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.- Parameters:
l- Listener object
-
getDirection
NavigationDirection getDirection()
Returns the current direction of the components that will be taken into account for zooming and panning.- Returns:
- Direction.
-
setDirection
void setDirection(NavigationDirection direction)
Sets the direction of the components that will be taken into account for zooming and panning.- Parameters:
direction- Direction.
-
connect
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.- Parameters:
navigator- Navigator which should be bound to this instance.
-
disconnect
void disconnect(Navigator navigator)
Decouples the actions of the current and the connected specified navigator. All actions will be applied separately to each navigator.- Parameters:
navigator- Navigator to be unbound from this instance.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG