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 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
    • setUpdateInterval

      @NotNull public @NotNull Layer setUpdateInterval(int updateInterval)
      Set this layer's update interval (in seconds).
      Parameters:
      updateInterval - new update interval
      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
    • 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