Class BaseLayer<T extends BaseLayer<?>>

java.lang.Object
com.jbstrap.jbmap.layers.Layer<BaseLayer<T>>
com.jbstrap.jbmap.layers.BaseLayer<T>
Type Parameters:
T - The layer class type
Direct Known Subclasses:
Area, Circle, CirclePoint, DivPoint, Line, Point, PopupPoint, Rectangle

public class BaseLayer<T extends BaseLayer<?>> extends Layer<BaseLayer<T>>

The base class of all layers.

All map layers must be extended from this layer.

This class ensures the basic functionalities of layers:

event handling, GeoJSON structure, coordinates, unique parameters, popup settings, and being assigned to a layer group.

Supported events:
Since:
4.0
  • Field Details

  • Constructor Details

    • BaseLayer

      protected BaseLayer(String name)
      Creates the base class of a layer.
      Parameters:
      name - The layer's unique name for identifying the layer Specify this name to get the layer from the containing LayerGroup.
      Throws:
      NullPointerException - Thrown if the name parameter is null
  • Method Details

    • getPopup

      public Popup getPopup()
      Gets the layer popup as a JBStrap component. If you get the layer popup component, you can add any JBStrap component to the popup.
      Returns:
      Layer popup component
    • addClickHandler

      public T addClickHandler(LayerClickEventHandler handler)
      Adds a layer click event handler to the layer. This handler is executed only once if the user clicks on the layer.
      Parameters:
      handler - The LayerClickEventHandler implementation
      Returns:
      The instantiated Layer class
    • getClickHandlers

      public List<com.jbstrap.core.event.handlers.BrowserEventHandler> getClickHandlers()
      Gets a list of layer click event handlers.
      Returns:
      A list of layer click event handlers
    • removeClickHandler

      public T removeClickHandler(LayerClickEventHandler handler)
      Removes the layer click event handler from the list of click event handlers. The removed event handler does not apply to the event.
      Parameters:
      handler - The LayerClickEventHandler to be removed
      Returns:
      The instantiated Layer class
    • addMouseOverHandler

      public T addMouseOverHandler(LayerMouseOverEventHandler handler)
      Adds a layer mouse over event handler to the layer. This handler is executed if the user hovers with the mouse over the layer.
      Parameters:
      handler - LayerMouseOverEventHandler implementation
      Returns:
      The instantiated Layer class
    • getMouseOverHandlers

      public List<com.jbstrap.core.event.handlers.BrowserEventHandler> getMouseOverHandlers()
      Gets a list of layer mouse over event handlers.
      Returns:
      A list of mouse over event handlers
    • removeMouseOverHandler

      public T removeMouseOverHandler(LayerMouseOverEventHandler handler)
      Removes the layer mouse over event handler from the list of mouse over event handlers. The removed event handler does not apply to the event.
      Parameters:
      handler - The LayerMouseOverEventHandler to be removed
      Returns:
      The instantiated Layer class
    • addMouseOutHandler

      public T addMouseOutHandler(LayerMouseOutEventHandler handler)
      Adds a mouse out event handler to the layer. This handler is executed if the user's mouse pointer leaves the layer.
      Parameters:
      handler - The LayerMouseOutEventHandler implementation
      Returns:
      The instantiated Layer class
    • getMouseOutHandlers

      public List<com.jbstrap.core.event.handlers.BrowserEventHandler> getMouseOutHandlers()
      Gets a list of mouse out event handlers.
      Returns:
      A list of mouse out event handlers assigned to the layer
    • removeMouseOutHandler

      public T removeMouseOutHandler(LayerMouseOutEventHandler handler)
      Removes a mouse out event handler from the list of mouse out event handlers. The removed event handler does not apply to the event.
      Parameters:
      handler - The LayerMouseOutEventHandler to be removed
      Returns:
      The instantiated Layer class
    • setParent

      public final T setParent(LayerGroup parent)
      Sets the layer's parent (the layer group). You can add a layer to a layer group LayerGroup.addLayer(BaseLayer) or set its parent, the layer group. The latter way can also be used to move a layer to another layer.
      Parameters:
      parent - The layer group
      Returns:
      Layer class instance
    • getParent

      public LayerGroup getParent()
      Gets the layer group of the layer. You get the layer group to which the layer is added.
      Returns:
      The layer group that currently holds the layer If not available, its value is null.
    • getName

      public String getName()
      Gets the layer's unique name. Use this name to identify a layer. Two layers cannot have the same name in the same layer group.
      Returns:
      Unique layer name
    • getTitle

      public String getTitle()
      Gets the layer's title
      Returns:
      Layer title
    • setTitle

      public T setTitle(String title)
      Sets the layer's title. This title is not displayed on the UI, but it exists as a parameter. E.g. it can be used as a titleParam component on the DivLayer instance.
      Parameters:
      title - Layer title
      Returns:
      Layer class instance
    • getPopupContent

      public String getPopupContent()
      Gets the layer popup content. The content that was specified using the setPopupContent(String) method.
      Returns:
      Layer popup content
    • setPopupContent

      public T setPopupContent(String popupContent)
      Sets the layer popup content once as a text. If you want to set a JBStrap content, you have to use the getPopup() method.
      Parameters:
      popupContent - Layer popup text
      Returns:
      Layer class instance
    • isPopupEnabled

      public boolean isPopupEnabled()
      Checks if the popup is enabled.
      Returns:
      If true, the popup is enabled, otherwise not
    • setPopupEnabled

      public T setPopupEnabled(boolean popupEnabled)
      Enabled the popup.
      Parameters:
      popupEnabled - If true, the layer popup is enabled, otherwise not The default setting is false.
      Returns:
      Layer class instance
    • openPopup

      public T openPopup()
      Displays the popup if enabled. If the popup display is not enabled, you can do this by using the setPopupEnabled(boolean) method. If you use this method at initialization time, the popup shows up as open on the layer. The layer also has to be visible on the map.
      Returns:
      Layer class instance
    • closePopup

      public T closePopup()
      Closes the displayed popup.
      Returns:
      Layer class instance
    • setCoordinates

      protected void setCoordinates(List<Double> coordinateList)
      Parameters:
      coordinateList - A list of Double type containing longitude and latitude coordinates
    • getGeometry

      protected com.jbstrap.core.Parameters getGeometry()
      Returns:
      Geometrical parameters
    • getProperties

      public final com.jbstrap.core.Parameters getProperties()
      Gets the setting parameters of the layer's GeoJSON structure.
      Returns:
      Setting parameters of the layer's GeoJSON structure
    • getCustomParams

      public com.jbstrap.core.Parameters getCustomParams()
      Gets the layer's unique parameters.
      Returns:
      The layer's unique parameters
    • setCustomParams

      public T setCustomParams(com.jbstrap.core.Parameters customParams)
      Sets the layer's unique parameters. You can use the addCustomParam(String, Object) method to add a parameter.
      Parameters:
      customParams - The layer's custom parameters
      Returns:
      Layer class instance
    • addCustomParam

      public T addCustomParam(String name, Object value)
      Adds a custom parameter to the layer.
      Parameters:
      name - Parameter name
      value - Parameter value
      Returns:
      Layer class instance
      Throws:
      NullPointerException - Thrown if the name parameter is null
    • removeCustomParam

      public T removeCustomParam(String name)
      Removes the parameter with the specified name from the layer's custom parameters.
      Parameters:
      name - Parameter name
      Returns:
      Layer class instance
      Throws:
      NullPointerException - Thrown if the name parameter is null
    • getParams

      public com.jbstrap.core.Parameters getParams()
      Gets the layer's full list of parameters.
      Returns:
      The layer's full list of parameters
    • isShown

      public boolean isShown()
      Gets the status of the layer's programmatical display.
      Returns:
      true if show() was used the last time and false if hide() was used
    • show

      public T show()
      The layer is displayed programmatically.
      Returns:
      Layer class instance
    • hide

      public T hide()
      The layer is programmatically hidden.
      Returns:
      Layer class instance
    • runJSLayer

      protected void runJSLayer(String script)
      Parameters:
      script - JavaScript
    • runJSLayerGroup

      protected void runJSLayerGroup(String script)
      Parameters:
      script - JavaScript