public class TLcdGXYAsynchronousLabelPlacer extends Object implements ILcdGXYViewLabelPlacer
Asynchronous label placing can be used in two cases :
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.
ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback
Constructor and Description |
---|
TLcdGXYAsynchronousLabelPlacer()
Create a new asynchronous label placer with a labeling algorithm that delegates to the appropriate layer's
labeling algorithm . |
TLcdGXYAsynchronousLabelPlacer(ILcdGXYLabelingAlgorithm aLabelingAlgorithm)
Create a new asynchronous label placer using the given labeling algorithm.
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Adds the given status listener to this view label placer.
|
Object |
clone()
Makes
Object.clone() public. |
ILcdLabelConflictChecker |
getLabelConflictChecker()
Returns the label conflict checker used when placing labels.
|
ILcdGXYLabelingAlgorithm |
getLabelingAlgorithm()
Returns the labeling algorithm used.
|
ILcdGXYLabelObstacleProvider |
getLabelObstacleProvider()
Returns the used
ILcdGXYLabelObstacleProvider . |
boolean |
isBusyPlacing()
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 various
ILcdGXYLayer s of the given ILcdGXYView . |
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 various
ILcdGXYLayer s from the given List . |
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.
|
public TLcdGXYAsynchronousLabelPlacer()
labeling algorithm
.public TLcdGXYAsynchronousLabelPlacer(ILcdGXYLabelingAlgorithm aLabelingAlgorithm)
Warning: when calling this constructor you are overriding the the layer's own label algorithms.
aLabelingAlgorithm
- a labeling algorithm.public ILcdGXYLabelingAlgorithm getLabelingAlgorithm()
public ILcdLabelConflictChecker getLabelConflictChecker()
setLabelConflictChecker
public void setLabelConflictChecker(ILcdLabelConflictChecker aLabelConflictChecker)
aLabelConflictChecker
- the label conflict checker to be used when placing labels.getLabelConflictChecker()
public ILcdGXYLabelObstacleProvider getLabelObstacleProvider()
ILcdGXYLabelObstacleProvider
.ILcdGXYLabelObstacleProvider
, or null
if no label
obstacle provider is used.setLabelObstacleProvider(com.luciad.view.gxy.ILcdGXYLabelObstacleProvider)
public void setLabelObstacleProvider(ILcdGXYLabelObstacleProvider aLabelObstacleProvider)
The default value is null
.
aLabelObstacleProvider
- a label obstacle provider.getLabelObstacleProvider()
public boolean isBusyPlacing()
true
if the label placer is still label placing, and false
otherwise.public Object clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()
public void addStatusListener(ILcdStatusListener aListener)
ILcdGXYViewLabelPlacer
addStatusListener
in interface ILcdGXYViewLabelPlacer
aListener
- a labeling listener.public void removeStatusListener(ILcdStatusListener aListener)
ILcdGXYViewLabelPlacer
removeStatusListener
in interface ILcdGXYViewLabelPlacer
aListener
- a labeling listener.public void placeLabels(Graphics aGraphics, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback)
ILcdGXYViewLabelPlacer
ILcdGXYLayer
s of the given ILcdGXYView
. 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 the ALcdLabelLocations
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.
placeLabels
in interface ILcdGXYViewLabelPlacer
aGraphics
- The current Graphics
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.ILcdGXYEditableLabelsLayer
,
ALcdLabelLocations.putLabelLocation(java.lang.Object, int, int, com.luciad.view.ILcdView, com.luciad.view.TLcdLabelLocation, int)
,
ALcdLabelLocations.setPainted(java.lang.Object, int, int, com.luciad.view.ILcdView, boolean, int)
public void placeLabels(Graphics aGraphics, List<ILcdGXYLayer> aGXYLayers, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback)
ILcdGXYViewLabelPlacer
ILcdGXYLayer
s from the given List
. 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 the ALcdLabelLocations
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.
placeLabels
in interface ILcdGXYViewLabelPlacer
aGraphics
- The current Graphics
instance.aGXYLayers
- Only the labels for the layers in this List
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.ILcdGXYEditableLabelsLayer
,
ALcdLabelLocations.putLabelLocation(java.lang.Object, int, int, com.luciad.view.ILcdView, com.luciad.view.TLcdLabelLocation, int)
,
ALcdLabelLocations.setPainted(java.lang.Object, int, int, com.luciad.view.ILcdView, boolean, int)