public class TLcdNoWarpMultilevelRasterPainter extends ALcdRasterPainter implements ILcdRasterPainter, ILcdGXYPainterProvider
ILcdGXYPainter
can paint ILcdMultilevelRaster
instances, applying only a scaling transformation. This requires that the
model reference is the same as the world reference of the view. For more
complex transformations, the TLcdWarpMultilevelRasterPainter
should
be used.
The painter picks the raster level to be painted, based on the pixel density of the rasters and on the resolution of the view. It essentially picks the first level for which raster pixels are not projected across multiple view pixels is selected. This approach avoids pixelation effects. The levelSwitchFactor property allows to adjust this behavior.
The startResolutionFactor and stopResolutionFactor properties additionally allow to put limits on the number of raster pixels per screen pixel.
DENSITY_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 |
---|
TLcdNoWarpMultilevelRasterPainter()
Creates a new TLcdNoWarpMultilevelRasterPainter, with a default name.
|
TLcdNoWarpMultilevelRasterPainter(String aDisplayName)
Creates a new TLcdNoWarpMultilevelRasterPainter.
|
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 |
clone()
Makes
Object.clone() public. |
ILcdGXYPainter |
getGXYPainter(Object aObject)
Finds an
ILcdGXYPainter that can be used to paint or locate the object passed. |
double |
getLevelSwitchFactor() |
double[] |
getLevelSwitchScales() |
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isUseDeferredSubTileDecoding()
Returns whether this painter does not wait for tiles to be fully decoded
before painting them.
|
boolean |
isUseSubTileImageCaching()
Returns whether this painter caches images that have been created from
raster subtiles.
|
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.
|
void |
setLevelSwitchFactor(double aLevelSwitchFactor)
Sets the factor that affects the scale point at which a raster level is
selected.
|
void |
setLevelSwitchScales(double[] aLevelSwitchScales)
Sets the scales at which the painter will switch between raster levels.
|
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setUseDeferredSubTileDecoding(boolean aDefer)
Specifies whether this painter should not wait for tiles to be fully
decoded before painting them.
|
void |
setUseSubTileImageCaching(boolean aCaching)
Specifies whether this painter should cache images that have been created
from raster subtiles.
|
int |
suitableRasterLevel(ILcdMultilevelRaster aMultiLevelRaster,
ILcdGXYContext aGXYContext)
Computes the raster level in the given multi-level raster that is most
suitable for processing or analysis, in the given context.
|
int |
suitableRasterLevel(ILcdMultilevelRaster aMultiLevelRaster,
ILcdGXYContext aGXYContext,
Graphics aGraphics)
Computes the raster level in the given multi-level raster that is most
suitable for display, in the given context.
|
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, removePropertyChangeListener, setClassTraceOn, setDisplayName
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBrightness, getColorModel, getMaxNoOfOutlineTiles, getMaxNumberOfOutlineTiles, getOutlineColor, getStartResolutionFactor, getStopResolutionFactor, getTransparency, isForcePainting, isPaintOutline, setBrightness, setColorModel, setForcePainting, setMaxNoOfOutlineTiles, setMaxNumberOfOutlineTiles, setOutlineColor, setPaintOutline, setStartResolutionFactor, setStopResolutionFactor, setTransparency
anchorPointSFCT, getCursor, getDisplayName, isTouched, snapTarget, supportSnap
addPropertyChangeListener, removePropertyChangeListener
public TLcdNoWarpMultilevelRasterPainter()
public TLcdNoWarpMultilevelRasterPainter(String aDisplayName)
aDisplayName
- the displayName of the painter.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 setUseSubTileImageCaching(boolean aCaching)
true
helps to
avoid disk access during painting (due to lazy loading of raster tiles).
It may also speed up the painting of rasters with non-standard color
models, like 16 bit indexed color images. The default is
false
.public boolean isUseSubTileImageCaching()
setUseSubTileImageCaching(boolean)
public void setUseDeferredSubTileDecoding(boolean aDefer)
true
means that parts of the view may remain blank, but the display will update
sooner. A proper complete display update will be triggered when there are
no more tiles waiting to be decoded. The default is false
.
This property is only relevant if isUseSubTileImageCaching()
is true
.
Note that this functionality is not needed for layers wrapped by ILcdGXYAsynchronousLayerWrapper. For best results, use the latter mechanism instead and set this property to false.
public boolean isUseDeferredSubTileDecoding()
setUseDeferredSubTileDecoding(boolean)
public void setLevelSwitchFactor(double aLevelSwitchFactor)
An alternative way to specify the scales of the levels to be painted
is setLevelSwitchScales
.
public double getLevelSwitchFactor()
setLevelSwitchFactor(double)
public void setLevelSwitchScales(double[] aLevelSwitchScales)
If the scales are not set, the raster pixel density is used to
automatically determine the level of the raster to be painted (also see
setLevelSwitchFactor
).
public double[] getLevelSwitchScales()
setLevelSwitchScales(double[])
public void setObject(Object aObject)
ILcdGXYPainter
Setting the object on the painter may have an effect on the internal state of the painter, for example, the color to use.
When the object is set to a painter, the context parameter in subsequent calls to methods in this class must contain a layer that contains this object and for which the painter for this object is this painter.
setObject
in interface ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public Object getObject()
ILcdGXYPainter
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
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 int suitableRasterLevel(ILcdMultilevelRaster aMultiLevelRaster, ILcdGXYContext aGXYContext)
aMultiLevelRaster
- the multi-level raster from which a raster is to
be selected for processing or analysis.aGXYContext
- the context that contains the model of the raster,
the model-to-world transformation, and the
view-to-world transformation.ALcdRasterPainter.setStartResolutionFactor(double)
,
setLevelSwitchFactor(double)
,
setLevelSwitchScales(double[])
,
ALcdRasterPainter.densityCheck(ILcdRaster, ILcdGXYContext)
public int suitableRasterLevel(ILcdMultilevelRaster aMultiLevelRaster, ILcdGXYContext aGXYContext, Graphics aGraphics)
aMultiLevelRaster
- the multi-level raster from which a raster is to
be selected for display.aGXYContext
- the context that contains the model of the raster,
the model-to-world transformation, and the
view-to-world transformation.aGraphics
- the Graphics instance on which the raster is to
be painted.ALcdRasterPainter.setStartResolutionFactor(double)
,
setLevelSwitchFactor(double)
,
setLevelSwitchScales(double[])
,
ALcdRasterPainter.densityCheck(ILcdRaster, ILcdGXYContext, Graphics)
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
public ILcdGXYPainter getGXYPainter(Object aObject)
ILcdGXYPainterProvider
ILcdGXYPainter
that can be used to paint or locate the object passed.
The painter provider is responsible for setting the object to the painter before returning the painter. An implementation should therefore have the following structure:
public ILcdGXYPainter getGXYPainter(Object aObject) {
ILcdGXYPainter painter = ... // find the painter for the object
if (painter != null) {
painter.setObject(aObject);
}
return painter;
}
getGXYPainter
in interface ILcdGXYPainterProvider
getGXYPainter
in class ALcdGXYPainter
aObject
- the object to find a painter forpublic 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 ALcdRasterPainter
Object.clone()