Class RadiusVertexAccessor<V>

  • All Implemented Interfaces:
    VertexAccessor<V>
    Direct Known Subclasses:
    RadiusGraphElementAccessor

    public class RadiusVertexAccessor<V>
    extends Object
    implements VertexAccessor<V>
    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

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

    Author:
    Tom Nelson, Joshua O'Madadhain
    • Field Detail

      • maxDistance

        protected double maxDistance
    • Constructor Detail

      • RadiusVertexAccessor

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

        public RadiusVertexAccessor​(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​(LayoutModel<V> layoutModel,
                           Point p)
        Specified by:
        getVertex in interface VertexAccessor<V>
        Parameters:
        layoutModel -
        p - the pick point
        Returns:
        the vertex associated with location p
      • getVertex

        public V getVertex​(LayoutModel<V> layoutModel,
                           double x,
                           double y)
        Gets the vertex nearest to the location of the (x,y) location selected, within a distance of this.maxDistance. Iterates through all visible vertices and checks their distance from the location. Override this method to provide a more efficient implementation.
        Specified by:
        getVertex in interface VertexAccessor<V>
        Parameters:
        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