y.view
Class HitInfo

java.lang.Object
  |
  +--y.view.HitInfo

public class HitInfo
extends Object

A class that collects hit information for a elements contained in a Graph2D.

It can be used in ViewMode objects to initiate a certain behaviour after a certain graph element was hit by a mouse pointer.

This class is aware of hierarchically grouped graphs. The hit test on nodes is performed in the order defined by the HierarchyManager.postTraverse(y.view.hierarchy.HierarchyManager.NodeVisitor) method.


Field Summary
static int BEND
          Type specifier for bends used to declare the order of search precedence.
static int EDGE
          Type specifier for edges used to declare the order of search precedence.
static int ELABEL
          Type specifier for edge labels used to declare the order of search precedence.
static int NLABEL
          Type specifier for node labels used to declare the order of search precedence.
static int NODE
          Type specifier for nodes used to declare the order of search precedence.
static int PORT
          Type specifier for ports used to declare the order of search precedence.
 
Constructor Summary
HitInfo(Graph2D graph, double x, double y, boolean firstHitOnly)
          Creates a new HitInfo object for the given graph.
HitInfo(Graph2D graph, double x, double y, boolean firstHitOnly, int p1, int p2, int p3, int p4, int p5, int p6)
          Creates a new HitInfo object for the given graph.
 
Method Summary
 Bend getHitBend()
          Returns the first bend that was hit or null if none were hit.
 Edge getHitEdge()
          Returns the first edge that was hit or null if none were hit.
 EdgeLabel getHitEdgeLabel()
          Returns the first edge label that was hit or null if none were hit.
 Node getHitNode()
          Returns the first node that was hit or null if none were hit.
 NodeLabel getHitNodeLabel()
          Returns the first node label that was hit or null if none were hit.
 Port getHitPort()
          Returns the first port that was hit or null if none were hit.
 boolean hasHitBends()
          Whether or not a bend was hit.
 boolean hasHitEdgeLabels()
          Whether or not an edge label was hit.
 boolean hasHitEdges()
          Whether or not an edge was hit.
 boolean hasHitNodeLabels()
          Whether or not a node label was hit.
 boolean hasHitNodes()
          Whether or not a node was hit.
 boolean hasHitPorts()
          Whether or not a port was hit.
 boolean hasHits()
          Whether or not something was hit.
 boolean hasMultiHits()
          Whether or not more than one element was hit.
 YCursor hitBends()
          Returns a cursor that grants access to all hit bends.
 YCursor hitEdgeLabels()
          Returns a cursor that grants access to all hit edge labels.
 YCursor hitEdges()
          Returns a cursor that grants access to all hit edges.
 YCursor hitNodeLabels()
          Returns a cursor that grants access to all hit node labels.
 YCursor hitNodes()
          Returns a cursor that grants access to all hit nodes.
 YCursor hitPorts()
          Returns a cursor that grants access to all hit ports
 void setPrecedence(int p1, int p2, int p3, int p4, int p5, int p6)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT

public static final int PORT
Type specifier for ports used to declare the order of search precedence.

See Also:
HitInfo.HitInfo(Graph2D, double, double, boolean, int, int, int, int, int, int), Constant Field Values

BEND

public static final int BEND
Type specifier for bends used to declare the order of search precedence.

See Also:
Constant Field Values

ELABEL

public static final int ELABEL
Type specifier for edge labels used to declare the order of search precedence.

See Also:
Constant Field Values

EDGE

public static final int EDGE
Type specifier for edges used to declare the order of search precedence.

See Also:
Constant Field Values

NODE

public static final int NODE
Type specifier for nodes used to declare the order of search precedence.

See Also:
Constant Field Values

NLABEL

public static final int NLABEL
Type specifier for node labels used to declare the order of search precedence.

See Also:
Constant Field Values
Constructor Detail

HitInfo

public HitInfo(Graph2D graph,
               double x,
               double y,
               boolean firstHitOnly)
Creates a new HitInfo object for the given graph. The HitInfo takes the given coordinate and collects all graph elements that are hit by this coordinate. The value of firstHitOnly determines if the hit test should stop or continue after one element has been hit.

In case firstHitOnly is true, then it is important to know the hit test ordering, which is first ports, then nodes, then bends, then edge labels, then edges, then nodes, then node labels.


HitInfo

public HitInfo(Graph2D graph,
               double x,
               double y,
               boolean firstHitOnly,
               int p1,
               int p2,
               int p3,
               int p4,
               int p5,
               int p6)
Creates a new HitInfo object for the given graph. The HitInfo takes the given coordinate and collects all graph elements that are hit by this coordinate. The value of firstHitOnly determines if the hit test should stop or continue after one element was hit.

In case firstHitOnly is true, then it is important to know the hit test ordering, which can be specified by the parameters p1 to p6 where p1 identifies the objects of highest precedence and p6 the objects of lowest precedence. The parameters p1 to p6 must be a permutation of the type specifiers HitInfo.PORT, HitInfo.BEND, HitInfo.ELABEL, HitInfo.EDGE, HitInfo.NODE, HitInfo.NLABEL. By default the precedence is first ports, then bends, then edge labels, then edges, then nodes, then node labels.

Method Detail

hasHits

public boolean hasHits()
Whether or not something was hit.


hasMultiHits

public boolean hasMultiHits()
Whether or not more than one element was hit.


hitNodes

public YCursor hitNodes()
Returns a cursor that grants access to all hit nodes.


hitBends

public YCursor hitBends()
Returns a cursor that grants access to all hit bends.


hitEdges

public YCursor hitEdges()
Returns a cursor that grants access to all hit edges.


hitPorts

public YCursor hitPorts()
Returns a cursor that grants access to all hit ports


hitNodeLabels

public YCursor hitNodeLabels()
Returns a cursor that grants access to all hit node labels.


hitEdgeLabels

public YCursor hitEdgeLabels()
Returns a cursor that grants access to all hit edge labels.


getHitNode

public Node getHitNode()
Returns the first node that was hit or null if none were hit.


getHitBend

public Bend getHitBend()
Returns the first bend that was hit or null if none were hit.


getHitEdge

public Edge getHitEdge()
Returns the first edge that was hit or null if none were hit.


getHitNodeLabel

public NodeLabel getHitNodeLabel()
Returns the first node label that was hit or null if none were hit.


getHitEdgeLabel

public EdgeLabel getHitEdgeLabel()
Returns the first edge label that was hit or null if none were hit.


getHitPort

public Port getHitPort()
Returns the first port that was hit or null if none were hit.


hasHitPorts

public boolean hasHitPorts()
Whether or not a port was hit.


hasHitEdgeLabels

public boolean hasHitEdgeLabels()
Whether or not an edge label was hit.


hasHitNodeLabels

public boolean hasHitNodeLabels()
Whether or not a node label was hit.


hasHitNodes

public boolean hasHitNodes()
Whether or not a node was hit.


hasHitEdges

public boolean hasHitEdges()
Whether or not an edge was hit.


hasHitBends

public boolean hasHitBends()
Whether or not a bend was hit.


setPrecedence

public void setPrecedence(int p1,
                          int p2,
                          int p3,
                          int p4,
                          int p5,
                          int p6)

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003