public abstract class ALcdGXYLabelPainter extends Object implements ILcdGXYLabelPainter2
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.
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
DEFAULT, SELECTED
Constructor and Description |
---|
ALcdGXYLabelPainter() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
Object |
clone()
Returns a new instance of this
ALcdGXYLabelPainter . |
protected void |
firePropertyChangeEvent(PropertyChangeEvent aPropertyChangeEvent)
Notifies the registered
PropertyChangeListener s of the specified event. |
String |
getDisplayName()
This default implementation returns the display name set with
setDisplayName , or toString() if this was set to null . |
int |
getLabelCount(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Return the number of labels for the currently set object.
|
Cursor |
getLabelCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor to indicate the type of editing aMode and
aGXYContext . |
int |
getLabelIndex()
Returns the index of the label that is currently painted or scheduled to paint.
|
TLcdLabelLocation |
getLabelLocation()
Returns the
TLcdLabelLocation that was previously set that contains the
information on the whereabouts of the label. |
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 |
getSubLabelCount(int aLabelIndex)
Returns the number of sublabels for the set object and the given label index.
|
int |
getSubLabelIndex()
Returns the index of the sublabel to paint.
|
Object |
labelSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns an
Object that can be used as snapping target when graphically editing
another Object or label than the one this ILcdGXYLabelPainter2 represents. |
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
De-registers the given
PropertyChangeListener 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 |
setObject(Object aObject)
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 by
setObject , setLabelIndex and setSubLabelIndex ,
considering the given ILcdGXYContext instance. |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isLabelTouched, labelAnchorPointSFCT, labelBoundsSFCT, paintLabel
getPossibleLocationCount
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
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.
addPropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
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.
removePropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
protected void firePropertyChangeEvent(PropertyChangeEvent aPropertyChangeEvent)
PropertyChangeListener
s of the specified event.aPropertyChangeEvent
- The event describing the property change of which the registered
listeners should be notified.addPropertyChangeListener(java.beans.PropertyChangeListener)
public TLcdLabelLocation getLabelLocation()
ILcdGXYLabelPainter2
TLcdLabelLocation
that was previously set that contains the
information on the whereabouts of the label.getLabelLocation
in interface ILcdGXYLabelPainter2
ILcdGXYLabelPainter2.setLabelLocation(com.luciad.view.TLcdLabelLocation)
public void setLabelLocation(TLcdLabelLocation aLabelLocation)
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 the ILcdGXYLabelPainter.getLocationIndex()
of the super interface. Contrary to the location
index returned by getLocationIndex
, the location index in
aLabelLocation
can be less than 0
, in which case the labels are
freely placed.
This method has to be called after ILcdGXYLabelPainter2.setObject(java.lang.Object)
has been called, as calling
setObject
clears this label location.
setLabelLocation
in interface ILcdGXYLabelPainter2
aLabelLocation
- The TLcdLabelLocation
instance containing all the
information about the location of the label.ILcdGXYLabelPainter2.setObject(java.lang.Object)
public void setObject(Object aObject)
ILcdGXYLabelPainter2
Setting the object should set the TLcdLabelLocation
to null
, to
ensure that older code which has not been adapted to this new interface keeps working.
setObject
in interface ILcdGXYLabelPainter
setObject
in interface ILcdGXYLabelPainter2
aObject
- The object to be labeled.ILcdGXYLabelPainter.getObject()
public Object getObject()
ILcdGXYLabelPainter
getObject
in interface ILcdGXYLabelPainter
ILcdGXYLabelPainter.setObject(java.lang.Object)
public int getLabelCount(Graphics aGraphics, ILcdGXYContext aGXYContext)
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.
getLabelCount
in interface ILcdGXYMultiLabelPainter
aGraphics
- The Graphics
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.0
.public void setLabelIndex(int aLabelIndex)
ILcdGXYMultiLabelPainter
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()
ILcdGXYMultiLabelPainter
getLabelIndex
in interface ILcdGXYMultiLabelPainter
ILcdGXYMultiLabelPainter.setLabelIndex(int)
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.
getSubLabelCount
in interface ILcdGXYMultiLabelPainter
aLabelIndex
- The label index for which you need to know the number of sublabels.0
.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext)
public void setSubLabelIndex(int aSubLabelIndex)
ILcdGXYMultiLabelPainter
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.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 getSubLabelIndex()
ILcdGXYMultiLabelPainter
getSubLabelIndex
in interface ILcdGXYMultiLabelPainter
ILcdGXYMultiLabelPainter.setSubLabelIndex(int)
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 Object clone()
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 class Object
ALcdGXYLabelPainter
of which the label location
is a deep clone.public Cursor getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
Cursor
to indicate the type of editing aMode
and
aGXYContext
.
This default implementation always returns null
. Override this method if you want
to display custom cursors.
getLabelCursor
in interface ILcdGXYLabelPainter2
aGraphics
- The Graphics
instance on which the label is painted.aMode
- The mode to consider. See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int,
ILcdGXYContext)
for more information.aGXYContext
- The ILcdGXYContext
containing extra information, such as the
layer, the view and the mouse position.Cursor
to indicate the type of editing aMode
and
aGXYContext
. Returns null
if no particular
Cursor
is required.public boolean supportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns whether this label painter supports snapping for the label specified by
setObject
, setLabelIndex
and setSubLabelIndex
,
considering the given ILcdGXYContext
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.
supportLabelSnap
in interface ILcdGXYLabelPainter2
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.true
if this label painter supports snapping for the specified label.labelSnapTarget
public Object labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Object
that can be used as snapping target when graphically editing
another Object
or label than the one this ILcdGXYLabelPainter2 represents. The
returned Object
can be the Object
this ILcdGXYLabelPainter2
represents or any other (e.g. an ILcdPoint
if getObject() is an
ILcdPointList
).
This default implementation always returns null
. Override this method if you want
to support snapping.
labelSnapTarget
in interface ILcdGXYLabelPainter2
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.Object
that can be used as snapping target when graphically editing
another Object
or label than the one this ILcdGXYLabelPainter2 represents
(returned by getObject()). This object can be null
.public String getDisplayName()
setDisplayName
, or toString()
if this was set to null
.getDisplayName
in interface ILcdGXYLabelPainter2
ILcdGXYLabelPainter2
public void setDisplayName(String aDisplayName)
aDisplayName
- The display name for this label painter. This can be null
, in
which case getDisplayName()
will return the result of
toString()
.getDisplayName