public class TLspEditableStyler extends ALspStyler
setStyle
method. If no style has been assigned to an object when
ILspStyler.style(...)
is called, a default style is used. This class can be
used in applications that wish to put the choice of style completely in the
hands of the end user.
This class is not intended for use as a generic styler implementation. For
example, if you have a layer with 100 car objects and 50 bike objects, you
should not use this class to assign a car style to 100 car objects and a bike
style to the 50 bike objects. That type of scenario would typically be
supported with a custom ILspStyler
, or for this particular example an
ALspToggleStyler
might also be suited.Constructor and Description |
---|
TLspEditableStyler()
Creates a new, empty styler.
|
TLspEditableStyler(List<? extends ALspStyle> aDefaultStyle)
Creates a new, empty styler with the given default style.
|
Modifier and Type | Method and Description |
---|---|
void |
clearStyles()
Removes all the styles set to this editable styler (if any).
|
List<ALspStyle> |
getDefaultStyle()
Returns the default style that is used for objects which have not been
assigned a specific style using
setStyle(...) . |
void |
removeStyle(ILcdModel aModel,
Object aObject)
Removes the style assigned to the given object (if any).
|
void |
setDefaultStyle(List<? extends ALspStyle> aDefaultStyle)
Sets the default style that is used for objects which have not been
assigned a specific style using
setStyle(com.luciad.model.ILcdModel, Object,
java.util.List) . |
void |
setStyle(ILcdModel aModel,
Object aObject,
List<? extends ALspStyle> aStyle)
Assigns the given style to the given object.
|
void |
style(Collection<?> aObjects,
ALspStyleCollector aStyleCollector,
TLspContext aContext)
Styles the objects or labels contained in
aObjects using the methods provided
by ALspStyleCollector . |
addStyleChangeListener, fireStyleChangeEvent, fireStyleChangeEvent, removeStyleChangeListener
public TLspEditableStyler()
public TLspEditableStyler(List<? extends ALspStyle> aDefaultStyle)
setStyle(ILcdModel, Object, List)
.aDefaultStyle
- the default style to usepublic List<ALspStyle> getDefaultStyle()
setStyle(...)
.public void setDefaultStyle(List<? extends ALspStyle> aDefaultStyle)
setStyle(com.luciad.model.ILcdModel, Object,
java.util.List)
.
If this is set to null, objects which have not been assigned a specific
style will not be painted at all.aDefaultStyle
- the default style to be used by this providerpublic void setStyle(ILcdModel aModel, Object aObject, List<? extends ALspStyle> aStyle)
ILspStyler.style(...)
will now use this style for this object. Note that
it is possible to assign a null style to an object. This will result in the
object not being painted. It will not result in the default style
being used. To revert an object back to the default style, use
removeStyle(ILcdModel, Object)
.aModel
- the model the object belongs toaObject
- the object to assign a style toaStyle
- the style to assign to the objectpublic void removeStyle(ILcdModel aModel, Object aObject)
ILspStyler.style(java.util.Collection, ALspStyleCollector, com.luciad.view.lightspeed.TLspContext)
will use the default style
for this
object.aModel
- the model the object belongs toaObject
- the object for which the style should be clearedpublic void clearStyles()
ILspStyler.style(...)
will use the default
style
.public 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.