public interface Navigator extends NavigationListener
Navigable
object. 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 methods setDefaultState()
and
reset()
.
Zooming and panning may be activated and deactivated using the methods
setZoomable(boolean)
and setPannable(boolean)
.
Additionally, the actions can also be bound to a certain direction—like
horizontal or vertical—by the convenience methods getDirection()
and setDirection(NavigationDirection)
. The data type, e.g. an enum
type, for directions must implement the interface
NavigationDirection
.
Sometimes, actions performed on an object should be applied to another
object synchronously. The methods connect(Navigator)
and
disconnect(Navigator)
may be implemented to provide functionality
for this use case.Modifier and Type | Method and Description |
---|---|
void |
addNavigationListener(NavigationListener l)
Adds the specified listener object that gets notified on changes to
navigation information like panning or zooming.
|
void |
connect(Navigator navigator)
Couples the actions of the current and the specified navigator.
|
void |
disconnect(Navigator navigator)
Decouples the actions of the current and the connected specified
navigator.
|
PointND<? extends Number> |
getCenter()
Returns the current center point.
|
NavigationDirection |
getDirection()
Returns the current direction of the components that will be taken into
account for zooming and panning.
|
double |
getZoom()
Returns the current zoom level of the associated object.
|
double |
getZoomFactor()
Returns the factor which is used to change the zoom level on
zoom in/out actions.
|
double |
getZoomMax()
Returns the minimal zoom factor.
|
double |
getZoomMin()
Returns the minimal zoom factor.
|
boolean |
isPannable()
Returns whether the associated object can be panned.
|
boolean |
isZoomable()
Returns whether the associated object can be zoomed.
|
void |
pan(PointND<? extends Number> deltas)
Moves the center by the relative values of the specified point.
|
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.
|
void |
reset()
Sets the object's position and zoom level to the default state.
|
void |
setCenter(PointND<? extends Number> center)
Sets a new center point.
|
void |
setDefaultState()
Sets the current state as the default state of the object.
|
void |
setDirection(NavigationDirection direction)
Sets the direction of the components that will be taken into account for
zooming and panning.
|
void |
setPannable(boolean pannable)
Sets whether the associated object can be panned.
|
void |
setZoom(double zoom)
Sets the zoom level of the associated object to the specified value.
|
void |
setZoomable(boolean zoomable)
Sets whether the associated object can be zoomed.
|
void |
setZoomFactor(double factor)
Sets the factor which should be used to change the zoom level on
zoom in/out actions.
|
void |
setZoomMax(double max)
Sets the maximal zoom factor.
|
void |
setZoomMin(double min)
Sets the minimal zoom factor.
|
void |
zoomIn()
Increases the current zoom level by the specified zoom factor.
|
void |
zoomOut()
Decreases the current zoom level by the specified zoom factor.
|
centerChanged, zoomChanged
boolean isZoomable()
true
if the object can be zoomed,
false
otherwise.void setZoomable(boolean zoomable)
zoomable
- A value that tells whether it should be possible to zoom
the associated object.double getZoom()
void setZoom(double zoom)
zoom
- New zoom level.void zoomIn()
isZoomable()
,
setZoomable(boolean)
void zoomOut()
isZoomable()
,
setZoomable(boolean)
boolean isPannable()
true
if the object can be panned,
false
otherwise.void setPannable(boolean pannable)
pannable
- A value that tells whether it should be possible to pan
the associated object.PointND<? extends Number> getCenter()
void setCenter(PointND<? extends Number> center)
center
- New center point in world units.isPannable()
,
setPannable(boolean)
void pan(PointND<? extends Number> deltas)
deltas
- Relative values to use for panning.isPannable()
,
setPannable(boolean)
void setDefaultState()
void reset()
double getZoomFactor()
void setZoomFactor(double factor)
factor
- The new zoom factor.double getZoomMin()
void setZoomMin(double min)
min
- New minimal zoom factor.double getZoomMax()
void setZoomMax(double max)
max
- New maximal zoom factor.void addNavigationListener(NavigationListener l)
l
- Listener objectvoid removeNavigationListener(NavigationListener l)
l
- Listener objectNavigationDirection getDirection()
void setDirection(NavigationDirection direction)
direction
- Direction.void connect(Navigator navigator)
navigator
- Navigator which should be bound to this instance.void disconnect(Navigator navigator)
navigator
- Navigator to be unbound from this instance.Copyright © 2009-2013. All Rights Reserved.