Search this API

y.view
Class HitInfo

java.lang.Object
  extended by y.view.HitInfo

public class HitInfo
extends java.lang.Object

A class that collects hit information for elements of a Graph2D.

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

The hit test order can be specified by providing an appropriate Iterator for a Graph2D's elements. If no such Iterator is given, the hit test on nodes is performed in the order defined by HierarchyManager.postTraversal() for hierarchically grouped graphs and in the inherent order defined by Graph.nodes() otherwise.

 

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 NPORT
          Type specifier for node ports 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
protected HitInfo()
          Constructs a new HitInfo with no associated hits.
  HitInfo(Graph2D graph, double x, double y, boolean firstHitOnly)
          Deprecated.  
  HitInfo(Graph2D graph, double x, double y, boolean firstHitOnly, int p1, int p2, int p3, int p4, int p5, int p6, int p7)
          Deprecated.  
  HitInfo(Graph2D graph, double x, double y, int type)
          Deprecated.  
  HitInfo(Graph2D graph, double x, double y, int type, boolean firstHitOnly)
          Deprecated.  
  HitInfo(Graph2D graph, java.util.Iterator elements, double x, double y, boolean firstHitOnly)
          Constructs a new HitInfo for the elements of the specified Graph2D.
  HitInfo(Graph2D graph, java.util.Iterator elements, double x, double y, boolean firstHitOnly, int p1, int p2, int p3, int p4, int p5, int p6, int p7)
          Constructs a new HitInfo for the elements of the specified Graph2D.
  HitInfo(Graph2DView view, double x, double y, boolean firstHitOnly)
          Constructs a new HitInfo for the graph elements associated to the specified Graph2DView.
  HitInfo(Graph2DView view, double x, double y, boolean firstHitOnly, int type)
          Constructs a new HitInfo for the graph elements associated to the specified Graph2DView.
  HitInfo(Graph2DView view, double x, double y, boolean firstHitOnly, int p1, int p2, int p3, int p4, int p5, int p6, int p7)
          Constructs a new HitInfo for the graph elements associated to the specified Graph2DView.
protected HitInfo(HitInfo prototype)
          Initializes a new HitInfo as a copy of the specified prototype hit data.
 
Method Summary
protected  void addHitBend(Bend bend)
          Adds the specified Bend as a confirmed hit for this HitInfo.
protected  void addHitEdge(Edge edge)
          Adds the specified Edge as a confirmed hit for this HitInfo.
protected  void addHitEdgeLabel(EdgeLabel label)
          Adds the specified EdgeLabel as a confirmed hit for this HitInfo.
protected  void addHitNode(Node node)
          Adds the specified Node as a confirmed hit for this HitInfo.
protected  void addHitNodeLabel(NodeLabel label)
          Adds the specified NodeLabel as a confirmed hit for this HitInfo.
protected  void addHitNodePort(NodePort port)
          Adds the specified NodePort as a confirmed hit for this HitInfo.
protected  void addHitPort(Port port)
          Adds the specified Port as a confirmed hit for this HitInfo.
 YCursor allHits()
          Returns a cursor that grants access to all hits.
