Class ALspLabelStyleCollectorWrapper
ALspLabelStyleCollector.
By default, wrapping a style collector in this wrapper does not have any
effect at all. Users of this class have to extend it to achieve the desired
behavior.
As an example, this class can be used to filter out all TLspTextStyle
instances before passing the styles on to the delegate. This allows you to
implement a fill toggle action.
The following example shows a styler that uses a wrapper that sets another ALspStyleTargetProvider:
public void locate( Collection<?> aObjects, ALspLabelStyleCollector aStyleCollector, TLspContext aContext ) {
ALspLabelStyleCollectorWrapper myWrapper = new ALspLabelStyleCollectorWrapper( aStyleCollector ) {
@Override
public ALspLabelStyleCollector geometry( ALspStyleTargetProvider aStyleTargetProvider ) {
fDelegate.geometry( fAnotherStyleTargetProvider );
}
};
fDelegateStyler.locate( aObjects, myWrapper, aContext );
}
- Since:
- 2012.0
-
Constructor Summary
ConstructorsConstructorDescriptionWrapper constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal ALspLabelStyleCollectoralgorithm(ILspLabelingAlgorithm aAlgorithm) Specifies the labeling algorithm to be used for the label(s) part of thisALspLabelStyleCollector.submit()call.algorithm(ILspLabelingAlgorithmProvider aAlgorithmProvider) Specifies the labeling algorithm provider to be used for the label(s) part of thisALspLabelStyleCollector.submit()call.anchorLabel(TLspPaintRepresentation aPaintRepresentation, Object aSublabelID) Specify the label to anchor a label to.final ALspLabelStyleCollectoranchorLabel(Object aSublabelID) Specify the label to anchor a label to.voiddestroy()Cleanup method for label location collector.final ALspLabelStyleCollectorSpecifies the geometry on which the style should be applied.geometry(ALspStyleTargetProvider aStyleTargetProvider) Specifies anALspStyleTargetProviderthat should be used to convert objects into a collection of objects on which the style can be applied.Returns the labeling algorithm provider that can be used for the labels part of thisALspLabelStyleCollector.submit()call.Returns the sublabel ID of the label to anchor a label to for the current set of labels.Returns the paint representation of the label to anchor a label to for the current set of labels.getGroup()Returns the group ID for the labels part of thisALspLabelStyleCollector.submit()call.Returns the label sublabel IDs that have been specified for the current set of objects.Collection<? extends Object> Returns the objects that have already been provided.Returns the priority provider that can be used to query the priority of the labels part of thisALspLabelStyleCollector.submit()call.Returns the styles that have been specified for the current set of objects.Returns the style target provider that has been provided together with the current set of objects.Specifies the declutter group the label(s) should be in.final ALspLabelStyleCollectorhide()Hides the specified objects.booleanReturns if the style information is specified for all labels of theobjects.Specifies an object that identifies a label for an object.final ALspLabelStyleCollectorlocations(int aShift, TLspLabelLocationProvider.Location... aLocations) Specifies a set of fixed locations to be used for the label(s).final ALspLabelStyleCollectorSpecifies a singleObjectto be styled.objects(Collection<? extends Object> aObjects) Specifies a collection of objects to be styled.final ALspLabelStyleCollectorpriority(int aPriority) Specifies a fixed priority for the label(s) part of thisALspLabelStyleCollector.submit()call.priority(ILspLabelPriorityProvider aPriorityProvider) Specifies a priority provider for the label(s) part of thisALspLabelStyleCollector.submit()call.final ALspLabelStyleCollectorApplies the style to the specified labels.final ALspLabelStyleCollectorApplies the given list of styles to the specified labels.Applies the given list of styles to the specified labels.voidsubmit()Submits the currently specified objects and location information.voidThis method is not called by thesubmit()method.
-
Constructor Details
-
ALspLabelStyleCollectorWrapper
Wrapper constructor.- Parameters:
aDelegate- The collector to which all calls will be delegated.
-
-
Method Details
-
destroy
public void destroy()Description copied from class:ALspLabelStyleCollectorCleanup method for label location collector. Specific implementations are encouraged to call this method when styling is done. This allows to check whether the collector was used correctly by theALspLabelStyler.- Overrides:
destroyin classALspLabelStyleCollector
-
getAlgorithmProvider
Description copied from class:ALspLabelStyleCollectorReturns the labeling algorithm provider that can be used for the labels part of thisALspLabelStyleCollector.submit()call.- Overrides:
getAlgorithmProviderin classALspLabelStyleCollector- Returns:
- An algorithm provider, or
nullif none was set.
-
getAnchorLabel
Description copied from class:ALspLabelStyleCollectorReturns the sublabel ID of the label to anchor a label to for the current set of labels.- Overrides:
getAnchorLabelin classALspLabelStyleCollector- Returns:
- An anchor object, can be
nullif the default anchor can be used.
-
getAnchorLabelPaintRepresentation
Description copied from class:ALspLabelStyleCollectorReturns the paint representation of the label to anchor a label to for the current set of labels.- Overrides:
getAnchorLabelPaintRepresentationin classALspLabelStyleCollector- Returns:
- An anchor object, can be
nullif the 'current' anchor can be used.
-
getGroup
Description copied from class:ALspLabelStyleCollectorReturns the group ID for the labels part of thisALspLabelStyleCollector.submit()call.- Overrides:
getGroupin classALspLabelStyleCollector- Returns:
- A declutter group ID, or
nullif none was set. - See Also:
-
getLabels
Description copied from class:ALspLabelStyleCollectorReturns the label sublabel IDs that have been specified for the current set of objects.Returns null if the information applies to all labels of the given domain objects.
- Overrides:
getLabelsin classALspLabelStyleCollector- Returns:
- A list of sublabel IDs, can be empty if a default sublabel ID can be used.
-
getPriorityProvider
Description copied from class:ALspLabelStyleCollectorReturns the priority provider that can be used to query the priority of the labels part of thisALspLabelStyleCollector.submit()call.- Overrides:
getPriorityProviderin classALspLabelStyleCollector- Returns:
- A priority provider, or
nullif none was set.
-
isAllLabels
public boolean isAllLabels()Description copied from class:ALspLabelStyleCollectorReturns if the style information is specified for all labels of theobjects.- Overrides:
isAllLabelsin classALspLabelStyleCollector- Returns:
- if the style information is specified for all labels of the objects.
-
getObjects
Description copied from class:ALspStyleCollectorReturns the objects that have already been provided. Can be called from withinALspStyleCollector.submitImpl(). ThisCollectionis reset after each call toALspStyleCollector.submit().- Overrides:
getObjectsin classALspStyleCollector- Returns:
- The collection of objects for which style has been specified.
-
getStyleTargetProvider
Description copied from class:ALspStyleCollectorReturns the style target provider that has been provided together with the current set of objects. Can be called from within
ALspStyleCollector.submitImpl(). This will be cleared after every call toALspStyleCollector.submit().It is possible that this method returns
null. In that case the domain object itself is used as the style target.Null by default.
- Overrides:
getStyleTargetProviderin classALspStyleCollector- Returns:
- The current style target provider or null.
-
getStyles
Description copied from class:ALspStyleCollectorReturns the styles that have been specified for the current set of objects. Can be called from withinALspStyleCollector.submitImpl(). ThisListis reset after each call toALspStyleCollector.submit().- Overrides:
getStylesin classALspStyleCollector- Returns:
- A list of styles, can be empty if the given objects should not be visualized.
-
hide
Hides the specified objects. A call to this method has to be preceded by a call that specifies objects such asALspStyleCollector.object(Object)orALspStyleCollector.objects(Collection). Example usage:
myCollector.object(myObject).hide().submit()This method forwards the call to the
styles(java.util.List)method with an empty style list. Override that method if you want to customize the behavior.- Overrides:
hidein classALspLabelStyleCollector- Returns:
- This style collector
-
object
Specifies a singleObjectto be styled. Preferably, this method should only be used if the given object uses a unique style, that is different from the style of all other objects. Example usage:
myCollector.object(myILcdPoint).style(myIconStyle).submit()The object must be an object that is part of the collection that has been passed as an argument inILspStyler.style(Collection, ALspStyleCollector, TLspContext). Specifying other objects after a call to this method will invalidate the result of this call.When you don't call the
geometry(ILcdShape)orgeometry(ALspStyleTargetProvider)method, this domain object is also used to retrieve the shape to which the labels is anchored. The domain object must then be anILcdShapeor it must have a shape.This method forwards the call to the
objects(java.util.Collection)method. Override that method if you want to customize the behavior.- Overrides:
objectin classALspLabelStyleCollector- Parameters:
aObject- The object to style.- Returns:
- this style collector
-
objects
Description copied from class:ALspLabelStyleCollectorSpecifies a collection of objects to be styled. This method can be used if multiple objects share the same style. Example usage:
myCollector.objects(Arrays.asList(myILcdPoint1,myILcdPoint2)).style(myIconStyle).submit()The objects must all be contained in the collection that has been passed as an argument inILspStyler.style(Collection, ALspStyleCollector, TLspContext). Specifying other objects after a call to this method will invalidate the result of this call.When you don't call the
geometry(ILcdShape)orgeometry(ALspStyleTargetProvider)method, these domain objects are also used to retrieve the shape to which the labels are anchored. The domain objects must then be anILcdShapeor they must have a shape.- Overrides:
objectsin classALspLabelStyleCollector- Parameters:
aObjects- The objects to style.- Returns:
- this style collector
-
geometry
Specifies the geometry on which the style should be applied. Preferably, this method should only be used if the domain object uses a unique style, that is different from the style of all other objects. TheaGeometryargument allows you to specify a particular geometry to which the styling should be applied, that is different from the object itself. Example usage:
myCollector.object(myObject).geometry(myObjectAsILcdPoint).style(myIconStyle).submit()For labels, this call specifies a geometry used to calculate the label's position. Use this if the domain object itself is not a shape, or if you need different geometry.
If not set, the domain object itself is used.
Exactly how to geometry is used to determine the label location depends on the algorithm itself.
See also
ILspLabelPainter.getAnchorObject.This method forwards the call to the
geometry(ALspStyleTargetProvider)method. Override that method if you want to customize the behavior.- Overrides:
geometryin classALspLabelStyleCollector- Parameters:
aGeometry- The geometry to which the styling should be applied- Returns:
- this style collector
-
geometry
Description copied from class:ALspLabelStyleCollectorSpecifies anALspStyleTargetProviderthat should be used to convert objects into a collection of objects on which the style can be applied. This method can be used if multiple objects share the same style. TheALspStyleTargetProvidercan be used in a number of cases:- Styling of objects that do not implement a known interface
- Styling of particular parts of an object, such as a specific shape in an ILcdShapeList, or a point of a point list.
- Conversion of the geometry of the object into a geometry that is more appropriate to achieve the desired visualization.
myCollector.objects(Arrays.asList(myObject1,myObject2)).geometry(myObjectToPointConverter).style(myIconStyle).submit()For labels, this call specifies the geometry used to calculate the label's position. Use this if the domain object itself is not a shape, or if you need different geometry. The object returned by the style target provider must be an
ILcdShapeor it must have a shape.If not set, the domain object itself is used. In the latter case, the domain object must be an
ILcdShapeor it must have a shape.Exactly how to geometry is used to determine the label location depends on the algorithm itself.
See also
ILspLabelPainter.getAnchorObject.If the style target provider returns multiple geometries for a label, only the first
ILcdShapeis used.- Overrides:
geometryin classALspLabelStyleCollector- Parameters:
aStyleTargetProvider- The target provider.- Returns:
- this style collector
-
style
Applies the style to the specified labels.
Example usage:
myCollector.object( myObject ).label( myLabelID ).style( myTextStyle ).submit()Specifying other styles after a call to this method will invalidate the result of this call.
Styles that are supported for labels are:
TLspTextStyle: to get text with a specific font, font color, size, halo etc.ALspLabelTextProviderStyle: to specify which text to use (default is toString()). See for exampleTLspDataObjectLabelTextProviderStyle.TLspIconStyle: to use custom icons as a label.TLspLabelBoxStyle: to specify fill color or frames.TLspPinLineStyle: to draw pins for the labels.TLspLabelOpacityStyle: to specify a global opacity for the label, or modulation color.
TLspLabelPainterfor more information.This method forwards the call to the
styles(java.util.List)method. Override that method if you want to customize the behavior.- Overrides:
stylein classALspLabelStyleCollector- Parameters:
aStyle- The style to apply.- Returns:
- This style collector.
-
styles
Description copied from class:ALspLabelStyleCollectorApplies the given list of styles to the specified labels.
Example usage:
myCollector.object( myObject ).label( myLabelID ).styles( myTextStyle, myTextProviderStyle ).submit()Specifying other styles after a call to this method will invalidate the result of this call.
Styles that are supported for labels are:
TLspTextStyle: to get text with a specific font, font color, size, halo etc.ALspLabelTextProviderStyle: to specify which text to use (default is toString()). See for exampleTLspDataObjectLabelTextProviderStyle.TLspIconStyle: to use custom icons as a label.TLspLabelBoxStyle: to specify fill color or frames.TLspPinLineStyle: to draw pins for the labels.TLspLabelOpacityStyle: to specify a global opacity for the label, or modulation color.
TLspLabelPainterfor more information.- Overrides:
stylesin classALspLabelStyleCollector- Parameters:
aStyles- The styles to apply.- Returns:
- This style collector.
-
styles
Applies the given list of styles to the specified labels.
Example usage:
myCollector.object( myObject ).label( myLabelID ).styles( myTextStyle, myTextProviderStyle ).submit()Specifying other styles after a call to this method will invalidate the result of this call.
Styles that are supported for labels are:
TLspTextStyle: to get text with a specific font, font color, size, halo etc.ALspLabelTextProviderStyle: to specify which text to use (default is toString()). See for exampleTLspDataObjectLabelTextProviderStyle.TLspIconStyle: to use custom icons as a label.TLspLabelBoxStyle: to specify fill color or frames.TLspPinLineStyle: to draw pins for the labels.TLspLabelOpacityStyle: to specify a global opacity for the label, or modulation color.
TLspLabelPainterfor more information.This method forwards the call to the
styles(java.util.List)method. Override that method if you want to customize the behavior.- Overrides:
stylesin classALspLabelStyleCollector- Parameters:
aStyles- The styles to apply.- Returns:
- This style collector.
-
algorithm
Specifies the labeling algorithm to be used for the label(s) part of this
ALspLabelStyleCollector.submit()call.By default, an algorithm is used based on the geometry of the domain object.
To avoid having to iterate over all objects in
ALspLabelStylerbecause of different labeling algorithms being used for different objects, it is possible to use theALspLabelStyleCollector.algorithm(ILspLabelingAlgorithmProvider)method instead. That method allows to use 1 instance ofILspLabelingAlgorithmProviderfor all objects. This algorithm provider can then calculate which algorithm to use for an object.This method forwards the call to the
algorithm(com.luciad.view.lightspeed.label.algorithm.ILspLabelingAlgorithmProvider)method. Override that method if you want to customize the behavior.- Overrides:
algorithmin classALspLabelStyleCollector- Parameters:
aAlgorithm- The algorithm to be used- Returns:
- this collector
-
algorithm
Description copied from class:ALspLabelStyleCollectorSpecifies the labeling algorithm provider to be used for the label(s) part of thisALspLabelStyleCollector.submit()call.By default, an algorithm is used based on the geometry of the domain object.
- Overrides:
algorithmin classALspLabelStyleCollector- Parameters:
aAlgorithmProvider- The algorithm provider to be used- Returns:
- this collector
-
locations
public final ALspLabelStyleCollector locations(int aShift, TLspLabelLocationProvider.Location... aLocations) Specifies a set of fixed locations to be used for the label(s).
This method is a convenience method. It is the same as calling
algorithm(new TLspLabelingAlgorithm(new TLspLabelLocationProvider(aShift, aLocations)).To avoid having to iterate over all objects in
ALspLabelStylerbecause of different locations being used for different objects, it is possible to use theALspLabelStyleCollector.algorithm(ILspLabelingAlgorithmProvider)method instead. That method allows to use 1 instance ofILspLabelingAlgorithmProviderfor all objects. This algorithm provider can then calculate which algorithm to use for an object.This method forwards the call to the
algorithm(com.luciad.view.lightspeed.label.algorithm.ILspLabelingAlgorithmProvider)method. Override that method if you want to customize the behavior.- Overrides:
locationsin classALspLabelStyleCollector- Parameters:
aShift- the amount of pixels the labels must be removed from the object anchor point.aLocations- a list of possible locations to place the labels.- Returns:
- this builder.
-
anchorLabel
public ALspLabelStyleCollector anchorLabel(TLspPaintRepresentation aPaintRepresentation, Object aSublabelID) Description copied from class:ALspLabelStyleCollectorSpecify the label to anchor a label to. The given
Objectis the sublabel ID for an other label of the same layer and domain object, but possibly a different paint representation. This makes it possible to make labels depend on labels from other painters. See alsoILspLabelPainter.getAnchorObject.If no label with the specified sublabel ID can be found, the label will be anchored to the domain object.
- Overrides:
anchorLabelin classALspLabelStyleCollector- Parameters:
aPaintRepresentation- The paint representation of the anchor.aSublabelID- The anchor label to use.- Returns:
- this collector
-
anchorLabel
Specify the label to anchor a label to. The given
Objectis the sublabel ID for an other label of the same layer, paint representation and domain object. See alsoILspLabelPainter.getAnchorObject.If no label with the specified sublabel ID can be found, the label will be anchored to the domain object.
This method forwards the call to the
anchorLabel(com.luciad.view.lightspeed.layer.TLspPaintRepresentation, Object)method. Override that method if you want to customize the behavior.- Overrides:
anchorLabelin classALspLabelStyleCollector- Parameters:
aSublabelID- The anchor sublabel to use.- Returns:
- this collector
-
group
Description copied from class:ALspLabelStyleCollectorSpecifies the declutter group the label(s) should be in.By default,
TLspLabelPlacer.DEFAULT_DECLUTTER_GROUPis used.- Overrides:
groupin classALspLabelStyleCollector- Parameters:
aGroup- The desired declutter group- Returns:
- this collector
- See Also:
-
label
Description copied from class:ALspLabelStyleCollectorSpecifies an object that identifies a label for an object. This is necessary for different labels per domain object.
Notes:
- This call is optional if you need just one label: a default sublabel ID of
"single"will be used. - The sublabel ID must be equal for the same label on subsequent styling calls.
- The sublabel ID must not be equal for different labels on the same domain object.
- The sublabel ID can be shared between different domain objects.
A typical usage would be to have a fixed set of different sublabel IDs, for example an
enum, or a series of integers.- Overrides:
labelin classALspLabelStyleCollector- Parameters:
aSublabelID- The sublabel ID- Returns:
- this style collector
- This call is optional if you need just one label: a default sublabel ID of
-
priority
Specifies a fixed priority for the label(s) part of thisALspLabelStyleCollector.submit()call.By default, labels have priority
Integer.MAX_VALUE, low priority.This method forwards the call to the
priority(com.luciad.view.lightspeed.label.ILspLabelPriorityProvider)method. Override that method if you want to customize the behavior.- Overrides:
priorityin classALspLabelStyleCollector- Parameters:
aPriority- The desired priority, 0 being highest priority- Returns:
- this collector
-
priority
Description copied from class:ALspLabelStyleCollectorSpecifies a priority provider for the label(s) part of thisALspLabelStyleCollector.submit()call.- Overrides:
priorityin classALspLabelStyleCollector- Parameters:
aPriorityProvider- The priority provider that can specify priorities.- Returns:
- this collector
-
submit
public void submit()Description copied from class:ALspLabelStyleCollectorSubmits the currently specified objects and location information. A call to this method has to be preceded by a call that specifies information such asALspLabelStyleCollector.geometry(com.luciad.shape.ILcdShape)orALspLabelStyleCollector.algorithm(com.luciad.view.lightspeed.label.algorithm.ILspLabelingAlgorithm). This mandatory method commits and links the location information provided to the domain object(s) and label(s). Example usage:
myCollector.object(myObject).label(1).geometry(myShape1).submit();Not calling this method will result in no information being specified at all. Calling any other method after already having provided objects and/or information will result in invalidating those previous calls. Also note that subsequent calls for the same labels override the information previously specified.
myCollector.object(myObject).label(2).geometry(myShape2).submit();- Overrides:
submitin classALspLabelStyleCollector
-
submitImpl
public void submitImpl()This method is not called by thesubmit()method. By default this call is delegated to the wrappedALspLabelStyleCollector.- Specified by:
submitImplin classALspLabelStyleCollector- See Also:
-