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
ILcdGXYLayers
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 singleILcdGXYLayeris chosenby the useramong 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
changeSupportFields inherited from interface com.luciad.gui.ILcdAction
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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 TypeMethodDescriptionvoidChooses anILcdGXYLayerfor the set view usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)and callsfitGXYLayer.protected ILcdGXYLayerchooseGXYLayer(ILcdGXYView aGXYView) Chooses anILcdGXYLayeramong those that belongs to theILcdGXYView.voidfit(ILcdGXYView aGXYView) Chooses anILcdGXYLayerusingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)and callsfitGXYLayer(aGXYLayer, aGXYView).protected voidfitFromBoundedModel(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 voidfitFromGXYLayerBounds(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.voidfitGXYLayer(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView) CallsfitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle)with a null rectangle.voidfitGXYLayer(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto) Rescales and pans the view so that the objects in the given layer are visible in the view.voidfitGXYLayers(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.doubleReturns 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.booleanReturns whether the fit behavior should take child layers into account when fitting.booleanReturns whether a view should revert toa predefined scalewhen fitting on a bounded model (or an unbounded model with only bounded elements) with width and height equal to 0.booleanDeprecated.This method has been deprecated.voidsetDialogMessage(String aDialogMessage) Sets the message to use inchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)voidsetExceptionHandler(ILcdExceptionHandler aExceptionHandler) Handles the exceptions thrown when fitting to a layer failed.voidsetFitToChildren(boolean aFitToChildren) Sets whether the fit behavior should also take child layers into account when fitting on layer tree nodes.voidsetFitToMaximumScaleOnBoundedPointModel(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.voidsetGXYView(ILcdGXYView aGXYView) Sets the view into which object representions will be fitted when invoking the action.voidsetMaximumScaleOnBoundedPointModel(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.voidsetTraceOn(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, setShortDescriptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.gui.ILcdAction
getValue, isEnabled, putValue, setEnabledMethods 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen only the informative, warning and error log messages are recorded.- Overrides:
setTraceOnin 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.Returnstrueif tracing is enabled for this class.- Overrides:
isTraceOnin 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 anILcdGXYLayerfor the set view usingchooseGXYLayer(com.luciad.view.gxy.ILcdGXYView)and callsfitGXYLayer.- Specified by:
actionPerformedin interfaceActionListener- See Also:
-
fit
Chooses anILcdGXYLayerusingchooseGXYLayer(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'sILcdModelimplementsILcdBounded,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 scalewhen 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 aILcdBoundedmodel 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 boundsotherwise. 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 anILcdGXYLayeramong those that belongs to theILcdGXYView. It pops up aDialogwith the setmessageto 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:
-