protected  boolean checkHit(Bend bend, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the specified Bend.
protected  boolean checkHit(EdgeLabel el, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the specified EdgeLabel.
protected  boolean checkHit(EdgeRealizer er, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the edge represented by the specified edgeRealizer.
protected  boolean checkHit(NodeLabel nl, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the specified NodeLabel.
protected  boolean checkHit(NodePort port, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the specified NodePort.
protected  boolean checkHit(NodeRealizer nr, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the node represented by the specified NodeRealizer.
protected  boolean checkHit(Port port, double x, double y)
          Determines whether or not the specified coordinates constitute a hit for the specified Port.
 HitInfo cycleHits(Graph2D graph, double x, double y)
          Performs a cyclic shift on all hits and returns the result as a new hit info.
 java.lang.Object getFirstHit()
          Returns the first hit or null if there are no hits.
 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.
 NodePort getHitNodePort()
          Returns the first node port 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 hasHitNodePorts()
          Whether or not a node port was hit.
 boolean hasHitNodes()
          Whether or not a node was hit.
 boolean hasHitPorts()
          Whether or not a port was hit.
 boolean hasHits()
          Returns whether or not something was hit.
 boolean hasMultiHits()
          Returns 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 hitNodePorts()
          Returns a cursor that grants access to all hit node ports.
 YCursor hitNodes()
          Returns a cursor that grants access to all hit nodes.
 YCursor hitPorts()
          Returns a cursor that grants access to all hit ports
 boolean sameHits(HitInfo another)
          Returns true if this hit info contains the same set of hits as another hit info.
 
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(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, 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:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values

ELABEL

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

See Also:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values

EDGE

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

See Also:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values

NODE

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

See Also:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values

NLABEL

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

See Also:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values

NPORT

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

See Also:
HitInfo(Graph2DView, double, double, boolean, int, int, int, int, int, int, int), HitInfo(Graph2D, java.util.Iterator, double, double, boolean, int, int, int, int, int, int, int), Constant Field Values
Constructor Detail

HitInfo

public HitInfo(Graph2D graph,
               double x,
               double y,
               boolean firstHitOnly)
Deprecated. 

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,
               int type)
Deprecated. 

Creates a new HitInfo object for the given graph. The HitInfo takes the given coordinate and collects the graph elements of the specified type that are hit by this coordinate.


HitInfo

public HitInfo(Graph2D graph,
               double x,
               double y,
               int type,
               boolean firstHitOnly)
Deprecated. 

Creates a new HitInfo object for the given graph. The HitInfo takes the given coordinate and collects the graph elements of the specified type 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.


HitInfo

public HitInfo(Graph2D graph,
               double x,
               double y,
               boolean firstHitOnly,
               int p1,
               int p2,
               int p3,
               int p4,
               int p5,
               int p6,
               int p7)
Deprecated. 

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 PORT, BEND, ELABEL, EDGE, NODE, NLABEL. By default the precedence is first ports, then bends, then edge labels, then edges, then nodes, then node labels.


HitInfo

public HitInfo(Graph2DView view,
               double x,
               double y,
               boolean firstHitOnly,
               int type)
Constructs a new HitInfo for the graph elements associated to the specified Graph2DView. If the specified Graph2DView's associated Graph2DRenderer is of type OrderRenderer the lastToFirst method of the OrderRenderer's currently appropriate painting order is used to determine the test order of the graph elements.

Parameters:
view - the Graph2DView whose associated graph elements are tested.
x - the x-coordinate of this hit test.
y - the y-coordinate of this hit test.
firstHitOnly - if true, only the first element hit at the specified coordinates is reported as a hit.
type - the element type to be tested.

HitInfo

public HitInfo(Graph2DView view,
               double x,
               double y,
               boolean firstHitOnly,
               int p1,
               int p2,
               int p3,
               int p4,
               int p5,
               int p6,
               int p7)
Constructs a new HitInfo for the graph elements associated to the specified Graph2DView. If the specified Graph2DView's associated Graph2DRenderer is of type OrderRenderer the lastToFirst method of the OrderRenderer's currently appropriate painting order is used to determine the test order of the graph elements.

Parameters:
view - the Graph2DView whose associated graph elements are tested.
x - the x-coordinate of this hit test.
y - the y-coordinate of this hit test.
firstHitOnly - if true, only the first element hit at the specified coordinates is reported as a hit.
p1 - element type with the highest precedence for this hit test.
p2 - element type with the second highest precedence for this hit test.
p3 - element type with the third highest precedence for this hit test.
p4 - element type with the fourth highest precedence for this hit test.
p5 - element type with the third lowest precedence for this hit test.
p6 - element type with the second lowest precedence for this hit test.
p7 - element type with the lowest precedence for this hit test.

HitInfo

public HitInfo(Graph2DView view,
               double x,
               double y,
               boolean firstHitOnly)
Constructs a new HitInfo for the graph elements associated to the specified Graph2DView. If the specified Graph2DView's associated Graph2DRenderer is of type OrderRenderer the lastToFirst method of the OrderRenderer's currently appropriate painting order is used to determine the test order (and implicit precedence) of the graph elements.

Parameters:
view - the Graph2DView whose associated graph elements are tested.
x - the x-coordinate of this hit test.
y - the y-coordinate of this hit test.
firstHitOnly - if true, only the first element hit at the specified coordinates is reported as a hit.

HitInfo

public HitInfo(Graph2D graph,
               java.util.Iterator elements,
               double x,
               double y,
               boolean firstHitOnly,
               int p1,
               int p2,
               int p3,
               int p4,
               int p5,
               int p6,
               int p7)
Constructs a new HitInfo for the elements of the specified Graph2D. Which elements are tested and in which order is determined by the specified Iterator and the element type precedence arguments p1 to p6.

Parameters:
graph - the Graph2D whose elements are to be tested.
elements - the Iterator used to traverse the graph elements to be tested.
x - the x-coordinate of this hit test.
y - the y-coordinate of this hit test.
firstHitOnly - if true, only the first element hit is reported as a hit; otherwise all hits are reported.
p1 - element type with the highest precedence for this hit test.
p2 - element type with the second highest precedence for this hit test.
p3 - element type with the third highest precedence for this hit test.
p4 - element type with the fourth highest precedence for this hit test.
p5 - element type with the third lowest precedence for this hit test.
p6 - element type with the second lowest precedence for this hit test.
p7 - element type with the lowest precedence for this hit test.

HitInfo

public HitInfo(Graph2D graph,
               java.util.Iterator elements,
               double x,
               double y,
               boolean firstHitOnly)
Constructs a new HitInfo for the elements of the specified Graph2D. Which elements are tested and in which order is determined by the specified Iterator.

Parameters:
graph - the Graph2D whose elements are to be tested.
elements - the Iterator used to traverse the graph elements to be tested.
x - the x-coordinate of this hit test.
y - the y-coordinate of this hit test.
firstHitOnly - if true, only the first element hit is reported as a hit; otherwise all hits are reported.

HitInfo

protected HitInfo()
Constructs a new HitInfo with no associated hits.


HitInfo

protected HitInfo(HitInfo prototype)
Initializes a new HitInfo as a copy of the specified prototype hit data.

Parameters:
prototype - the hit data to copy.
Method Detail

addHitBend

protected void addHitBend(Bend bend)
Adds the specified Bend as a confirmed hit for this HitInfo.

Parameters:
bend - the confirmed hit.

addHitEdge

protected void addHitEdge(Edge edge)
Adds the specified Edge as a confirmed hit for this HitInfo.

Parameters:
edge - the confirmed hit.

addHitEdgeLabel

protected void addHitEdgeLabel(EdgeLabel label)
Adds the specified EdgeLabel as a confirmed hit for this HitInfo.

Parameters:
label - the confirmed hit.

addHitNode

protected void addHitNode(Node node)
Adds the specified Node as a confirmed hit for this HitInfo.

Parameters:
node - the confirmed hit.

addHitNodeLabel

protected void addHitNodeLabel(NodeLabel label)
Adds the specified NodeLabel as a confirmed hit for this HitInfo.

Parameters:
label - the confirmed hit.

addHitPort

protected void addHitPort(Port port)
Adds the specified Port as a confirmed hit for this HitInfo.

Parameters:
port - the confirmed hit.

addHitNodePort

protected void addHitNodePort(NodePort port)
Adds the specified NodePort as a confirmed hit for this HitInfo.

Parameters:
port - the confirmed hit.

checkHit

protected boolean checkHit(NodeRealizer nr,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the node represented by the specified NodeRealizer.

Parameters:
nr - the NodeRealizer representing the node to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the node represented by the specified NodeRealizer is hit; false if it is not.

checkHit

protected boolean checkHit(NodeLabel nl,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the specified NodeLabel.

Parameters:
nl - the NodeLabel to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the specified NodeLabel is hit; false if it is not.

checkHit

protected boolean checkHit(EdgeRealizer er,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the edge represented by the specified edgeRealizer.

Parameters:
er - the edgeRealizer representing the edge to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the edge represented by the specified EdgeRealizer is hit; false if it is not.

checkHit

protected boolean checkHit(EdgeLabel el,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the specified EdgeLabel.

Parameters:
el - the EdgeLabel to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the specified EdgeLabel is hit; false if it is not.

checkHit

protected boolean checkHit(Bend bend,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the specified Bend.

Parameters:
bend - the Bend to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the specified Bend is hit; false if it is not.

checkHit

protected boolean checkHit(Port port,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the specified Port.

Parameters:
port - the Port to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the specified Port is hit; false if it is not.

checkHit

protected boolean checkHit(NodePort port,
                           double x,
                           double y)
Determines whether or not the specified coordinates constitute a hit for the specified NodePort.

Parameters:
port - the NodePort to be checked.
x - the x-coordinate of the hit.
y - the y-coordinate of the hit.
Returns:
true if the specified Port is hit; false if it is not.

hasHits

public boolean hasHits()
Returns whether or not something was hit.


hasMultiHits

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


allHits

public YCursor allHits()
Returns a cursor that grants access to all hits.


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.


hitNodePorts

public YCursor hitNodePorts()
Returns a cursor that grants access to all hit node ports.


getFirstHit

public java.lang.Object getFirstHit()
Returns the first hit or null if there are no hits.


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.


getHitNodePort

public NodePort getHitNodePort()
Returns the first node port that was hit or null if none were hit.


hasHitNodePorts

public boolean hasHitNodePorts()
Whether or not a node port was 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.


cycleHits

public HitInfo cycleHits(Graph2D graph,
                         double x,
                         double y)
Performs a cyclic shift on all hits and returns the result as a new hit info. If this hit info contains less than two elements, this instance is returned. Otherwise the first hit element in allHits() becomes the last element while all other elements retain their order.


sameHits

public boolean sameHits(HitInfo another)
Returns true if this hit info contains the same set of hits as another hit info.

Parameters:
another - another hit info
Returns:
true if this hit info contains the same set of hits as another hit info

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