Class Layer

    • Field Detail

      • VISIBLE_PROP

        public static final java.lang.String VISIBLE_PROP
        The visibility property for this layer. May be true (visible) or false (hidden).
      • OPACITY_PROP

        public static final java.lang.String OPACITY_PROP
        The opacity of this layer. A number between 0 and 1
      • NAME_PROP

        public static final java.lang.String NAME_PROP
        The name property of the layer. You can listen to name changes by listening to changes to this property.
      • FILTER_STATE_PROP

        public static final java.lang.String FILTER_STATE_PROP
        Property that defines the filter state. This is currently not used.
      • propertyChangeSupport

        protected java.beans.PropertyChangeSupport propertyChangeSupport
        keeps track of property change listeners
      • visible

        private boolean visible
        The visibility state of the layer.
      • opacity

        private double opacity
        The opacity of the layer.
      • background

        private boolean background
        The layer should be handled as a background layer in automatic handling
      • name

        private java.lang.String name
        The name of this layer.
      • renamed

        private boolean renamed
        This is set if user renamed this layer.
      • associatedFile

        private java.io.File associatedFile
        If a file is associated with this layer, this variable should be set to it.
    • Constructor Detail

      • Layer

        protected Layer​(java.lang.String name)
        Create the layer and fill in the necessary components.
        Parameters:
        name - Layer name
    • Method Detail

      • getIcon

        public abstract javax.swing.Icon getIcon()
        Return a representative small image for this layer. The image must not be larger than 64 pixel in any dimension.
        Returns:
        layer icon
      • hasColor

        public boolean hasColor()
        Determines whether the layer has / can handle colors.
        Returns:
        whether the layer has / can handle colors.
        Since:
        15496
      • getColor

        public java.awt.Color getColor()
        Return the current color of the layer
        Returns:
        null when not present or not supported
        Since:
        15496
      • setColor

        public void setColor​(java.awt.Color color)
        Sets the color for this layer. Nothing happens if not supported by the layer
        Parameters:
        color - the color to be set, null for default
        Since:
        15496
      • getToolTipText

        public abstract java.lang.String getToolTipText()
        Returns a small tooltip hint about some statistics for this layer.
        Returns:
        A small tooltip hint about some statistics for this layer.
      • mergeFrom

        public abstract void mergeFrom​(Layer from)
        Merges the given layer into this layer. Throws if the layer types are incompatible.
        Parameters:
        from - The layer that get merged into this one. After the merge, the other layer is not usable anymore and passing to one others mergeFrom should be one of the last things to do with a layer.
      • isMergable

        public abstract boolean isMergable​(Layer other)
        Determines if the other layer can be merged into this layer.
        Parameters:
        other - The other layer that is tested to be mergable with this.
        Returns:
        Whether the other layer can be merged into this layer.
      • visitBoundingBox

        public abstract void visitBoundingBox​(BoundingXYVisitor v)
        Visits the content bounds of this layer. The behavior of this method depends on the layer, but each implementation should attempt to cover the relevant content of the layer in this method.
        Parameters:
        v - The visitor that gets notified about the contents of this layer.
      • getInfoComponent

        public abstract java.lang.Object getInfoComponent()
        Gets the layer information to display to the user. This is used if the user requests information about this layer. It should display a description of the layer content.
        Returns:
        Either a String or a Component describing the layer.
      • isInfoResizable

        public boolean isInfoResizable()
        Determines if info dialog can be resized (false by default).
        Returns:
        true if the info dialog can be resized, false otherwise
        Since:
        6708
      • getMenuEntries

        public abstract javax.swing.Action[] getMenuEntries()
        Returns list of actions. Action can implement LayerAction interface when it needs to be represented by other menu component than JMenuItem or when it supports multiple layers. Actions that support multiple layers should also have correct equals implementation.

        Use Layer.SeparatorLayerAction.INSTANCE instead of new JSeparator

        Returns:
        menu actions for this layer
      • destroy

        public void destroy()
        Called, when the layer is removed from the mapview and is going to be destroyed.

        This is because the Layer constructor cannot add itself safely as a listener to the layerlist dialog, because there may be no such dialog yet (loaded via command line parameter).

        Specified by:
        destroy in interface Destroyable
      • setAssociatedFile

        public void setAssociatedFile​(java.io.File file)
        Sets the associated file for this layer.

        The associated file might be the one that the user opened.

        Parameters:
        file - The file, may be null
      • getLabel

        public java.lang.String getLabel()
        Replies a label for this layer useful for UI elements. Defaults to the layer name
        Returns:
        a label for this layer
        Since:
        17626
      • getName

        public java.lang.String getName()
        Replies the name of the layer
        Returns:
        the name of the layer
      • setName

        public void setName​(java.lang.String name)
        Sets the name of the layer
        Parameters:
        name - the name. If null, the name is set to the empty string.
      • rename

        public final void rename​(java.lang.String name)
        Rename layer and set renamed flag to mark it as renamed (has user given name).
        Parameters:
        name - the name. If null, the name is set to the empty string.
      • isRenamed

        public boolean isRenamed()
        Replies true if user renamed this layer
        Returns:
        true if user renamed this layer
      • isBackgroundLayer

        public boolean isBackgroundLayer()
        Replies true if this layer is a background layer
        Returns:
        true if this layer is a background layer
      • setBackgroundLayer

        public void setBackgroundLayer​(boolean background)
        Sets whether this layer is a background layer
        Parameters:
        background - true, if this layer is a background layer
      • setVisible

        public void setVisible​(boolean visible)
        Sets the visibility of this layer. Emits property change event for property VISIBLE_PROP.
        Parameters:
        visible - true, if the layer is visible; false, otherwise.
      • isVisible

        public boolean isVisible()
        Replies true if this layer is visible. False, otherwise.
        Returns:
        true if this layer is visible. False, otherwise.
      • getOpacity

        public double getOpacity()
        Gets the opacity of the layer, in range 0...1
        Returns:
        The opacity
      • setOpacity

        public void setOpacity​(double opacity)
        Sets the opacity of the layer, in range 0...1
        Parameters:
        opacity - The opacity
        Throws:
        java.lang.IllegalArgumentException - if the opacity is out of range
      • toggleVisible

        public void toggleVisible()
        Toggles the visibility state of this layer.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Adds a PropertyChangeListener
        Parameters:
        listener - the listener
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Removes a PropertyChangeListener
        Parameters:
        listener - the listener
      • fireVisibleChanged

        protected void fireVisibleChanged​(boolean oldValue,
                                          boolean newValue)
        fires a property change for the property VISIBLE_PROP
        Parameters:
        oldValue - the old value
        newValue - the new value
      • fireOpacityChanged

        protected void fireOpacityChanged​(double oldValue,
                                          double newValue)
        fires a property change for the property OPACITY_PROP
        Parameters:
        oldValue - the old value
        newValue - the new value
      • isProjectionSupported

        public boolean isProjectionSupported​(Projection proj)
        Allows to check whether a projection is supported or not.
        Parameters:
        proj - projection
        Returns:
        True if projection is supported for this layer
      • nameSupportedProjections

        public java.lang.String nameSupportedProjections()
        Specify user information about projections
        Returns:
        User readable text telling about supported projections
      • onPostLoadFromFile

        public void onPostLoadFromFile()
        Initializes the layer after a successful load of data from a file
        Since:
        5459
      • isSavable

        public boolean isSavable()
        Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).
        Returns:
        true if this layer can be saved to a file
        Since:
        5459
      • checkSaveConditions

        public boolean checkSaveConditions()
        Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)
        Returns:
        true, if it is safe to save.
        Since:
        5459
      • getChangesetSourceTag

        public java.lang.String getChangesetSourceTag()
        Get the source for the layer
        Returns:
        The string for the changeset source tag or null
        Since:
        15371
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object