public class TLcdEarthGXYMultivaluedRasterPainter extends ALcdEarthGXYPainter implements ILcdStatusSource
ILcdGXYPainter
can paint the multi-valued raster data of ILcdEarthTileSet
instances in a 2D view.
ILcdEarthTileSet
that can
produce tiles with multi-valued raster data. The tile data should be a TLcdEarthMultivaluedData
. The first multi-valued raster
coverage in the tile set that can produce such tiles will be used (see chooseTileSetCoverage(com.luciad.earth.tileset.ILcdEarthTileSet)
).
setDeltaX(int)
and
setDeltaY(int)
methods. The actual painting of the icons is delegated to the ILcdParameterizedIcon
that is set. Note that a valid parameterized icon must be set on this painter before it can be
used. The tile level is chosen such that each painted icon in the view maps to approximately one
raster value, if possible.
If some tiles are not available, the tiles at lower levels will be used automatically to avoid
gaps.
If required this painter will transform the raster data between different coordinate systems.
ALcdEarthGXYPainter.isAsynchronousTileRequestAllowed()
and ALcdEarthGXYPainter.isRepaintViewWhenTileAvailable()
should be
set to true
(default).
setCacheSize(int)
). Other tiles will also be cached if there is enough
memory (see isSoftCachingEnabled()
). Tiles that reside in either of these caches will be
updated automatically every minute (see getUpdateInterval()
). You can use the updateTiles(com.luciad.view.gxy.ILcdGXYView)
method to update all tiles that are currently
cached immediately.
TLcdGXYAsynchronousPaintQueue.setInterruptPainting(boolean)
)defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdEarthGXYMultivaluedRasterPainter()
Creates a new multi-valued raster painter with the default settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
protected ILcdEarthTileSetCoverage |
chooseTileSetCoverage(ILcdEarthTileSet aTileSet)
Chooses a coverage from the given tile set to be drawn by this painter.
|
void |
clearCache()
Clears both the fixed cached cache and the soft cache if it is enabled.
|
void |
clearCache(Object aObject)
Clears both the fixed cached cache and the soft cache, if it is enabled, for an object.
|
Object |
clone()
Makes
Object.clone() public. |
protected ILcdEarthTileSet |
configureBaseTileSet(Object aObject,
ILcdEarthTileSet aTileSet)
Configures the base tile set.
|
protected ILcdEarthTileSet |
createAsynchronousTileSet(Object aObject,
ILcdEarthTileSet aTileSet)
Creates a tile set that can produce tiles asynchronously.
|
int |
getDeltaX()
Returns the horizontal grid spacing of the icons.
|
int |
getDeltaY()
Returns the vertical grid spacing of the icons.
|
ILcdParameterizedIcon |
getParameterizedIcon()
Returns the parameterized icon that is used.
|
TLcdEarthTileContext |
getTileContext(Object aObject)
Returns the tile context for the most recent paint of an object.
|
protected ILcdEarthTileSet |
getTileSet(Object aObject)
The first time the tile set for an object is retrieved this base tile set is
configured and then wrapped with an
asynchronous tile set to ensure smooth painting. |
long |
getUpdateInterval()
Returns the time between two updates for a tile.
|
boolean |
isAllowOutdatedTiles()
Returns whether outdated tiles may be returned if an exception occurs while retrieving a tile.
|
boolean |
isAutoIncreaseCacheSize()
Returns whether the size of the fixed cache will be increased automatically if it is too small
to contain all visible tiles at the optimal level of detail.
|
boolean |
isSoftCachingEnabled()
Returns whether the soft cache is enabled or not.
|
protected boolean |
isValidCoverage(ILcdEarthTileSetCoverage aCoverage)
Returns whether the given coverage can be drawn by this painter.
|
void |
paint(Graphics aGraphics,
int aMode,
ILcdGXYContext aContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
setAllowOutdatedTiles(boolean aAllowOutdatedTiles)
Sets whether outdated tiles may be returned if an exception occurs while retrieving a tile.
|
void |
setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
Sets whether the tiles can be requested asynchronously.
|
void |
setAutoIncreaseCacheSize(boolean aAutoIncreaseCacheSize)
Sets whether the size of the fixed cache should be increased automatically if it is too small
to contain all visible tiles at the optimal level of detail.
|
void |
setCacheSize(int aCacheSize)
This sets the size of the fixed cache which uses hard references (in #tiles).
|
void |
setDeltaX(int aDeltaX)
Sets the horizontal grid spacing of the icons.
|
void |
setDeltaY(int aDeltaY)
Sets the vertical grid spacing of the icons.
|
void |
setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
Sets the exception handler that is used to handle exceptions that occur during tile retrieval.
|
void |
setParameterizedIcon(ILcdParameterizedIcon aParameterizedIcon)
Sets the parameterized icon that is used.
|
void |
setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
Sets whether the view is repainted when a tile becomes available.
|
void |
setSoftCachingEnabled(boolean aSoftCachingEnabled)
Enables or disables the soft cache.
|
void |
setUpdateInterval(long aTime)
Sets the time between two updates for a tile.
|
void |
updateTiles(ILcdGXYView aGXYView)
Updates all tiles that are cached in both the fixed cache and the soft cache.
|
void |
updateTiles(Object aObject,
ILcdGXYView aGXYView)
Updates all tiles that are cached in both the fixed cache and the soft cache for an object.
|
boundsSFCT, getCacheSize, getExceptionHandler, getObject, getTileSet, getTileSetCoverage, isAsynchronousTileRequestAllowed, isRepaintViewWhenTileAvailable, isTouched, setObject
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
public TLcdEarthGXYMultivaluedRasterPainter()
public int getDeltaX()
50
.public void setDeltaX(int aDeltaX)
aDeltaX
- the horizontal distance between the icons (in #pixels)public int getDeltaY()
50
.public void setDeltaY(int aDeltaY)
aDeltaY
- the vertical distance between the icons (in #pixels)public ILcdParameterizedIcon getParameterizedIcon()
null
public void setParameterizedIcon(ILcdParameterizedIcon aParameterizedIcon)
null
value before this painter can be used.aParameterizedIcon
- the parameterized iconpublic void setCacheSize(int aCacheSize)
setAutoIncreaseCacheSize(boolean)
property.
Next to this cache there is also an optional cache that uses soft references (see isSoftCachingEnabled()
).setCacheSize
in class ALcdEarthGXYPainter
aCacheSize
- the new cache sizepublic void clearCache()
clearCache
in class ALcdEarthGXYPainter
setCacheSize(int)
,
isSoftCachingEnabled()
public void clearCache(Object aObject)
aObject
- the object whose cache should be clearedsetCacheSize(int)
,
isSoftCachingEnabled()
public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
ALcdEarthGXYPainter
setAsynchronousTileRequestAllowed
in class ALcdEarthGXYPainter
aAsynchronousTileRequestAllowed
- True if the tiles can be requested asynchronouslyALcdEarthGXYPainter.isAsynchronousTileRequestAllowed()
public void setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
ALcdEarthGXYPainter
setRepaintViewWhenTileAvailable
in class ALcdEarthGXYPainter
aRepaintViewWhenTileAvailable
- whether the view should repainted when a tile becomes
availablepublic void updateTiles(ILcdGXYView aGXYView)
aGXYView
- the view that this painter is painting insetCacheSize(int)
,
isSoftCachingEnabled()
public void updateTiles(Object aObject, ILcdGXYView aGXYView)
aObject
- the object whose tiles should be updatedaGXYView
- the view that this painter is painting insetCacheSize(int)
,
isSoftCachingEnabled()
public boolean isAutoIncreaseCacheSize()
true
if the size of the fixed cache will be increased automatically if it
is too small to containsetCacheSize(int)
public void setAutoIncreaseCacheSize(boolean aAutoIncreaseCacheSize)
aAutoIncreaseCacheSize
- whether if the size of the fixed cache should be increased
automatically if it is too small to containsetCacheSize(int)
public boolean isSoftCachingEnabled()
true
if the soft cache is enabledsetCacheSize(int)
public void setSoftCachingEnabled(boolean aSoftCachingEnabled)
aSoftCachingEnabled
- whether the soft cache should be enabledisSoftCachingEnabled()
public void setUpdateInterval(long aTime)
aTime
- the time in millisecondsgetUpdateInterval()
public long getUpdateInterval()
ILcdEarthTileSet.updateTile(com.luciad.earth.tileset.ALcdEarthTile, com.luciad.earth.tileset.TLcdEarthTileOperationMode, com.luciad.earth.tileset.ILcdEarthTileSetCallback, java.lang.Object)
if they are older than this time. The
tiles will never be updated automatically if Long.MAX_VALUE
is set as the time.
The tiles will be updated continuously if 0
is set as the time.
The default time is 1 minute.public boolean isAllowOutdatedTiles()
true
.true
if outdated tiles may be returned if an exception occurs while
retrieving a tilepublic void setAllowOutdatedTiles(boolean aAllowOutdatedTiles)
aAllowOutdatedTiles
- true
if outdated tiles may be returned if an exception
occurs while retrieving a tileisAllowOutdatedTiles()
public void setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
ALcdEarthGXYPainter
setExceptionHandler
in class ALcdEarthGXYPainter
aExceptionHandler
- the exception handlerpublic TLcdEarthTileContext getTileContext(Object aObject)
null
if the specified object has never been painted or if
its cache as been cleared
.
The set of painted tiles may or may not contain some painted tiles if they are no longer available
(for example due to garbage collection).
The returned map will never change and is thread-safe for reading.aObject
- the objectnull
protected ILcdEarthTileSet getTileSet(Object aObject)
configured
and then wrapped
with an
asynchronous tile set to ensure smooth painting.getTileSet
in class ALcdEarthGXYPainter
aObject
- the object being paintedprotected ILcdEarthTileSet configureBaseTileSet(Object aObject, ILcdEarthTileSet aTileSet)
aObject
- the object being paintedaTileSet
- the base tile setchooseTileSetCoverage(com.luciad.earth.tileset.ILcdEarthTileSet)
,
getTileSet(Object)
protected ILcdEarthTileSet createAsynchronousTileSet(Object aObject, ILcdEarthTileSet aTileSet)
aObject
- the object being paintedaTileSet
- the tile setTLcdEarthAsynchronousTileSet
,
getTileSet(Object)
protected ILcdEarthTileSetCoverage chooseTileSetCoverage(ILcdEarthTileSet aTileSet)
chooseTileSetCoverage
in class ALcdEarthGXYPainter
aTileSet
- the tile set whose tiles are being paintedisValidCoverage(com.luciad.earth.tileset.ILcdEarthTileSetCoverage)
protected boolean isValidCoverage(ILcdEarthTileSetCoverage aCoverage)
true
if the coverage implements ILcdEarthRasterTileSetCoverage
and the tiles set supports
a format with TLcdEarthMultivaluedData
as format
class and no format name with the specified coverage.aCoverage
- the candidate coveragetrue
if the given coverage can be paintedILcdEarthRasterTileSetCoverage
,
ILcdEarthTileSet.isFormatSupported(com.luciad.earth.tileset.ILcdEarthTileSetCoverage,
com.luciad.earth.tileset.TLcdEarthTileFormat)
public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aContext)
ILcdGXYPainter
The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:
The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.
When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for
interpreting interaction on the representation of an object and modifying the representation of the object
accordingly. The painter is not responsible for modifying the object itself, this is done by
a corresponding ILcdGXYEditor
.
Implementations of ILcdGXYPainter
and ILcdGXYEditor
interfaces must be consistent for
an object: the painter must display the result of the user interaction on the object, while the editor is
responsible for modifying the object as a result of the user interaction.
A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter
and ILcdGXYEditor
interfaces in a single class.
When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as
snap target by the method snapTarget
must be painted in order to provide the user with a visual indication of the snap target.
The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.
paint
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aContext
- the ILcdGXYContext
the drawing depends on.public Object clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdEarthGXYPainter
Object.clone()
public void addStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
Registers the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source,
you can use a ALcdWeakStatusListener
instance as status listener.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.