public class TLcdGXYTiledWMSProxyPainter extends ALcdGXYPainter implements ILcdStatusSource
Painter for visualizing ALcdWMSProxy
objects in a GXY view.
When painting, the ALcdWMSProxy
object is used to connect and retrieve
the necessary raster data from the WMS. This painter requests the data from the WMS in tiles, using
either a default tile grid or a custom tile grid.
While using tiles usually optimizes performance (more specifically, it allows faster feedback and
the ability to use caching),
there may be some visual artifacts regarding content that is not tied to world coordinates.
For example, logo's may appear multiple times and labels may only be partially visible.
This painter reprojects the data from the WMS if necessary. The painter automatically determines a reference that is supported by all layers in the GetMap request and that is similar to the world reference of the view. The resulting image is then warped to match the current world reference.
If a tile is requested which contains WMS layers without a common reference, the painter uses multiple requests with different references. It should be noted that using layers with incompatible references will generally be slower because multiple maps have to be retrieved.
TLcdWMSProxyGXYPainter
,
Serialized FormdefaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdGXYTiledWMSProxyPainter()
Creates a new painter with the default settings.
|
TLcdGXYTiledWMSProxyPainter(int aLevel0Rows,
int aLevel0Columns,
int aTileWidth,
int aTileHeight,
int aMaxLevels,
ILcdBounds aBounds,
ILcdGeoReference aGeoReference)
Creates a new painter with the given tile grid.
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aStatusListener)
Registers the given listener so it will receive status events from this source.
|
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.
|
Object |
clone()
Makes
Object.clone() public. |
int |
getAvailableTileCount()
Returns the number of tiles that are already retrieved.
|
float |
getBrightness()
Returns the brightness factor that is applied to painted tiles.
|
float |
getContrast()
Returns the contrast that is applied to painted tiles.
|
TLcdWMSGetFeatureInfoContext |
getFeatureInfoContext(int aX,
int aY,
ILcdGXYContext aGXYContext)
Returns a
TLcdWMSGetFeatureInfoContext for the given view coordinate. |
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
int |
getOversamplingRate()
Returns the sampling rate used when transforming the raster.
|
int |
getPendingTileCount()
Returns the number of tiles that are requested but not retrieved yet.
|
double |
getQuality()
Returns the current painting quality.
|
float |
getTransparency()
Returns the transparency factor that is applied to painted tiles.
|
boolean |
isParentTileRequestAllowed()
Returns whether a request for parent tiles may be made when tiles are requested.
|
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 |
paint(Graphics aGraphics,
int aMode,
ILcdGXYContext aContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
void |
removeStatusListener(ILcdStatusListener aStatusListener)
Removes the specified listener so it is no longer notified.
|
void |
setBrightness(float aBrightness)
Sets the brightness factor that is applied to painted tiles.
|
void |
setContrast(float aContrast)
Sets the contrast (gamma correction) that is applied to painted tiles.
|
void |
setObject(Object aObject)
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 |
setParentTileRequestAllowed(boolean aParentTileRequestAllowed)
Sets whether parent tiles of the visible tiles may be requested.
|
void |
setQuality(double aQuality)
Sets the quality of the painted result.
|
void |
setTransparency(float aTransparency)
Sets the transparency factor to be applied to painted tiles.
|
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
public TLcdGXYTiledWMSProxyPainter()
public TLcdGXYTiledWMSProxyPainter(int aLevel0Rows, int aLevel0Columns, int aTileWidth, int aTileHeight, int aMaxLevels, ILcdBounds aBounds, ILcdGeoReference aGeoReference)
aLevel0Rows
- the number of rows at the lowest level of detail.aLevel0Columns
- the number of columns at the lowest level of detail.aTileWidth
- the width of a single tile in pixels.aTileHeight
- the height of a single tile in pixels.aMaxLevels
- the number of levels.aBounds
- the geographical extent of the tile grid, specified according to aGeoReference
.aGeoReference
- the geographical reference of the tile grid.public void addStatusListener(ILcdStatusListener aStatusListener)
ILcdStatusSource
Registers the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source,
you can use a ALcdWeakStatusListener
instance as status listener.
addStatusListener
in interface ILcdStatusSource
aStatusListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aStatusListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aStatusListener
- The listener to remove.public void setParentTileRequestAllowed(boolean aParentTileRequestAllowed)
true
by default, because it benefits user experience (e.g. data is immediately
available when zooming out). Disabling this might be required to support stringent operation conditions
that require the minimum possible amount of tile requests; in this case, only the visible tiles will be
requested.aParentTileRequestAllowed
- whether the parent tiles of the visible tiles may be requestedpublic boolean isParentTileRequestAllowed()
setParentTileRequestAllowed(boolean)
public int getPendingTileCount()
public int getAvailableTileCount()
public float getTransparency()
setTransparency(float)
public void setTransparency(float aTransparency)
aTransparency
- the transparencypublic float getBrightness()
setBrightness(float)
public void setBrightness(float aBrightness)
aBrightness
- the brightnesspublic float getContrast()
setContrast(float)
public void setContrast(float aContrast)
aContrast
- the contrastpublic 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 raster contains sharp edges, but it also increases
the computational cost.
This property is only relevant for rasters that have to be warped, that
is, when the model reference of the raster 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 double getQuality()
setQuality(double)
public void setQuality(double aQuality)
0.25
means that 4 pixels in the view will map to one raster value on average. A value of 0 means
that you only the least detailed level will be painted.
The default value is 1.0
.aQuality
- the new qualitypublic 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 aMode, ILcdGXYContext aContext)
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
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aContext
- the ILcdGXYContext
the drawing depends on.public TLcdWMSGetFeatureInfoContext getFeatureInfoContext(int aX, int aY, ILcdGXYContext aGXYContext)
Returns a TLcdWMSGetFeatureInfoContext
for the given view coordinate. This context can be used
to perform a GetFeatureInfo request, see ALcdWMSProxy#createFeatureInfoInputStream
. Before calling this method, the WMS proxy for which to get the
GetFeatureInfo context should be set on the painter.
aX
- the x coordinate (in view coordinates) for which to retrieve a TLcdWMSGetFeatureInfoContext
aY
- the y coordinate (in view coordinates) for which to retrieve a TLcdWMSGetFeatureInfoContext
aGXYContext
- the context.TLcdWMSGetFeatureInfoContext
for the given view coordinate or null
when the given
coordinate lie outside the WMS model bounds.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.
isTouched
in interface ILcdGXYPainter
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 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.
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.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 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()