Class ALcdEarthGXYPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYPainter
com.luciad.earth.view.gxy.ALcdEarthGXYPainter
All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable
Direct Known Subclasses:
TLcdEarthGXYMultivaluedRasterPainter, TLcdEarthGXYRasterPainter, TLcdEarthGXYVectorPainter

public abstract class ALcdEarthGXYPainter extends ALcdGXYPainter
A base class for painting ILcdEarthTileSets in an ILcdGXYView.
Since:
8.2
See Also:
  • Constructor Details

    • ALcdEarthGXYPainter

      public ALcdEarthGXYPainter()
      Constructs a new ALcdEarthGXYPainter with the default cache size.
    • ALcdEarthGXYPainter

      public ALcdEarthGXYPainter(int aCacheSize)
      Constructs a new ALcdEarthGXYPainter with the specified cache size.
      Parameters:
      aCacheSize - the size of the cache
  • Method Details

    • getCacheSize

      public int getCacheSize()
      Returns the size of the cache (in #tiles).
      Returns:
      the size of the cache
    • setCacheSize

      public void setCacheSize(int aCacheSize)
      Sets the size of the cache (in #tiles). If the new cache size is smaller than the current cache size some elements will be removed from the cache.
      Parameters:
      aCacheSize - the new cache size
    • clearCache

      public void clearCache()
      Clears the cache.
    • isAsynchronousTileRequestAllowed

      public boolean isAsynchronousTileRequestAllowed()
      Returns whether the tiles can be requested asynchronously. A positive return value indicates that tiles may be requested asynchronously to improve performance but this is not guaranteed. However if the return values is negative, it is guaranteed that no tiles will be requested asynchronously. This can result in bad performance but guarantees that all visible data is painted.
      Returns:
      True if the tiles can be requested asynchronously.
    • setAsynchronousTileRequestAllowed

      public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
      Sets whether the tiles can be requested asynchronously.
      Parameters:
      aAsynchronousTileRequestAllowed - True if the tiles can be requested asynchronously
      See Also:
    • isRepaintViewWhenTileAvailable

      public boolean isRepaintViewWhenTileAvailable()
      Returns whether the view is repainted when a tile becomes available.
      Returns:
      whether the view is repainted when a tile becomes available
    • setRepaintViewWhenTileAvailable

      public void setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
      Sets whether the view is repainted when a tile becomes available.
      Parameters:
      aRepaintViewWhenTileAvailable - whether the view should repainted when a tile becomes available
    • getExceptionHandler

      public ILcdExceptionHandler getExceptionHandler()
      Returns the exception handler that is used to handle exceptions that occur during tile retrieval. The default exception handler simply writes a log entry.
      Returns:
      the exception handler
    • setExceptionHandler

      public void setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
      Sets the exception handler that is used to handle exceptions that occur during tile retrieval.
      Parameters:
      aExceptionHandler - the exception handler
    • setObject

      public void setObject(Object aObject)
      Sets the tile set to the specified object and chooses a coverage in it.
      Parameters:
      aObject - the object for which the representation shall be handled by this painter.
      See Also:
    • getTileSet

      protected ILcdEarthTileSet getTileSet(Object aObject)
      Called by setObject(Object)) each time aObject is painted, in order to retrieve an ILcdEarthTileSet corresponding to that object.

      By default, this method simply assumes that aObject itself is a tile set. This behavior could for example be overridden by a derived class to add some custom tile set wrappers.

      Parameters:
      aObject - the object being painted
      Returns:
      a tile set
    • chooseTileSetCoverage

      protected abstract ILcdEarthTileSetCoverage chooseTileSetCoverage(ILcdEarthTileSet aTileSet)
      Chooses a coverage in a tile set.
      Parameters:
      aTileSet - the tile set that will be painted
      Returns:
      a coverage in the specified tile set that should be painted
    • getObject

      public Object getObject()
      Description copied from interface: ILcdGXYPainter
      Returns the Object for which the representation is currently being handled by this painter.
      Returns:
      the Object for which the representation is currently being handled by this painter.
      See Also:
    • getTileSet

      protected ILcdEarthTileSet getTileSet()
      Returns the tile set for the current object.
      Returns:
      the tile set for the current object.
      See Also:
    • getTileSetCoverage

      protected ILcdEarthTileSetCoverage getTileSetCoverage()
      Returns the coverage in the tile set for the current object.
      Returns:
      the coverage in the tile set for the current object.
      See Also:
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdGXYPainter
      Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.

      If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.

      The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model space for ILcdBounded objects.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation). For example, an object may be represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation must take this different representation into account.
      aContext - the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.
      aBoundsSFCT - the bounds that must be adapted to encompass the representation of the object in the given mode and context. These bounds must not be taken into account when the method has thrown an exception.
      Throws:
      TLcdNoBoundsException - if no bounds can be determined for the representation of the object. This can happen when the object does not have a representation in the given context, for example when it is located in a part of the world which is not visible in the current view.
      See Also:
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aContext)
      Description copied from interface: ILcdGXYPainter
      Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.

      The location that must be taken into account to check whether the representation is touched can be retrieved from the context passed with the methods ILcdGXYContext.getX() and ILcdGXYContext.getY(). If the check is part of an ongoing operation of user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also be taken into account using the methods ILcdGXYContext.getDeltaX() and ILcdGXYContext.getDeltaY(). The context contains the transformations required to convert this location into the equivalent location in model space. Implementations of this interface usually follow either of the following patterns:

      • transform the location of the interaction back to model space and compare the coordinates with the object in model space.
      • transform the location to world space and compare with a world representation of the object. This forces the painter into caching a world representation of the object. Caching a view representation of an object is not very practical as it would have to change whenever the view's scale changes or when it is panned. A world representation of an object only changes when the view's XYWorldReference changes, which happens less frequently.

      As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.

      The boundsSFCT is often used to speed up the performance of this method as a location outside these bounds can never touch the representation of the object.

      Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in
      aContext - contains the location of the interaction and the transformations to convert this location into model coordinates
      Returns:
      true if the representation of the object in the given mode is touched by the location as defined in the context passed, false otherwise
      See Also:
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdGXYPainter
      Returns:
      a clone of this painter provider.
      See Also: