Class TLcdGXYCompositeViewLabelPlacer
- All Implemented Interfaces:
ILcdCloneable
,ILcdGXYViewLabelPlacer
,Cloneable
A consequence of this is that there can be overlap between labels from layers of different labeling groups.
Because all delegate label placers place their labels independently, it is possible to avoid
label placement computations when only layers of one group are invalidated. This class does
this using an ILcdGXYViewLabelPlacer
. The delegate label placers are only called
when at least one of their layers was invalidated. Otherwise, the delegate label placers is not
called, and the previous labeling results are reused during painting.
The advantage of using this class is that groups of layers can be labeled completely independently. This makes it possible for example to place labels for a group of fast layers and for a group of slow layers by two different label placers. In that case, the labeling can be executed on two different threads, so they don't block each other. Because of this, the labels of the fast layers will always be up to date. An other advantage is that this class makes it possible to mix synchronous and asynchronous label placing for different groups of layers.
Note: This class will only work correctly when using one of the following ILcdGXYView implementations :
TLcdGXYViewBufferedImage
TLcdGXYViewJPanel
TLcdGXYViewJPanelLightWeight
- Since:
- 10.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.gxy.labeling.ILcdGXYViewLabelPlacer
ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Adds the given status listener to this view label placer.void
This method clears allILcdGXYViewLabelPlacer
s which are currently used.clone()
MakesObject.clone()
public.protected ILcdGXYViewLabelPlacer
createViewLabelPlacer
(String aGroupID, ILcdGXYView aGXYView) Creates a new view label placer for the given group ID in the given view.protected String
getGroupID
(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView) This method returns a group ID for the given layer.boolean
Checks if any asynchronous label placers are 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.
-
Constructor Details
-
TLcdGXYCompositeViewLabelPlacer
public TLcdGXYCompositeViewLabelPlacer()
-
-
Method Details
-
isBusyPlacing
public boolean isBusyPlacing()Checks if any asynchronous label placers are busy label placing or if label placing is scheduled.- Returns:
true
if the label placer is still label placing, andfalse
otherwise.- Since:
- 2022.0
-
getGroupID
This method returns a group ID for the given layer. See the class doc for more information about group IDs. Override this method to provide a custom implementation.By default this method returns the same group ID for every layers.
- Parameters:
aGXYLayer
- a given gxy layer.aGXYView
- the gxy view which contains the given layer- Returns:
- the group ID for the given layer. Should never be
null
.
-
createViewLabelPlacer
Creates a new view label placer for the given group ID in the given view. If the returned label placer isnull
, layers associated with the given group ID never have their labels placed.Override this method to return a custom view label placer.
By default this method creates a
TLcdGXYLabelPlacer
which uses aTLcdGXYLabelPainterLocationLabelingAlgorithm
.- Parameters:
aGroupID
- a group ID.aGXYView
- a gxy view.- Returns:
- a
ILcdGXYViewLabelPlacer
for the given group ID. Can benull
.
-
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:
-
clearViewLabelPlacerCache
public void clearViewLabelPlacerCache()This method clears allILcdGXYViewLabelPlacer
s which are currently used. After this method is called, this composite view label placer will create otherILcdGXYViewLabelPlacer
s again when labels are placed, seecreateViewLabelPlacer
. -
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:
-
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.
-