Class ALcdGXYLabelPainter
- All Implemented Interfaces:
ILcdPropertyChangeSource
,ILcdGXYLabelPainter
,ILcdGXYLabelPainter2
,ILcdGXYMultiLabelPainter
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdGXYCompositeLabelPainter
,TLcdGXYCurvedPathLabelPainter
,TLcdGXYLabelPainterAdapter
,TLcdGXYOffsetIconPainter
,TLcdGXYPolygonStampLabelPainter
,TLcdGXYPolylineStampLabelPainter
,TLcdGXYStampLabelPainter
This class implements some of the functionality common to most ILcdGXYLabelPainter2
s.
It is provided to facilitate the implementation of an ILcdGXYLabelPainter2
.
This default implementation assumes a single label and with a single sublabel. Override the
getLabelCount
and getSubLabelCount
methods to provide support
for multiple labels with multiple sublabels.
- Since:
- 7.0
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
DEFAULT, SELECTED
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListener
to be notified when this object's properties change.clone()
Returns a new instance of thisALcdGXYLabelPainter
.protected void
firePropertyChangeEvent
(PropertyChangeEvent aPropertyChangeEvent) Notifies the registeredPropertyChangeListener
s of the specified event.This default implementation returns the display name set withsetDisplayName
, ortoString()
if this was set tonull
.int
getLabelCount
(Graphics aGraphics, ILcdGXYContext aGXYContext) Return the number of labels for the currently set object.getLabelCursor
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.int
Returns the index of the label that is currently painted or scheduled to paint.Returns theTLcdLabelLocation
that was previously set that contains the information on the whereabouts of the label.int
Gets the index of location where to paint the label(s) of the set Object.Gets the Object this ILcdGXYLabelPainter can label.int
getSubLabelCount
(int aLabelIndex) Returns the number of sublabels for the set object and the given label index.int
Returns the index of the sublabel to paint.labelSnapTarget
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns anObject
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents.void
removePropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListener
from receiving property change events for this object.void
setDisplayName
(String aDisplayName) Sets the display name for this label painter.void
setLabelIndex
(int aLabelIndex) Sets the label.void
setLabelLocation
(TLcdLabelLocation aLabelLocation) Sets the label location of the label.void
setLocationIndex
(int aLocationIndex) Sets the index of location where to paint the label(s) of the set Object.void
Sets the Object to be labeled by this ILcdGXYLabelPainter.void
setSubLabelIndex
(int aSubLabelIndex) Sets the sublabel index.boolean
supportLabelSnap
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether this label painter supports snapping for the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
, considering the givenILcdGXYContext
instance.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.ILcdGXYLabelPainter
getPossibleLocationCount
Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
isLabelTouched, labelAnchorPointSFCT, labelBoundsSFCT, paintLabel
-
Constructor Details
-
ALcdGXYLabelPainter
public ALcdGXYLabelPainter()
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSource
Registers the given
PropertyChangeListener
to be notified when this object's properties change.In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source, you can use a
ALcdWeakPropertyChangeListener
instance as property change listener.- Specified by:
addPropertyChangeListener
in interfaceILcdPropertyChangeSource
- Parameters:
aPropertyChangeListener
- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSource
De-registers the given
PropertyChangeListener
from receiving property change events for this object.If the listener was added more than once, it will be notified one less time after being removed. If the listener is
null
, or was never added, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListener
in interfaceILcdPropertyChangeSource
- Parameters:
aPropertyChangeListener
- the listener that should no longer be notified of changes of this object's properties- See Also:
-
firePropertyChangeEvent
Notifies the registeredPropertyChangeListener
s of the specified event.- Parameters:
aPropertyChangeEvent
- The event describing the property change of which the registered listeners should be notified.- See Also:
-
getLabelLocation
Description copied from interface:ILcdGXYLabelPainter2
Returns theTLcdLabelLocation
that was previously set that contains the information on the whereabouts of the label.- Specified by:
getLabelLocation
in interfaceILcdGXYLabelPainter2
- Returns:
- The label location that was previously set.
- See Also:
-
setLabelLocation
Description copied from interface:ILcdGXYLabelPainter2
Sets the label location of the label. This label location will be used to determine what the bounds of the label are, where it must be painted, etc.
Note that
aLabelLocation
also contains a label location index. This is independent of theILcdGXYLabelPainter.getLocationIndex()
of the super interface. Contrary to the location index returned bygetLocationIndex
, the location index inaLabelLocation
can be less than0
, in which case the labels are freely placed.This method has to be called after
ILcdGXYLabelPainter2.setObject(java.lang.Object)
has been called, as callingsetObject
clears this label location.- Specified by:
setLabelLocation
in interfaceILcdGXYLabelPainter2
- Parameters:
aLabelLocation
- TheTLcdLabelLocation
instance containing all the information about the location of the label.- See Also:
-
setObject
Description copied from interface:ILcdGXYLabelPainter2
Sets the Object to be labeled by this ILcdGXYLabelPainter.Setting the object should set the
TLcdLabelLocation
tonull
, to ensure that older code which has not been adapted to this new interface keeps working.- Specified by:
setObject
in interfaceILcdGXYLabelPainter
- Specified by:
setObject
in interfaceILcdGXYLabelPainter2
- Parameters:
aObject
- The object to be labeled.- See Also:
-
getObject
Description copied from interface:ILcdGXYLabelPainter
Gets the Object this ILcdGXYLabelPainter can label.- Specified by:
getObject
in interfaceILcdGXYLabelPainter
- Returns:
- the Object this ILcdGXYLabelPainter can label.
- See Also:
-
getLabelCount
Return the number of labels for the currently set object. The default implementation returns
1
. Override this method if you need to support multiple labels.- Specified by:
getLabelCount
in interfaceILcdGXYMultiLabelPainter
- Parameters:
aGraphics
- TheGraphics
instance on which the labels would be painted.aGXYContext
- The context containing information about the layer and the view for which the label would be drawn.- Returns:
- The number of labels for the set object. This should be greater than
0
.
-
setLabelIndex
public void setLabelIndex(int aLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainter
Sets the label. The results of any subsequent method calls to
ILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
andILcdGXYLabelPainter.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.- Specified by:
setLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Parameters:
aLabelIndex
- The label index. This should be larger than or equal to0
and less than the resultILcdGXYMultiLabelPainter.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext)
.- See Also:
-
getLabelIndex
public int getLabelIndex()Description copied from interface:ILcdGXYMultiLabelPainter
Returns the index of the label that is currently painted or scheduled to paint.- Specified by:
getLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Returns:
- the index of the label that is currently painted or scheduled to paint.
- See Also:
-
getSubLabelCount
public int getSubLabelCount(int aLabelIndex) Returns the number of sublabels for the set object and the given label index. The default implementation returns
1
. Override this method if you need to support multiple sublabels.- Specified by:
getSubLabelCount
in interfaceILcdGXYMultiLabelPainter
- Parameters:
aLabelIndex
- The label index for which you need to know the number of sublabels.- Returns:
- The number of sublabels. This should be greater than
0
. - See Also:
-
setSubLabelIndex
public void setSubLabelIndex(int aSubLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainter
Sets the sublabel index. The results of any subsequent method calls toILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
andILcdGXYLabelPainter.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.- Specified by:
setSubLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Parameters:
aSubLabelIndex
- The sub label index. This should be larger than or equal to0
and less than the resultILcdGXYMultiLabelPainter.getSubLabelCount(int)
.- See Also:
-
getSubLabelIndex
public int getSubLabelIndex()Description copied from interface:ILcdGXYMultiLabelPainter
Returns the index of the sublabel to paint.- Specified by:
getSubLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Returns:
- the index of the sublabel to paint.
- See Also:
-
setLocationIndex
public void setLocationIndex(int aLocationIndex) Description copied from interface:ILcdGXYLabelPainter
Sets the index of location where to paint the label(s) of the set Object.- Specified by:
setLocationIndex
in interfaceILcdGXYLabelPainter
- Parameters:
aLocationIndex
- the index of the location. Must be between 0 and getPossibleLocationCount() - 1.- See Also:
-
getLocationIndex
public int getLocationIndex()Description copied from interface:ILcdGXYLabelPainter
Gets the index of location where to paint the label(s) of the set Object.- Specified by:
getLocationIndex
in interfaceILcdGXYLabelPainter
- Returns:
- the index of the position. Must be between 0 and getPossibleLocationCount() - 1.
- See Also:
-
clone
Returns a new instance of thisALcdGXYLabelPainter
. The label location of the clone is a clone of the label location of the original. No other objects are cloned.- Specified by:
clone
in interfaceILcdGXYLabelPainter
- Specified by:
clone
in interfaceILcdGXYLabelPainter2
- Overrides:
clone
in classObject
- Returns:
- A new instance of this
ALcdGXYLabelPainter
of which the label location is a deep clone.
-
getLabelCursor
Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.This default implementation always returns
null
. Override this method if you want to display custom cursors.- Specified by:
getLabelCursor
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- The mode to consider. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, ILcdGXYContext)
for more information.aGXYContext
- TheILcdGXYContext
containing extra information, such as the layer, the view and the mouse position.- Returns:
- a
Cursor
to indicate the type of editingaMode
andaGXYContext
. Returnsnull
if no particularCursor
is required.
-
supportLabelSnap
Returns whether this label painter supports snapping for the label specified by
setObject
,setLabelIndex
andsetSubLabelIndex
, considering the givenILcdGXYContext
instance. When the label painter supports snap for the specified label and context, it can return a snap target for this label and context.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.
This default implementation returns
false
. Override this method if you want to support snapping.- Specified by:
supportLabelSnap
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.- Returns:
true
if this label painter supports snapping for the specified label.- See Also:
-
labelSnapTarget
Returns anObject
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents. The returnedObject
can be theObject
this ILcdGXYLabelPainter2 represents or any other (e.g. anILcdPoint
if getObject() is anILcdPointList
).This default implementation always returns
null
. Override this method if you want to support snapping.- Specified by:
labelSnapTarget
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.- Returns:
- an
Object
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents (returned by getObject()). This object can benull
.
-
getDisplayName
This default implementation returns the display name set withsetDisplayName
, ortoString()
if this was set tonull
.- Specified by:
getDisplayName
in interfaceILcdGXYLabelPainter2
- Returns:
- the display name of this
ILcdGXYLabelPainter2
-
setDisplayName
Sets the display name for this label painter.- Parameters:
aDisplayName
- The display name for this label painter. This can benull
, in which casegetDisplayName()
will return the result oftoString()
.- See Also:
-