public class ALspStyleCollectorWrapper extends ALspStyleCollector
ALspStyleCollector
.
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 TLspFillStyle
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 changes the opacity of the icon styles:
public void style( Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext ) { ALspStyleCollectorWrapper myWrapper = new ALspStyleCollectorWrapper(aStyleCollector) { @Override public ALspStyleCollector styles(List extends ALspStyle> aStyles) { ListopacityStyles = new ArrayList (); for (ALspStyle style : aStyles) { if (style instanceof TLspIconStyle) { style = ((TLspIconStyle) style).asBuilder().opacity(.2f).build(); } opacityStyles.add(style); } return super.styles(opacityStyles); } }; fDelegateStyler.style( aObjects, myWrapper, aContext ); }
Constructor and Description |
---|
ALspStyleCollectorWrapper(ALspStyleCollector aDelegate)
Wrapper constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Cleanup method for style collector.
|
ALspStyleCollector |
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. |
ALspStyleCollector |
geometry(ILcdShape aGeometry)
Specifies the geometry
on which the style should be applied.
|
Collection<? extends Object> |
getObjects()
Returns the objects that have already been provided.
|
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.
|
ALspStyleCollector |
hide()
Hides the specified objects.
|
ALspStyleCollector |
object(Object aObject)
Specifies a single
Object to be styled. |
ALspStyleCollector |
objects(Collection<? extends Object> aObjects)
Specifies a collection of objects to be styled.
|
ALspStyleCollector |
style(ALspStyle aStyle)
Applies the given style to the specified objects.
|
ALspStyleCollector |
styles(ALspStyle... aStyles)
Applies the given list of styles to the specified objects.
|
ALspStyleCollector |
styles(List<? extends ALspStyle> aStyles)
Applies the given list of styles to the specified objects.
|
void |
submit()
Submits the currently specified objects and styles.
|
void |
submitImpl()
This method is not called by the
submit() method. |
public ALspStyleCollectorWrapper(ALspStyleCollector aDelegate)
aDelegate
- The collector to which all calls will be delegated.public void destroy()
ALspStyleCollector
ILspStyler
.destroy
in class ALspStyleCollector
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 ALspStyleCollector 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 ALspStyleCollector
public final ALspStyleCollector 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 ALspStyleCollector
aObject
- The object to style.public ALspStyleCollector 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 ALspStyleCollector
aObjects
- The objects to style.public final ALspStyleCollector 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()
This method forwards the call to the geometry(ALspStyleTargetProvider)
method. Override that method if you want to customize the behavior.
geometry
in class ALspStyleCollector
aGeometry
- The geometry to which the styling should be appliedpublic ALspStyleCollector geometry(ALspStyleTargetProvider aStyleTargetProvider)
ALspStyleCollector
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()
geometry
in class ALspStyleCollector
aStyleTargetProvider
- The target provider.public final ALspStyleCollector style(ALspStyle aStyle)
ALspStyleCollector.object(Object)
or ALspStyleCollector.objects(Collection)
.
Example usage:myCollector.object(myILcdPoint).style(myIconStyle).submit()
Specifying other styles after a call to this method will invalidate the
result of this call.
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 ALspStyleCollector
aStyle
- The style to apply.public ALspStyleCollector styles(List<? extends ALspStyle> aStyles)
ALspStyleCollector
ALspStyleCollector.object(Object)
or ALspStyleCollector.objects(Collection)
.
Example usage:myCollector.object(myILcdPoint).styles(Arrays.asList(myIconStyle,myVerticalLineStyle)).submit()
Specifying other styles after a call to this method will invalidate the
result of this call.styles
in class ALspStyleCollector
aStyles
- The styles to apply. This list should not be modified after using
it as an argument in this method.public final ALspStyleCollector styles(ALspStyle... aStyles)
ALspStyleCollector.object(Object)
or ALspStyleCollector.objects(Collection)
.
Example usage:myCollector.object(myILcdPoint).styles(myIconStyle,myVerticalLineStyle).submit()
Specifying other styles after a call to this method will invalidate the
result of this call.
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 ALspStyleCollector
aStyles
- The style to apply.public void submit()
ALspStyleCollector
ALspStyleCollector.style(ALspStyle)
or ALspStyleCollector.hide()
. This mandatory method submits
a part of the styling before specifying new objects and styles.
Example usage:myCollector.object(myILcdPoint1).style(myIconStyle1).submit();
myCollector.object(myILcdPoint2).style(myIconStyle2).submit();
When this method is called multiple times for the same objects, all specified styles from the different calls
will be applied.
Example to apply a line style to all objects and an additional fill style to one specific object:myCollector.objects(myObjects).style(myLineStyle).submit();
myCollector.object(myFirstObject).style(myFillStyle).submit();
Not calling this method will result in no styles being specified at all.
Calling any other method after already having provided objects and/or
styles will result in invalidating those previous calls.submit
in class ALspStyleCollector
public void submitImpl()
submit()
method. By default this call is delegated
to the wrapped ALspStyleCollector
.submitImpl
in class ALspStyleCollector
ALspStyleCollector.getObjects()
,
ALspStyleCollector.getStyleTargetProvider()
,
ALspStyleCollector.getStyles()