public class ClosestShapePickSupport<V,E> extends Object implements GraphElementAccessor<V,E>
GraphElementAccessor
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 from ShapePickSupport
in that it only checks
the closest element to see whether it contains the pick point.
Possible unexpected odd behaviors:
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, then ShapePickSupport
and this class should have the same behavior.Modifier and Type | Field and Description |
---|---|
protected float |
pickSize |
protected VisualizationServer<V,E> |
vv |
Constructor and Description |
---|
ClosestShapePickSupport(VisualizationServer<V,E> vv)
Create a
ShapePickSupport with the vv
VisualizationServer and default pick footprint. |
ClosestShapePickSupport(VisualizationServer<V,E> vv,
float pickSize)
Creates a
ShapePickSupport for the vv
VisualizationServer, with the specified pick footprint. |
Modifier and Type | Method and Description |
---|---|
E |
getEdge(Layout<V,E> layout,
double x,
double y)
Returns an edge which is associated with the
location
(x,y) . |
V |
getVertex(Layout<V,E> layout,
double x,
double y)
Returns a vertex which is associated with the
location
(x,y) . |
Collection<V> |
getVertices(Layout<V,E> layout,
Shape rectangle)
Returns the vertices contained within
rectangle relative
to layout . |
protected VisualizationServer<V,E> vv
protected float pickSize
public ClosestShapePickSupport(VisualizationServer<V,E> vv, float pickSize)
ShapePickSupport
for the vv
VisualizationServer, with the specified pick footprint.
The VisualizationServer
is used to fetch the current
Layout
.vv
- source of the current Layout
.pickSize
- the size of the pick footprint for line edgespublic ClosestShapePickSupport(VisualizationServer<V,E> vv)
ShapePickSupport
with the vv
VisualizationServer and default pick footprint.
The footprint defaults to 2.public E getEdge(Layout<V,E> layout, double x, double y)
GraphElementAccessor
(x,y)
. This is typically determined
with respect to the edge's location as specified
by a Layout
.getEdge
in interface GraphElementAccessor<V,E>
GraphElementAccessor.getEdge(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
public V getVertex(Layout<V,E> layout, double x, double y)
GraphElementAccessor
(x,y)
. This is typically determined
with respect to the vertex's location as specified
by a Layout
.getVertex
in interface GraphElementAccessor<V,E>
GraphElementAccessor.getVertex(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
public Collection<V> getVertices(Layout<V,E> layout, Shape rectangle)
GraphElementAccessor
rectangle
relative
to layout
.getVertices
in interface GraphElementAccessor<V,E>
GraphElementAccessor.getVertices(edu.uci.ics.jung.algorithms.layout.Layout, java.awt.Shape)
Copyright © 2015. All rights reserved.