public class TLcdGXYImagePainter extends ALcdGXYPainter
ILcdGXYView
.
This painter can optionally apply operators to images via the
setOperatorChain(com.luciad.imaging.operator.ALcdImageOperatorChain)
method.
This painter supports all ALcdImage
variants
(ALcdBasicImage,
ALcdMultilevelImage,
ALcdImageMosaic and
ALcdMultilevelImageMosaic), as well as
ILcdRaster,
ILcdMultilevelRaster and
ILcdEarthTileSet
.
This painter can warp images between different coordinate systems, if required, or just paint linearly scaled images, if possible.
It paints the visible portion of the image if the scale of the
ILcdGXYView
on which to paint is such that the screen resolution
is inside the range defined by the properties startResolutionFactor and
stopResolutionFactor. Outside of this range, it paints only the outline of
the image. The resolution factor defines the ratio between the
resolution of the raster and the resolution of the screen. For example, a
resolution factor of 4 indicates that 4 image pixels are used to color a
single screen pixel. A factor of 0.25 indicates that a single image 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 image becomes visible at a point where 2
raster pixels are merged into a single screen pixel, and the image becomes
invisible at a point where a single raster pixel is blurred into two screen
pixels.
The value of the startResolutionFactor, 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, when painting the
visible portion of the image. The minimum value of the maximum number of
tiles is always four because the visible portion can always be pointed 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
image 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.
Given a multilevel image, the painter picks the level to be painted based on the pixel density of the images and on the resolution of the view. It essentially picks the first level for which image pixels are not projected across multiple view pixels. This approach avoids pixelation effects. The levelSwitchFactor property allows to adjust this behavior.
ALcdMultilevelImageMosaic
independently of its tile structureisAsynchronousTileRequestAllowed()
and isRepaintViewWhenTileAvailable()
should be
set to true
(default).
When visualizing non-color data such as elevation data or multiband/hyperspectral data the painter needs to convert
the data to displayable colors. You can configure an image operator chain
to control the conversion to colors. Typically this can be done by selecting bands
and either interpreting them as color bands
or
mapping values to colors
.
By default the painter converts elevation data to color using the default color map
or otherwise maps the first band to gray-scale values.
com.luciad.imaging
,
Serialized FormdefaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdGXYImagePainter()
Create a new painter which uses the default shared imaging engine.
|
TLcdGXYImagePainter(ALcdImagingEngine aImagingEngine)
Create a new painter which uses the specified imaging engine.
|
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. |
static ILcdGXYPainterProvider |
create(ILcdModel aModel,
ALcdImagingEngine aImagingEngine)
This method creates a painter provider that configures a GXY painter with the defaults for painting raster data.
|
float |
getBrightness()
Returns the current brightness value.
|
float |
getContrast()
Returns the current contrast value.
|
double |
getLevelSwitchFactor() |
double[] |
getLevelSwitchScales() |
int |
getMaxNumberOfOutlineTiles() |
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
float |
getOpacity()
Returns the current opacity setting.
|
ALcdImageOperatorChain |
getOperatorChain()
Returns the current image operator chain.
|
ILcdGXYPainterStyle |
getOutlineAreaFillStyle() |
Color |
getOutlineColor() |
ILcdGXYPainterStyle |
getOutlineStyle()
Returns the style that is used to draw the bounds of images and/or tiles.
|
int |
getOversamplingRate()
Returns the sampling rate used when transforming the image.
|
double |
getStartResolutionFactor() |
double |
getStartScale()
Returns the start scale.
|
double |
getStopResolutionFactor() |
double |
getStopScale()
Returns the stop scale.
|
int |
getWarpBlockSize()
Returns the width and height of the block in which the image
transformation is approximated using bilinear interpolation.
|
boolean |
isAsynchronousTileRequestAllowed()
Returns whether the tiles can be requested asynchronously.
|
boolean |
isAvoidOpaqueBorder() |
boolean |
isFillOutlineArea() |
boolean |
isForcePainting() |
boolean |
isPaintOutline() |
boolean |
isRepaintViewWhenTileAvailable()
Returns whether the view is repainted when a tile becomes available.
|
boolean |
isTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Checks if the representation of the object in the given mode is touched at the location as defined in the
supplied context.
|
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 |
setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
Sets whether the tiles can be requested asynchronously.
|
void |
setAvoidOpaqueBorder(boolean aAvoidOpaqueBorder)
Specifies whether the painter should avoid drawing opaque borders around
transformed images.
|
void |
setBrightness(float aBrightness)
Sets the brightness factor that is applied to painted rasters.
|
void |
setContrast(float aContrast)
Sets the gamma correction that is applied to painted rasters.
|
void |
setFillOutlineArea(boolean aFillOutlineArea)
Specifies whether the image outlines and tile outlines should be filled
when the pixel density (number of image pixels per screen pixel) of the
image to be painted is higher than the startResolutionFactor.
|
void |
setForcePainting(boolean aForcePainting)
Specifies whether the visible portion of the image should always be
painted, irrespective of the startResolutionFactor and
stopResolutionFactor.
|
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 image levels.
|
void |
setMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles)
Sets the maximum number of outlines of individual tiles to paint when
the pixel density (number of image pixels per screen pixel) of the image
to be painted is higher than the startResolutionFactor.
|
void |
setObject(Object aObject)
Sets the object to be painted.
|
void |
setOpacity(float aOpacity)
Sets the opacity of the image.
|
void |
setOperatorChain(ALcdImageOperatorChain aOperatorChain)
Sets the operator chain to be applied to painted images.
|
void |
setOutlineAreaFillStyle(ILcdGXYPainterStyle aFillStyle)
Sets the style that is used when filling the outline area of images and/or tiles.
|
void |
setOutlineColor(Color aColor)
Sets the line color used to paint the image outlines and tile outlines
when the pixel density (number of image pixels per screen pixel) of the
image to be painted is higher than the startResolutionFactor.
|
void |
setOutlineStyle(ILcdGXYPainterStyle aOutlineStyle)
Sets the style that is used when drawing the bounds of the image and/or tiles.
|
void |
setOversamplingRate(int aOverSamplingRate)
Sets the number of samples used per pixel when transforming a image.
|
void |
setPaintOutline(boolean aPaintOutline)
Specifies whether the image outlines and tile outlines should be painted
when the pixel density (number of image pixels per screen pixel) of the
image to be painted is higher than the startResolutionFactor.
|
void |
setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
Sets whether the view is repainted when a tile becomes available.
|
void |
setStartResolutionFactor(double aFactor)
Sets the highest pixel density (number of image pixels per screen pixel)
at which an image is painted.
|
void |
setStartScale(double aStartScale)
As an alternative for the start resolution factor and stop resolution factor, this method and
getStopScale() can be used for more intuitive control on when to paint an image and when
to paint the outline. |
void |
setStopResolutionFactor(double aFactor)
Sets the lowest pixel density (number of image pixels per screen pixel)
at which an image is painted.
|
void |
setStopScale(double aStopScale)
As an alternative for the start resolution factor and stop resolution factor, this method and
getStartScale() can be used for more intuitive control on when to paint an image. |
void |
setWarpBlockSize(int aWarpBlockSize)
Sets the width and height of the block in which the image transformation
is approximated using bilinear interpolation.
|
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
public TLcdGXYImagePainter()
public TLcdGXYImagePainter(ALcdImagingEngine aImagingEngine)
aImagingEngine
- imaging engine to use.public static ILcdGXYPainterProvider create(ILcdModel aModel, ALcdImagingEngine aImagingEngine)
ALcdImage
or has an ALcdImage
.ILcdRaster
,
ILcdMultilevelRaster
or ILcdEarthTileSet
.aModel
- the model for which to create a painter provider.aImagingEngine
- the imaging engine to use. This may be null
, in which case, a default imaging engine is used.public ALcdImageOperatorChain getOperatorChain()
public void setOperatorChain(ALcdImageOperatorChain aOperatorChain)
aOperatorChain
- the operator chainpublic void setObject(Object aObject)
aObject
- the object to be paintedILcdGXYPainter.getObject()
public Object getObject()
ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void paint(Graphics aGraphics, int aMode, 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.
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- 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.
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 boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
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 inaGXYContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public double getStartResolutionFactor()
setStartResolutionFactor(double)
public double getStopResolutionFactor()
setStopResolutionFactor(double)
public double getLevelSwitchFactor()
setLevelSwitchFactor(double)
public double[] getLevelSwitchScales()
setLevelSwitchScales(double[])
public double getStartScale()
setStartScale(double)
public double getStopScale()
setStopScale(double)
public boolean isForcePainting()
setForcePainting(boolean)
public boolean isPaintOutline()
setPaintOutline(boolean)
public ILcdGXYPainterStyle getOutlineStyle()
null
public Color getOutlineColor()
setOutlineColor(java.awt.Color)
public boolean isFillOutlineArea()
setFillOutlineArea(boolean)
public ILcdGXYPainterStyle getOutlineAreaFillStyle()
public int getMaxNumberOfOutlineTiles()
setMaxNumberOfOutlineTiles(int)
public void setStartResolutionFactor(double aFactor)
public void setStopResolutionFactor(double aFactor)
public void setLevelSwitchFactor(double aLevelSwitchFactor)
public void setLevelSwitchScales(double[] aLevelSwitchScales)
If the scales are not set (default), the pixel density is used to
automatically determine the level to be painted (also see
setLevelSwitchFactor
).
aLevelSwitchScales
- the level switch scalesILcdGXYView.getScale()
public void setForcePainting(boolean aForcePainting)
public void setOpacity(float aOpacity)
aOpacity
- opacity valuepublic float getOpacity()
setOpacity(float)
public void setPaintOutline(boolean aPaintOutline)
setStartResolutionFactor(double)
public void setOutlineStyle(ILcdGXYPainterStyle aOutlineStyle)
non-null
value the configure style will take precedence over the
configured outline color if the style modifies the Graphics current color.aOutlineStyle
- the outline style to usesetPaintOutline(boolean)
,
setOutlineColor(java.awt.Color)
public void setOutlineColor(Color aColor)
public void setFillOutlineArea(boolean aFillOutlineArea)
public void setOutlineAreaFillStyle(ILcdGXYPainterStyle aFillStyle)
null
and fill outline area
is enabled the result visual result on screen is undefined.aFillStyle
- the fill style to usesetFillOutlineArea(boolean)
public void setMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles)
setStartResolutionFactor(double)
public void setStartScale(double aStartScale)
getStopScale()
can be used for more intuitive control on when to paint an image and when
to paint the outline. When the internal scale of the view (ILcdGXYView.getScale()
is smaller than the start scale, the outline will be painted in stead of the image.
The default value is 0.
Warning: when the view scale is in between the start and stop scale, the start
resolution factor and the stop resolution factor are still used as a second check. If you don't
want interference from these two settings, set the start resolution factor to Double.POSITIVE_INFINITY
and the stop resolution factor to 0.aStartScale
- The view scale at which one starts painting the image rather that the outline (when zooming in).getStartScale()
public void setStopScale(double aStopScale)
getStartScale()
can be used for more intuitive control on when to paint an image.
When the internal scale of the view (ILcdGXYView.getScale()
is larger than the stop scale, the image won't be painted.
The default value is Double.POSITIVE_INFINITY.aStopScale
- The view scale at which one stops painting the image (when zooming in).getStopScale()
public void setAvoidOpaqueBorder(boolean aAvoidOpaqueBorder)
The painter normally uses the default pixel of an image when painting the border around a transformed image. If the default pixel is transparent, the border is invisible. Otherwise, the border is opaque. This typically occurs if an image 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 images. Leaving the property unset is therefore
preferable, for instance when the area around painted images is not
relevant for the application. The default is false
.
public boolean isAvoidOpaqueBorder()
setAvoidOpaqueBorder(boolean)
public void setOversamplingRate(int aOverSamplingRate)
(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 image contains sharp edges, but it also increases
the computational cost.
This property is only relevant for images that have to be warped, that is, when the model reference of the image is different from the world reference of the view.
aOverSamplingRate
- the number of samples used per pixel in one direction.public int getOversamplingRate()
setOversamplingRate(int)
public void setWarpBlockSize(int aWarpBlockSize)
This property is only relevant for images that have to be warped, that is, when the model reference of the image is different from the world reference of the view.
aWarpBlockSize
- the width and height, expressed in pixels.public int getWarpBlockSize()
setWarpBlockSize(int)
public void setBrightness(float aBrightness)
aBrightness
- the new brightness valuepublic void setContrast(float aContrast)
aContrast
- the new contrast valuepublic float getBrightness()
setBrightness(float)
public float getContrast()
setContrast(float)
public boolean isAsynchronousTileRequestAllowed()
off-screen
view to create a screenshot of the layer. If this feature is disabled then the repaint on tile available
should typically also be disabled.
Asynchronous tile requests are allowed by default.true
if the tiles can be requested asynchronouslyisRepaintViewWhenTileAvailable()
public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
aAsynchronousTileRequestAllowed
- true
if the tiles can be requested asynchronouslyisAsynchronousTileRequestAllowed()
public boolean isRepaintViewWhenTileAvailable()
asynchronous tile requests
are
allowed.isAsynchronousTileRequestAllowed()
public void setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
aRepaintViewWhenTileAvailable
- whether the view should repainted when a tile becomes
availableisRepaintViewWhenTileAvailable()
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()