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 :
TLcdGXYViewBufferedImageTLcdGXYViewJPanelTLcdGXYViewJPanelLightWeight
- Since:
- 10.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.gxy.labeling.ILcdGXYViewLabelPlacer
ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(ILcdStatusListener aListener) Adds the given status listener to this view label placer.voidThis method clears allILcdGXYViewLabelPlacers which are currently used.clone()MakesObject.clone()public.protected ILcdGXYViewLabelPlacercreateViewLabelPlacer(String aGroupID, ILcdGXYView aGXYView) Creates a new view label placer for the given group ID in the given view.protected StringgetGroupID(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView) This method returns a group ID for the given layer.booleanChecks if any asynchronous label placers are busy label placing or if label placing is scheduled.voidplaceLabels(Graphics aGraphics, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) The implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayers of the givenILcdGXYView.voidplaceLabels(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 variousILcdGXYLayers from the givenList.voidremoveStatusListener(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:
trueif the label placer is still label placing, andfalseotherwise.- 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
TLcdGXYLabelPlacerwhich uses aTLcdGXYLabelPainterLocationLabelingAlgorithm.- Parameters:
aGroupID- a group ID.aGXYView- a gxy view.- Returns:
- a
ILcdGXYViewLabelPlacerfor the given group ID. Can benull.
-
clone
Description copied from interface:ILcdCloneableMakes
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:
clonein interfaceILcdCloneable- Overrides:
clonein classObject- See Also:
-
clearViewLabelPlacerCache
public void clearViewLabelPlacerCache()This method clears allILcdGXYViewLabelPlacers which are currently used. After this method is called, this composite view label placer will create otherILcdGXYViewLabelPlacers again when labels are placed, seecreateViewLabelPlacer. -
placeLabels
public void placeLabels(Graphics aGraphics, ILcdGXYView aGXYView, ILcdGXYViewLabelPlacer.ViewLabelPlacerCallback aCallback) Description copied from interface:ILcdGXYViewLabelPlacerThe implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayers 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
ILcdGXYEditableLabelsLayers. This method should then inform theALcdLabelLocationsassociated 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:
placeLabelsin interfaceILcdGXYViewLabelPlacer- Parameters:
aGraphics- The currentGraphicsinstance.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:ILcdGXYViewLabelPlacerThe implementation of this method shall define how to place the labels of all objects in the variousILcdGXYLayers 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
ILcdGXYEditableLabelsLayers. This method should then inform theALcdLabelLocationsassociated 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:
placeLabelsin interfaceILcdGXYViewLabelPlacer- Parameters:
aGraphics- The currentGraphicsinstance.aGXYLayers- Only the labels for the layers in thisListwill 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:ILcdGXYViewLabelPlacerAdds the given status listener to this view label placer. Whenever an event occurs concerning the labeling process, this listener is notified.- Specified by:
addStatusListenerin interfaceILcdGXYViewLabelPlacer- Parameters:
aListener- a labeling listener.
-
removeStatusListener
Description copied from interface:ILcdGXYViewLabelPlacerRemoves the given status listener from this view label placer. After calling this method, the given listener will not be notified anymore.- Specified by:
removeStatusListenerin interfaceILcdGXYViewLabelPlacer- Parameters:
aListener- a labeling listener.
-