org.graffiti.plugin.view.interactive
Class GraphElementFinder

java.lang.Object
  extended by org.graffiti.plugin.view.interactive.GraphElementFinder

public abstract class GraphElementFinder
extends Object

Subclasses of GraphElementFinder provide methods for detecting GraphElements that lay on the top at a specific position or intersect a specific rectangle. Instances of GraphElementFinder are usually handed out by InteractiveViews on call to InteractiveView.getGraphElementFinder(). On some InteractiveViews, obtaining a GraphElement by its position is most efficiently done during the drawing process. When called via the deferred... methods, GraphElementFinder is free to decide whether the search and the result callback should be performed immediately (before the method returns) or at a more convenient point in time. get... methods always perform searches and return results immediately.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Constructor Summary
GraphElementFinder()
           
 
Method Summary
protected abstract  void addIntersectingEdges(Rectangle2D rectangle, Set<? super Edge> set)
          Adds all Edges intersecting rectangle to set.
protected abstract  void addIntersectingNodes(Rectangle2D rectangle, Set<? super Node> set)
          Adds all Nodes intersecting rectangle to set.
 void deferredEdgeNodeAt(Point2D position, double tolerance, Callback<?,? super Edge> callback)
          The deferred variant of getEdgeAt(Point2D, double).
 void deferredGetBend(Point2D position, Edge edge, double tolerance, Callback<?,String> callback)
          The deferred variant of getBend(Point2D, Edge, double).
 void deferredIsOnShapeBorder(Point2D position, Node node, double tolerance, Callback<?,Boolean> callback)
          The deferred variant of isOnShapeBorder(Point2D, Node, double).
 void deferredTellElementAt(Point2D position, double edgeTolerance, Callback<?,? super GraphElement> callback)
          The deferred variant of getElementAt(Point2D, double).
 void deferredTellIntersectingEdges(Rectangle2D rectangle, Callback<?,? super Set<Edge>> callback)
          The deferred variant of getIntersectingEdges(Rectangle2D).
 void deferredTellIntersectingElements(Rectangle2D rectangle, Callback<?,? super Set<GraphElement>> callback)
          The deferred variant of getIntersectingElements(Rectangle2D).
 void deferredTellIntersectingNodes(Rectangle2D rectangle, Callback<?,? super Set<Node>> callback)
          The deferred variant of getIntersectingNodes(Rectangle2D).
 void deferredTellNodeAt(Point2D position, Callback<?,? super Node> callback)
          The deferred variant of getNodeAt(Point2D).
abstract  String getBend(Point2D position, Edge edge, double tolerance)
          Returns which bend of edge lies near position.
abstract  Edge getEdgeAt(Point2D position, double tolerance)
          Returns the topmost Edge lying near position.
 GraphElement getElementAt(Point2D position, double edgeTolerance)
          Returns the topmost GraphElement lying near position.
 Set<Edge> getIntersectingEdges(Rectangle2D rectangle)
          Returns all Edges intersecting rectangle.
 Set<GraphElement> getIntersectingElements(Rectangle2D rectangle)
          Returns all GraphElements intersecting rectangle.
 Set<Node> getIntersectingNodes(Rectangle2D rectangle)
          Returns all Nodes intersecting rectangle.
abstract  Node getNodeAt(Point2D position)
          Returns the topmost Node lying at position.
abstract  boolean isOnShapeBorder(Point2D position, Node node, double tolerance)
          Decides if position is near the shape border of node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphElementFinder

public GraphElementFinder()
Method Detail

getElementAt

public GraphElement getElementAt(Point2D position,
                                 double edgeTolerance)
Returns the topmost GraphElement lying near position.

Parameters:
position - the logical coordinate where graph elements are searched at.
edgeTolerance - determines how far the edges may be apart from position to be considered. Nodes must be exactly at the position to be returned.
Returns:
the topmost GraphElement lying near position.

getNodeAt

public abstract Node getNodeAt(Point2D position)
Returns the topmost Node lying at position.

Parameters:
position - the logical coordinate where nodes are searched at.
Returns:
the topmost Node lying at position.

getEdgeAt

public abstract Edge getEdgeAt(Point2D position,
                               double tolerance)
Returns the topmost Edge lying near position.

Parameters:
position - the logical coordinate where edges are searched at.
tolerance - determines how far the edges may be apart from position to be considered.
Returns:
the topmost Edge lying near position.

getIntersectingElements

public Set<GraphElement> getIntersectingElements(Rectangle2D rectangle)
Returns all GraphElements intersecting rectangle. The default implementation creates a new HashSet and fills it by calls to addIntersectingNodes(Rectangle2D, Set) and addIntersectingEdges(Rectangle2D, Set).

