Class ALspStyleCollectorWrapper
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) {
List<ALspStyle> opacityStyles = new ArrayList<ALspStyle>();
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 );
}
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionALspStyleCollectorWrapper
(ALspStyleCollector aDelegate) Wrapper constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Cleanup method for style collector.final ALspStyleCollector
Specifies the geometry on which the style should be applied.geometry
(ALspStyleTargetProvider aStyleTargetProvider) Specifies anALspStyleTargetProvider
that should be used to convert objects into a collection of objects on which the style can be applied.Collection
<? extends Object> Returns the objects that have already been provided.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.final ALspStyleCollector
hide()
Hides the specified objects.final ALspStyleCollector
Specifies a singleObject
to be styled.objects
(Collection<? extends Object> aObjects) Specifies a collection of objects to be styled.final ALspStyleCollector
Applies the given style to the specified objects.final ALspStyleCollector
Applies the given list of styles to the specified objects.Applies the given list of styles to the specified objects.void
submit()
Submits the currently specified objects and styles.void
This method is not called by thesubmit()
method.
-
Constructor Details
-
ALspStyleCollectorWrapper
Wrapper constructor.- Parameters:
aDelegate
- The collector to which all calls will be delegated.
-
-
Method Details
-
destroy
public void destroy()Description copied from class:ALspStyleCollector
Cleanup method for style collector. Specific implementations are encouraged to call this method when styling is done. This allows to check whether the style collector was used correctly by theILspStyler
.- Overrides:
destroy
in classALspStyleCollector
-
getObjects
Description copied from class:ALspStyleCollector
Returns the objects that have already been provided. Can be called from withinALspStyleCollector.submitImpl()
. ThisCollection
is reset after each call toALspStyleCollector.submit()
.- Overrides:
getObjects
in classALspStyleCollector
- Returns:
- The collection of objects for which style has been specified.
-
getStyleTargetProvider
Description copied from class: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 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:
getStyleTargetProvider
in classALspStyleCollector
- Returns:
- The current style target provider or null.
-
getStyles
Description copied from class:ALspStyleCollector
Returns the styles that have been specified for the current set of objects. Can be called from withinALspStyleCollector.submitImpl()
. ThisList
is reset after each call toALspStyleCollector.submit()
.- Overrides:
getStyles
in 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:
hide
in classALspStyleCollector
- Returns:
- This style collector
-
object
Specifies a singleObject
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 inILspStyler.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.- Overrides:
object
in classALspStyleCollector
- Parameters:
aObject
- The object to style.- Returns:
- this style collector
-
objects
Description copied from class:ALspStyleCollector
Specifies 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.- Overrides:
objects
in classALspStyleCollector
- 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. TheaGeometry
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.- Overrides:
geometry
in classALspStyleCollector
- Parameters:
aGeometry
- The geometry to which the styling should be applied- Returns:
- this style collector
-
geometry
Description copied from class:ALspStyleCollector
Specifies anALspStyleTargetProvider
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. TheALspStyleTargetProvider
can 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()
- Overrides:
geometry
in classALspStyleCollector
- Parameters:
aStyleTargetProvider
- The target provider.- Returns:
- this style collector
-
style
Applies the given style to 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(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.- Overrides:
style
in classALspStyleCollector
- Parameters:
aStyle
- The style to apply.- Returns:
- This style collector.
-
styles
Description copied from class:ALspStyleCollector
Applies the given list of styles to 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(myILcdPoint).styles(Arrays.asList(myIconStyle,myVerticalLineStyle)).submit()
Specifying other styles after a call to this method will invalidate the result of this call.- Overrides:
styles
in classALspStyleCollector
- Parameters:
aStyles
- The styles to apply. This list should not be modified after using it as an argument in this method.- Returns:
- This style collector.
-
styles
Applies the given list of styles to 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(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.- Overrides:
styles
in classALspStyleCollector
- Parameters:
aStyles
- The style to apply.- Returns:
- This style collector.
-
submit
public void submit()Description copied from class:ALspStyleCollector
Submits the currently specified objects and styles. A call to this method has to be preceded by a call that specifies styles such asALspStyleCollector.style(ALspStyle)
orALspStyleCollector.hide()
. This mandatory method submits a part of the styling before specifying new objects and styles. Example usage:
myCollector.object(myILcdPoint1).style(myIconStyle1).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.object(myILcdPoint2).style(myIconStyle2).submit();
myCollector.objects(myObjects).style(myLineStyle).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.
myCollector.object(myFirstObject).style(myFillStyle).submit();- Overrides:
submit
in classALspStyleCollector
-
submitImpl
public void submitImpl()This method is not called by thesubmit()
method. By default this call is delegated to the wrappedALspStyleCollector
.- Specified by:
submitImpl
in classALspStyleCollector
- See Also:
-