public abstract class ALcdLabelLocations extends Object
ALcdLabelLocations
is the central place where information is kept about the
position of labels and whether or not they were drawn. It is specific to a single
ILcdLayer
, for example a ILcdGXYEditableLabelsLayer
. Refer to the
documentation of that class how this information is used in other classes.
For a single label, this information is updated and retrieved using the methods putLabelLocation
and getLabelLocationSFCT
respectively.
It is also possible to consult all
stored label location information using the methods
applyOnAllLabelLocations
and
applyOnPaintedLabelLocations
It is up to the implementation of this class how this information is stored. One implementation may store the information inside the domain objects, while another implementation may store this information external to the domain object in some sort of a map.
All classes that contain label painting logic, such as the implementations of ILcdGXYLayer
, ILcdGXYLayerLabelPainter
and
ILcdGXYViewLabelPainter
, must inform this information store on which
labels have been painted.
Implementations can use TLcdLabelLocationEventSupport
to facilitate
the handling of events.
ILcdGXYEditableLabelsLayer
Modifier and Type | Class and Description |
---|---|
static class |
ALcdLabelLocations.LabelLocationFunction
Iterator to iterate over label locations.
|
Constructor and Description |
---|
ALcdLabelLocations() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addLabelLocationListener(ILcdLabelLocationListener aListener)
Adds the specified listener to this information store.
|
abstract void |
addLabelPaintedListener(ILcdLabelPaintedListener aListener)
Adds the specified listener to this information store.
|
abstract void |
applyOnAllLabelLocations(ILcdView aView,
ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction)
Iterates over all stored label locations by calling
applyOnLabelLocation
for every label location. |
abstract void |
applyOnPaintedLabelLocations(ILcdView aView,
ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction)
Iterates over all label locations for the labels that were painted by calling
applyOnLabelLocation for
every painted label location. |
abstract void |
clearAllPainted(ILcdView aView,
int aFireEventMode)
Clears the painted status of all labels for the given
ILcdView . |
abstract TLcdLabelLocation |
createLabelLocation()
Creates a new instance of (an extension of)
TLcdLabelLocation . |
abstract void |
fireCollectedChanges(ILcdView aView)
Informs the label location listeners of the changes that were collected in
putLabelLocation . |
abstract void |
fireCollectedLabelPaintedChanges(ILcdView aView)
Informs the listeners registered using
addLabelPaintedListener(ILcdLabelPaintedListener)
of the changes that were collected in setPainted(Object, int, int, ILcdView, boolean, int) and
clearAllPainted(ILcdView, int) . |
void |
getDefaultLabelLocationSFCT(Object aObject,
int aLabelIndex,
int aSubLabelIndex,
ILcdView aView,
TLcdLabelLocation aLocationSFCT)
Retrieves the default label location information of the specified label and puts that information
in
aLocationSFCT . |
abstract boolean |
getLabelLocationSFCT(Object aObject,
int aLabelIndex,
int aSubLabelIndex,
ILcdView aView,
TLcdLabelLocation aLocationSFCT)
Retrieves the label location information of the specified label and puts that information in
aLocationSFCT . |
abstract ILcdLayer |
getLayer()
Returns the layer to which this
ALcdLabelLocations instance belongs. |
abstract boolean |
isPainted(Object aObject,
int aLabelIndex,
int aSubLabelIndex,
ILcdView aView)
Returns whether or not the specified label is currently painted.
|
abstract void |
putLabelLocation(Object aObject,
int aLabelIndex,
int aSubLabelIndex,
ILcdView aView,
TLcdLabelLocation aLocation,
int aFireEventMode)
Stores the given information so it can be
retrieved later on. |
abstract void |
removeLabelLocationListener(ILcdLabelLocationListener aListener)
Removes the specified listener.
|
abstract void |
removeLabelPaintedListener(ILcdLabelPaintedListener aListener)
Removes the specified listener.
|
abstract void |
setPainted(Object aObject,
int aLabelIndex,
int aSubLabelIndex,
ILcdView aView,
boolean aPainted,
int aFireEventMode)
Marks the specified label as painted or not painted according to
aPainted . |
public abstract void addLabelLocationListener(ILcdLabelLocationListener aListener)
aListener
- The listener that should be informed when there are changes in the label
information.putLabelLocation(Object, int, int, ILcdView, TLcdLabelLocation, int)
public abstract void removeLabelLocationListener(ILcdLabelLocationListener aListener)
aListener
- The listener to remove.public abstract void addLabelPaintedListener(ILcdLabelPaintedListener aListener)
TLcdLabelPaintedEvent
.aListener
- The listener that should be informed when there are changes in the
painted status of a label.setPainted(Object, int, int, ILcdView, boolean, int)
,
clearAllPainted(ILcdView, int)
public abstract void removeLabelPaintedListener(ILcdLabelPaintedListener aListener)
aListener
- The listener to remove.public abstract void fireCollectedChanges(ILcdView aView)
Informs the label location listeners of the changes that were collected in putLabelLocation
. These changes
were only collected when the aEventMode
parameter of this method was
ILcdFireEventMode#FIRE_LATER
.
The queue of collected changes is empty when this method returns.
aView
- The ILcdView
for which to fire the collected changes.addLabelLocationListener(ILcdLabelLocationListener)
,
putLabelLocation(Object, int, int, ILcdView, TLcdLabelLocation, int)
public abstract void putLabelLocation(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocation, int aFireEventMode)
Stores the given information so it can be retrieved
later on.
This method also allows to remove the information: just let the TLcdLabelLocation be
null
.
If you specify ILcdFireEventMode#FIRE_LATER
for aEventMode
, you
must either call fireCollectedChanges(ILcdView)
sometime afterward or call this method with
ILcdFireEventMode#FIRE_NOW
as event mode. This allows you to make multiple changes
to the label locations and inform the listeners afterward in one go, which can be more
efficient than informing them at each change.
Before storing the given label location, one should make sure that the bounds of the parent
label are set (see TLcdLabelLocation.setParentBounds(java.awt.Rectangle, double)
. Examples
of code that should do this are the label placer (see ILcdGXYViewLabelPlacer
),
the label editor, or other code that manually adjusts offset labels.
aObject
- The domain object to which this label information applies. This object
should be contained in the ILcdModel
of the associated
ILcdLayer
aLabelIndex
- The label to which this label information applies.aSubLabelIndex
- The sub label to which this label information applies.aView
- The view for which the location applies.aLocation
- The label information. No reference to this object is kept within the
implementations of this class. This allows the client of this class to
reuse the same object. If this location is null
, any
label information already present in this instance about the given
domain object, label index and sublabel index is removed from this class.aFireEventMode
- A code indicating if and when the listeners should be informed of this
change. This code should be one of ILcdFireEventMode.FIRE_NOW
,
ILcdFireEventMode.FIRE_LATER
or ILcdFireEventMode.NO_EVENT
getLabelLocationSFCT(java.lang.Object, int, int, com.luciad.view.ILcdView, com.luciad.view.TLcdLabelLocation)
public abstract boolean getLabelLocationSFCT(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocationSFCT)
aLocationSFCT
. The return value indicates whether or not the requested information
was available in this store.
aObject
should be contained in the ILcdModel of the ILcdLayer
to which this ALcdLabelLocations belongs.
aObject
- The domain object for which you want to retrieve the label location
information.aLabelIndex
- The label for which you want to retrieve the label location information.aSubLabelIndex
- The sub label for which you want to retrieve the label location
information.aView
- The view for which the location is retrieved.aLocationSFCT
- The TLcdLabelLocation
instance that will be updated with the
label location information. It is up to the implementation of this class
to decide what happens when the information was not available.
One should use createLabelLocation
to create a valid
instance for this parameter.true
if the requested label location information was available,
false
otherwise.public void getDefaultLabelLocationSFCT(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocationSFCT)
aLocationSFCT
.
aObject
should be contained in the ILcdModel of the ILcdLayer
to which this ALcdLabelLocations belongs.
aObject
- The domain object for which you want to retrieve the label location
information.aLabelIndex
- The label for which you want to retrieve the label location information.aSubLabelIndex
- The sub label for which you want to retrieve the label location
information.aView
- The view for which the location is retrieved.aLocationSFCT
- The TLcdLabelLocation
instance that will be updated with the default
label location information. One should use createLabelLocation
to
create a valid instance for this parameter.public abstract void applyOnAllLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction)
Iterates over all stored label locations by calling
applyOnLabelLocation
for every label location.
If applyOnLabelLocation
returns
true
, the iteration continues, if it returns false
the iteration is
aborted.
aView
- Iterate over the labels for this view.aLabelLocationFunction
- The label iterator. This label iterator contains the logic of what to do
with each label.public abstract void applyOnPaintedLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction)
Iterates over all label locations for the labels that were painted by calling
applyOnLabelLocation
for
every painted label location. The iteration order is preferably the order in which they were marked as
painted.
If applyOnLabelLocation
returns
true
, the iteration continues, if it returns false
the iteration is
aborted.
aView
- Iterate over the labels painter for this view.aLabelLocationFunction
- The label iterator. This label iterator contains the logic of what to do
with each label.public abstract void fireCollectedLabelPaintedChanges(ILcdView aView)
Informs the listeners registered using addLabelPaintedListener(ILcdLabelPaintedListener)
of the changes that were collected in setPainted(Object, int, int, ILcdView, boolean, int)
and
clearAllPainted(ILcdView, int)
. These changes were only collected when the
aEventMode
parameter of this method was ILcdFireEventMode#FIRE_LATER
.
The queue of collected changes is empty when this method returns.
aView
- The ILcdView
for which to fire the collected changes.addLabelPaintedListener(ILcdLabelPaintedListener)
,
setPainted(Object, int, int, ILcdView, boolean, int)
,
clearAllPainted(ILcdView, int)
public abstract void setPainted(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, boolean aPainted, int aFireEventMode)
Marks the specified label as painted or not painted according to aPainted
.
All code that paints a label should call this method when they actually paint a label. For instance implementations of ILcdGXYEditableLabelsLayer, ILcdGXYLayerLabelPainter and ILcdGXYViewLabelPainter should call this method when they paint a label.
aObject
- The domain object for which the label was painted.aLabelIndex
- The label index of the label that was painted.aSubLabelIndex
- The sub label index of the label that was painted.aView
- Mark the label painted or not painted on this view, according to
aPainted
.aPainted
- Whether or not the label should be marked as painted.aFireEventMode
- A code indicating if and when the listeners should be informed of this
change. This code should be one of ILcdFireEventMode.FIRE_NOW
,
ILcdFireEventMode.FIRE_LATER
or ILcdFireEventMode.NO_EVENT
clearAllPainted(ILcdView, int)
public abstract boolean isPainted(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView)
aObject
- The domain objectaLabelIndex
- The label index of the label for which you want to know if it was
painted.aSubLabelIndex
- The sub label index of the label for which you want to know if it was
painted.aView
- The view for which we want to know if the label was painted on it.ILcdView
.applyOnPaintedLabelLocations(com.luciad.view.ILcdView, com.luciad.view.ALcdLabelLocations.LabelLocationFunction)
public abstract void clearAllPainted(ILcdView aView, int aFireEventMode)
ILcdView
. This is typically
done right before a layer (or layer label painter or view label painter etc) starts painting
the labels.aView
- The view for which to clear all painted labels, or null to clear the status for all views.aFireEventMode
- A code indicating if and when the listeners should be informed of this
change. This code should be one of ILcdFireEventMode.FIRE_NOW
,
ILcdFireEventMode.FIRE_LATER
or ILcdFireEventMode.NO_EVENT
public abstract ILcdLayer getLayer()
ALcdLabelLocations
instance belongs.ALcdLabelLocations
instance belongs.public abstract TLcdLabelLocation createLabelLocation()
TLcdLabelLocation
.
Use this method to have a working TLcdLabelLocation
instance
that can for example be passed to getLabelLocationSFCT
.TLcdLabelLocation
instance.TLcdLabelLocation