Class Intersection<V>

  • Type Parameters:
    V - The type of elements in the intersection
    All Implemented Interfaces:
    java.lang.Cloneable

    public class Intersection<V>
    extends java.lang.Object
    implements java.lang.Cloneable
    Represents an intersection between two or more elements.
    • Constructor Detail

      • Intersection

        public Intersection​(java.awt.geom.Point2D interPoint,
                            double tolerance)
        Allocates a new intersection
        Parameters:
        interPoint - the spatial point where the intersection happened
        tolerance - tolerance used to detect all the elements involved in the interaction
    • Method Detail

      • getNextId

        protected static long getNextId()
      • getId

        public long getId()
        Gets the intersection ID
        Returns:
        the intersection ID
      • getMembersCount

        public int getMembersCount()
        Gets the number of elements participating in the intersection
        Returns:
        the number of elements in the intersection
      • addMember

        public void addMember​(IntersectionMember<V> member)
        Adds a member to the intersection
        Parameters:
        member - an intersection member
      • removeMember

        public void removeMember​(IntersectionMember<V> member)
        Removes an intersection member
        Parameters:
        member - an intersection member
      • containsMember

        public boolean containsMember​(IntersectionMember<V> member)
        Tells whether an intersection member belongs to the current intersection
        Parameters:
        member - an intersection member
        Returns:
        true if it is a member of the intersection
      • getMembers

        public java.util.Collection<IntersectionMember<V>> getMembers()
        Gets all the members of the intersection
        Returns:
        a collection of intersection members
      • markAsOwner

        public void markAsOwner​(IntersectionMember<V> member)
        Sets the given member as the owner of the intersection. An intersection may not have an owner. An owner can be the element that creates the interaction, for example, an element that was added or that was moved.
        Parameters:
        member - a member of the intersection
      • isOwner

        public boolean isOwner​(IntersectionMember<V> member)
        Tells whether the given member is owner of the intersection.
        Parameters:
        member - a member of the intersection
        Returns:
        true if the element is the owner
      • getOwner

        public IntersectionMember<V> getOwner()
        Gets the member marked as intersection owner (if any)
        Returns:
        an intersection member or null if the intersection has not owner member
      • getIntersectionPoint

        public java.awt.geom.Point2D getIntersectionPoint()
        Gets the spatial point where the intersection occurred
        Returns:
        a java point
      • setIntersectionPoint

        public void setIntersectionPoint​(java.awt.geom.Point2D interPoint)
        Sets the spatial point where the intersection occurred
        Parameters:
        interPoint - a java point
      • pickFirstMember

        public IntersectionMember<V> pickFirstMember​(int geomType)
        Gets the first member found with the given geometry type
        Parameters:
        geomType - a geometry type
        Returns:
        the first member found or null if no members were found
      • getMembers

        public java.util.Collection<IntersectionMember<V>> getMembers​(int geomType)
        Gets all the members with the given geometry type
        Parameters:
        geomType - a geometry type
        Returns:
        a collection of intersection members
      • getMember

        public IntersectionMember<V> getMember​(long memId)
        Gets a member identified by the given ID
        Parameters:
        memId - an intersection member ID
        Returns:
        an intersection member of null if the member was not found
      • getTolerance

        public double getTolerance()
        Gets the tolerance used to detect the intersection
        Returns:
        a tolerance value
      • setTolerance

        public void setTolerance​(double tolerance)
        Sets the tolerance used to detect the intersection
        Parameters:
        tolerance - a tolerance value
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException