Class SimpleLayerProvider

java.lang.Object
xyz.jpenilla.squaremap.api.SimpleLayerProvider
All Implemented Interfaces:
LayerProvider

public final class SimpleLayerProvider extends Object implements LayerProvider
A simple LayerProvider implementation, backed by a Map.
  • Method Details

    • builder

      public static @NonNull SimpleLayerProvider.Builder builder(@NonNull String label)
      Get a new SimpleLayerProvider.Builder instance
      Parameters:
      label - label for the layer
      Returns:
      new builder
    • builder

      public static @NonNull SimpleLayerProvider.Builder builder(@NonNull Supplier<String> labelSupplier)
      Get a new SimpleLayerProvider.Builder instance
      Parameters:
      labelSupplier - label supplier for the layer
      Returns:
      new builder
    • addMarker

      public void addMarker(@NonNull Key key, @NonNull Marker marker)
      Add a new marker to this layer
      Parameters:
      key - key
      marker - marker
    • removeMarker

      public @Nullable Marker removeMarker(@NonNull Key key)
      Remove an existing marker from this layer, returning either the removed marker, or null if no marker was present for the provided key.
      Parameters:
      key - key
      Returns:
      the existing marker or null
    • clearMarkers

      public void clearMarkers()
      Remove all registered markers
    • registeredMarkers

      public @NonNull Map<Key,Marker> registeredMarkers()
      Get an unmodifiable view of the registered markers
      Returns:
      registered markers
    • hasMarker

      public boolean hasMarker(@NonNull Key key)
      Check whether a marker is registered for a key
      Parameters:
      key - key
      Returns:
      whether a marker is registered
    • getLabel

      public @NonNull String getLabel()
      Description copied from interface: LayerProvider
      Get the label of this LayerProvider, shown in the control box
      Specified by:
      getLabel in interface LayerProvider
      Returns:
      label
    • showControls

      public boolean showControls()
      Description copied from interface: LayerProvider
      Whether to show this layer in the control box

      Default implementation always returns true

      Specified by:
      showControls in interface LayerProvider
      Returns:
      boolean
    • defaultHidden

      public boolean defaultHidden()
      Description copied from interface: LayerProvider
      Whether this layer is hidden by default in the control box

      Default implementation always returns false

      Specified by:
      defaultHidden in interface LayerProvider
      Returns:
      boolean
    • layerPriority

      public int layerPriority()
      Description copied from interface: LayerProvider
      0-indexed order for this layer in the control box

      Falls back to alpha-numeric ordering based on name if there are order conflicts

      Specified by:
      layerPriority in interface LayerProvider
      Returns:
      arbitrary number
    • zIndex

      public int zIndex()
      Description copied from interface: LayerProvider
      0-indexed z-index for this layer. Used in determining what layers are visually on top of other layers.

      Falls back to alpha-numeric ordering based on name if there are order conflicts

      Default implementation returns LayerProvider.layerPriority()

      Specified by:
      zIndex in interface LayerProvider
      Returns:
      arbitrary number
    • getMarkers

      public @NonNull Collection<Marker> getMarkers()
      Description copied from interface: LayerProvider
      Get the markers to display
      Specified by:
      getMarkers in interface LayerProvider
      Returns:
      markers