Class TLspEditableStyler
java.lang.Object
com.luciad.view.lightspeed.style.styler.ALspStyler
com.luciad.view.lightspeed.style.styler.TLspEditableStyler
- All Implemented Interfaces:
ILspStyler
A styler which maintains a user-created mapping of domain objects to styles.
This mapping can be updated using the
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.- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionCreates a new, empty styler.TLspEditableStyler
(List<? extends ALspStyle> aDefaultStyle) Creates a new, empty styler with the given default style. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes all the styles set to this editable styler (if any).Returns the default style that is used for objects which have not been assigned a specific style usingsetStyle(...)
.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 usingsetStyle(com.luciad.model.ILcdModel, Object, java.util.List)
.void
Assigns the given style to the given object.void
style
(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext) Styles the objects or labels contained inaObjects
using the methods provided byALspStyleCollector
.Methods inherited from class com.luciad.view.lightspeed.style.styler.ALspStyler
addStyleChangeListener, fireStyleChangeEvent, fireStyleChangeEvent, removeStyleChangeListener
-
Constructor Details
-
TLspEditableStyler
public TLspEditableStyler()Creates a new, empty styler. The default style is set to null, which means objects will not be painted until a style has been assigned to them or a non-null default style is set.- See Also:
-
TLspEditableStyler
Creates a new, empty styler with the given default style. All objects will be painted with this default style until they are explicitly assigned a different style usingsetStyle(ILcdModel, Object, List)
.- Parameters:
aDefaultStyle
- the default style to use
-
-
Method Details
-
getDefaultStyle
Returns the default style that is used for objects which have not been assigned a specific style usingsetStyle(...)
.- Returns:
- the default style used by this provider, must not be modified.
-
setDefaultStyle
Sets the default style that is used for objects which have not been assigned a specific style usingsetStyle(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.- Parameters:
aDefaultStyle
- the default style to be used by this provider
-
setStyle
Assigns the given style to the given object. Subsequent calls toILspStyler.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, useremoveStyle(ILcdModel, Object)
.- Parameters:
aModel
- the model the object belongs toaObject
- the object to assign a style toaStyle
- the style to assign to the object
-
removeStyle
Removes the style assigned to the given object (if any). Subsequent calls toILspStyler.style(java.util.Collection, ALspStyleCollector, com.luciad.view.lightspeed.TLspContext)
will use thedefault style
for this object.- Parameters:
aModel
- the model the object belongs toaObject
- the object for which the style should be cleared
-
clearStyles
public void clearStyles()Removes all the styles set to this editable styler (if any). Subsequent calls toILspStyler.style(...)
will use thedefault style
. -
style
Description copied from interface:ILspStyler
Styles the objects or labels contained in
aObjects
using the methods provided byALspStyleCollector
.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 inaObjects
. Note that not all objects have to be styled. Objects that are not submitted inaStyleCollector
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.
- Parameters:
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.
-