Class TLcdLabelLocations
Implementation of ALcdLabelLocations
that stores the label locations external
from the domain objects.
This implementation returns the default location (specified in the constructor) when the requested information is not present.
This implementation relies on the identity of the object that is passed to
the methods, so ==
instead of equals
.
- Since:
- 7.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.luciad.view.ALcdLabelLocations
ALcdLabelLocations.LabelLocationFunction
-
Constructor Summary
ConstructorDescriptionTLcdLabelLocations
(ILcdLayer aLayer, TLcdLabelLocation aDefaultLabelLocation) Constructs a new instance with the specified default location and belonging to the specified layer.TLcdLabelLocations
(ILcdLayer aLayer, TLcdLabelLocation aDefaultLabelLocation, ILcdLabelDependencyProvider aLabelDependencyProvider) Constructs a new instance with the specified default location and belonging to the specified layer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified listener to this information store.void
addLabelPaintedListener
(ILcdLabelPaintedListener aListener) Adds the specified listener to this information store.void
applyOnAllLabelLocations
(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Iterates over all stored label locations by callingapplyOnLabelLocation
for every label location.void
applyOnPaintedLabelLocations
(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Iterates over all label locations for the labels that were painted by callingapplyOnLabelLocation
for every painted label location.void
clearAllPainted
(ILcdView aView, int aEventMode) Clears the painted status of all labels for the givenILcdView
.Creates a newTLcdLabelLocation
by cloning the given default label location.void
fireCollectedChanges
(ILcdView aView) Informs the label location listeners of the changes that were collected inputLabelLocation
.void
Informs the listeners registered usingALcdLabelLocations.addLabelPaintedListener(ILcdLabelPaintedListener)
of the changes that were collected inALcdLabelLocations.setPainted(Object, int, int, ILcdView, boolean, int)
andALcdLabelLocations.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 inaLocationSFCT
.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 inaLocationSFCT
.getLayer()
Returns the layer to which thisALcdLabelLocations
instance belongs.boolean
Returns whether or not the specified label is currently painted.void
putLabelLocation
(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocation, int aEventMode) Stores the given information so it can beretrieved
later on.void
Removes the specified listener.void
Removes the specified listener.void
Sets the layer to which this instance belongs.void
setPainted
(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, boolean aPainted, int aEventMode) Marks the specified label as painted or not painted according toaPainted
.
-
Constructor Details
-
TLcdLabelLocations
Constructs a new instance with the specified default location and belonging to the specified layer.- Parameters:
aLayer
- The layer to which this instance belongs. This can benull
, but the layer must be set withsetLayer(ILcdLayer)
before any other method of this class is called.aDefaultLabelLocation
- The default location information to return when the requested label location is not available. SeeALcdLabelLocations.getLabelLocationSFCT(Object, int, int, ILcdView, TLcdLabelLocation)
-
TLcdLabelLocations
public TLcdLabelLocations(ILcdLayer aLayer, TLcdLabelLocation aDefaultLabelLocation, ILcdLabelDependencyProvider aLabelDependencyProvider) Constructs a new instance with the specified default location and belonging to the specified layer.When this constructor is used, the given label dependency provider is used to place a reference to an other label in the
TLcdLabelLocation
instances when a requested label location is not available, seeALcdLabelLocations.getLabelLocationSFCT(java.lang.Object, int, int, com.luciad.view.ILcdView, com.luciad.view.TLcdLabelLocation)
.The given label dependency provider should not contain cyclic dependencies, i.e. a label should not depend on itself (directly or indirectly). It should also return at most one parent label for each label. This parent should be a label of the same object as the the given label. So labels should not reference labels from other objects.
- Parameters:
aLayer
- The layer to which this instance belongs. This can benull
, but the layer must be set withsetLayer(ILcdLayer)
before any other method of this class is called.aDefaultLabelLocation
- The default location information to return when the requested label location is not available. SeeALcdLabelLocations.getLabelLocationSFCT(Object, int, int, ILcdView, TLcdLabelLocation)
aLabelDependencyProvider
- a label dependency provider.
-
-
Method Details
-
addLabelLocationListener
Description copied from class:ALcdLabelLocations
Adds the specified listener to this information store. This listener will be notified of changes in the label information.- Specified by:
addLabelLocationListener
in classALcdLabelLocations
- Parameters:
aListener
- The listener that should be informed when there are changes in the label information.- See Also:
-
removeLabelLocationListener
Description copied from class:ALcdLabelLocations
Removes the specified listener. This listener will no longer be notified of changes in the label information.- Specified by:
removeLabelLocationListener
in classALcdLabelLocations
- Parameters:
aListener
- The listener to remove.
-
addLabelPaintedListener
Description copied from class:ALcdLabelLocations
Adds the specified listener to this information store. The listener will be notified of changes in the label painted status with aTLcdLabelPaintedEvent
.- Specified by:
addLabelPaintedListener
in classALcdLabelLocations
- Parameters:
aListener
- The listener that should be informed when there are changes in the painted status of a label.- See Also:
-
removeLabelPaintedListener
Description copied from class:ALcdLabelLocations
Removes the specified listener. This listener will no longer be notified of changes in the painted label information.- Specified by:
removeLabelPaintedListener
in classALcdLabelLocations
- Parameters:
aListener
- The listener to remove.
-
fireCollectedChanges
Description copied from class:ALcdLabelLocations
Informs the label location listeners of the changes that were collected in
putLabelLocation
. These changes were only collected when theaEventMode
parameter of this method wasILcdFireEventMode#FIRE_LATER
.The queue of collected changes is empty when this method returns.
- Specified by:
fireCollectedChanges
in classALcdLabelLocations
- Parameters:
aView
- TheILcdView
for which to fire the collected changes.- See Also:
-
putLabelLocation
public void putLabelLocation(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocation, int aEventMode) Description copied from class:ALcdLabelLocations
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
foraEventMode
, you must either callALcdLabelLocations.fireCollectedChanges(ILcdView)
sometime afterward or call this method withILcdFireEventMode#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 (seeILcdGXYViewLabelPlacer
), the label editor, or other code that manually adjusts offset labels.- Specified by:
putLabelLocation
in classALcdLabelLocations
- Parameters:
aObject
- The domain object to which this label information applies. This object should be contained in theILcdModel
of the associatedILcdLayer
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 isnull
, any label information already present in this instance about the given domain object, label index and sublabel index is removed from this class.aEventMode
- A code indicating if and when the listeners should be informed of this change. This code should be one ofILcdFireEventMode.FIRE_NOW
,ILcdFireEventMode.FIRE_LATER
orILcdFireEventMode.NO_EVENT
- See Also:
-
getLabelLocationSFCT
public 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 inaLocationSFCT
. 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.This implementation loads the default values in
aLocationSFCT
in case the requested information is not present. This is done by callinggetDefaultLabelLocationSFCT
.- Specified by:
getLabelLocationSFCT
in classALcdLabelLocations
- Parameters:
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
- TheTLcdLabelLocation
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 usecreateLabelLocation
to create a valid instance for this parameter.- Returns:
true
if the requested label location information was available,false
otherwise.- See Also:
-
getDefaultLabelLocationSFCT
public 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 inaLocationSFCT
.aObject
should be contained in the ILcdModel of the ILcdLayer to which this ALcdLabelLocations belongs.This implementation copies the properties of the default label location (given in the constructor) to the given label location. It also tries to add a parent label if an
ILcdLabelDependencyProvider
was passed in the constructor.- Overrides:
getDefaultLabelLocationSFCT
in classALcdLabelLocations
- Parameters:
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
- TheTLcdLabelLocation
instance that will be updated with the default label location information. One should usecreateLabelLocation
to create a valid instance for this parameter.
-
applyOnAllLabelLocations
public void applyOnAllLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Description copied from class:ALcdLabelLocations
Iterates over all stored label locations by calling
applyOnLabelLocation
for every label location.If
applyOnLabelLocation
returnstrue
, the iteration continues, if it returnsfalse
the iteration is aborted.- Specified by:
applyOnAllLabelLocations
in classALcdLabelLocations
- Parameters:
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.
-
applyOnPaintedLabelLocations
public void applyOnPaintedLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Description copied from class:ALcdLabelLocations
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
returnstrue
, the iteration continues, if it returnsfalse
the iteration is aborted.- Specified by:
applyOnPaintedLabelLocations
in classALcdLabelLocations
- Parameters:
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.
-
fireCollectedLabelPaintedChanges
Description copied from class:ALcdLabelLocations
Informs the listeners registered using
ALcdLabelLocations.addLabelPaintedListener(ILcdLabelPaintedListener)
of the changes that were collected inALcdLabelLocations.setPainted(Object, int, int, ILcdView, boolean, int)
andALcdLabelLocations.clearAllPainted(ILcdView, int)
. These changes were only collected when theaEventMode
parameter of this method wasILcdFireEventMode#FIRE_LATER
.The queue of collected changes is empty when this method returns.
- Specified by:
fireCollectedLabelPaintedChanges
in classALcdLabelLocations
- Parameters:
aView
- TheILcdView
for which to fire the collected changes.- See Also:
-
setPainted
public void setPainted(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, boolean aPainted, int aEventMode) Description copied from class:ALcdLabelLocations
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.
- Specified by:
setPainted
in classALcdLabelLocations
- Parameters:
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 toaPainted
.aPainted
- Whether or not the label should be marked as painted.aEventMode
- A code indicating if and when the listeners should be informed of this change. This code should be one ofILcdFireEventMode.FIRE_NOW
,ILcdFireEventMode.FIRE_LATER
orILcdFireEventMode.NO_EVENT
- See Also:
-
isPainted
Description copied from class:ALcdLabelLocations
Returns whether or not the specified label is currently painted.- Specified by:
isPainted
in classALcdLabelLocations
- Parameters:
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.- Returns:
- Whether or not the specified label was marked as painted for the given
ILcdView
. - See Also:
-
clearAllPainted
Description copied from class:ALcdLabelLocations
Clears the painted status of all labels for the givenILcdView
. This is typically done right before a layer (or layer label painter or view label painter etc) starts painting the labels.- Specified by:
clearAllPainted
in classALcdLabelLocations
- Parameters:
aView
- The view for which to clear all painted labels, or null to clear the status for all views.aEventMode
- A code indicating if and when the listeners should be informed of this change. This code should be one ofILcdFireEventMode.FIRE_NOW
,ILcdFireEventMode.FIRE_LATER
orILcdFireEventMode.NO_EVENT
-
getLayer
Description copied from class:ALcdLabelLocations
Returns the layer to which thisALcdLabelLocations
instance belongs.- Specified by:
getLayer
in classALcdLabelLocations
- Returns:
- The layer to which this
ALcdLabelLocations
instance belongs.
-
setLayer
Sets the layer to which this instance belongs. If this layer is not set in the constructor, it must be set before any other methods are called.- Parameters:
aLayer
- The layer to which this instance belongs.
-
createLabelLocation
Creates a newTLcdLabelLocation
by cloning the given default label location.- Specified by:
createLabelLocation
in classALcdLabelLocations
- Returns:
- A new
TLcdLabelLocation
. - See Also:
-