Class RadiusGraphElementAccessor<V,​E>

  • All Implemented Interfaces:
    GraphElementAccessor<V,​E>
    Direct Known Subclasses:
    RadiusPickSupport

    public class RadiusGraphElementAccessor<V,​E>
    extends java.lang.Object
    implements GraphElementAccessor<V,​E>
    Simple implementation of PickSupport that returns the vertex or edge that is closest to the specified location. This implementation provides the same picking options that were available in previous versions of AbstractLayout.

    No element will be returned that is farther away than the specified maximum distance.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double maxDistance  
    • Constructor Summary

      Constructors 
      Constructor Description
      RadiusGraphElementAccessor()
      Creates an instance with an effectively infinite default maximum distance.
      RadiusGraphElementAccessor​(double maxDistance)
      Creates an instance with the specified default maximum distance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      E getEdge​(Layout<V,​E> layout, double x, double y)  
      E getEdge​(Layout<V,​E> layout, double x, double y, double maxDistance)
      Gets the vertex nearest to the location of the (x,y) location selected, whose endpoints are < maxDistance.
      V getVertex​(Layout<V,​E> layout, double x, double y)
      Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance.
      V getVertex​(Layout<V,​E> layout, double x, double y, double maxDistance)
      Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance.
      java.util.Collection<V> getVertices​(Layout<V,​E> layout, java.awt.Shape rectangle)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maxDistance

        protected double maxDistance
    • Constructor Detail

      • RadiusGraphElementAccessor

        public RadiusGraphElementAccessor()
        Creates an instance with an effectively infinite default maximum distance.
      • RadiusGraphElementAccessor

        public RadiusGraphElementAccessor​(double maxDistance)
        Creates an instance with the specified default maximum distance.
        Parameters:
        maxDistance - the maximum distance at which any element can be from a specified location and still be returned
    • Method Detail

      • getVertex

        public V getVertex​(Layout<V,​E> layout,
                           double x,
                           double y)
        Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance. Iterates through all visible vertices and checks their distance from the click. Override this method to provide a more efficient implementation.
        Specified by:
        getVertex in interface GraphElementAccessor<V,​E>
        Parameters:
        layout - the context in which the location is defined
        x - the x coordinate of the location
        y - the y coordinate of the location
        Returns:
        a vertex which is associated with the location (x,y) as given by layout
      • getVertex

        public V getVertex​(Layout<V,​E> layout,
                           double x,
                           double y,
                           double maxDistance)
        Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance. Iterates through all visible vertices and checks their distance from the location. Override this method to provide a more efficient implementation.
        Parameters:
        layout - the context in which the location is defined
        x - the x coordinate of the location
        y - the y coordinate of the location
        maxDistance - the maximum distance at which any element can be from a specified location and still be returned
        Returns:
        a vertex which is associated with the location (x,y) as given by layout
      • getVertices

        public java.util.Collection<V> getVertices​(Layout<V,​E> layout,
                                                   java.awt.Shape rectangle)
        Specified by:
        getVertices in interface GraphElementAccessor<V,​E>
        Parameters:
        layout - the layout instance that records the positions for all vertices
        rectangle - the region in which the returned vertices are located
        Returns:
        the vertices whose locations given by layout are contained within rectangle
      • getEdge

        public E getEdge​(Layout<V,​E> layout,
                         double x,
                         double y)
        Specified by:
        getEdge in interface GraphElementAccessor<V,​E>
        Parameters:
        layout - the context in which the location is defined
        x - the x coordinate of the location
        y - the y coordinate of the location
        Returns:
        an edge which is associated with the location (x,y) as given by layout, generally by reference to the edge's endpoints
      • getEdge

        public E getEdge​(Layout<V,​E> layout,
                         double x,
                         double y,
                         double maxDistance)
        Gets the vertex nearest to the location of the (x,y) location selected, whose endpoints are < maxDistance. Iterates through all visible vertices and checks their distance from the location. Override this method to provide a more efficient implementation.
        Parameters:
        layout - the context in which the location is defined
        x - the x coordinate of the location
        y - the y coordinate of the location
        maxDistance - the maximum distance at which any element can be from a specified location and still be returned
        Returns:
        an edge which is associated with the location (x,y) as given by layout