Class ALcdEarthGXYPainter
- All Implemented Interfaces:
ILcdCloneable
,ILcdPropertyChangeSource
,ILcdGXYPainter
,ILcdGXYPainterProvider
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdEarthGXYMultivaluedRasterPainter
,TLcdEarthGXYRasterPainter
,TLcdEarthGXYVectorPainter
ILcdEarthTileSet
s in an ILcdGXYView
.- Since:
- 8.2
- See Also:
-
Field Summary
Fields inherited from class com.luciad.view.gxy.ALcdGXYPainter
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
Fields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
-
Constructor Summary
ConstructorDescriptionConstructs a newALcdEarthGXYPainter
with the default cache size.ALcdEarthGXYPainter
(int aCacheSize) Constructs a newALcdEarthGXYPainter
with the specified cache size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boundsSFCT
(Graphics aGraphics, int aMode, ILcdGXYContext aContext, ILcd2DEditableBounds aBoundsSFCT) 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.protected abstract ILcdEarthTileSetCoverage
chooseTileSetCoverage
(ILcdEarthTileSet aTileSet) Chooses a coverage in a tile set.void
Clears the cache.clone()
MakesObject.clone()
public.int
Returns the size of the cache (in #tiles).Returns the exception handler that is used to handle exceptions that occur during tile retrieval.Returns the Object for which the representation is currently being handled by this painter.protected ILcdEarthTileSet
Returns the tile set for the current object.protected ILcdEarthTileSet
getTileSet
(Object aObject) Called bysetObject(Object)
) each timeaObject
is painted, in order to retrieve anILcdEarthTileSet
corresponding to that object.protected ILcdEarthTileSetCoverage
Returns the coverage in the tile set for the current object.boolean
Returns whether the tiles can be requested asynchronously.boolean
Returns whether the view is repainted when a tile becomes available.boolean
isTouched
(Graphics aGraphics, int aMode, ILcdGXYContext aContext) Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.void
setAsynchronousTileRequestAllowed
(boolean aAsynchronousTileRequestAllowed) Sets whether the tiles can be requested asynchronously.void
setCacheSize
(int aCacheSize) Sets the size of the cache (in #tiles).void
setExceptionHandler
(ILcdExceptionHandler aExceptionHandler) Sets the exception handler that is used to handle exceptions that occur during tile retrieval.void
void
setRepaintViewWhenTileAvailable
(boolean aRepaintViewWhenTileAvailable) Sets whether the view is repainted when a tile becomes available.Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYPainter
paint
-
Constructor Details
-
ALcdEarthGXYPainter
public ALcdEarthGXYPainter()Constructs a newALcdEarthGXYPainter
with the default cache size. -
ALcdEarthGXYPainter
public ALcdEarthGXYPainter(int aCacheSize) Constructs a newALcdEarthGXYPainter
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
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
Sets the exception handler that is used to handle exceptions that occur during tile retrieval.- Parameters:
aExceptionHandler
- the exception handler
-
setObject
- Parameters:
aObject
- the object for which the representation shall be handled by this painter.- See Also:
-
getTileSet
Called bysetObject(Object)
) each timeaObject
is painted, in order to retrieve anILcdEarthTileSet
corresponding to that object. By default, this method simply assumes thataObject
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
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
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
Returns the tile set for the current object.- Returns:
- the tile set for the current object.
- See Also:
-
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 paintedaMode
- 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
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()
andILcdGXYContext.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 methodsILcdGXYContext.getDeltaX()
andILcdGXYContext.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 paintedaMode
- the mode the object is represented inaContext
- 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
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.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 interfaceILcdCloneable
- Specified by:
clone
in interfaceILcdGXYPainterProvider
- Overrides:
clone
in classALcdGXYPainter
- Returns:
- a clone of this painter provider.
- See Also:
-