Class LayerList

java.lang.Object
com.luciad.layers.LayerList
All Implemented Interfaces:
AutoCloseable

public final class LayerList extends Object implements AutoCloseable
Represents an ordered list of layers.

The order within this list determines the order in which layers are painted.

Note that this class tracks on which thread it is constructed. This is done so that, in subsequent calls, it can verify that the same threads are used consistently. When an inconsistency is detected, an assertion is triggered. This means that all functions on LayerList must be called on the thread on which the Map was constructed (the "UI" thread). The only exception is adding and removing observers. Related article: Threading rules for the Map

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty layer list.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Layer layer)
    Adds the given layer to this layer list.
    void
    add(Layer layer, long targetIndex)
    Adds the given layer to this layer list.
    void
    Adds an observer to be notified of changes to this layer list.
    void
    addObserver(ILayerListObserver observer, boolean seedObserver)
    Adds an observer to be notified of changes to this layer list.
    void
     
    protected void
     
    findLayerById(long layerId)
    Searches for the layer with a provided id in the layer list.
    List<@NotNull Layer>
    Returns the vector that represents the ordering of all layers in this layer list.
    void
    move(long layerId, long targetIndex)
    Moves the layer with the given id to the target index.
    void
    remove(long layerId)
    Removes the layer with the given id.
    void
    Removes the given observer.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LayerList

      public LayerList()
      Constructs an empty layer list.
  • Method Details

    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getLayers

      @NotNull public List<@NotNull Layer> getLayers()
      Returns the vector that represents the ordering of all layers in this layer list.

      The order is defined as bottom-to-top. This means that the first layer in this vector is painted first (and appears at the bottom), and that the last layer of this vector is painted last (and appears at the top).

      Returns:
      the vector that represents the ordering of all layers in this layer list.
    • findLayerById

      @Nullable public Layer findLayerById(long layerId)
      Searches for the layer with a provided id in the layer list.
      Parameters:
      layerId - a layer id
      Returns:
      the layer that corresponds with the given id, or null.
    • add

      public void add(@NotNull Layer layer) throws IllegalArgumentException, NullPointerException
      Adds the given layer to this layer list.
      Parameters:
      layer - a layer
      Throws:
      IllegalArgumentException - when the layer has already been added.
      NullPointerException - when the layer is null.
    • add

      public void add(@NotNull Layer layer, long targetIndex) throws IllegalArgumentException, NullPointerException
      Adds the given layer to this layer list.
      Parameters:
      layer - a layer
      targetIndex - the index at which to add the layer
      Throws:
      IllegalArgumentException - exception when the layer has already been added or when the target index is not in range.
      NullPointerException - when the layer is null.
    • remove

      public void remove(long layerId) throws IllegalArgumentException
      Removes the layer with the given id.
      Parameters:
      layerId - the id of the layer to remove
      Throws:
      IllegalArgumentException - when this LayerList does not contain a layer with the given id
    • move

      public void move(long layerId, long targetIndex) throws IllegalArgumentException
      Moves the layer with the given id to the target index.
      Parameters:
      layerId - the id of the layer to move
      targetIndex - a target index
      Throws:
      IllegalArgumentException - when this LayerList does not contain a layer with the given id or when the target index is not in range
    • addObserver

      public void addObserver(@NotNull ILayerListObserver observer, boolean seedObserver) throws IllegalArgumentException, NullPointerException
      Adds an observer to be notified of changes to this layer list.

      Adding the same observer twice is forbidden, and will cause an exception to be thrown.

      Parameters:
      observer - an observer, must not be null
      seedObserver - whether to inform the observer about the layers that are currently present
      Throws:
      IllegalArgumentException - when the observer was already added.
      NullPointerException - when the observer is null.
    • addObserver

      public void addObserver(@NotNull ILayerListObserver observer) throws IllegalArgumentException, NullPointerException
      Adds an observer to be notified of changes to this layer list.

      Adding the same observer twice is forbidden, and will cause an exception to be thrown.

      Parameters:
      observer - an observer, must not be null
      Throws:
      IllegalArgumentException - when the observer was already added.
      NullPointerException - when the observer is null.
    • removeObserver

      public void removeObserver(@NotNull ILayerListObserver observer) throws IllegalArgumentException, NullPointerException
      Removes the given observer.

      If the given observer was never added, an exception is thrown.

      Parameters:
      observer - an observer, must not be null
      Throws:
      IllegalArgumentException - when the observer is not known.
      NullPointerException - when the observer is null.