public class ALspLabelStyleCollectorWrapper extends ALspLabelStyleCollector
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 ); }
Constructor and Description |
---|
ALspLabelStyleCollectorWrapper(ALspLabelStyleCollector aDelegate)
Wrapper constructor.
|
Modifier and Type | Method and Description |
---|---|
ALspLabelStyleCollector |
algorithm(ILspLabelingAlgorithm aAlgorithm)
Specifies the labeling algorithm to be used for the label(s) part of this
ALspLabelStyleCollector.submit() call. |
ALspLabelStyleCollector |
algorithm(ILspLabelingAlgorithmProvider aAlgorithmProvider)
Specifies the labeling algorithm provider to be used for the label(s) part of this
ALspLabelStyleCollector.submit() call. |
ALspLabelStyleCollector |
anchorLabel(Object aSublabelID)
Specify the label to anchor a label to.
|
ALspLabelStyleCollector |
anchorLabel(TLspPaintRepresentation aPaintRepresentation,
Object aSublabelID)
Specify the label to anchor a label to.
|
void |
destroy()
Cleanup method for label location collector.
|
ALspLabelStyleCollector |
geometry(ALspStyleTargetProvider aStyleTargetProvider)
Specifies an
ALspStyleTargetProvider that should be used to convert objects
into a collection of objects on which the style can be applied. |
ALspLabelStyleCollector |
geometry(ILcdShape aGeometry)
Specifies the geometry
on which the style should be applied.
|
ILspLabelingAlgorithmProvider |
getAlgorithmProvider()
Returns the labeling algorithm provider that can be used for the labels part
of this
ALspLabelStyleCollector.submit() call. |
Object |
getAnchorLabel()
Returns the sublabel ID of the label to anchor a label to for the current set of labels.
|
TLspPaintRepresentation |
getAnchorLabelPaintRepresentation()
Returns the paint representation of the label to anchor a label to for the current
set of labels.
|
String |
getGroup()
Returns the group ID for the labels part of this
ALspLabelStyleCollector.submit() call. |
Collection<Object> |
getLabels()
Returns the label sublabel IDs that have been specified for the current set of objects.
|
Collection<? extends Object> |
getObjects()
Returns the objects that have already been provided.
|
ILspLabelPriorityProvider |
getPriorityProvider()
Returns the priority provider that can be used to query the priority of the labels part
of this
ALspLabelStyleCollector.submit() call. |
List<ALspStyle> |
getStyles()
Returns the styles that have been specified for the current set of objects.
|
ALspStyleTargetProvider |
getStyleTargetProvider()
Returns the style target provider that has been provided together with the
current set of objects.
|
ALspLabelStyleCollector |
group(String aGroup)
Specifies the declutter group the label(s) should be in.
|
ALspLabelStyleCollector |
hide()
Hides the specified objects.
|
boolean |
isAllLabels()
Returns if the style information is specified for all labels of the
objects . |
ALspLabelStyleCollector |
label(Object aSublabelID)
Specifies an object that identifies a label for an object.
|
ALspLabelStyleCollector |
locations(int aShift,
TLspLabelLocationProvider.Location... aLocations)
Specifies a set of fixed locations to be used for the label(s).
|
ALspLabelStyleCollector |
object(Object aObject)
Specifies a single
Object to be styled. |
ALspLabelStyleCollector |
objects(Collection<? extends Object> aObjects)
Specifies a collection of objects to be styled.
|
ALspLabelStyleCollector |
priority(ILspLabelPriorityProvider aPriorityProvider)
Specifies a priority provider for the label(s) part of this
ALspLabelStyleCollector.submit() call. |
ALspLabelStyleCollector |
priority(int aPriority)
Specifies a fixed priority for the label(s) part of this
ALspLabelStyleCollector.submit() call. |
ALspLabelStyleCollector |
style(ALspStyle aStyle)
Applies the style to the specified labels.
|
ALspLabelStyleCollector |
styles(ALspStyle... aStyles)
Applies the given list of styles to the specified labels.
|
ALspLabelStyleCollector |
styles(List<? extends ALspStyle> aStyles)
Applies the given list of styles to the specified labels.
|
void |
submit()
Submits the currently specified objects and location information.
|
void |
submitImpl()
This method is not called by the
submit() method. |
public ALspLabelStyleCollectorWrapper(ALspLabelStyleCollector aDelegate)
aDelegate
- The collector to which all calls will be delegated.public void destroy()
ALspLabelStyleCollector
ALspLabelStyler
.destroy
in class ALspLabelStyleCollector
public ILspLabelingAlgorithmProvider getAlgorithmProvider()
ALspLabelStyleCollector
ALspLabelStyleCollector.submit()
call.getAlgorithmProvider
in class ALspLabelStyleCollector
null
if none was set.public Object getAnchorLabel()
ALspLabelStyleCollector
getAnchorLabel
in class ALspLabelStyleCollector
null
if the default anchor can be used.public TLspPaintRepresentation getAnchorLabelPaintRepresentation()
ALspLabelStyleCollector
getAnchorLabelPaintRepresentation
in class ALspLabelStyleCollector
null
if the 'current' anchor can be used.public String getGroup()
ALspLabelStyleCollector
ALspLabelStyleCollector.submit()
call.getGroup
in class ALspLabelStyleCollector
null
if none was set.TLspLabelPlacer
public Collection<Object> getLabels()
ALspLabelStyleCollector
Returns null if the information applies to all labels of the given domain objects.
getLabels
in class ALspLabelStyleCollector
public ILspLabelPriorityProvider getPriorityProvider()
ALspLabelStyleCollector
ALspLabelStyleCollector.submit()
call.getPriorityProvider
in class ALspLabelStyleCollector
null
if none was set.public boolean isAllLabels()
ALspLabelStyleCollector
objects
.isAllLabels
in class ALspLabelStyleCollector
public Collection<? extends Object> getObjects()
ALspStyleCollector
ALspStyleCollector.submitImpl()
. This Collection
is reset after
each call to ALspStyleCollector.submit()
.getObjects
in class ALspStyleCollector
public ALspStyleTargetProvider getStyleTargetProvider()
ALspStyleCollector
Returns 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 to ALspStyleCollector.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.
getStyleTargetProvider
in class ALspStyleCollector
public List<ALspStyle> getStyles()
ALspStyleCollector
ALspStyleCollector.submitImpl()
. This List
is reset after
each call to ALspStyleCollector.submit()
.getStyles
in class ALspStyleCollector
public final ALspLabelStyleCollector hide()
ALspStyleCollector.object(Object)
or
ALspStyleCollector.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.
hide
in class ALspLabelStyleCollector
public final ALspLabelStyleCollector object(Object aObject)
Object
to 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 in
ILspStyler.style(Collection, ALspStyleCollector, TLspContext)
.
Specifying other objects after a call to this method will invalidate the
result of this call.
This method forwards the call to the objects(java.util.Collection)
method. Override that method if you want to customize the behavior.
object
in class ALspLabelStyleCollector
aObject
- The object to style.public ALspLabelStyleCollector objects(Collection<? extends Object> aObjects)
ALspStyleCollector
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 in
ILspStyler.style(Collection, ALspStyleCollector, TLspContext)
.
Specifying other objects after a call to this method will invalidate the
result of this call.objects
in class ALspLabelStyleCollector
aObjects
- The objects to style.public final ALspLabelStyleCollector geometry(ILcdShape aGeometry)
aGeometry
argument 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.
geometry
in class ALspLabelStyleCollector
aGeometry
- The geometry to which the styling should be appliedpublic ALspLabelStyleCollector geometry(ALspStyleTargetProvider aStyleTargetProvider)
ALspLabelStyleCollector
ALspStyleTargetProvider
that 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.
The ALspStyleTargetProvider
can be used in a number of cases:
myCollector.objects(Arrays.asList(myObject1,myObject2)).geometry(myObjectToPointConverter).style(myIconStyle).submit()
For labels, this call specifies 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
.
If the style target provider returns multiple geometries for a label, only the first ILcdShape
is used.
geometry
in class ALspLabelStyleCollector
aStyleTargetProvider
- The target provider.public final ALspLabelStyleCollector style(ALspStyle aStyle)
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 example TLspDataObjectLabelTextProviderStyle
.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.TLspLabelPainter
for more information.
This method forwards the call to the styles(java.util.List)
method. Override that method if you want to customize the behavior.
style
in class ALspLabelStyleCollector
aStyle
- The style to apply.public ALspLabelStyleCollector styles(List<? extends ALspStyle> aStyles)
ALspLabelStyleCollector
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 example TLspDataObjectLabelTextProviderStyle
.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.TLspLabelPainter
for more information.styles
in class ALspLabelStyleCollector
aStyles
- The styles to apply.public final ALspLabelStyleCollector styles(ALspStyle... aStyles)
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 example TLspDataObjectLabelTextProviderStyle
.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.TLspLabelPainter
for more information.
This method forwards the call to the styles(java.util.List)
method. Override that method if you want to customize the behavior.
styles
in class ALspLabelStyleCollector
aStyles
- The styles to apply.public final ALspLabelStyleCollector algorithm(ILspLabelingAlgorithm aAlgorithm)
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 ALspLabelStyler
because of different labeling
algorithms being used for different objects, it is possible to use the ALspLabelStyleCollector.algorithm(ILspLabelingAlgorithmProvider)
method instead. That method allows to use 1 instance of ILspLabelingAlgorithmProvider
for 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.
algorithm
in class ALspLabelStyleCollector
aAlgorithm
- The algorithm to be usedpublic ALspLabelStyleCollector algorithm(ILspLabelingAlgorithmProvider aAlgorithmProvider)
ALspLabelStyleCollector
ALspLabelStyleCollector.submit()
call.
By default, an algorithm is used based on the geometry of the domain object.
algorithm
in class ALspLabelStyleCollector
aAlgorithmProvider
- The algorithm provider to be usedpublic 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 ALspLabelStyler
because of different
locations being used for different objects, it is possible to use the ALspLabelStyleCollector.algorithm(ILspLabelingAlgorithmProvider)
method instead. That method allows to use 1 instance of ILspLabelingAlgorithmProvider
for 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.
locations
in class ALspLabelStyleCollector
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.public ALspLabelStyleCollector anchorLabel(TLspPaintRepresentation aPaintRepresentation, Object aSublabelID)
ALspLabelStyleCollector
Specify the label to anchor a label to. The given Object
is 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 also ILspLabelPainter.getAnchorObject
.
If no label with the specified sublabel ID can be found, the label will be anchored to the domain object.
anchorLabel
in class ALspLabelStyleCollector
aPaintRepresentation
- The paint representation of the anchor.aSublabelID
- The anchor label to use.public final ALspLabelStyleCollector anchorLabel(Object aSublabelID)
Specify the label to anchor a label to. The given Object
is the sublabel ID
for an other label of the same layer, paint representation and domain object. See also
ILspLabelPainter.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.
anchorLabel
in class ALspLabelStyleCollector
aSublabelID
- The anchor sublabel to use.public ALspLabelStyleCollector group(String aGroup)
ALspLabelStyleCollector
By default, TLspLabelPlacer.DEFAULT_DECLUTTER_GROUP
is used.
group
in class ALspLabelStyleCollector
aGroup
- The desired declutter groupTLspLabelPlacer
public ALspLabelStyleCollector label(Object aSublabelID)
ALspLabelStyleCollector
Specifies an object that identifies a label for an object. This is necessary for different labels per domain object.
Notes:
"single"
will be used.A typical usage would be to have a fixed set of different sublabel IDs, for example an
enum
, or a series of integers.
label
in class ALspLabelStyleCollector
aSublabelID
- The sublabel IDpublic final ALspLabelStyleCollector priority(int aPriority)
ALspLabelStyleCollector.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.
priority
in class ALspLabelStyleCollector
aPriority
- The desired priority, 0 being highest prioritypublic ALspLabelStyleCollector priority(ILspLabelPriorityProvider aPriorityProvider)
ALspLabelStyleCollector
ALspLabelStyleCollector.submit()
call.priority
in class ALspLabelStyleCollector
aPriorityProvider
- The priority provider that can specify priorities.public void submit()
ALspLabelStyleCollector
ALspLabelStyleCollector.geometry(com.luciad.shape.ILcdShape)
or ALspLabelStyleCollector.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();
myCollector.object(myObject).label(2).geometry(myShape2).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.submit
in class ALspLabelStyleCollector
public void submitImpl()
submit()
method. By default this call is delegated
to the wrapped ALspLabelStyleCollector
.submitImpl
in class ALspLabelStyleCollector
ALspStyleCollector.getObjects()
,
ALspStyleCollector.getStyleTargetProvider()
,
ALspStyleCollector.getStyles()