Package org.jungrapht.visualization.util
Class RadiusGraphElementAccessor<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.layout.util.RadiusVertexAccessor<V>
-
- org.jungrapht.visualization.util.RadiusGraphElementAccessor<V,E>
-
- All Implemented Interfaces:
GraphElementAccessor<V,E>,EdgeAccessor<V,E>,VertexAccessor<V>
public class RadiusGraphElementAccessor<V,E> extends RadiusVertexAccessor<V> implements GraphElementAccessor<V,E>
Simple implementation of GraphElementAccessor that returns the vertex or edge that is closest to the specified location.No element will be returned that is farther away than the specified maximum distance.
- Author:
- Tom Nelson, Joshua O'Madadhain
-
-
Field Summary
-
Fields inherited from class org.jungrapht.visualization.layout.util.RadiusVertexAccessor
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 EgetEdge(LayoutModel<V> layoutModel, double x, double y)Gets the edge nearest to the location of the (x,y) location selected, whose endpoints are <maxDistance.EgetEdge(LayoutModel<V> layoutModel, Point p)Gets the edge nearest to the point location selected, whose endpoints are <maxDistance.Set<V>getVertices(LayoutModel<V> layoutModel, Shape rectangle)-
Methods inherited from class org.jungrapht.visualization.layout.util.RadiusVertexAccessor
getVertex, getVertex
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jungrapht.visualization.layout.util.VertexAccessor
getVertex, getVertex
-
-
-
-
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
-
getEdge
public E getEdge(LayoutModel<V> layoutModel, Point p)
Gets the edge nearest to the point location selected, whose endpoints are <maxDistance. Iterates through all visible edges and checks their distance from the location. Override this method to provide a more efficient implementation.- Specified by:
getEdgein interfaceEdgeAccessor<V,E>- Parameters:
layoutModel-p- the pick location- Returns:
-
getEdge
public E getEdge(LayoutModel<V> layoutModel, double x, double y)
Gets the edge 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.- Specified by:
getEdgein interfaceEdgeAccessor<V,E>- Parameters:
layoutModel- the context in which the location is definedx- the x coordinate of the locationy- the y coordinate of the location- Returns:
- an edge which is associated with the location
(x,y)as given bylayoutModel
-
getVertices
public Set<V> getVertices(LayoutModel<V> layoutModel, Shape rectangle)
- Specified by:
getVerticesin interfaceGraphElementAccessor<V,E>rectangle- the region in which the returned vertices are located- Returns:
- the vertices whose locations given by
layoutModelare contained withinshape
-
-