public abstract class ALcdEarthGXYPainter extends ALcdGXYPainter
ILcdEarthTileSet
s in an ILcdGXYView
.defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
ALcdEarthGXYPainter()
Constructs a new
ALcdEarthGXYPainter with the default cache size. |
ALcdEarthGXYPainter(int aCacheSize)
Constructs a new
ALcdEarthGXYPainter with the specified cache size. |
Modifier and Type | Method and Description |
---|---|
void |
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 |
clearCache()
Clears the cache.
|
Object |
clone()
Makes
Object.clone() public. |
int |
getCacheSize()
Returns the size of the cache (in #tiles).
|
ILcdExceptionHandler |
getExceptionHandler()
Returns the exception handler that is used to handle exceptions that occur during tile
retrieval.
|
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
protected ILcdEarthTileSet |
getTileSet()
Returns the tile set for the current object.
|
protected ILcdEarthTileSet |
getTileSet(Object aObject)
Called by
setObject(Object) ) each time aObject is painted, in order
to retrieve an ILcdEarthTileSet corresponding to that object. |
protected ILcdEarthTileSetCoverage |
getTileSetCoverage()
Returns the coverage in the tile set for the current object.
|
boolean |
isAsynchronousTileRequestAllowed()
Returns whether the tiles can be requested asynchronously.
|
boolean |
isRepaintViewWhenTileAvailable()
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 |
setObject(Object aObject)
|
void |
setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
Sets whether the view is repainted when a tile becomes available.
|
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
paint
public ALcdEarthGXYPainter()
ALcdEarthGXYPainter
with the default cache size.public ALcdEarthGXYPainter(int aCacheSize)
ALcdEarthGXYPainter
with the specified cache size.aCacheSize
- the size of the cachepublic int getCacheSize()
public void setCacheSize(int aCacheSize)
aCacheSize
- the new cache sizepublic void clearCache()
public boolean isAsynchronousTileRequestAllowed()
public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
aAsynchronousTileRequestAllowed
- True if the tiles can be requested asynchronouslyisAsynchronousTileRequestAllowed()
public boolean isRepaintViewWhenTileAvailable()
public void setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
aRepaintViewWhenTileAvailable
- whether the view should repainted when a tile becomes
availablepublic ILcdExceptionHandler getExceptionHandler()
public void setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
aExceptionHandler
- the exception handlerpublic void setObject(Object aObject)
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
protected ILcdEarthTileSet getTileSet(Object aObject)
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.aObject
- the object being paintedprotected abstract ILcdEarthTileSetCoverage chooseTileSetCoverage(ILcdEarthTileSet aTileSet)
aTileSet
- the tile set that will be paintedpublic Object getObject()
ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
protected ILcdEarthTileSet getTileSet()
getTileSet(Object)
protected ILcdEarthTileSetCoverage getTileSetCoverage()
getTileSet()
,
getObject()
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
ILcdGXYPainter
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.
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.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.isTouched
public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aContext)
ILcdGXYPainter
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:
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.
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 coordinatesboundsSFCT
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 ALcdGXYPainter
Object.clone()