Class TLcdGXYViewFitAction

java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.view.gxy.TLcdGXYViewFitAction
All Implemented Interfaces:
ILcdAction, ILcdPropertyChangeSource, ActionListener, Serializable, EventListener

public class TLcdGXYViewFitAction extends ALcdAction implements ILcdAction
Makes the representations of all Objects that belong to one or more ILcdGXYLayers fit into the containing ILcdGXYView.

It can be triggered as follows:

For fitting on part of a layer by passing your own model bounds, see TLcdFitGXYLayerInViewClipAction.
For fitting on the selection of a view, see TLcdFitSelectionInViewClipAction
See Also:
  • 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

      public TLcdGXYViewFitAction(ILcdGXYView aGXYView)
      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

      public TLcdGXYViewFitAction(ILcdGXYView aGXYView, boolean aRegisterInstance)
      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 either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Overrides:
      setTraceOn in class ALcdAction
      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.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class ALcdAction
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • getGXYView

      public ILcdGXYView 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

      public void setGXYView(ILcdGXYView aGXYView)
      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

      public void actionPerformed(ActionEvent e)
      Chooses an ILcdGXYLayer for the set view using chooseGXYLayer(com.luciad.view.gxy.ILcdGXYView) and calls fitGXYLayer.
      Specified by:
      actionPerformed in interface ActionListener
      See Also:
    • fit

      public void fit(ILcdGXYView aGXYView)
      Chooses an ILcdGXYLayer using chooseGXYLayer(com.luciad.view.gxy.ILcdGXYView) and calls fitGXYLayer(aGXYLayer, aGXYView).
      Parameters:
      aGXYView - the view to fit and to select a layer from.
      See Also:
    • fitGXYLayer

      public void fitGXYLayer(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView)
      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 calls fitFromBoundedModel(com.luciad.shape.ILcdBounded, com.luciad.view.gxy.ILcdGXYLayer, com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle) if the ILcdGXYLayer's ILcdModel implements ILcdBounded, 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 set exception 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. If null, 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 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.
      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 by fitGXYLayer(ILcdGXYLayer, ILcdGXYView, java.awt.Rectangle) when fitting on a single layer whose model implements ILcdBounded.

      It changes the scale and the world origin of a view so that all objects of a layer with a ILcdBounded 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 if isFitToMaximumScaleOnBoundedPointModel() 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 implements ILcdBounded, and the layer bounds otherwise.

      This method does not throw exceptions, but instead passes exceptions to the set exception 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 too
      aGXYView - the view to fit.
      aRectangleToFitInto - a rectangle in view coordinates where to fit the representation of all objects into. If null, the view bounds are used.
      See Also:
    • fitFromGXYLayerBounds

      protected void fitFromGXYLayerBounds(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, Rectangle aRectangleToFitInto)
      This is called by fitGXYLayer(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 if isFitToMaximumScaleOnBoundedPointModel() 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

      public void setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
      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

      protected ILcdGXYLayer chooseGXYLayer(ILcdGXYView aGXYView)
      Chooses an ILcdGXYLayer among those that belongs to the ILcdGXYView. It pops up a Dialog with the set message 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

      public void setDialogMessage(String aDialogMessage)
      Parameters:
      aDialogMessage - to message to display to the user when choosing a layer
      See Also:
    • getDialogMessage

      public String getDialogMessage()
      Returns:
      to message to display to the user when choosing a layer
      See Also: