edu.uci.ics.jung.visualization.picking
Class ClosestShapePickSupport<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.visualization.picking.ClosestShapePickSupport<V,E>
All Implemented Interfaces:
GraphElementAccessor<V,E>

public class ClosestShapePickSupport<V,E>
extends Object
implements GraphElementAccessor<V,E>

A 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:

Users who want to avoid either of these should use 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.


Field Summary
protected  float pickSize
           
protected  VisualizationServer<V,E> vv
           
 
Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vv

protected VisualizationServer<V,E> vv

pickSize

protected float pickSize
Constructor Detail

ClosestShapePickSupport

public ClosestShapePickSupport(VisualizationServer<V,E> vv,
                               float pickSize)
Creates a ShapePickSupport for the vv VisualizationServer, with the specified pick footprint. The VisualizationServer is used to fetch the current Layout.

Parameters:
vv - source of the current Layout.
pickSize - the size of the pick footprint for line edges

ClosestShapePickSupport

public ClosestShapePickSupport(VisualizationServer<V,E> vv)
Create a ShapePickSupport with the vv VisualizationServer and default pick footprint. The footprint defaults to 2.

Method Detail

getEdge

public E getEdge(Layout<V,E> layout,
                 double x,
                 double y)
Description copied from interface: GraphElementAccessor
Returns an edge which is associated with the location (x,y). This is typically determined with respect to the edge's location as specified by a Layout.

Specified by:
getEdge in interface GraphElementAccessor<V,E>
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 a vertex which is associated with the location (x,y). This is typically determined with respect to the vertex's location as specified by a Layout.

Specified by:
getVertex in interface GraphElementAccessor<V,E>
See Also:
GraphElementAccessor.getVertex(edu.uci.ics.jung.algorithms.layout.Layout, double, double)

getVertices

public Collection<V> getVertices(Layout<V,E> layout,
                                 Shape rectangle)
Description copied from interface: GraphElementAccessor
Returns the vertices contained within rectangle relative to layout.

Specified by:
getVertices in interface GraphElementAccessor<V,E>
See Also:
GraphElementAccessor.getVertices(edu.uci.ics.jung.algorithms.layout.Layout, java.awt.Shape)


Copyright © 2009. All Rights Reserved.