Class RadiusVertexAccessor<V>
- java.lang.Object
-
- org.jungrapht.visualization.layout.util.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 ofNo element will be returned that is farther away than the specified maximum distance.
- Author:
- Tom Nelson, Joshua O'Madadhain
-
-
Field Summary
Fields Modifier and Type Field Description protected double
maxDistance
-
Constructor Summary
Constructors Constructor Description RadiusVertexAccessor()
Creates an instance with an effectively infinite default maximum distance.RadiusVertexAccessor(double maxDistance)
Creates an instance with the specified default maximum distance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 ofthis.maxDistance
.V
getVertex(LayoutModel<V> layoutModel, Point p)
-
-
-
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 interfaceVertexAccessor<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 ofthis.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 interfaceVertexAccessor<V>
- Parameters:
x
- the x coordinate of the locationy
- the y coordinate of the location- Returns:
- a vertex which is associated with the location
(x,y)
as given bylayout
-
-