Parameters:
rectangle - the rectangle that intersects the GraphElements to be returned.
Returns:
all GraphElements intersecting rectangle.

getIntersectingNodes

public Set<Node> getIntersectingNodes(Rectangle2D rectangle)
Returns all Nodes intersecting rectangle. The default implementation creates a new HashSet and fills it by a call to addIntersectingNodes(Rectangle2D, Set).

Parameters:
rectangle - the rectangle that intersects the Nodes to be returned.
Returns:
all Nodes intersecting rectangle.

getIntersectingEdges

public Set<Edge> getIntersectingEdges(Rectangle2D rectangle)
Returns all Edges intersecting rectangle. The default implementation creates a new HashSet and fills it by a call to addIntersectingEdges(Rectangle2D, Set).

Parameters:
rectangle - the rectangle that intersects the Edges to be returned.
Returns:
all Edges intersecting rectangle.

addIntersectingNodes

protected abstract void addIntersectingNodes(Rectangle2D rectangle,
                                             Set<? super Node> set)
Adds all Nodes intersecting rectangle to set.

Parameters:
rectangle - the rectangle which intersects the nodes to be added to set.
set - the set the intersecting nodes are added to.

addIntersectingEdges

protected abstract void addIntersectingEdges(Rectangle2D rectangle,
                                             Set<? super Edge> set)
Adds all Edges intersecting rectangle to set.

Parameters:
rectangle - the rectangle which intersects the edges to be added to set.
set - the set the intersecting edges are added to.

isOnShapeBorder

public abstract boolean isOnShapeBorder(Point2D position,
                                        Node node,
                                        double tolerance)
Decides if position is near the shape border of node. Efficiency hint: Implementors can assume that position lies within the boundary box of the node shape.

Parameters:
position - the tested position in logical coordinates.
node - the node.
tolerance - determines how far position may be apart from shape border for positive result.
Returns:
if position is near the shape border of node.

getBend

public abstract String getBend(Point2D position,
                               Edge edge,
                               double tolerance)
Returns which bend of edge lies near position.

Parameters:
position - the position in logical coordinates the bend is searched at.
edge - the edge whose bends are considered.
tolerance - determines how far a bend may be apart from position to be returned.
Returns:
the bend which lies near position or "" if no bend was found.
See Also:
EdgeGraphicAttribute.getBends()

deferredTellElementAt

public void deferredTellElementAt(Point2D position,
                                  double edgeTolerance,
                                  Callback<?,? super GraphElement> callback)
The deferred variant of getElementAt(Point2D, double). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
position - the position to search at.
edgeTolerance - the tolerance.
callback - is communicated the result.

deferredTellNodeAt

public void deferredTellNodeAt(Point2D position,
                               Callback<?,? super Node> callback)
The deferred variant of getNodeAt(Point2D). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
position - the position to search at.
callback - is communicated the result.

deferredEdgeNodeAt

public void deferredEdgeNodeAt(Point2D position,
                               double tolerance,
                               Callback<?,? super Edge> callback)
The deferred variant of getEdgeAt(Point2D, double). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
position - the position to search at.
callback - is communicated the result.

deferredTellIntersectingElements

public void deferredTellIntersectingElements(Rectangle2D rectangle,
                                             Callback<?,? super Set<GraphElement>> callback)
The deferred variant of getIntersectingElements(Rectangle2D). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
rectangle - the rectangle to search at.
callback - is communicated the result.

deferredTellIntersectingNodes

public void deferredTellIntersectingNodes(Rectangle2D rectangle,
                                          Callback<?,? super Set<Node>> callback)
The deferred variant of getIntersectingNodes(Rectangle2D). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
rectangle - the rectangle to search at.
callback - is communicated the result.

deferredTellIntersectingEdges

public void deferredTellIntersectingEdges(Rectangle2D rectangle,
                                          Callback<?,? super Set<Edge>> callback)
The deferred variant of getIntersectingEdges(Rectangle2D). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
rectangle - the rectangle to search at.
callback - is communicated the result.

deferredIsOnShapeBorder

public void deferredIsOnShapeBorder(Point2D position,
                                    Node node,
                                    double tolerance,
                                    Callback<?,Boolean> callback)
The deferred variant of isOnShapeBorder(Point2D, Node, double). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
position - the position to search at.
node - the node.
tolerance - the tolerance.
callback - is communicated the result.

deferredGetBend

public void deferredGetBend(Point2D position,
                            Edge edge,
                            double tolerance,
                            Callback<?,String> callback)
The deferred variant of getBend(Point2D, Edge, double). The view decides for the most suitable moment to communicate the result. The default implementation calls back before the method returns.

Parameters:
position - the position.
edge - the edge.
tolerance - the tolerance.
callback - is communicated the result.


Generated at 2012-05-30 11:00:36 PM CEST