public class ShapePickSupport<V,E> extends Object implements GraphElementAccessor<V,E>
GraphElementAccessor
that returns elements whose Shape
contains the specified pick point or region.Modifier and Type | Class and Description |
---|---|
static class |
ShapePickSupport.Style
The available picking heuristics:
Style.CENTERED : returns the element whose
center is closest to the pick point. |
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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)
Returns the vertex, if any, whose shape contains (x, y).
|
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() . |
protected float pickSize
protected VisualizationServer<V,E> vv
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.protected ShapePickSupport.Style style
CENTERED
.public ShapePickSupport(VisualizationServer<V,E> vv, float pickSize)
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.).vv
- source of the current Layout
.pickSize
- the size of the pick footprint for line edgespublic ShapePickSupport(VisualizationServer<V,E> vv)
ShapePickSupport
for the specified
VisualizationServer
with a default pick footprint.
of size 2.vv
- the visualization server used for renderingpublic ShapePickSupport.Style getStyle()
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.)
public void setStyle(ShapePickSupport.Style style)
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.)
style
- the style to setpublic V getVertex(Layout<V,E> layout, double x, double y)
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 pointpublic Collection<V> getVertices(Layout<V,E> layout, Shape shape)
Shape
.
The shape is in screen coordinates, and the graph vertices
are transformed to screen coordinates before they are tested
for inclusion.getVertices
in interface GraphElementAccessor<V,E>
layout
- the layout instance that records the positions for all verticesshape
- the region in which the returned vertices are locatedCollection
of vertices whose layout
coordinates are contained in shape
.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)
protected Collection<V> getFilteredVertices(Layout<V,E> layout)
protected Collection<E> getFilteredEdges(Layout<V,E> layout)
protected boolean verticesAreFiltered()
getFilteredVertices()
.true
if there is an active vertex filtering
mechanism for this visualization, false
otherwiseprotected boolean edgesAreFiltered()
getFilteredEdges()
.true
if there is an active edge filtering
mechanism for this visualization, false
otherwiseprotected boolean isVertexRendered(Context<Graph<V,E>,V> context)
true
if this vertex in this graph is included
in the collections of elements to be rendered, and false
otherwise.context
- the vertex and graph to be queriedtrue
if this vertex is
included in the collections of elements to be rendered, false
otherwise.protected boolean isEdgeRendered(Context<Graph<V,E>,E> context)
true
if this edge and its endpoints
in this graph are all included in the collections of
elements to be rendered, and false
otherwise.context
- the edge and graph to be queriedtrue
if this edge and its endpoints are all
included in the collections of elements to be rendered, false
otherwise.public float getPickSize()
public void setPickSize(float pickSize)
pickSize
- the length of one side of the (square) picking area, in view coordinatesCopyright © 2015. All rights reserved.