Class TLcdWarpMultilevelRasterPainter
- All Implemented Interfaces:
ILcdRasterPainter
,ILcdCloneable
,ILcdPropertyChangeSource
,ILcdGXYPainter
,ILcdGXYPainterProvider
,Serializable
,Cloneable
ILcdGXYPainter
can paint ILcdMultilevelRaster
instances, warping them between different coordinate systems as required.
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.
- See Also:
-
Field Summary
Fields inherited from class com.luciad.format.raster.ALcdRasterPainter
DENSITY_OK, DENSITY_TOO_HIGH, DENSITY_TOO_LOW, fBrightness, fColorModel, fContrast, fFillOutlineArea, fForcePainting, fMaxNumberOfOutlineTiles, fPaintOutline, fRGBImageFilter, fStartResolutionFactor, fStopResolutionFactor, fTransparency
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
ConstructorDescriptionCreates a new TLcdWarpMultilevelRasterPainter, with a default name.TLcdWarpMultilevelRasterPainter
(String aDisplayName) Creates a new TLcdWarpMultilevelRasterPainter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.clone()
MakesObject.clone()
public.protected Image
createTransformedImage
(ILcdGXYContext aGXYContext, Rectangle aClip, ILcdRaster aRaster, RGBImageFilter aRGBImageFilter, float aTransparency, float aBrightness, float aContrast, ColorModel aColorModel) Creates the warped image that can be painted onto the view.int
Returns the additional border around all sides of the view.getGXYPainter
(Object aObject) Finds anILcdGXYPainter
that can be used to paint or locate the object passed.double
Returns the factor that affects the scale point at which a raster level is selected.double[]
Returns the scales at which the painter will switch between raster levels.Returns the Object for which the representation is currently being handled by this painter.int
Returns the sampling rate used when transforming the raster.boolean
Returns whether this painter caches the warped raster images it has painted.int
Returns the width and height of the block in which the raster transformation is approximated using bilinear interpolation.boolean
boolean
Returns whether this painter caches a single warped raster image with this raster painter.boolean
Deprecated.This method has been deprecated.void
paint
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.void
setAvoidOpaqueBorder
(boolean aAvoidOpaqueBorder) Specifies whether the painter should avoid drawing opaque borders around transformed rasters.void
setBorder
(int aBorder) Sets an additional border around all sides of the view, defining a region in which a painted raster is transformed and cached.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
Sets the Object for which the representation shall be handled by this painter.void
setOversamplingRate
(int aOverSamplingRate) Sets the number of samples used per pixel when transforming a raster.void
setPaintCache
(boolean aCache) Specifies whether this painter should cache the warped raster images it has painted.void
setReuseInternalBuffer
(boolean aReuseInternalBuffer) Specifies whether this painter should cache a single warped raster image with this raster painter, or whether it should cache a warped raster image with each raster that is painted.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.void
setWarpBlockSize
(int aWarpBlockSize) Sets the width and height of the block in which the raster transformation is approximated using bilinear interpolation.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.Methods inherited from class com.luciad.format.raster.ALcdRasterPainter
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
Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, removePropertyChangeListener, setClassTraceOn, setDisplayName
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
anchorPointSFCT, getCursor, getDisplayName, isTouched, snapTarget, supportSnap
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
Methods inherited from interface com.luciad.format.raster.ILcdRasterPainter
getBrightness, getColorModel, getMaxNoOfOutlineTiles, getMaxNumberOfOutlineTiles, getOutlineColor, getStartResolutionFactor, getStopResolutionFactor, getTransparency, isForcePainting, isPaintOutline, setBrightness, setColorModel, setForcePainting, setMaxNoOfOutlineTiles, setMaxNumberOfOutlineTiles, setOutlineColor, setPaintOutline, setStartResolutionFactor, setStopResolutionFactor, setTransparency
-
Constructor Details
-
TLcdWarpMultilevelRasterPainter
public TLcdWarpMultilevelRasterPainter()Creates a new TLcdWarpMultilevelRasterPainter, with a default name. -
TLcdWarpMultilevelRasterPainter
Creates a new TLcdWarpMultilevelRasterPainter.- Parameters:
aDisplayName
- the displayName of the painter.
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdGXYPainter
- Parameters:
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.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdGXYPainter
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setPaintCache
public void setPaintCache(boolean aCache) Specifies whether this painter should cache the warped raster images it has painted. A warped raster image has the same size as the view for which it was created. Caching it may improve performance if it can be reused, and it can generally avoid repeated allocation of large image objects on the heap. The default istrue
.- See Also:
-
getPaintCache
public boolean getPaintCache()Returns whether this painter caches the warped raster images it has painted.- See Also:
-
setReuseInternalBuffer
public void setReuseInternalBuffer(boolean aReuseInternalBuffer) Specifies whether this painter should cache a single warped raster image with this raster painter, or whether it should cache a warped raster image with each raster that is painted. Caching a single image with this painter and reusing it is generally more memory-efficient. Caching images with the painted rasters can improve performance, but it may also waste a a lot of memory. The default isfalse
.This property is only relevant if
setPaintCache(boolean)
istrue
. -
isReuseInternalBuffer
public boolean isReuseInternalBuffer()Returns whether this painter caches a single warped raster image with this raster painter.- See Also:
-
setAvoidOpaqueBorder
public void setAvoidOpaqueBorder(boolean aAvoidOpaqueBorder) Specifies whether the painter should avoid drawing opaque borders around transformed rasters.The painter normally uses the default pixel of a raster when painting the border around a transformed raster. If the default pixel is transparent, the border is invisible. Otherwise, the border is opaque. This typically occurs if a raster has an IndexColorModel without a transparent color index.
Setting this property activates some additional processing to avoid the opaque border anyway. The processing overhead can run up to 50% when painting described rasters. Leaving the property unset is therefore preferable, for instance when the area around painted rasters is not relevant for the application. The default is
false
. -
isAvoidOpaqueBorder
public boolean isAvoidOpaqueBorder()- See Also:
-
setBorder
public void setBorder(int aBorder) Sets an additional border around all sides of the view, defining a region in which a painted raster is transformed and cached. A full repaint will be slower, but subsequent panning over the cached region will then be faster. For instance, a border of 200 pixels around a view of 800 by 600 pixels defines a cache region of 1200 by 1000 pixels. The default border is 0 pixels.- Parameters:
aBorder
- the border, expressed in pixels.
-
getBorder
public int getBorder()Returns the additional border around all sides of the view.- See Also:
-
setOversamplingRate
public void setOversamplingRate(int aOverSamplingRate) Sets the number of samples used per pixel when transforming a raster. The default is 1. The total number of samples used per pixel equals(aOverSamplingRate * aOverSamplingRate)
. For instance, if the oversampling rate is set to 2, the painter will take 4 samples per pixel and average their values. This increases the image quality, especially if the raster contains sharp edges, but it also increases the computational cost.- Parameters:
aOverSamplingRate
- the number of samples used per pixel in one direction.
-
getOversamplingRate
public int getOversamplingRate()Returns the sampling rate used when transforming the raster. This is the number of samples used per pixel in one direction.- See Also:
-
setWarpBlockSize
public void setWarpBlockSize(int aWarpBlockSize) Sets the width and height of the block in which the raster transformation is approximated using bilinear interpolation. Smaller values result in more accurate results, but also larger computation times. The default is 64. With a value of 1, every pixel is transformed without approximation.- Parameters:
aWarpBlockSize
- the width and height, expressed in pixels.
-
getWarpBlockSize
public int getWarpBlockSize()Returns the width and height of the block in which the raster transformation is approximated using bilinear interpolation.- See Also:
-
setLevelSwitchFactor
public void setLevelSwitchFactor(double aLevelSwitchFactor) Sets the factor that affects the scale point at which a raster level is selected. The default value is 1.0: as soon as a single raster pixel would project to several screen pixels, a higher resolution level is used. This way, the highest practical raster quality is chosen. A value smaller than 1.0 delays this switching: a single raster pixel may project to multiple screen pixels. Such a value may cause pixelating effects, but it can reduce the burden of loading, decoding, and caching rasters.An alternative way to specify the scales of the levels to be painted is
setLevelSwitchScales
. -
getLevelSwitchFactor
public double getLevelSwitchFactor()Returns the factor that affects the scale point at which a raster level is selected.- See Also:
-
setLevelSwitchScales
public void setLevelSwitchScales(double[] aLevelSwitchScales) Sets the scales at which the painter will switch between raster levels. The number of values must be equal to the number of raster levels minus 1. They should be specified in ascending order, corresponding to raster levels with increasing resolutions.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
). -
getLevelSwitchScales
public double[] getLevelSwitchScales()Returns the scales at which the painter will switch between raster levels.- See Also:
-
setObject
Description copied from interface:ILcdGXYPainter
Sets the Object for which the representation shall be handled by this painter.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.
- Specified by:
setObject
in interfaceILcdGXYPainter
- Parameters:
aObject
- the object for which the representation shall be handled by this painter.- See Also:
-
getObject
Description copied from interface:ILcdGXYPainter
Returns the Object for which the representation is currently being handled by this painter.- Specified by:
getObject
in interfaceILcdGXYPainter
- Returns:
- the Object for which the representation is currently being handled by this painter.
- See Also:
-
paint
Description copied from interface:ILcdGXYPainter
Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.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:
- transformations which allow to compute the location in view space of points and bounds given in model, space
- a pen which can connect points with a line or create arcs around a point,
- the view for which the object's representation must be painted. This can be useful when the painted object depends on the scale of the view, or the presence of other layers in the view.
- the current location(s) of the mouse or input device and the last location(s) the mouse or input device was pressed.
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 ofILcdGXYPainter
andILcdGXYEditor
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 theILcdGXYPainter
andILcdGXYEditor
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.
- Specified by:
paint
in interfaceILcdGXYPainter
- Overrides:
paint
in classALcdRasterPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aGXYContext
- theILcdGXYContext
the drawing depends on.
-
suitableRasterLevel
Computes the raster level in the given multi-level raster that is most suitable for processing or analysis, in the given context. The level is based on the pixel densities of the rasters compared to the scale of the view, taking into account the necessary transformations between the raster's model coordinates and the view coordinates.- Parameters:
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.- Returns:
- the suitable raster level.
- See Also:
-
suitableRasterLevel
public 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. The level is based on the pixel densities of the rasters compared to the scale of the view and the Graphics, taking into account the necessary transformations between the raster's model coordinates and the view coordinates.- Parameters:
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.- Returns:
- the suitable raster level.
- See Also:
-
createTransformedImage
protected Image createTransformedImage(ILcdGXYContext aGXYContext, Rectangle aClip, ILcdRaster aRaster, RGBImageFilter aRGBImageFilter, float aTransparency, float aBrightness, float aContrast, ColorModel aColorModel) Creates the warped image that can be painted onto the view.This method is subject to change.
- See Also:
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, 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.- Specified by:
boundsSFCT
in interfaceILcdGXYPainter
- 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.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.- 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:
-
getGXYPainter
Description copied from interface:ILcdGXYPainterProvider
Finds anILcdGXYPainter
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; }
- Specified by:
getGXYPainter
in interfaceILcdGXYPainterProvider
- Overrides:
getGXYPainter
in classALcdGXYPainter
- Parameters:
aObject
- the object to find a painter for- Returns:
- a painter that can be used to paint or locate the object; or null if no painter could be found for the given object, or the object could not be set on the retrieved painter.
-
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 classALcdRasterPainter
- Returns:
- a clone of this painter provider.
- See Also:
-