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

java.lang.Object
  extended by edu.uci.ics.jung.visualization.picking.ShapePickSupport<V,E>
All Implemented Interfaces:
GraphElementAccessor<V,E>
Direct Known Subclasses:
LayoutLensShapePickSupport, ViewLensShapePickSupport

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

A GraphElementAccessor that returns elements whose Shape contains the specified pick point or region.

Author:
Tom Nelson

Nested Class Summary
static class ShapePickSupport.Style
          The available picking heuristics:
  • Style.CENTERED: returns the element whose center is closest to the pick point.
  •  
    Field Summary
    protected  float pickSize
               
    protected  ShapePickSupport.Style style
              The current picking heuristic for this instance.
    protected  VisualizationServer<V,E> vv
              The VisualizationServer in which the this instance is being used for picking.
     
    Constructor Summary
    ShapePickSupport(VisualizationServer<V,E> vv)
              Create a ShapePickSupport for the specified VisualizationServer with a default pick footprint.
    ShapePickSupport(VisualizationServer<V,E> vv, float pickSize)
              Creates a ShapePickSupport for the vv VisualizationServer, with the specified pick footprint and the default pick style.
     
    Method Summary
    protected  boolean edgesAreFiltered()
              Quick test to allow optimization of getFilteredEdges().
     E getEdge(Layout<V,E> layout, double x, double y)
              Returns an edge whose shape intersects the 'pickArea' footprint of the passed x,y, coordinates.
    protected  Collection<E> getFilteredEdges(Layout<V,E> layout)
               
    protected  Collection<V> getFilteredVertices(Layout<V,E> layout)
               
     float getPickSize()
              Returns the size of the edge picking area.
     ShapePickSupport.Style getStyle()
              Returns the style of picking used by this instance.
     V getVertex(Layout<V,E> layout, double x, double y)
              Iterates over Vertices, checking to see if x,y is contained in the Vertex's Shape.
     Collection<V> getVertices(Layout<V,E> layout, Shape shape)
              Returns the vertices whose layout coordinates are contained in Shape.
    protected  boolean isEdgeRendered(Context<Graph<V,E>,E> context)
              Returns true if this edge and its endpoints in this graph are all included in the collections of elements to be rendered, and false otherwise.
    protected  boolean isVertexRendered(Context<Graph<V,E>,V> context)
              Returns true if this vertex in this graph is included in the collections of elements to be rendered, and false otherwise.
     void setPickSize(float pickSize)
              Sets the size of the edge picking area.
     void setStyle(ShapePickSupport.Style style)
              Specifies the style of picking to be used by this instance.
    protected  boolean verticesAreFiltered()
              Quick test to allow optimization of getFilteredVertices().
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    pickSize

    protected float pickSize

    vv

    protected VisualizationServer<V,E> vv
    The VisualizationServer in which the this instance is being used for picking. Used to retrieve properties such as the layout, renderer, vertex and edge shapes, and coordinate transformations.


    style

    protected ShapePickSupport.Style style
    The current picking heuristic for this instance. Defaults to CENTERED.

    Constructor Detail

    ShapePickSupport

    public ShapePickSupport(VisualizationServer<V,E> vv,
                            float pickSize)
    Creates a ShapePickSupport for the vv VisualizationServer, with the specified pick footprint and the default pick style. The VisualizationServer is used to access properties of the current visualization (layout, renderer, coordinate transformations, vertex/edge shapes, etc.).

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

    ShapePickSupport

    public ShapePickSupport(VisualizationServer<V,E> vv)
    Create a ShapePickSupport for the specified VisualizationServer with a default pick footprint. of size 2.

    Method Detail

    getStyle

    public ShapePickSupport.Style getStyle()
    Returns the style of picking used by this instance. This specifies which of the elements, among those whose shapes contain the pick point, is returned. The available styles are:

    Returns:
    the style of picking used by this instance

    setStyle

    public void setStyle(ShapePickSupport.Style style)
    Specifies the style of picking to be used by this instance. This specifies which of the elements, among those whose shapes contain the pick point, will be returned. The available styles are:

    Parameters:
    style - the style to set

    getVertex

    public V getVertex(Layout<V,E> layout,
                       double x,
                       double y)
    Iterates over Vertices, checking to see if x,y is contained in the Vertex's Shape. If (x,y) is contained in more than one vertex, use the vertex whose center is closest to the pick point.

    Specified by:
    getVertex in interface GraphElementAccessor<V,E>
    See Also:
    edu.uci.ics.jung.visualization.picking.PickSupport#getVertex(double, double)

    getVertices

    public Collection<V> getVertices(Layout<V,E> layout,
                                     Shape shape)
    Returns the vertices whose layout coordinates are contained in Shape. The shape is in screen coordinates, and the graph vertices are transformed to screen coordinates before they are tested for inclusion.

    Specified by:
    getVertices in interface GraphElementAccessor<V,E>
    Returns:
    the Collection of vertices whose layout coordinates are contained in shape.

    getEdge

    public E getEdge(Layout<V,E> layout,
                     double x,
                     double y)
    Returns an edge whose shape intersects the 'pickArea' footprint of the passed x,y, coordinates.

    Specified by:
    getEdge in interface GraphElementAccessor<V,E>

    getFilteredVertices

    protected Collection<V> getFilteredVertices(Layout<V,E> layout)
    Parameters:
    layout -
    Returns:

    getFilteredEdges

    protected Collection<E> getFilteredEdges(Layout<V,E> layout)
    Parameters:
    layout -
    Returns:

    verticesAreFiltered

    protected boolean verticesAreFiltered()
    Quick test to allow optimization of getFilteredVertices().

    Returns:
    true if there is an active vertex filtering mechanism for this visualization, false otherwise

    edgesAreFiltered

    protected boolean edgesAreFiltered()
    Quick test to allow optimization of getFilteredEdges().

    Returns:
    true if there is an active edge filtering mechanism for this visualization, false otherwise

    isVertexRendered

    protected boolean isVertexRendered(Context<Graph<V,E>,V> context)
    Returns true if this vertex in this graph is included in the collections of elements to be rendered, and false otherwise.

    Parameters:
    context - the vertex and graph to be queried
    Returns:
    true if this vertex is included in the collections of elements to be rendered, false otherwise.

    isEdgeRendered

    protected boolean isEdgeRendered(Context<Graph<V,E>,E> context)
    Returns true if this edge and its endpoints in this graph are all included in the collections of elements to be rendered, and false otherwise.

    Parameters:
    context - the edge and graph to be queried
    Returns:
    true if this edge and its endpoints are all included in the collections of elements to be rendered, false otherwise.

    getPickSize

    public float getPickSize()
    Returns the size of the edge picking area. The picking area is square; the size is specified as the length of one side, in view coordinates.

    Returns:
    the size of the edge picking area

    setPickSize

    public void setPickSize(float pickSize)
    Sets the size of the edge picking area.

    Parameters:
    the - length of one side of the (square) picking area, in view coordinates


    Copyright © 2009. All Rights Reserved.