public abstract class ALspStyle extends Object implements ILspStyler
ILspStyler
.
For convenience, this class also implements ILspStyler
by styling all
objects using itself. This makes it very easy to configure a layer or painter
with only one style. Do note that it will never fire style change events,
because styles are immutable.
Subclasses introducing state should override the equals
and
hashCode
methods, check their own state, and delegate to this
class.Modifier and Type | Class and Description |
---|---|
static class |
ALspStyle.Builder<B extends ALspStyle.Builder<B>>
Builder for styles.
|
Modifier | Constructor and Description |
---|---|
protected |
ALspStyle(int aZOrder)
Constructs a style.
|
Modifier and Type | Method and Description |
---|---|
void |
addStyleChangeListener(ILspStyleChangeListener aListener)
Registers a style change listener with this styler.
|
abstract ALspStyle.Builder<?> |
asBuilder()
Creates a new builder initialized with all the properties of this style.
|
boolean |
equals(Object o) |
int |
getZOrder()
Returns the Z-order of this style.
|
int |
hashCode() |
boolean |
isCompatible(TLspPaintPass aPaintPass)
Utility method to determine whether the style is compatible with the given paint pass.
|
abstract boolean |
isTransparent()
Determines whether this style is transparent.
|
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 . |
protected ALspStyle(int aZOrder)
aZOrder
- defines the relative ordering of this style with respect to other
styles in the same layerpublic abstract boolean isTransparent()
public void addStyleChangeListener(ILspStyleChangeListener aListener)
ILspStyler
addStyleChangeListener
in interface ILspStyler
aListener
- the style change listener to addpublic void removeStyleChangeListener(ILspStyleChangeListener aListener)
ILspStyler
removeStyleChangeListener
in interface ILspStyler
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.
style
in interface ILspStyler
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.public boolean isCompatible(TLspPaintPass aPaintPass)
aPaintPass
- the paint passtrue
if the style can be used in the given paint pass, false
otherwise
.public int getZOrder()
Returns the Z-order of this style. Styles of the same type should be painted from lowest to highest Z-order. This means that styles with the highest Z-order will be painted on top.
For optimal results, use values between 0 and 100.
Increasing the number of different Z-orders can negatively impact painting performance. By default, it is set to 0.
public abstract ALspStyle.Builder<?> asBuilder()