public class ViewportLimiter extends Object
CanvasControl
to limit the interactive movement of the viewport.
The ViewportLimiter
instance should be consulted whenever the user tries to
change the viewport. Using method limitViewport(CanvasControl, RectD)
the desired viewport can be validated by
the implementation. Note that setting the Zoom
property or ViewPoint
property will not be influenced by implementations of this class. It is up to the caller to perform verification.
getBounds()
Constructor and Description |
---|
ViewportLimiter()
Initializes a new instance of the
ViewportLimiter class. |
Modifier and Type | Method and Description |
---|---|
RectD |
getBounds()
Gets the maximal allowed navigable bounds for the viewport.
|
protected RectD |
getCurrentBounds(CanvasControl canvas,
RectD suggestedViewport)
Gets the to bounds that should be honored for the upcoming call.
|
boolean |
isHonoringBothDimensionsEnabled()
Gets a value indicating whether both dimensions of
Bounds need to be honored. |
RectD |
limitViewport(CanvasControl canvas,
RectD suggestedViewport)
Inspects the desired or suggested new viewport for the given control and returns a valid viewport to use.
|
void |
setBounds(RectD value)
Sets the maximal allowed navigable bounds for the viewport.
|
void |
setHonoringBothDimensionsEnabled(boolean value)
Sets a value indicating whether both dimensions of
Bounds need to be honored. |
public ViewportLimiter()
ViewportLimiter
class.public final RectD getBounds()
null
. This value will be used by the default implementation of limitViewport(CanvasControl, RectD)
to crop the desired viewport to.setBounds(RectD)
protected RectD getCurrentBounds(CanvasControl canvas, RectD suggestedViewport)
This method is used as callback by limitViewport(CanvasControl, RectD)
for each request. The default
implementation just yields Bounds
.
canvas
- The canvas control.suggestedViewport
- The suggested viewport.null
.public final boolean isHonoringBothDimensionsEnabled()
Bounds
need to be honored.true
if both dimensions need to be honored, otherwise false
.setHonoringBothDimensionsEnabled(boolean)
public RectD limitViewport(CanvasControl canvas, RectD suggestedViewport)
canvas
- The canvas control on which the viewport should be applied.suggestedViewport
- The suggested viewport.public final void setBounds(RectD value)
value
- The bounds or null
. This value will be used by the default implementation of limitViewport(CanvasControl, RectD)
to crop the desired viewport to.getBounds()
public final void setHonoringBothDimensionsEnabled(boolean value)
Bounds
need to be honored.value
- true
if both dimensions need to be honored, otherwise false
.isHonoringBothDimensionsEnabled()