Class ClosestShapePickSupport<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.visualization.picking.ClosestShapePickSupport<V,E>
-
- All Implemented Interfaces:
GraphElementAccessor<V,E>
public class ClosestShapePickSupport<V,E> extends java.lang.Object implements GraphElementAccessor<V,E>
AGraphElementAccessor
that finds the closest element to the pick point, and returns it if it is within the element's shape. This is best suited to elements with convex shapes that do not overlap. It differs fromShapePickSupport
in that it only checks the closest element to see whether it contains the pick point. Possible unexpected odd behaviors:- If the elements overlap, this mechanism may pick another element than the one that's "on top" (rendered last) if the pick point is closer to the center of an obscured vertex.
- If element shapes are not convex, then this mechanism may return
null
even if the pick point is inside some element's shape, if the pick point is closer to the center of another element.
ShapePickSupport
instead, which is slower but more flexible. If neither of the above conditions (overlapping elements or non-convex shapes) is true, thenShapePickSupport
and this class should have the same behavior.
-
-
Field Summary
Fields Modifier and Type Field Description protected float
pickSize
protected VisualizationServer<V,E>
vv
-
Constructor Summary
Constructors Constructor Description ClosestShapePickSupport(VisualizationServer<V,E> vv)
Create aShapePickSupport
with thevv
VisualizationServer and default pick footprint.ClosestShapePickSupport(VisualizationServer<V,E> vv, float pickSize)
Creates aShapePickSupport
for thevv
VisualizationServer, with the specified pick footprint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
getEdge(Layout<V,E> layout, double x, double y)
V
getVertex(Layout<V,E> layout, double x, double y)
Returns the vertex, if any, associated with (x, y).java.util.Collection<V>
getVertices(Layout<V,E> layout, java.awt.Shape rectangle)
-
-
-
Field Detail
-
vv
protected VisualizationServer<V,E> vv
-
pickSize
protected float pickSize
-
-
Constructor Detail
-
ClosestShapePickSupport
public ClosestShapePickSupport(VisualizationServer<V,E> vv, float pickSize)
Creates aShapePickSupport
for thevv
VisualizationServer, with the specified pick footprint. TheVisualizationServer
is used to fetch the currentLayout
.- Parameters:
vv
- source of the currentLayout
.pickSize
- the size of the pick footprint for line edges
-
ClosestShapePickSupport
public ClosestShapePickSupport(VisualizationServer<V,E> vv)
Create aShapePickSupport
with thevv
VisualizationServer and default pick footprint. The footprint defaults to 2.- Parameters:
vv
- source of the currentLayout
.
-
-
Method Detail
-
getEdge
public E getEdge(Layout<V,E> layout, double x, double y)
- Specified by:
getEdge
in interfaceGraphElementAccessor<V,E>
- Parameters:
layout
- 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 bylayout
, generally by reference to the edge's endpoints - See Also:
GraphElementAccessor.getEdge(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
-
getVertex
public V getVertex(Layout<V,E> layout, double x, double y)
Description copied from interface:GraphElementAccessor
Returns the vertex, if any, associated with (x, y).- Specified by:
getVertex
in interfaceGraphElementAccessor<V,E>
- Parameters:
layout
- the layout instance that records the positions for all verticesx
- the x coordinate of the pick pointy
- the y coordinate of the pick point- Returns:
- the vertex associated with (x, y)
- See Also:
GraphElementAccessor.getVertex(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
-
getVertices
public java.util.Collection<V> getVertices(Layout<V,E> layout, java.awt.Shape rectangle)
- Specified by:
getVertices
in interfaceGraphElementAccessor<V,E>
- Parameters:
layout
- the layout instance that records the positions for all verticesrectangle
- the region in which the returned vertices are located- Returns:
- the vertices whose locations given by
layout
are contained withinrectangle
- See Also:
GraphElementAccessor.getVertices(edu.uci.ics.jung.algorithms.layout.Layout, java.awt.Shape)
-
-