Class MapElement

    • Field Detail

      • ATTR_USE_CONTAINER_COLOR

        public static final String ATTR_USE_CONTAINER_COLOR
        Name of the attribute that indicates if the element must use its container's color.
        See Also:
        Constant Field Values
      • ATTR_VISUALIZATION_TYPE

        public static final String ATTR_VISUALIZATION_TYPE
        Name of the attribute that indicates if the element must use its container's color.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MapElement

        public MapElement​(UUID id,
                          AttributeCollection attributeSource)
        Create a new map element.
        Parameters:
        id - is the unique identifier of this element, or null if unknown.
        attributeSource - is the source of the attributes for this map element.
        Since:
        4.0
    • Method Detail

      • setUUID

        public final void setUUID​(UUID id)
        Set the unique identifier for element.

        A Unique IDentifier (UID) must be unique for all the object instances.

        Overrides:
        setUUID in class AbstractGISElement<GISElementContainer<?>,​MapElement>
        Parameters:
        id - is the new identifier
        Since:
        4.0
      • fireElementChanged

        protected final void fireElementChanged()
        Fire the event that indicates this object has changed.
      • isReadOnlyObject

        @Pure
        public final boolean isReadOnlyObject()
        Description copied from interface: GISEditable
        Replies if this editable object want to be seen as a reed-only object.

        Even if this object replies true, it is possible to change its attributes. The value replied by this function is just a desire from this object. It could be used by the GUI to allow edition or not from a graphical component.

        Specified by:
        isReadOnlyObject in interface GISEditable
        Returns:
        true if this object ant to be assumed as read-only, otherwise false
      • setReadOnlyObject

        public final void setReadOnlyObject​(boolean readOnly)
        Set if this editable object want to be seen as a reed-only object.

        Even if this object replies true, it is possible to change its attributes. The value replied by this function is just a desire from this object. It could be used by the GUI to allow edition or not from a graphical component.

        Parameters:
        readOnly - the read-only flag value.
      • onAttributeChanged

        protected void onAttributeChanged​(String name)
        This function is invoked by the attribute provider each time an attribute has changed.

        You should override this method to provide several feedback to the GISLayerContainer for instance.

        Parameters:
        name - is the name of the attribute that changed
      • fireGraphicalAttributeChanged

        protected final void fireGraphicalAttributeChanged()
        Invoked when one of the graphical attributes of this element has changed, except those that change the bounding boxes.

        This function does not call resetBoundingBox().

        In the implementation of a MapElement, prefers to call fireGraphicalAttributeChanged() or fireShapeChanged() instead of resetBoundingBox().

        If the attributes that change concern the shape (bounding box) of the element, prefers an invocation of fireShapeChanged() instead of fireGraphicalAttributeChanged()

      • fireShapeChanged

        protected final void fireShapeChanged()
        Invoked when the shape of this element changed.

        This method also reset the bounding box to allow its re-computation (with a call to resetBoundingBox().

        In the implementation of a MapElement, prefers to call fireGraphicalAttributeChanged() or fireShapeChanged() instead of resetBoundingBox().

        If the attributes that change does not concern the shape (bounding box) of the element, prefers an invocation of fireGraphicalAttributeChanged() instead of fireShapeChanged()

      • equals

        @Pure
        public boolean equals​(Object obj)
        Replies if the specified objects is the same as this one.
        Overrides:
        equals in class Object
      • equals

        @Pure
        public abstract boolean equals​(MapElement element)
        Replies if the specified objects is the same as this one.
        Parameters:
        element - the element to compare to.
        Returns:
        true if the given element is equal to this object, otherwise false
      • hashCode

        @Pure
        public abstract int hashCode()
        Overrides:
        hashCode in class Object
      • getDistance

        @Pure
        public abstract double getDistance​(Point2D<?,​?> point)
        Replies the distance between this MapElement and point.
        Parameters:
        point - the point to compute the distance to.
        Returns:
        the distance. Should be negative depending of the MapElement type.
      • contains

        @Pure
        public abstract boolean contains​(Point2D<?,​?> point,
                                         double delta)
        Replies if the specified point (x,y) was inside the figure of this MapElement.
        Parameters:
        point - is a geo-referenced coordinate
        delta - is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system
        Returns:
        true if the specified point has a distance nearest than delta to this element, otherwise false
      • contains

        @Pure
        public final boolean contains​(Point2D<?,​?> point)
        Replies if the specified point (x,y) was inside the figure of this MapElement.

        If this MapElement has no associated figure, this method always returns false.

        Parameters:
        point - is a geo-referenced coordinate
        Returns:
        true if this MapElement had an associated figure and the specified point was inside this bounds of this figure, otherwhise false
      • boundsContains

        @Pure
        protected final boolean boundsContains​(double x,
                                               double y,
                                               double delta)
        Replies if the specified point (x,y) was inside the bounds of this MapElement.
        Parameters:
        x - is a geo-referenced coordinate
        y - is a geo-referenced coordinate
        delta - is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system
        Returns:
        true if the point is inside the bounds of this object, otherwise false
      • intersects

        @Pure
        public abstract boolean intersects​(Shape2D<?,​?,​?,​?,​?,​? extends Rectangle2afp<?,​?,​?,​?,​?,​?>> rectangle)
        Replies if this element has an intersection with the specified rectangle.
        Parameters:
        rectangle - the rectangle
        Returns:
        true if this MapElement is intersecting the specified area, otherwise false
      • boundsIntersects

        @Pure
        protected final boolean boundsIntersects​(Shape2D<?,​?,​?,​?,​?,​? extends Rectangle2afp<?,​?,​?,​?,​?,​?>> rectangle)
        Replies if the bounds of this element has an intersection with the specified rectangle.
        Parameters:
        rectangle - the rectangle.
        Returns:
        true if this bounds is intersecting the specified area, otherwise false
      • setContainerColorUse

        public void setContainerColorUse​(boolean useContainerColor)
        Set the flag that indicates if this element use its color or the container's color.
        Parameters:
        useContainerColor - must be true if this element must use the container's color, and must be false to use the element's color.
      • isContainerColorUsed

        @Pure
        public boolean isContainerColorUsed()
        Replies the flag that indicates if this element use its color or the container's color.
        Returns:
        true if this element must use the container's color, and false to use the element's color.
      • getRawColor

        @Pure
        public Integer getRawColor()
        Description copied from interface: GISEditable
        Replies the color stored inside this element.
        Specified by:
        getRawColor in interface GISEditable
        Returns:
        the color of this element, or null.
      • setColor

        public void setColor​(int color)
        Description copied from interface: GISEditable
        Set the color of this element.
        Specified by:
        setColor in interface GISEditable
        Parameters:
        color - the new color
      • getVisualizationType

        @Pure
        public MapElement.VisualizationType getVisualizationType()
        Replies the type of visualization that must be used by this element.
        Returns:
        the type of visualization
      • setVisualizationType

        public void setVisualizationType​(MapElement.VisualizationType type)
        Set the type of visualization that must be used by this element.
        Parameters:
        type - the visualization type.