public class TLcdGXYCurvedPathLabelPainter extends ALcdGXYLabelPainter implements ILcdGXYLabelPainterProvider
TLcdGXYCurvedPathLabelLocation
is used.
Usually this is done by changing the layer's label locations. For a TLcdGXYLayer
,
this could be done as follows:
layer.setLabelLocations( new TLcdLabelLocations( layer, new TLcdGXYCurvedPathLabelLocation() ) );
The curved label location class describes an exact location on an ILcdAWTPath
.
It defines the following 3 fields:
TLcdGXYCurvedPathLabelLocation.getLocationIndex()</code> : should be <code>-1
.TLcdGXYCurvedPathLabelLocation.getSubPathIndex()
TLcdGXYCurvedPathLabelLocation.getAWTPathParameter()
TLcdGXYCurvedPathLabelingAlgorithm
can be used to place curved path labels. This labeling algorithm also works using
TLcdGXYCurvedPathLabelLocation
s, and fills in the 'sub path index' and
'awt path parameter' fields.
This label painter also supports fixed label placement (TLcdLabelLocation.getLocationIndex() >= 0)
).
In that case it drapes the label at the middle of the path (sub path index = 0 and awt path parameter = 0.5).
This allows this label painter to be used in combination with
TLcdGXYLabelPainterLocationLabelingAlgorithm
.
It also supports regular free placement, in case an invalid awt path parameter is used. I.e.
if the path parameter < 0
or > 1
and if TLcdLabelLocation.getLocationIndex() == -1
.
In that case, the label is placed as described by
TLcdLabelLocation.getRotation()
TLcdLabelLocation.getLocationX()
TLcdLabelLocation.getLocationY()
labelBoundsSFCT
method is customized using a wrapper or an extension
of this label painter, the labeling algorithm will not be able to use this information. So it
will work with other bounds than the one returned by the used label painter. This might cause
overlapping labels.TLcdGXYCurvedPathLabelLocation
,
TLcdGXYCurvedPathLabelingAlgorithm
,
ILcdGXYEditableLabelsLayer
,
Serialized FormBODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
DEFAULT, SELECTED
Constructor and Description |
---|
TLcdGXYCurvedPathLabelPainter()
Creates a new
TLcdGXYCurvedPathLabelPainter , using TLcdGXYLabelingPathProvider as path provider. |
TLcdGXYCurvedPathLabelPainter(ILcdGXYLabelingPathProvider aPathProvider)
Creates a new
TLcdGXYCurvedPathLabelPainter , using the given path provider. |
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()
Returns a new instance of this
ALcdGXYLabelPainter . |
double |
getExtraCharacterSpacing()
Returns the extra spacing between each character.
|
Font |
getFont()
Gets the
Font for drawing the labels. |
Color |
getForeground()
Gets the foreground color of the labels (text).
|
ILcdGXYLabelPainter |
getGXYLabelPainter(Object aObject)
Finds an
ILcdGXYLabelPainter that can be used to label the object passed. |
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.
|
ILcdGXYLabelingPathProvider |
getPathProvider()
Returns the used path provider.
|
int |
getPossibleLocationCount(Graphics aGraphics)
Returns the number of possible locations where this
ILcdGXYLabelPainter can
paint/draw the labels of the set domain Object . |
Color |
getSelectionColor()
Gets the selection color of a label
|
boolean |
isHaloEnabled()
Returns true if the halo effect is on for the labels, false otherwise.
|
boolean |
isLabelTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Tests if the label specified by
setObject , setLabelIndex and
setSubLabelIndex is touched at view location (specified by
aGXYContext.getX() and aGXYContext.getY() ), considering the mode and the
ILcdGXYContext instance. |
boolean |
isUseImageCache()
Returns
true</code> when label image caching is enabled, <code>false otherwise. |
void |
labelAnchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Sets
aPointSFCT to the anchor point of the label specified by
setObject , setLabelIndex and setSubLabelIndex . |
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 specified by
setObject , setLabelIndex and
setSubLabelIndex on aGraphics . |
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Removes a
PropertyChangeListener from this painter. |
String |
retrieveLabels(Object aObject,
int aLabelIndex,
int aSubLabelIndex)
This method should return the label text.
|
void |
setExtraCharacterSpacing(double aExtraCharacterSpacing)
Sets an extra spacing between each two characters in the label String.
|
void |
setFont(Font aFont)
Sets the
Font</code> for drawing the labels to <code>aFont . |
void |
setForeground(Color aForegroundColor)
Sets the color of the labels to
aForegroundColor . |
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 for the labels on or off.
|
void |
setHaloThickness(int aThickness)
Sets the thickness (in pixels) of the halo to be added around labels.
|
void |
setSelectionColor(Color aSelectionColor)
Sets the selection color of a label to aSelectionColor.
|
void |
setUseImageCache(boolean aUseCache)
Sets whether or not labels with halos should be cached as images.
|
firePropertyChangeEvent, getDisplayName, getLabelCount, getLabelCursor, getLabelIndex, getLabelLocation, getLocationIndex, getObject, getSubLabelCount, getSubLabelIndex, labelSnapTarget, setDisplayName, setLabelIndex, setLabelLocation, setLocationIndex, setObject, setSubLabelIndex, supportLabelSnap
public TLcdGXYCurvedPathLabelPainter()
TLcdGXYCurvedPathLabelPainter
, using TLcdGXYLabelingPathProvider
as path provider.public TLcdGXYCurvedPathLabelPainter(ILcdGXYLabelingPathProvider aPathProvider)
TLcdGXYCurvedPathLabelPainter
, using the given path provider.aPathProvider
- a path provider.public ILcdGXYLabelingPathProvider getPathProvider()
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
to this painter.addPropertyChangeListener
in interface ILcdPropertyChangeSource
addPropertyChangeListener
in class ALcdGXYLabelPainter
aPropertyChangeListener
- the receiver of property change events generated by this objectremovePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
from this painter.removePropertyChangeListener
in interface ILcdPropertyChangeSource
removePropertyChangeListener
in class ALcdGXYLabelPainter
aPropertyChangeListener
- the listener to be removedaddPropertyChangeListener(java.beans.PropertyChangeListener)
public boolean isHaloEnabled()
setHaloEnabled(boolean)
public void setHaloEnabled(boolean aHaloEnabled)
aHaloEnabled
- true if halos should be added, false otherwiseisHaloEnabled()
public int getHaloThickness()
setHaloThickness(int)
public void setHaloThickness(int aThickness)
aThickness
- the new halo thicknessTLcdGXYHaloLabelPainter.setHaloThickness(int)
,
setHaloEnabled(boolean)
public Color getHaloColor()
setHaloColor(java.awt.Color)
public void setHaloColor(Color aColor)
aColor
- the new halo colorTLcdGXYHaloLabelPainter.setHaloColor(java.awt.Color)
,
setHaloEnabled(boolean)
public void setHaloAlgorithm(TLcdHaloAlgorithm aHaloAlgorithm)
TLcdHaloAlgorithm
for more information on the available algorithms.aHaloAlgorithm
- the algorithm to be used for rendering halo's.TLcdHaloAlgorithm
,
getHaloAlgorithm()
,
setHaloEnabled(boolean)
public TLcdHaloAlgorithm getHaloAlgorithm()
TLcdHaloAlgorithm
,
setHaloAlgorithm(com.luciad.util.TLcdHaloAlgorithm)
public boolean isUseImageCache()
true</code> when label image caching is enabled, <code>false
otherwise.true</code> when label image caching is enabled, <code>false
otherwisesetUseImageCache(boolean)
public void setUseImageCache(boolean aUseCache)
aUseCache
- specifies whether image caching should be enabledTLcdGXYHaloLabelPainter.setUseImageCache(boolean)
,
setHaloEnabled(boolean)
,
isUseImageCache()
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 void setFont(Font aFont)
Font</code> for drawing the labels to <code>aFont
.aFont
- the font to use to paint labels.getFont()
public Font getFont()
Font
for drawing the labels. The default value is plain Dialog of size 10.setFont(java.awt.Font)
public void setForeground(Color aForegroundColor)
aForegroundColor
.aForegroundColor
- the color to be used to paint the labels foreground (text).getForeground()
public Color getForeground()
setForeground(java.awt.Color)
public void setSelectionColor(Color aSelectionColor)
aSelectionColor
- the color to use to paint labels for selected objects.getSelectionColor()
public Color getSelectionColor()
setSelectionColor(java.awt.Color)
public double getExtraCharacterSpacing()
setExtraCharacterSpacing(double)
public void setExtraCharacterSpacing(double aExtraCharacterSpacing)
0.0
by default.aExtraCharacterSpacing
- the extra spacing between two characters in the label String.getExtraCharacterSpacing()
public String retrieveLabels(Object aObject, int aLabelIndex, int aSubLabelIndex)
aObject
- the labeled object.aLabelIndex
- the label index.aSubLabelIndex
- the sublabel index.public void paintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYLabelPainter2
Paints the label specified by setObject
, setLabelIndex
and
setSubLabelIndex
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 specified label in the given
mode, considering aGXYContext
and the set TLcdLabelLocation
.
The domain object, label index, sublabel index and the label location should be set before calling this method using the respective methods.
This interface extends the original contract of the paintLabel method to allow for more
modes. Where in the super interface the mode could only be one of ILcdGXYLabelPainter.DEFAULT
or ILcdGXYLabelPainter.SELECTED
, the mode now can be a
bitwise combination of several constants
paintLabel
in interface ILcdGXYLabelPainter
paintLabel
in interface ILcdGXYLabelPainter2
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination of aGXYContext
- the drawing context for the labelILcdGXYLabelPainter.DEFAULT
,
ILcdGXYLabelPainter.SELECTED
public double labelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) throws TLcdNoBoundsException
ILcdGXYLabelPainter2
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 domain object, the label index, the sublabel index and the location of the label for which the bounds are retrieved should be set before calling this method using the respective methods.
Note that if this label painter is used in conjunction with a labeling algorithm, the bounds should preferably be independent of the location, as this will yield the best results.
labelBoundsSFCT
in interface ILcdGXYLabelPainter
labelBoundsSFCT
in interface ILcdGXYLabelPainter2
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.ILcdGXYViewLabelPainter
,
ILcdGXYLayerLabelPainter
,
ILcdGXYLabelPainter2.labelAnchorPointSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Point)
public boolean isLabelTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYLabelPainter2
setObject
, setLabelIndex
and
setSubLabelIndex
is touched at view location (specified by
aGXYContext.getX()
and aGXYContext.getY()
), considering the mode and the
ILcdGXYContext
instance.
Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.
isLabelTouched
in interface ILcdGXYLabelPainter2
aGraphics
- The Graphics
instance on which the label is painted.aMode
- the mode to consider. This is a bitwise combinations of several constants.
See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- the ILcdGXYContext
to consider.ILcdGXYContext
public void labelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
ILcdGXYLabelPainter2
Sets aPointSFCT
to the anchor point of the label specified by
setObject
, setLabelIndex
and setSubLabelIndex
.
If the location index is less than 0, the label anchor point is unambiguously determined by the
label location
. The actual label is to be painted somewhere around
this anchor point. This method is typically called to compare the result with
the label bounds, thus determining the exact relation between the label
and its location
.
Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.
labelAnchorPointSFCT
in interface ILcdGXYLabelPainter2
aGraphics
- The Graphics
instance on which the label is painted.aMode
- The mode to consider. This can be a bitwise combination of several
constants. See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- The ILcdGXYContext
that can be used to retrieve extra
information.aPointSFCT
- The point which will be updated to reflect the location of the anchor
point.TLcdNoBoundsException
- if the Object doesn't have any valid anchor point, e.g. if it is
always invisible in the current projection.ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYLabelPainter2.getLabelLocation()
,
ILcdGXYLabelPainter2.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
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 ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
ILcdGXYLabelPainterProvider
ILcdGXYLabelPainter
that can be used to label the object passed.
The label painter provider is responsible for setting the object to the label painter before returning the label painter. An implementation should therefore have the following structure:
public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject) {
ILcdGXYLabelPainter labelPainter = ... // find the label painter for the object
if (labelPainter != null) {
labelPainter.setObject(aObject);
}
return labelPainter;
}
getGXYLabelPainter
in interface ILcdGXYLabelPainterProvider
aObject
- the object to find a label painter forpublic Object clone()
ALcdGXYLabelPainter
ALcdGXYLabelPainter
. The label location
of the clone is a clone of the label location of the original. No other objects
are cloned.clone
in interface ILcdGXYLabelPainter
clone
in interface ILcdGXYLabelPainter2
clone
in interface ILcdGXYLabelPainterProvider
clone
in class ALcdGXYLabelPainter
ALcdGXYLabelPainter
of which the label location
is a deep clone.