public class TLcdAllInMemoryRasterPainter extends ALcdRasterPainter implements ILcdGXYPainter
TLcdAllInMemoryRasterPainter
implements an ILcdGXYPainter
for an ILcdRaster
.
TLcdAllInMemoryRasterPainter
paints only the outline of the tiles of the raster
if the scale of the ILcdGXYView
on which to paint
is such that the screen resolution is outside the
range defined by the properties startResolutionFactor
and stopResolutionFactor.
Otherwise, TLcdAllInMemoryRasterPainter
paints the visible portion of
the raster.
The resolution factor defines ratio between the
resolution of the raster and the resolution of the screen,
the resolution being the number of pixels per unit area.
For example, a resolution factor of 4 indicates that 4
raster pixels are used to produce a single screen pixel,
and a factor of 0.25 indicates that a single raster pixel
will be used to paint four screen pixels.
Typical values for startResolutionFactor and stopResolutionFactor
are 2 and 0.5, respectively,
indicating that as we zoom in,
the raster becomes visible at a point where 2 raster pixels are
merged into a single screen pixel, and the raster becomes
invisible at a point where a single raster pixel is blurred
into two screen pixels.
The value of the startResolutionFactor together with
the dimensions of the tiles and the dimension of
the ILcdGXYView
on which to paint, determine the
maximum number of tiles that need to be loaded in memory
upon painting the visible portion of the raster.
The minimum value of the maximum number of tiles is always four
because the visible portion can always be located at
the intersection of four tiles.
Suppose we have tiles of 1024 by 1024 pixels, and a maximum
ILcdGXYView
size of 800 by 600. Suppose further that we
we choose a startResolutionFactor of 9. Then, there may
be a maximum of 3 by 2 tiles needed to paint the 800 by 600
ILcdGXYView
, thus requiring 6 tiles to be in memory.
This calculation is a rough approximation because
of the non-linear transformation between the data reference
of the raster and the data reference of the ILcdGXYView
.
For example, at a small scale, an ILcdGXYView
with a data reference
based on an Orthographic projection may require more tiles
than calculated with the above procedure.
Therefore, as a rule of thumb, allocate twice the amount
of memory to hold the maximum number of tiles calculated.
It is clear that if the number of non-empty tiles in the raster is less than four, the value of the startResolutionFactor can be set at any value.
Often, multiple instances of ILcdRaster
with
different resolutions are painted in different layers.
In that case, the choice of the startResolutionFactor and the
stopResolutionFactor of the different TLcdAllInMemoryRasterPainters
is often chosen in such a way that the stopResolutionFactor
of the painter in one layer corresponds to the startResolutionFactor
of the next layer holding a raster with a higher resolution.
For example, suppose we have two ILcdRasters
, one that holds
1 degree by 1 degree tiles of 1024 by 1024 pixels and a second
raster 30' by 30' of 1024 by 1024 pixels.
The resolution of the second raster is four times the resolution
of the first raster. Hence, in order to match the stopResolutionFactor
of the first raster with the startResolutionFactor of the second
raster, they have to be in the proportion of 1 to 4.
The symmetrical choice around a ResolutionFactor of 1
is 0.5 for the stopResolutionFactor of the painter of the first raster
and 2 for the startResolutionFactor of the painter of the second raster.
ILcdRaster
,
Serialized FormDENSITY_OK, DENSITY_TOO_HIGH, DENSITY_TOO_LOW, fBrightness, fColorModel, fContrast, fFillOutlineArea, fForcePainting, fMaxNumberOfOutlineTiles, fPaintOutline, fRGBImageFilter, fStartResolutionFactor, fStopResolutionFactor, fTransparency
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdAllInMemoryRasterPainter() |
TLcdAllInMemoryRasterPainter(String aDisplayName) |
Modifier and Type | Method and Description |
---|---|
void |
boundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
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.
|
Object |
getObject()
Gets the Object this ILcdGXYPainter represents.
|
boolean |
getPaintCache() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
paint(Graphics aGraphics,
int aState,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setObject(Object aObject)
Sets the Object to be represented by this ILcdGXYPainter.
|
void |
setPaintCache(boolean aCache)
Specifies whether the painter should cache the raster images it has drawn.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
clone, densityCheck, densityCheck, getBrightness, getColorModel, getContrast, getMaxNoOfOutlineTiles, getMaxNumberOfOutlineTiles, getOutlineAreaFillStyle, getOutlineColor, getOutlineStyle, getRGBImageFilter, getSnapIcon, getStartResolutionFactor, getStartScale, getStopResolutionFactor, getStopScale, getTransparency, idealPixelDensity, idealPixelDensity, idealPixelDensity, isFillOutlineArea, isForcePainting, isPaintOutline, isTouched, resolutionFactor, setBrightness, setColorModel, setContrast, setFillOutlineArea, setForcePainting, setMaxNoOfOutlineTiles, setMaxNumberOfOutlineTiles, setOutlineAreaFillStyle, setOutlineColor, setOutlineStyle, setPaintOutline, setRGBImageFilter, setSnapIcon, setStartResolutionFactor, setStartScale, setStopResolutionFactor, setStopScale, setTransparency, snapTarget, supportSnap
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, removePropertyChangeListener, setDisplayName
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
anchorPointSFCT, getCursor, getDisplayName, isTouched, snapTarget, supportSnap
clone
addPropertyChangeListener, removePropertyChangeListener
public TLcdAllInMemoryRasterPainter()
public TLcdAllInMemoryRasterPainter(String aDisplayName)
aDisplayName
- the displayName of the painter.public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.setTraceOn
in class ALcdGXYPainter
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.public boolean isTraceOn()
true
if tracing is enabled for this class.isTraceOn
in class ALcdGXYPainter
public void setObject(Object aObject)
ILcdRaster
.setObject
in interface ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public Object getObject()
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void setPaintCache(boolean aCache)
public boolean getPaintCache()
public void paint(Graphics aGraphics, int aState, ILcdGXYContext aGXYContext)
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
paint
in class ALcdRasterPainter
aGraphics
- the Graphics on which the representation of the object is paintedaState
- the mode the object is represented in (see class documentation).aGXYContext
- the ILcdGXYContext
the drawing depends on.public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, 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.
boundsSFCT
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). 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.aGXYContext
- 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