edu.uci.ics.jung.visualization
Class ShapePickSupport

java.lang.Object
  extended by edu.uci.ics.jung.visualization.ShapePickSupport
All Implemented Interfaces:
GraphElementAccessor, PickSupport

public class ShapePickSupport
extends Object
implements PickSupport

ShapePickSupport provides access to Vertices and Edges based on their actual shapes.

Author:
Tom Nelson - RABA Technologies

Field Summary
protected  HasGraphLayout hasGraphLayout
           
protected  HasShapeFunctions hasShapeFunctions
           
protected  LayoutTransformer layoutTransformer
           
protected  float pickSize
           
 
Constructor Summary
ShapePickSupport()
          Create an instance.
ShapePickSupport(float pickSize)
           
ShapePickSupport(HasGraphLayout hasGraphLayout, LayoutTransformer layoutTransformer, HasShapeFunctions hasShapeFunctions, float pickSize)
          Create an instance.
 
Method Summary
 Edge getEdge(double x, double y)
          return an edge whose shape intersects the 'pickArea' footprint of the passed x,y, coordinates.
 LayoutTransformer getLayoutTransformer()
           
 Vertex getVertex(double x, double y)
          Iterates over Vertices, checking to see if x,y is contained in the Vertex's Shape.
 void setHasGraphLayout(HasGraphLayout hasGraphLayout)
          called by a HasLayout impl (like VisualizationViewer) when this PickSupport impl is added to it.
 void setHasShapes(HasShapeFunctions hasShapes)
           
 void setLayout(Layout layout)
          ShapePickSupport gets its layout from its VisualizationViewer, so this method currently does nothing.
 void setLayoutTransformer(LayoutTransformer layoutTransformer)
          When this PickSupport is set on a VisualizationViewer, the VisualizationViewer calls this method to pass its layout transformer in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasGraphLayout

protected HasGraphLayout hasGraphLayout

hasShapeFunctions

protected HasShapeFunctions hasShapeFunctions

pickSize

protected float pickSize

layoutTransformer

protected LayoutTransformer layoutTransformer
Constructor Detail

ShapePickSupport

public ShapePickSupport(HasGraphLayout hasGraphLayout,
                        LayoutTransformer layoutTransformer,
                        HasShapeFunctions hasShapeFunctions,
                        float pickSize)
Create an instance. The HasGraphLayout is used as the source of the current Graph Layout. The HasShapes is used to access the VertexShapes and the EdgeShapes

Parameters:
hasGraphLayout - source of the current layout.
hasShapeFunctions - source of Vertex and Edge shapes.
pickSize - how large to make the pick footprint for line edges

ShapePickSupport

public ShapePickSupport(float pickSize)

ShapePickSupport

public ShapePickSupport()
Create an instance. The pickSize footprint defaults to 2.

Method Detail

setHasGraphLayout

public void setHasGraphLayout(HasGraphLayout hasGraphLayout)
called by a HasLayout impl (like VisualizationViewer) when this PickSupport impl is added to it. This allows the PickSupport to always get the current Layout and the current Renderer from thecomponent it supports picking on.

Specified by:
setHasGraphLayout in interface PickSupport

setHasShapes

public void setHasShapes(HasShapeFunctions hasShapes)
Parameters:
hasShapes - The hasShapes to set.

getLayoutTransformer

public LayoutTransformer getLayoutTransformer()
Returns:
Returns the layoutTransformer.

setLayoutTransformer

public void setLayoutTransformer(LayoutTransformer layoutTransformer)
When this PickSupport is set on a VisualizationViewer, the VisualizationViewer calls this method to pass its layout transformer in

Parameters:
layoutTransformer - The layoutTransformer to set.

getVertex

public Vertex getVertex(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
See Also:
GraphElementAccessor.getVertex(double, double)

getEdge

public Edge getEdge(double x,
                    double y)
return an edge whose shape intersects the 'pickArea' footprint of the passed x,y, coordinates.

Specified by:
getEdge in interface GraphElementAccessor

setLayout

public void setLayout(Layout layout)
ShapePickSupport gets its layout from its VisualizationViewer, so this method currently does nothing.

Specified by:
setLayout in interface GraphElementAccessor
See Also:
GraphElementAccessor.setLayout(edu.uci.ics.jung.visualization.Layout)