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) |
V |
getVertex(Layout<V,E> layout,
double x,
double y)
Returns the vertex, if any, associated with (x, y).
|
Collection<V> |
getVertices(Layout<V,E> layout,
Shape rectangle) |
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.vv
- source of the current Layout
.public E getEdge(Layout<V,E> layout, double x, double y)
getEdge
in interface GraphElementAccessor<V,E>
layout
- the context in which the location is definedx
- the x coordinate of the locationy
- the y coordinate of the location(x,y)
as given by layout
, generally by reference to the edge's endpointsGraphElementAccessor.getEdge(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
public V getVertex(Layout<V,E> layout, double x, double y)
GraphElementAccessor
getVertex
in interface GraphElementAccessor<V,E>
layout
- the layout instance that records the positions for all verticesx
- the x coordinate of the pick pointy
- the y coordinate of the pick pointGraphElementAccessor.getVertex(edu.uci.ics.jung.algorithms.layout.Layout, double, double)
public Collection<V> getVertices(Layout<V,E> layout, Shape rectangle)
getVertices
in interface GraphElementAccessor<V,E>
layout
- the layout instance that records the positions for all verticesrectangle
- the region in which the returned vertices are locatedlayout
are contained within rectangle
GraphElementAccessor.getVertices(edu.uci.ics.jung.algorithms.layout.Layout, java.awt.Shape)
Copyright © 2015. All rights reserved.