Class Layer

java.lang.Object
net.pl3x.map.core.Keyed
net.pl3x.map.core.markers.layer.Layer
All Implemented Interfaces:
JsonSerializable
Direct Known Subclasses:
SimpleLayer

@NullMarked public abstract class Layer extends Keyed implements JsonSerializable
Represents a layer of markers and other metadata.
  • Constructor Details

    • Layer

      public Layer(String key, Supplier<String> labelSupplier)
      Create a layer.
      Parameters:
      key - key for layer
  • Method Details

    • getLabel

      public String getLabel()
      Get the label of this layer, shown in the control box.
      Returns:
      layer label
    • setLabel

      public Layer setLabel(String label)
      Set the label of this layer, shown in the control box.
      Parameters:
      label - new label
      Returns:
      this layer
    • setLabel

      public Layer setLabel(Supplier<String> labelSupplier)
      Set the label supplier of this layer, shown in the control box.
      Parameters:
      labelSupplier - new label supplier
      Returns:
      this layer
    • getUpdateInterval

      public int getUpdateInterval()
      Get this layer's update interval (in seconds).
      Returns:
      update interval
    • getUpdateInterval

      public int getUpdateInterval(boolean ticks)
      Get this layer's update interval (in seconds or in ticks).
      Parameters:
      ticks - set to true to get update interval as ticks instead of seconds
      Returns:
      update interval
    • setUpdateInterval

      public Layer setUpdateInterval(int updateInterval)
      Set this layer's update interval (in seconds).
      Parameters:
      updateInterval - new update interval
      Returns:
      this layer
    • setUpdateInterval

      public Layer setUpdateInterval(int updateInterval, boolean ticks)
      Set this layer's update interval (in seconds or in ticks).
      Parameters:
      updateInterval - new update interval
      ticks - set to true to treat the interval value as ticks instead of seconds
      Returns:
      this layer
    • shouldShowControls

      public boolean shouldShowControls()
      Get whether to show this layer in the control box.
      Returns:
      true if showing controls
    • setShowControls

      public Layer setShowControls(boolean showControls)
      Set whether to show this layer in the control box.
      Parameters:
      showControls - true to show
      Returns:
      this layer
    • isDefaultHidden

      public boolean isDefaultHidden()
      Get if this layer is hidden by default in the control box.
      Returns:
      true if hidden by default
    • setDefaultHidden

      public Layer setDefaultHidden(boolean defaultHidden)
      Set if this layer is hidden by default in the control box.
      Parameters:
      defaultHidden - true to hide by default
      Returns:
      this layer
    • getPriority

      public int getPriority()
      Get the indexed order for this layer in the control box.

      Falls back to alphanumeric ordering based on label if there are order conflicts.

      Returns:
      layer priority
    • setPriority

      public Layer setPriority(int priority)
      Set the indexed order for this layer in the control box.

      Falls back to alphanumeric ordering based on label if there are order conflicts.

      Parameters:
      priority - new priority
      Returns:
      this layer
    • getZIndex

      public @Nullable Integer getZIndex()
      Get the z-index for this layer. Used in determining what layers are visually on top of other layers.

      Falls back to alphanumeric ordering based on name if there are order conflicts.

      Defaults to 'getPriority()' if null.

      Returns:
      layer z-index
    • setZIndex

      public Layer setZIndex(@Nullable Integer zIndex)
      Set the z-index for this layer. Used in determining what layers are visually on top of other layers.

      Falls back to alphanumeric ordering based on name if there are order conflicts.

      Defaults to 'getPriority()' if null.

      Parameters:
      zIndex - new z-index
      Returns:
      this layer
    • getPane

      public @Nullable String getPane()
      Get the map pane for this layer.
      Returns:
      map pane
    • setPane

      public Layer setPane(@Nullable String pane)
      Set the map pane for this layer.

      If the pane does not exist, it will be created the first time it is used.

      Parameters:
      pane - new map pane
      Returns:
      this layer
    • getCss

      public @Nullable String getCss()
      Get the custom CSS to add for this layer.
      Returns:
      custom CSS
    • setCss

      public Layer setCss(@Nullable String css)
      Set the custom CSS to add for this layer.
      Parameters:
      css - new custom CSS
      Returns:
      this layer
    • isLiveUpdate

      public @org.jspecify.annotations.Nullable boolean isLiveUpdate()
      Get if this layer gets pushed through sse.
      Returns:
      true if being sent through sse
    • setLiveUpdate

      public Layer setLiveUpdate(@org.jspecify.annotations.Nullable boolean liveUpdate)
      Set whether to push this layer through sse.
      Parameters:
      liveUpdate - true to push this layer through sse.
      Returns:
      this layer
    • getMarkers

      public abstract Collection<Marker<?>> getMarkers()
      Get the markers to display in this Layer.
      Returns:
      markers to display
    • toJson

      public com.google.gson.JsonObject toJson()
      Description copied from interface: JsonSerializable
      Jsonify this object.
      Specified by:
      toJson in interface JsonSerializable
      Returns:
      object as json element
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Keyed
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Keyed
    • toString

      public String toString()
      Overrides:
      toString in class Keyed