Package com.luciad.view.gxy
Class TLcdGXYViewFitAction
java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.view.gxy.TLcdGXYViewFitAction
- All Implemented Interfaces:
ILcdAction
,ILcdPropertyChangeSource
,ActionListener
,Serializable
,EventListener
Makes the representations of all Objects that belong to one or more
For fitting on the selection of a view, see
ILcdGXYLayer
s
fit into the containing ILcdGXYView
.
It can be triggered as follows:
- interactively, by calling
actionPerformed(java.awt.event.ActionEvent)
orfit(com.luciad.view.gxy.ILcdGXYView)
. A singleILcdGXYLayer
is chosenby the user
among those that belong to the - programmatically, by calling
fitGXYLayer(ILcdGXYLayer, ILcdGXYView, Rectangle)
orfitGXYLayers(ILcdGXYLayer[], ILcdGXYView, java.awt.Rectangle)
. The latter allows fitting on multiple layers and can be called from a background thread.
ILcdGXYView
.
TLcdFitGXYLayerInViewClipAction
.For fitting on the selection of a view, see
TLcdFitSelectionInViewClipAction
- See Also:
-
Field Summary
Fields inherited from class com.luciad.gui.ALcdAction
changeSupport
Fields inherited from interface com.luciad.gui.ILcdAction
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE
-
Constructor Summary
ConstructorDescriptionConstructs an action to fit on a view, without setting the view.TLcdGXYViewFitAction
(boolean aRegisterInstance) Deprecated.use one of the constructors without the aRegisterInstance parameter.TLcdGXYViewFitAction
(ILcdGXYView aGXYView) Constructs an action to fit on a view.TLcdGXYViewFitAction
(ILcdGXYView aGXYView, boolean aRegisterInstance) Deprecated.use one of the constructors without the aRegisterInstance parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Chooses anILcdGXYLayer
for the set view usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
and callsfitGXYLayer
.protected ILcdGXYLayer
chooseGXYLayer
(ILcdGXYView aGXYView) Chooses anILcdGXYLayer
among those that belongs to theILcdGXYView
.void
fit
(ILcdGXYView aGXYView) Chooses anILcdGXYLayer
usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
and callsfitGXYLayer(aGXYLayer, aGXYView)
.protected void
fitFromBoundedModel
(ILcdBounded aBounded, ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) This method is called byfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
when fitting on a single layer whose model implementsILcdBounded
.protected void
fitFromGXYLayerBounds
(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) This is called byfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
when fitting on a single layer whose model is not bounded.void
fitGXYLayer
(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView) CallsfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
with a null rectangle.void
fitGXYLayer
(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) Rescales and pans the view so that the objects in the given layer are visible in the view.void
fitGXYLayers
(ILcdGXYLayer[] aGXYLayers, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) Rescales and pans the view so that the objects in the layers are visible in the view.Returns the message to use inchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
Returns the view into which object representions will be fitted when invoking the action.double
Returns the scale to which the view should revert when fitting on a bounded model (or an unbounded model with only bounded elements) whose bounds have zero width and height.boolean
Returns whether the fit behavior should take child layers into account when fitting.boolean
Returns whether a view should revert toa predefined scale
when fitting on a bounded model (or an unbounded model with only bounded elements) with width and height equal to 0.boolean
Deprecated.This method has been deprecated.void
setDialogMessage
(String aDialogMessage) Sets the message to use inchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
void
setExceptionHandler
(ILcdExceptionHandler aExceptionHandler) Handles the exceptions thrown when fitting to a layer failed.void
setFitToChildren
(boolean aFitToChildren) Sets whether the fit behavior should also take child layers into account when fitting on layer tree nodes.void
setFitToMaximumScaleOnBoundedPointModel
(boolean aFitToMaximumScaleOnBoundedPointModel) Sets whether a view should revert to a predefined scale when fitting on a bounded model (or an unbounded model with only bounded elements) with width and height equal to 0.void
setGXYView
(ILcdGXYView aGXYView) Sets the view into which object representions will be fitted when invoking the action.void
setMaximumScaleOnBoundedPointModel
(double aMaximumScaleOnBoundedPointModel) Sets the scale to which the view should revert when fitting on a bounded model (or an unbounded model with only bounded elements) whose bounds have zero width and height.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.Methods inherited from class com.luciad.gui.ALcdAction
addPropertyChangeListener, firePropertyChange, getDisplayName, getIcon, getLongDescription, getName, getShortDescription, getValue, isEnabled, putValue, registerInstance, removePropertyChangeListener, setClassTraceOn, setDisplayName, setEnabled, setIcon, setLongDescription, setName, setShortDescription
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.gui.ILcdAction
getValue, isEnabled, putValue, setEnabled
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
TLcdGXYViewFitAction
public TLcdGXYViewFitAction()Constructs an action to fit on a view, without setting the view. Set the view before invoking this action.- See Also:
-
TLcdGXYViewFitAction
Constructs an action to fit on a view.- Parameters:
aGXYView
- the view that should be fitted.
-
TLcdGXYViewFitAction
public TLcdGXYViewFitAction(boolean aRegisterInstance) Deprecated.use one of the constructors without the aRegisterInstance parameter.- Parameters:
aRegisterInstance
- whether or not to register this action as a Bean
-
TLcdGXYViewFitAction
Deprecated.use one of the constructors without the aRegisterInstance parameter.- Parameters:
aGXYView
- the view that should be fitted.aRegisterInstance
- whether or not to register this action as a Bean
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdAction
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdAction
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
getGXYView
Returns the view into which object representions will be fitted when invoking the action.- Returns:
- the view into which object representions will be fitted.
-
setGXYView
Sets the view into which object representions will be fitted when invoking the action.- Parameters:
aGXYView
- the view into which object representions will be fitted.
-
actionPerformed
Chooses anILcdGXYLayer
for the set view usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
and callsfitGXYLayer
.- Specified by:
actionPerformed
in interfaceActionListener
- See Also:
-
fit
Chooses anILcdGXYLayer
usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
and callsfitGXYLayer(aGXYLayer, aGXYView)
.- Parameters:
aGXYView
- the view to fit and to select a layer from.- See Also:
-
fitGXYLayer
CallsfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
with a null rectangle.- Parameters:
aGXYLayer
- the layer to fit to.aGXYView
- the view to fit.- See Also:
-
fitGXYLayer
public void fitGXYLayer(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) Rescales and pans the view so that the objects in the given layer are visible in the view. This method callsfitFromBoundedModel(com.luciad.shape.ILcdBounded, com.luciad.view.gxy.ILcdGXYLayer, com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle)
if theILcdGXYLayer
'sILcdModel
implementsILcdBounded
,fitFromGXYLayerBounds(com.luciad.view.gxy.ILcdGXYLayer, com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle)
otherwise. This method does not throw exceptions, but instead passes exceptions to the setexception handler
. This is done when it is impossible to fit on any of the layers passed to this method. When it was only possible to fit on certain layers and not on all no exception will be generated.- Parameters:
aGXYLayer
- the layer to fit to.aGXYView
- the view to fit.aRectangleToFitInto
- a rectangle in view coordinates where to fit the representation of all objects into. Ifnull
, the view bounds are used.- See Also:
-
getMaximumScaleOnBoundedPointModel
public double getMaximumScaleOnBoundedPointModel()Returns the scale to which the view should revert when fitting on a bounded model (or an unbounded model with only bounded elements) whose bounds have zero width and height.- Returns:
- the scale to which the view should revert when fitting on a bounded model whose bounds have zero width and height (typically an ILcdBounded model containing only 1 point).
-
setMaximumScaleOnBoundedPointModel
public void setMaximumScaleOnBoundedPointModel(double aMaximumScaleOnBoundedPointModel) Sets the scale to which the view should revert when fitting on a bounded model (or an unbounded model with only bounded elements) whose bounds have zero width and height.- Parameters:
aMaximumScaleOnBoundedPointModel
- the new scale to revert to when a new scale could not be computed from the models bounds.- See Also:
-
isFitToMaximumScaleOnBoundedPointModel
public boolean isFitToMaximumScaleOnBoundedPointModel()Returns whether a view should revert toa predefined scale
when fitting on a bounded model (or an unbounded model with only bounded elements) with width and height equal to 0.- Returns:
- whether a view should revert to a predefined scale when fitting on a bounded model with width and height equal to 0.
-
setFitToMaximumScaleOnBoundedPointModel
public void setFitToMaximumScaleOnBoundedPointModel(boolean aFitToMaximumScaleOnBoundedPointModel) Sets whether a view should revert to a predefined scale when fitting on a bounded model (or an unbounded model with only bounded elements) with width and height equal to 0. Default value is true.- Parameters:
aFitToMaximumScaleOnBoundedPointModel
- true to make the view revert to a predefined scale when fitting on a bounded model with width and height equal to 0.0.- See Also:
-
setFitToChildren
public void setFitToChildren(boolean aFitToChildren) Sets whether the fit behavior should also take child layers into account when fitting on layer tree nodes.- Parameters:
aFitToChildren
- true if the children of the layers should also be taken into account- See Also:
-
isFitToChildren
public boolean isFitToChildren()Returns whether the fit behavior should take child layers into account when fitting.- Returns:
- true if the children of the layers should also be taken into account
-
fitFromBoundedModel
protected void fitFromBoundedModel(ILcdBounded aBounded, ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) throws TLcdNoBoundsException This method is called byfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
when fitting on a single layer whose model implementsILcdBounded
. It changes the scale and the world origin of a view so that all objects of a layer with aILcdBounded
model are displayed in the view or in a rectangle of the view. If the bounded has width and height zero, the view will revert to a predefined scale ifisFitToMaximumScaleOnBoundedPointModel()
is true.- Parameters:
aBounded
- the bounded object (model).aGXYLayer
- the layer for which the bounded is the model.aGXYView
- the view to fit.aRectangleToFitInto
- the rectangle to fit into.- Throws:
TLcdNoBoundsException
- when the layer could not be made entirely visible in the views world reference.
-
fitGXYLayers
public void fitGXYLayers(ILcdGXYLayer[] aGXYLayers, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) Rescales and pans the view so that the objects in the layers are visible in the view. It uses the model bounds if the layer's model implementsILcdBounded
, and thelayer bounds
otherwise. This method does not throw exceptions, but instead passes exceptions to the setexception handler
. This is done when it is impossible to fit on any of the layers passed to this method. When it was only possible to fit on certain layers and not on all no exception will be generated. This method can be invoked from a background thread as well as from the EDT thread.- Parameters:
aGXYLayers
- the layers to fit tooaGXYView
- the view to fit.aRectangleToFitInto
- a rectangle in view coordinates where to fit the representation of all objects into. Ifnull
, the view bounds are used.- See Also:
-
fitFromGXYLayerBounds
protected void fitFromGXYLayerBounds(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) This is called byfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)
when fitting on a single layer whose model is not bounded. It changes the scale and the world origin of a view so that all objects of a layer are displayed in the view or in a rectangle of the view. If the union of all object bounds has width and height zero, the view will revert to a predefined scale ifisFitToMaximumScaleOnBoundedPointModel()
is true.- Parameters:
aGXYLayer
- the layer to fit on.aGXYView
- the view to fit.aRectangleToFitInto
- the rectangle to fit into.- Throws:
TLcdNoBoundsException
- when the layer could not be made entirely visible in the views world reference.
-
setExceptionHandler
Handles the exceptions thrown when fitting to a layer failed. This can only occur when all objects in the model of the layer are out of bounds in the current view. The exception handler should be used to explain users of the reason why the fit action failed. The default implementation prints a warning on the log when tracing is turned on.- Parameters:
aExceptionHandler
- clarifies why the fit action failed.- See Also:
-
chooseGXYLayer
Chooses anILcdGXYLayer
among those that belongs to theILcdGXYView
. It pops up aDialog
with the setmessage
to allow the user to choose one. This method can be redefined for specific needs.- Parameters:
aGXYView
- the view to choose a layer from.- Returns:
- the layer to fit on in the given view.
- See Also:
-
setDialogMessage
Sets the message to use inchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
- Parameters:
aDialogMessage
- to message to display to the user when choosing a layer- See Also:
-
getDialogMessage
Returns the message to use inchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)
- Returns:
- to message to display to the user when choosing a layer
- See Also:
-