public abstract class ALspToggleStyler extends ALspStyler
isUseSpecialStyler(Object, TLspContext)
method
that returns true or false based on the given object. This will allow the implementation
to delegate to the appropriate styler.Modifier | Constructor and Description |
---|---|
protected |
ALspToggleStyler(ILspStyler aRegularStyler,
ILspStyler aSpecialStyler)
Creates an
ALspToggleStyler |
Modifier and Type | Method and Description |
---|---|
void |
addStyleChangeListener(ILspStyleChangeListener aListener)
Registers a style change listener with this styler.
|
ILspStyler |
getRegularStyler()
Returns the 'regular' styler instance which was passed in the constructor
|
ILspStyler |
getSpecialStyler()
Returns the 'special' styler instance which was passed in the constructor
|
protected abstract boolean |
isUseSpecialStyler(Object aObject,
TLspContext aContext)
Determines whether the special styler should be used.
|
void |
removeStyleChangeListener(ILspStyleChangeListener aListener)
Unregisters a style change listener from this styler.
|
void |
style(Collection<?> aObjects,
ALspStyleCollector aStyleCollector,
TLspContext aContext)
Styles the objects or labels contained in
aObjects using the methods provided
by ALspStyleCollector . |
fireStyleChangeEvent, fireStyleChangeEvent
protected ALspToggleStyler(ILspStyler aRegularStyler, ILspStyler aSpecialStyler)
ALspToggleStyler
aRegularStyler
- The styler that will be used if isUseSpecialStyler(Object, TLspContext)
returns false.aSpecialStyler
- The styler that will be used if isUseSpecialStyler(Object, TLspContext)
returns true.public void addStyleChangeListener(ILspStyleChangeListener aListener)
ILspStyler
addStyleChangeListener
in interface ILspStyler
addStyleChangeListener
in class ALspStyler
aListener
- the style change listener to addpublic void removeStyleChangeListener(ILspStyleChangeListener aListener)
ILspStyler
removeStyleChangeListener
in interface ILspStyler
removeStyleChangeListener
in class ALspStyler
aListener
- the style change listener to removepublic void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext)
ILspStyler
Styles the objects or labels contained in aObjects
using the methods provided
by ALspStyleCollector
.
Example usages for object styling:
// Same style for all objects:
aStyleCollector.objects(aObjects).style(myStyle).submit();
// Object specific styling:
aStyleCollector.object(myObject1).style(myStyle1).submit();
aStyleCollector.object(myObject2).style(myStyle2).submit();
Example usages for label styling:
if (aStyleCollector instanceof ALspLabelStyleCollector) {
ALspLabelStyleCollector labelStyleCollector = (ALspLabelStyleCollector)aStyleCollector;
// Specify a priority for all labels of all objects:
labelStyleCollector.objects(aDomainObjects).allLabels().priority(3).styles(...).submit();
// Specify an algorithm for a specific label:
labelStyleCollector.object(myObject1).label(123).algorithm(...).styles(...).submit();
}
The objects that are provided to aStyleCollector
must be objects that are contained in
aObjects
. Note that not all objects have to be styled. Objects that are not submitted in
aStyleCollector
will not be painted.
This method can be called very frequently, depending on the (amount of) data. If this method is not implemented efficiently, painting performance may be affected.
aObjects
- The objects to be styled.aStyleCollector
- A style collector to which all styling information
should be passed, this collector is only valid within this method
call, and can no longer be used afterwards.aContext
- Provides context information that may affect styling, such as view specific properties.protected abstract boolean isUseSpecialStyler(Object aObject, TLspContext aContext)
aObject
- the objectaContext
- provides context informationpublic ILspStyler getSpecialStyler()
public ILspStyler getRegularStyler()