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

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

    Constructors
    Constructor
    Description
    Layer(@NotNull String key, @NotNull Supplier<@NotNull String> labelSupplier)
    Create a layer.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(@Nullable Object o)
     
    @Nullable String
    Get the custom CSS to add for this layer.
    @NotNull String
    Get the label of this layer, shown in the control box.
    abstract @NotNull Collection<@NotNull Marker<?>>
    Get the markers to display in this Layer.
    @Nullable String
    Get the map pane for this layer.
    int
    Get the indexed order for this layer in the control box.
    int
    Get this layer's update interval (in seconds).
    int
    getUpdateInterval(boolean ticks)
    Get this layer's update interval (in seconds or in ticks).
    @Nullable Integer
    Get the z-index for this layer.
    int
     
    boolean
    Get if this layer is hidden by default in the control box.
    @org.jetbrains.annotations.Nullable boolean
    Get if this layer gets pushed through sse.
    @NotNull Layer
    setCss(@Nullable String css)
    Set the custom CSS to add for this layer.
    @NotNull Layer
    setDefaultHidden(boolean defaultHidden)
    Set if this layer is hidden by default in the control box.
    @NotNull Layer
    setLabel(@NotNull String label)
    Set the label of this layer, shown in the control box.
    @NotNull Layer
    setLabel(@NotNull Supplier<@NotNull String> labelSupplier)
    Set the label supplier of this layer, shown in the control box.
    @NotNull Layer
    setLiveUpdate(@org.jetbrains.annotations.Nullable boolean liveUpdate)
    Set whether to push this layer through sse.
    @NotNull Layer
    setPane(@Nullable String pane)
    Set the map pane for this layer.
    @NotNull Layer
    setPriority(int priority)
    Set the indexed order for this layer in the control box.
    @NotNull Layer
    setShowControls(boolean showControls)
    Set whether to show this layer in the control box.
    @NotNull Layer
    setUpdateInterval(int updateInterval)
    Set this layer's update interval (in seconds).
    @NotNull Layer
    setUpdateInterval(int updateInterval, boolean ticks)
    Set this layer's update interval (in seconds or in ticks).
    @NotNull Layer
    setZIndex(@Nullable Integer zIndex)
    Set the z-index for this layer.
    boolean
    Get whether to show this layer in the control box.
    @NotNull com.google.gson.JsonObject
    Jsonify this object.
    @NotNull String
     

    Methods inherited from class net.pl3x.map.core.Keyed

    getKey

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Layer

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

    • getLabel

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

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

      @NotNull public @NotNull Layer setLabel(@NotNull @NotNull Supplier<@NotNull 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

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

      @NotNull public @NotNull 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

      @NotNull public @NotNull 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

      @NotNull public @NotNull 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

      @NotNull public @NotNull 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

      @Nullable 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

      @NotNull public @NotNull Layer setZIndex(@Nullable @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

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

      @NotNull public @NotNull Layer setPane(@Nullable @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

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

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

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

      @NotNull public @NotNull Layer setLiveUpdate(@Nullable @org.jetbrains.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

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

      @NotNull public @NotNull 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 @Nullable Object o)
      Overrides:
      equals in class Keyed
    • hashCode

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

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Keyed