public class TLcdGXYHaloLabelPainter extends Object implements ILcdGXYMultiLabelPainter, ILcdGXYLabelPainterProvider, Cloneable
ILcdGXYLabelPainter
or ILcdGXYLabelPainterProvider
implementation.
If the decorated class implements both, a cast to either
ILcdGXYLabelPainter
or ILcdGXYLabelPainterProvider
is necessary to
select the correct constructor.
When the decorated class is passed as a ILcdGXYLabelPainterProvider
, this class
must also be used as a ILcdGXYLabelPainterProvider
, which means that
getGXYLabelPainter(Object)
must be called before painting any labels.
ILcdGXYLabelPainter
or ILcdGXYMultiLabelPainter
.
If your label painter implements ILcdGXYLabelPainter2
,
we strongly recommend using TLcdGXYHaloLabelPainter2
instead.
Note that when using this label painter, it is important that the delegate label painter's
ILcdGXYLabelPainter.labelBoundsSFCT
method is correctly implemented.
Due to TLcdGXYHaloLabelPainter's use of offscreen images, anything that the delegate label painter
draws outside of the returned label bounds may be clipped away.
clearImageCache(Object)
method to
remove that object's cached image. Note that changing the halo color or
thickness automatically clears the entire image cache.TLcdGXYHaloLabelPainter2
,
Serialized FormDEFAULT, SELECTED
Constructor and Description |
---|
TLcdGXYHaloLabelPainter(ILcdGXYLabelPainter aLabelPainter)
Creates a new
TLcdGXYHaloLabelPainter wrapping the given label painter, with default
halo parameters (Color = white, thickness = 1). |
TLcdGXYHaloLabelPainter(ILcdGXYLabelPainter aLabelPainter,
Color aHaloColor,
int aHaloThickness)
Creates a new
TLcdGXYHaloLabelPainter wrapping the given label painter, configured
with the given halo color and thickness. |
TLcdGXYHaloLabelPainter(ILcdGXYLabelPainterProvider aLabelPainterProvider)
Creates a new
TLcdGXYHaloLabelPainterProvider wrapping the given label painter provider, with default
halo parameters (Color = white, thickness = 1). |
TLcdGXYHaloLabelPainter(ILcdGXYLabelPainterProvider aLabelPainterProvider,
Color aHaloColor,
int aHaloThickness)
Creates a new
TLcdGXYHaloLabelPainterProvider wrapping the given label painter provider, configured
with the given halo color and thickness. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Adds a
PropertyChangeListener to this painter. |
void |
clearImageCache()
Clears the entire label image cache.
|
void |
clearImageCache(Object aObject)
Clears the label image cache for the given object.
|
Object |
clone()
Redefines
Object.clone to make it public. |
ILcdGXYLabelPainter |
getDelegateLabelPainter()
Returns the
ILcdGXYLabelPainter to which the rendering of the
labels is delegated. |
ILcdGXYLabelPainterProvider |
getDelegateLabelPainterProvider()
Returns the
ILcdGXYLabelPainterProvider to which the rendering of the
labels is delegated. |
ILcdGXYLabelPainter |
getGXYLabelPainter(Object aObject)
Always returns this label painter itself.
|
TLcdHaloAlgorithm |
getHaloAlgorithm()
Returns the algorithm that is used for rendering halo's.
|
Color |
getHaloColor()
Returns the current halo color.
|
int |
getHaloThickness()
Returns the current halo thickness.
|
int |
getLabelCount(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns the number of labels for the object set to this label painter.
|
int |
getLabelIndex()
Returns the index of the label that is currently painted or scheduled to paint.
|
int |
getLocationIndex()
Gets the index of location where to paint the label(s) of the set Object.
|
Object |
getObject()
Gets the Object this ILcdGXYLabelPainter can label.
|
int |
getPossibleLocationCount(Graphics aGraphics)
Returns the number of possible locations where this
ILcdGXYLabelPainter can
paint/draw the labels of the set domain Object . |
int |
getSubLabelCount(int aLabelIndex)
Return the number of sublabels in a label.
|
int |
getSubLabelIndex()
Returns the index of the sublabel to paint.
|
boolean |
isHaloEnabled()
Returns true if the halo effect is on, false otherwise.
|
boolean |
isUseImageCache()
Returns
true when label image caching is enabled, false otherwise. |
double |
labelBoundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Rectangle aRectangleSFCT)
Calculates the bounds of the label that can be painted.
|
void |
paintLabel(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Paints the label of the set Object on
aGraphics . |
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Removes a
PropertyChangeListener from this painter. |
void |
setDelegateLabelPainter(ILcdGXYLabelPainter aDelegateLabelPainter)
Sets the
ILcdGXYLabelPainter to which the rendering of the
labels is to be delegated. |
void |
setDelegateLabelPainterProvider(ILcdGXYLabelPainterProvider aDelegateLabelPainterProvider)
Sets the
ILcdGXYLabelPainterProvider to which the rendering of the
labels is to be delegated. |
void |
setHaloAlgorithm(TLcdHaloAlgorithm aHaloAlgorithm)
Sets the algorithm to be used for rendering halo's.
|
void |
setHaloColor(Color aColor)
Sets the color of the halo to be added around labels.
|
void |
setHaloEnabled(boolean aHaloEnabled)
Switches the halo effect on or off.
|
void |
setHaloThickness(int aThickness)
Sets the thickness (in pixels) of the halo to be added around labels.
|
void |
setLabelIndex(int aLabelIndex)
Sets the label.
|
void |
setLocationIndex(int aLocationIndex)
Sets the index of location where to paint the label(s) of the set Object.
|
void |
setObject(Object aObject)
Sets the Object to be labeled by this ILcdGXYLabelPainter.
|
void |
setSubLabelIndex(int aSubLabelIndex)
Sets the sublabel index.
|
void |
setUseImageCache(boolean aUseCache)
Sets whether or not labels should be cached as images.
|
public TLcdGXYHaloLabelPainter(ILcdGXYLabelPainter aLabelPainter)
TLcdGXYHaloLabelPainter
wrapping the given label painter, with default
halo parameters (Color = white, thickness = 1). If the delegate painter is
an ILcdGXYLabelPainter2
, use TLcdGXYHaloLabelPainter2
instead.aLabelPainter
- the ILcdGXYLabelPainter
rendering the label.public TLcdGXYHaloLabelPainter(ILcdGXYLabelPainter aLabelPainter, Color aHaloColor, int aHaloThickness)
TLcdGXYHaloLabelPainter
wrapping the given label painter, configured
with the given halo color and thickness. If the delegate painter is
an ILcdGXYLabelPainter2
, use TLcdGXYHaloLabelPainter2
instead.aLabelPainter
- the ILcdGXYLabelPainter
rendering the label.aHaloColor
- the halo coloraHaloThickness
- the halo thicknesspublic TLcdGXYHaloLabelPainter(ILcdGXYLabelPainterProvider aLabelPainterProvider)
TLcdGXYHaloLabelPainterProvider
wrapping the given label painter provider, with default
halo parameters (Color = white, thickness = 1). If the delegate painter provider returns
an ILcdGXYLabelPainter2
label painters, use TLcdGXYHaloLabelPainter2
instead.
Note that this constructor demands that the provider is used as a ILcdGXYLabelPainterProvider
,
which means that getGXYLabelPainter(Object)
must be called before using it to paint
a label.
aLabelPainterProvider
- the ILcdGXYLabelPainterProvider
rendering the label.public TLcdGXYHaloLabelPainter(ILcdGXYLabelPainterProvider aLabelPainterProvider, Color aHaloColor, int aHaloThickness)
TLcdGXYHaloLabelPainterProvider
wrapping the given label painter provider, configured
with the given halo color and thickness. If the delegate painter provider is
an ILcdGXYLabelPainterProvider2
, use TLcdGXYHaloLabelPainter2
instead.
Note that this constructor demands that the provider is used as a ILcdGXYLabelPainterProvider
,
which means that getGXYLabelPainter(Object)
must be called before using it to paint
a label.
aLabelPainterProvider
- the ILcdGXYLabelPainterProvider
rendering the label.aHaloColor
- the halo coloraHaloThickness
- the halo thicknesspublic boolean isHaloEnabled()
setHaloEnabled(boolean)
public void setHaloEnabled(boolean aHaloEnabled)
aHaloEnabled
- true if halos should be added, false otherwisepublic int getHaloThickness()
setHaloThickness(int)
public void setHaloThickness(int aThickness)
aThickness
- the new halo thicknesspublic Color getHaloColor()
setHaloColor(java.awt.Color)
public void setHaloColor(Color aColor)
aColor
- the new halo colorpublic void setHaloAlgorithm(TLcdHaloAlgorithm aHaloAlgorithm)
TLcdHaloAlgorithm
for more information on the available algorithms.aHaloAlgorithm
- the algorithm to be used for rendering halo's.TLcdHaloAlgorithm
,
getHaloAlgorithm()
public TLcdHaloAlgorithm getHaloAlgorithm()
TLcdHaloAlgorithm
,
setHaloAlgorithm(com.luciad.util.TLcdHaloAlgorithm)
public boolean isUseImageCache()
true
when label image caching is enabled, false
otherwise.true
when label image caching is enabled, false
otherwisepublic void setUseImageCache(boolean aUseCache)
ILcdModelListener
that removes an object from the image cache
whenever that object changes.aUseCache
- specifies whether image caching should be enabledclearImageCache()
,
clearImageCache(Object)
public void clearImageCache()
clearImageCache(Object)
.setUseImageCache(boolean)
public void clearImageCache(Object aObject)
clearImageCache()
.aObject
- the object for which the cache to be cleared.setUseImageCache(boolean)
public ILcdGXYLabelPainter getDelegateLabelPainter()
ILcdGXYLabelPainter
to which the rendering of the
labels is delegated.ILcdGXYLabelPainter
to which the rendering of the labels is delegated.public void setDelegateLabelPainter(ILcdGXYLabelPainter aDelegateLabelPainter)
ILcdGXYLabelPainter
to which the rendering of the
labels is to be delegated. If the delegate painter is
an ILcdGXYLabelPainter2
, use TLcdGXYHaloLabelPainter2
instead.aDelegateLabelPainter
- the ILcdGXYLabelPainter
to which the rendering of the labels is delegated.public ILcdGXYLabelPainterProvider getDelegateLabelPainterProvider()
ILcdGXYLabelPainterProvider
to which the rendering of the
labels is delegated.ILcdGXYLabelPainterProvider
to which the rendering of the labels is delegated.public void setDelegateLabelPainterProvider(ILcdGXYLabelPainterProvider aDelegateLabelPainterProvider)
ILcdGXYLabelPainterProvider
to which the rendering of the
labels is to be delegated. If the delegate painter provider returns
ILcdGXYLabelPainter2
instances, use TLcdGXYHaloLabelPainter2
instead.aDelegateLabelPainterProvider
- the ILcdGXYLabelPainterProvider
to which the rendering of the labels is delegated.public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
to this painter.aPropertyChangeListener
- the receiver of property change events generated by this objectremovePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
from this painter.aPropertyChangeListener
- the listener to be removedaddPropertyChangeListener(java.beans.PropertyChangeListener)
public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
getGXYLabelPainter
in interface ILcdGXYLabelPainterProvider
aObject
- the object for which a label painter is requestedpublic void setObject(Object aObject)
ILcdGXYLabelPainter
setObject
in interface ILcdGXYLabelPainter
aObject
- The object to be labeled.ILcdGXYLabelPainter.getObject()
public Object getObject()
ILcdGXYLabelPainter
getObject
in interface ILcdGXYLabelPainter
ILcdGXYLabelPainter.setObject(java.lang.Object)
public void setLocationIndex(int aLocationIndex)
ILcdGXYLabelPainter
setLocationIndex
in interface ILcdGXYLabelPainter
aLocationIndex
- the index of the location. Must be between 0 and getPossibleLocationCount()
- 1.ILcdGXYLabelPainter.getLocationIndex()
public int getLocationIndex()
ILcdGXYLabelPainter
getLocationIndex
in interface ILcdGXYLabelPainter
ILcdGXYLabelPainter.setLocationIndex(int)
public void paintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYLabelPainter
Paints the label of the set Object on aGraphics
. aGXYContext
should
contain the ILcdGXYView
for which the label is painted and
ILcdGXYLayer
to which the object belongs
The implementation of this method shall define how to paint the label of the set Object in
the given mode, considering aGXYContext
and the possible locations
aLocationIndex
(of multiple alternatives).
The domain Object
of the label to be painted and the location index should be
set before calling this method using the setObject
and
setLocationIndex
methods respectively.
paintLabel
in interface ILcdGXYLabelPainter
aGraphics
- the Graphics
instance on which to paint.aMode
- a combination of ILcdGXYLabelPainter.DEFAULT and ILcdGXYLabelPainter.SELECTED.aGXYContext
- the ILcdGXYContext
in which the label painting has to be
performed.ILcdGXYLabelPainter.DEFAULT
,
ILcdGXYLabelPainter.SELECTED
public int getPossibleLocationCount(Graphics aGraphics)
ILcdGXYLabelPainter
ILcdGXYLabelPainter
can
paint/draw the labels of the set domain Object
.
The domain Object
for which the location count is retrieved should be set
before calling this method using the ILcdGXYLabelPainter.setObject(java.lang.Object)
method.
getPossibleLocationCount
in interface ILcdGXYLabelPainter
aGraphics
- the Graphics the label will be painted on.ILcdGXYLabelPainter
can
paint/draw the labels of the set Object.ILcdGXYLabelPainter.setLocationIndex(int)
public double labelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) throws TLcdNoBoundsException
ILcdGXYLabelPainter
Calculates the bounds of the label that can be painted. The bounds are
set as a side effect in aRectangleSFCT
, the orientation of
aRectangleSFCT
is returned as an angle.
The bounds represent the upper left point of the label, and a width and a height. The rotation value represents the rotation of the label bounds around the upper left point.
The object for which the bounds are retrieved and the location index of the label should be
set before calling this method using the ILcdGXYLabelPainter.setObject(java.lang.Object)
and ILcdGXYLabelPainter.setLocationIndex(int)
methods respectively.
labelBoundsSFCT
in interface ILcdGXYLabelPainter
aGraphics
- the aGraphics
to consider.aMode
- the representation mode of the label.aGXYContext
- the ILcdGXYContext
the drawing depends on.aRectangleSFCT
- the Rectangle
containing the bounds of the label in view /
graphics coordinates as side effect.TLcdNoBoundsException
- if the Object doesn't have any valid bounds, e.g. if it is always
invisible in the current projection.ILcdGXYLabelPainter.DEFAULT
,
ILcdGXYLabelPainter.SELECTED
public Object clone()
ILcdGXYLabelPainter
Object.clone
to make it public.clone
in interface ILcdGXYLabelPainter
clone
in interface ILcdGXYLabelPainterProvider
clone
in class Object
public void setLabelIndex(int aLabelIndex)
Sets the label. The results of any subsequent method calls to ILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
and ILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
etc. will apply to the label and sublabel indicated by this label index.
setLabelIndex
in interface ILcdGXYMultiLabelPainter
aLabelIndex
- The label index. This should be larger than or equal to 0
and
less than the result ILcdGXYMultiLabelPainter.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext)
.ILcdGXYMultiLabelPainter.setSubLabelIndex(int)
public int getLabelIndex()
getLabelIndex
in interface ILcdGXYMultiLabelPainter
ILcdGXYMultiLabelPainter.setLabelIndex(int)
public int getLabelCount(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns the number of labels for the object set to this label painter.
Note: when returning multiple (moveable) labels for the same object, it might be useful to useTLcdGXYEditControllerModel2.EDIT_WHAT_FIRST_TOUCHED_LABEL
to avoid that a mouse drag moves them all together.
This implementation calls the delegate label painter if it implements ILcdGXYMultiLabelPainter,
else it returns 1;getLabelCount
in interface ILcdGXYMultiLabelPainter
aGraphics
- The Graphics currently painting onaGXYContext
- The ILcdGXYContext currently validpublic int getSubLabelIndex()
getSubLabelIndex
in interface ILcdGXYMultiLabelPainter
ILcdGXYMultiLabelPainter.setSubLabelIndex(int)
public void setSubLabelIndex(int aSubLabelIndex)
ILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
and
ILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
etc. will apply to the label and sublabel indicated by this sublabel
index.
This implementation calls the delegate label painter if it implements ILcdGXYMultiLabelPainter.setSubLabelIndex
in interface ILcdGXYMultiLabelPainter
aSubLabelIndex
- The sub label index. This should be larger than or equal to
0
and less than the result ILcdGXYMultiLabelPainter.getSubLabelCount(int)
.ILcdGXYMultiLabelPainter.setLabelIndex(int)
public int getSubLabelCount(int aLabelIndex)
getSubLabelCount
in interface ILcdGXYMultiLabelPainter
aLabelIndex
- the index of the label.