Class ShapePickSupport<V,E>
java.lang.Object
edu.uci.ics.jung.visualization.picking.ShapePickSupport<V,E>
- All Implemented Interfaces:
GraphElementAccessor<V,E>
- Direct Known Subclasses:
LayoutLensShapePickSupport,ViewLensShapePickSupport
A
GraphElementAccessor that returns elements whose Shape
contains the specified pick point or region.- Author:
- Tom Nelson
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe available picking heuristics:Style.CENTERED: returns the element whose center is closest to the pick point. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatprotected ShapePickSupport.StyleThe current picking heuristic for this instance.protected VisualizationServer<V, E> TheVisualizationServerin which the this instance is being used for picking. -
Constructor Summary
ConstructorsConstructorDescriptionCreate aShapePickSupportfor the specifiedVisualizationServerwith a default pick footprint.ShapePickSupport(VisualizationServer<V, E> vv, float pickSize) Creates aShapePickSupportfor thevvVisualizationServer, with the specified pick footprint and the default pick style. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanQuick test to allow optimization ofgetFilteredEdges().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) floatReturns the size of the edge picking area.getStyle()Returns the style of picking used by this instance.Returns the vertex, if any, whose shape contains (x, y).getVertices(Layout<V, E> layout, Shape shape) Returns the vertices whose layout coordinates are contained inShape.protected booleanReturnstrueif this edge and its endpoints in this graph are all included in the collections of elements to be rendered, andfalseotherwise.protected booleanReturnstrueif this vertex in this graph is included in the collections of elements to be rendered, andfalseotherwise.voidsetPickSize(float pickSize) Sets the size of the edge picking area.voidsetStyle(ShapePickSupport.Style style) Specifies the style of picking to be used by this instance.protected booleanQuick test to allow optimization ofgetFilteredVertices().
-
Field Details
-
pickSize
protected float pickSize -
vv
TheVisualizationServerin 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
The current picking heuristic for this instance. Defaults toCENTERED.
-
-
Constructor Details
-
ShapePickSupport
Creates aShapePickSupportfor thevvVisualizationServer, with the specified pick footprint and the default pick style. TheVisualizationServeris used to access properties of the current visualization (layout, renderer, coordinate transformations, vertex/edge shapes, etc.).- Parameters:
vv- source of the currentLayout.pickSize- the size of the pick footprint for line edges
-
ShapePickSupport
Create aShapePickSupportfor the specifiedVisualizationServerwith a default pick footprint. of size 2.- Parameters:
vv- the visualization server used for rendering
-
-
Method Details
-
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:Style.CENTERED: returns the element whose center is closest to the pick point.Style.LOWEST: returns the first such element encountered. (If the element collection has a consistent ordering, this will also be the element "on the bottom", that is, the one which is rendered first.)Style.HIGHEST: returns the last such element encountered. (If the element collection has a consistent ordering, this will also be the element "on the top", that is, the one which is rendered last.)
- Returns:
- the style of picking used by this instance
-
setStyle
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:Style.CENTERED: returns the element whose center is closest to the pick point.Style.LOWEST: returns the first such element encountered. (If the element collection has a consistent ordering, this will also be the element "on the bottom", that is, the one which is rendered first.)Style.HIGHEST: returns the last such element encountered. (If the element collection has a consistent ordering, this will also be the element "on the top", that is, the one which is rendered last.)
- Parameters:
style- the style to set
-
getVertex
Returns the vertex, if any, whose shape contains (x, y). If (x,y) is contained in more than one vertex's shape, returns the vertex whose center is closest to the pick point.- Specified by:
getVertexin interfaceGraphElementAccessor<V,E> - Parameters:
layout- the layout instance that records the positions for all verticesx- the x coordinate of the pick pointy- the y coordinate of the pick point- Returns:
- the vertex whose shape contains (x,y), and whose center is closest to the pick point
-
getVertices
Returns the vertices whose layout coordinates are contained inShape. The shape is in screen coordinates, and the graph vertices are transformed to screen coordinates before they are tested for inclusion.- Specified by:
getVerticesin interfaceGraphElementAccessor<V,E> - Parameters:
layout- the layout instance that records the positions for all verticesshape- the region in which the returned vertices are located- Returns:
- the
Collectionof vertices whoselayoutcoordinates are contained inshape.
-
getEdge
Returns an edge whose shape intersects the 'pickArea' footprint of the passed x,y, coordinates.- Specified by:
getEdgein interfaceGraphElementAccessor<V,E> - Parameters:
layout- the context in which the location is definedx- the x coordinate of the locationy- the y coordinate of the location- Returns:
- an edge whose shape intersects the pick area centered on the location
(x,y)
-
getFilteredVertices
-
getFilteredEdges
-
verticesAreFiltered
protected boolean verticesAreFiltered()Quick test to allow optimization ofgetFilteredVertices().- Returns:
trueif there is an active vertex filtering mechanism for this visualization,falseotherwise
-
edgesAreFiltered
protected boolean edgesAreFiltered()Quick test to allow optimization ofgetFilteredEdges().- Returns:
trueif there is an active edge filtering mechanism for this visualization,falseotherwise
-
isVertexRendered
Returnstrueif this vertex in this graph is included in the collections of elements to be rendered, andfalseotherwise.- Parameters:
context- the vertex and graph to be queried- Returns:
trueif this vertex is included in the collections of elements to be rendered,falseotherwise.
-
isEdgeRendered
Returnstrueif this edge and its endpoints in this graph are all included in the collections of elements to be rendered, andfalseotherwise.- Parameters:
context- the edge and graph to be queried- Returns:
trueif this edge and its endpoints are all included in the collections of elements to be rendered,falseotherwise.
-
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:
pickSize- the length of one side of the (square) picking area, in view coordinates
-