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
ConstructorsConstructorDescriptionTLcdLabelLocations(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 TypeMethodDescriptionvoidAdds the specified listener to this information store.voidaddLabelPaintedListener(ILcdLabelPaintedListener aListener) Adds the specified listener to this information store.voidapplyOnAllLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Iterates over all stored label locations by callingapplyOnLabelLocationfor every label location.voidapplyOnPaintedLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Iterates over all label locations for the labels that were painted by callingapplyOnLabelLocationfor every painted label location.voidclearAllPainted(ILcdView aView, int aEventMode) Clears the painted status of all labels for the givenILcdView.Creates a newTLcdLabelLocationby cloning the given default label location.voidfireCollectedChanges(ILcdView aView) Informs the label location listeners of the changes that were collected inputLabelLocation.voidInforms the listeners registered usingALcdLabelLocations.addLabelPaintedListener(ILcdLabelPaintedListener)of the changes that were collected inALcdLabelLocations.setPainted(Object, int, int, ILcdView, boolean, int)andALcdLabelLocations.clearAllPainted(ILcdView, int).voidgetDefaultLabelLocationSFCT(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.booleangetLabelLocationSFCT(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 thisALcdLabelLocationsinstance belongs.booleanReturns whether or not the specified label is currently painted.voidputLabelLocation(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdView aView, TLcdLabelLocation aLocation, int aEventMode) Stores the given information so it can beretrievedlater on.voidRemoves the specified listener.voidRemoves the specified listener.voidSets the layer to which this instance belongs.voidsetPainted(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
TLcdLabelLocationinstances 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:ALcdLabelLocationsAdds the specified listener to this information store. This listener will be notified of changes in the label information.- Specified by:
addLabelLocationListenerin classALcdLabelLocations- Parameters:
aListener- The listener that should be informed when there are changes in the label information.- See Also:
-
removeLabelLocationListener
Description copied from class:ALcdLabelLocationsRemoves the specified listener. This listener will no longer be notified of changes in the label information.- Specified by:
removeLabelLocationListenerin classALcdLabelLocations- Parameters:
aListener- The listener to remove.
-
addLabelPaintedListener
Description copied from class:ALcdLabelLocationsAdds the specified listener to this information store. The listener will be notified of changes in the label painted status with aTLcdLabelPaintedEvent.- Specified by:
addLabelPaintedListenerin 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:ALcdLabelLocationsRemoves the specified listener. This listener will no longer be notified of changes in the painted label information.- Specified by:
removeLabelPaintedListenerin classALcdLabelLocations- Parameters:
aListener- The listener to remove.
-
fireCollectedChanges
Description copied from class:ALcdLabelLocationsInforms the label location listeners of the changes that were collected in
putLabelLocation. These changes were only collected when theaEventModeparameter of this method wasILcdFireEventMode#FIRE_LATER.The queue of collected changes is empty when this method returns.
- Specified by:
fireCollectedChangesin classALcdLabelLocations- Parameters:
aView- TheILcdViewfor 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:ALcdLabelLocationsStores the given information so it can be
retrievedlater on.This method also allows to remove the information: just let the TLcdLabelLocation be
null.If you specify
ILcdFireEventMode#FIRE_LATERforaEventMode, you must either callALcdLabelLocations.fireCollectedChanges(ILcdView)sometime afterward or call this method withILcdFireEventMode#FIRE_NOWas 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:
putLabelLocationin classALcdLabelLocations- Parameters:
aObject- The domain object to which this label information applies. This object should be contained in theILcdModelof the associatedILcdLayeraLabelIndex- 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_LATERorILcdFireEventMode.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.aObjectshould be contained in the ILcdModel of the ILcdLayer to which this ALcdLabelLocations belongs.This implementation loads the default values in
aLocationSFCTin case the requested information is not present. This is done by callinggetDefaultLabelLocationSFCT.- Specified by:
getLabelLocationSFCTin 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- TheTLcdLabelLocationinstance 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 usecreateLabelLocationto create a valid instance for this parameter.- Returns:
trueif the requested label location information was available,falseotherwise.- 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.aObjectshould 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
ILcdLabelDependencyProviderwas passed in the constructor.- Overrides:
getDefaultLabelLocationSFCTin 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- TheTLcdLabelLocationinstance that will be updated with the default label location information. One should usecreateLabelLocationto create a valid instance for this parameter.
-
applyOnAllLabelLocations
public void applyOnAllLabelLocations(ILcdView aView, ALcdLabelLocations.LabelLocationFunction aLabelLocationFunction) Description copied from class:ALcdLabelLocationsIterates over all stored label locations by calling
applyOnLabelLocationfor every label location.If
applyOnLabelLocationreturnstrue, the iteration continues, if it returnsfalsethe iteration is aborted.- Specified by:
applyOnAllLabelLocationsin 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:ALcdLabelLocationsIterates over all label locations for the labels that were painted by calling
applyOnLabelLocationfor every painted label location. The iteration order is preferably the order in which they were marked as painted.If
applyOnLabelLocationreturnstrue, the iteration continues, if it returnsfalsethe iteration is aborted.- Specified by:
applyOnPaintedLabelLocationsin 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:ALcdLabelLocationsInforms 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 theaEventModeparameter of this method wasILcdFireEventMode#FIRE_LATER.The queue of collected changes is empty when this method returns.
- Specified by:
fireCollectedLabelPaintedChangesin classALcdLabelLocations- Parameters:
aView- TheILcdViewfor 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:ALcdLabelLocationsMarks 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:
setPaintedin 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_LATERorILcdFireEventMode.NO_EVENT- See Also:
-
isPainted
Description copied from class:ALcdLabelLocationsReturns whether or not the specified label is currently painted.- Specified by:
isPaintedin 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:ALcdLabelLocationsClears 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:
clearAllPaintedin 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_LATERorILcdFireEventMode.NO_EVENT
-
getLayer
Description copied from class:ALcdLabelLocationsReturns the layer to which thisALcdLabelLocationsinstance belongs.- Specified by:
getLayerin classALcdLabelLocations- Returns:
- The layer to which this
ALcdLabelLocationsinstance 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 newTLcdLabelLocationby cloning the given default label location.- Specified by:
createLabelLocationin classALcdLabelLocations- Returns:
- A new
TLcdLabelLocation. - See Also:
-