Class TLspEditableStyler

java.lang.Object
com.luciad.view.lightspeed.style.styler.ALspStyler
com.luciad.view.lightspeed.style.styler.TLspEditableStyler
All Implemented Interfaces:
ILspStyler

public class TLspEditableStyler extends ALspStyler
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 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

      public TLspEditableStyler(List<? extends ALspStyle> aDefaultStyle)
      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 using setStyle(ILcdModel, Object, List).
      Parameters:
      aDefaultStyle - the default style to use
  • Method Details

    • getDefaultStyle

      public List<ALspStyle> getDefaultStyle()
      Returns the default style that is used for objects which have not been assigned a specific style using setStyle(...).
      Returns:
      the default style used by this provider, must not be modified.
    • setDefaultStyle

      public 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). 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

      public void setStyle(ILcdModel aModel, Object aObject, List<? extends ALspStyle> aStyle)
      Assigns the given style to the given object. Subsequent calls to 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).
      Parameters:
      aModel - the model the object belongs to
      aObject - the object to assign a style to
      aStyle - the style to assign to the object
    • removeStyle

      public void removeStyle(ILcdModel aModel, Object aObject)
      Removes the style assigned to the given object (if any). Subsequent calls to ILspStyler.style(java.util.Collection, ALspStyleCollector, com.luciad.view.lightspeed.TLspContext) will use the default style for this object.
      Parameters:
      aModel - the model the object belongs to
      aObject - 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 to ILspStyler.style(...) will use the default style.
    • style

      public void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext)
      Description copied from interface: 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.

      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.