Class TLcdGXYAsynchronousLabelPlacer
- All Implemented Interfaces:
ILcdCloneable
,ILcdGXYViewLabelPlacer
,Cloneable
Asynchronous label placing can be used in two cases :
- with asynchronous painting disabled : label placing is executed partly on the EventDispatch thread, and partly on a background thread. The consequence is that in this case asynchronous label placing still shows blocking behavior when it uses the EventDispatch thread.
- with asynchronous painting enabled : label placing is executed partly on the PaintQueue thread(s) and partly on a background thread. Because the EventDispatch thread is never used, label placing is non-blocking.
When using asynchronous labeling, thread-safety of the labeling algorithms should be kept in mind.
Problems can occur if the ILcdGXYLabelingAlgorithm.collectLabelInfo
implementation is not thread safe. When this is the case, an instance of the (non thread-safe)
labeling algorithm should not be used on multiple threads. This is especially important when
asynchronous painting is used, because in that case, the collecting method of the labeling
algorithm can be executed on multiple PaintQueue threads.
When the collecting method of a labeling algorithm is thread-safe, they can be used on multiple threads without a problem. One should also make sure that when the collecting of labeling information is performed on multiple threads, the set priority provider is also thread-safe.
Note: When using this label placer in combination with asynchronous painting, it passes the wrapped layer to the labeling algorithm, and not the asynchronous layer wrapper.
- Since:
- 10.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.gxy.labeling.ILcdGXYViewLabelPlacer
ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback
-
Constructor Summary
ConstructorDescriptionCreate a new asynchronous label placer with a labeling algorithm that delegates to the appropriate layer'slabeling algorithm
.TLcdGXYAsynchronousLabelPlacer
(ILcdGXYLabelingAlgorithm aLabelingAlgorithm) Create a new asynchronous label placer using the given labeling algorithm. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Adds the given status listener to this view label placer.clone()
MakesObject.clone()
public.Returns the label conflict checker used when placing labels.Returns the labeling algorithm used.Returns the usedILcdGXYLabelObstacleProvider
.boolean
Checks if the asynchronous label placer is busy label placing or if label placing is scheduled.void
placeLabels
(Graphics aGraphics, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) The implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayer
s of the givenILcdGXYView
.void
placeLabels
(Graphics aGraphics, List<ILcdGXYLayer> aGXYLayers, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) The implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayer
s from the givenList
.void
removeStatusListener
(ILcdStatusListener aListener) Removes the given status listener from this view label placer.void
setLabelConflictChecker
(ILcdLabelConflictChecker aLabelConflictChecker) Sets the label conflict checker to be used when placing labels.void
setLabelObstacleProvider
(ILcdGXYLabelObstacleProvider aLabelObstacleProvider) Sets the used label obstacle provider.
-
Constructor Details
-
TLcdGXYAsynchronousLabelPlacer
public TLcdGXYAsynchronousLabelPlacer()Create a new asynchronous label placer with a labeling algorithm that delegates to the appropriate layer'slabeling algorithm
.- Since:
- 2020.0
-
TLcdGXYAsynchronousLabelPlacer
Create a new asynchronous label placer using the given labeling algorithm.Warning: when calling this constructor you are overriding the the layer's own label algorithms.
- Parameters:
aLabelingAlgorithm
- a labeling algorithm.
-
-
Method Details
-
getLabelingAlgorithm
Returns the labeling algorithm used.- Returns:
- the labeling algorithm.
-
getLabelConflictChecker
Returns the label conflict checker used when placing labels.- Returns:
- the label conflict checker used when placing labels.
- See Also:
-
setLabelConflictChecker
Sets the label conflict checker to be used when placing labels.- Parameters:
aLabelConflictChecker
- the label conflict checker to be used when placing labels.- See Also:
-
getLabelObstacleProvider
Returns the usedILcdGXYLabelObstacleProvider
.- Returns:
- the used
ILcdGXYLabelObstacleProvider
, ornull
if no label obstacle provider is used. - See Also:
-
setLabelObstacleProvider
Sets the used label obstacle provider. This obstacle provider is used to provide the labeling algorithm with obstacles: places where preferably no labels are placed.The default value is
null
.- Parameters:
aLabelObstacleProvider
- a label obstacle provider.- See Also:
-
isBusyPlacing
public boolean isBusyPlacing()Checks if the asynchronous label placer is busy label placing or if label placing is scheduled.- Returns:
true
if the label placer is still label placing, andfalse
otherwise.
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.java.lang.Object
, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }
- Specified by:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classObject
- See Also:
-
addStatusListener
Description copied from interface:ILcdGXYViewLabelPlacer
Adds the given status listener to this view label placer. Whenever an event occurs concerning the labeling process, this listener is notified.- Specified by:
addStatusListener
in interfaceILcdGXYViewLabelPlacer
- Parameters:
aListener
- a labeling listener.
-
removeStatusListener
Description copied from interface:ILcdGXYViewLabelPlacer
Removes the given status listener from this view label placer. After calling this method, the given listener will not be notified anymore.- Specified by:
removeStatusListener
in interfaceILcdGXYViewLabelPlacer
- Parameters:
aListener
- a labeling listener.
-
placeLabels
public void placeLabels(Graphics aGraphics, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) Description copied from interface:ILcdGXYViewLabelPlacer
The implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayer
s of the givenILcdGXYView
. Here one can implement or use various smart algorithms to check whether or not to place a label at a certain location.Layers for which labels are placed should be
ILcdGXYEditableLabelsLayer
s. This method should then inform theALcdLabelLocations
associated with that layer which labels were placed, and where they were placed.This method should only be called once every time the view is invalidated.
- Specified by:
placeLabels
in interfaceILcdGXYViewLabelPlacer
- Parameters:
aGraphics
- The currentGraphics
instance.aGXYView
- The view for which to place the labels.aCallback
- Will be invoked when labels are updated, and when the label placing has ended.- See Also:
-
placeLabels
public void placeLabels(Graphics aGraphics, List<ILcdGXYLayer> aGXYLayers, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) Description copied from interface:ILcdGXYViewLabelPlacer
The implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayer
s from the givenList
. Here one can implement or use various smart algorithms to check whether or not to place a label at a certain location.Layers for which labels are placed should be
ILcdGXYEditableLabelsLayer
s. This method should then inform theALcdLabelLocations
associated with that layer which labels were placed, and where they were placed.This method should only be called once every time the view is invalidated.
- Specified by:
placeLabels
in interfaceILcdGXYViewLabelPlacer
- Parameters:
aGraphics
- The currentGraphics
instance.aGXYLayers
- Only the labels for the layers in thisList
will be placed.aGXYView
- The view for which to place the labels.aCallback
- Will be invoked when labels are updated, and when the label placing has ended.- See Also:
-