yfiles.client.tiles.HitTest
Class HitTest

This is a client side hit test. The main functions are getHitInfo() and getOverlaps(). Both return a hit info object. There are some "static" methods like yfiles.client.tiles.HitTest.getHitIds() which return specific information contained in a hit info. An instance of this class is initialized for a specific graph a set of interesting graph elements. These parameters can be changed lateron using setEventTypes() and setGraphParameters(). An instance of this class fetches the data for answering hit test queries from the server. Answering the queries is performed on the basis of this data on the client side.

 
Constructor Summary
HitTest(/*String*/ baseURL, /*String*/ path, /*GraphBounds*/ worldBounds, /*Boolean*/ nodeEvents, /*Boolean*/ edgeEvents, /*Boolean*/ nodeLabelEvents, /*Boolean*/ edgeLabelEvents, /*Boolean*/ paperEvents)
           This is a client side hit test.
 
Method Summary
  clear()
          clears the hit test data.
 GraphBounds getBounds(/*Object*/ hitInfo)
          returns the bounds of the first hit for the given hit info.
 GraphBounds getBoundsForId(/*String*/ id)
          returns the bounds of the graph element with the given id.
 Object[] getControlPoints(/*String*/ edgeId)
          returns the path of the edge with the given edgeId as an array of objects with x and y attributes.
 String getDescription(/*Object*/ hitInfo)
          returns the URL of the first hit of the given hit info.
 String getElementType(/*Object || String*/ hitInfoOrId)
          returns the type of graph element for the first hit of the given hit info or the given id.
 Object getEmptyHitInfo(/*Number*/ worldX, /*Number*/ worldY)
          returns an empty hit info structure for the given world coordinates.
 Number getHitCount(/*Object*/ hitInfo)
          returns the number of hits for the given hit info.
 String getHitId(/*Object*/ hitInfo)
          returns the id of the first hit for the given hit info or null.
 String[] getHitIds(/*Object*/ hitInfo)
          returns an array with all hit ids for the given graph info.
 Object getHitInfo(/*Number*/ worldX, /*Number*/ worldY, /*Boolean*/ firstHitOnly)
          returns a hit info structure for the given world coordinates.
 Object getLabelInfo(/*String*/ labelId)
          returns information on the label with the given id.
 Object getOverlaps(/*Number*/ x1, /*Number*/ y1, /*Number*/ x2, /*Number*/ y2)
          returns a hit info structure for the graph elements overlapping the rectangular region with upper left corner (x1,y1) and lower right corner (x2,y2).
 String getUrl(/*Object*/ hitInfo)
          returns the URL of the first hit of the given hit info.
 boolean isActive()
          returns true, if at least one kind of graph elements is marked as relevant (see setEventTypes()).
  onNewData()
          is called, if new hit test data for the current graph has been loaded.
  refresh()
          refreshes the hit test data for the current graph.
  setCoords(/*Object*/ info, /*float*/ x, /*float*/ y)
          sets the coordinates for the given hit info.
  setEdgeTestSensitivity(/*Number*/ sensitivity)
          sets the edge test sensitivity in world units.
  setEventTypes(/*Boolean*/ nodeEvents, /*Boolean*/ edgeEvents, /*Boolean*/ nodeLabelEvents, /*Boolean*/ edgeLabelEvents, /*Boolean*/ paperEvents)
          changes the set of relevant graph elements for this hit test.
  setGraphParameters(/*String?*/ baseURL, /*String?*/ path, /*GraphBounds?*/ worldBounds)
          changes some parameters for this hit test.
 
Constructor Detail

HitTest

HitTest(/*String*/ baseURL, /*String*/ path, /*GraphBounds*/ worldBounds, /*Boolean*/ nodeEvents, /*Boolean*/ edgeEvents, /*Boolean*/ nodeLabelEvents, /*Boolean*/ edgeLabelEvents, /*Boolean*/ paperEvents)
This is a client side hit test. The main functions are getHitInfo() and getOverlaps(). Both return a hit info object. There are some "static" methods like yfiles.client.tiles.HitTest.getHitIds() which return specific information contained in a hit info. An instance of this class is initialized for a specific graph a set of interesting graph elements. These parameters can be changed lateron using setEventTypes() and setGraphParameters(). An instance of this class fetches the data for answering hit test queries from the server. Answering the queries is performed on the basis of this data on the client side.
Parameters:
baseURL - the base path for server requests (possibly relative to the current page, default ".")
path - the symbolic name of the graph
worldBounds - the bounds for which to answer hit queries in world coordinates
nodeEvents - whether nodes are relevant for this hit test
edgeEvents - whether edges are relevant for this hit test
nodeLabelEvents - whether node labels are relevant for this hit test
edgeLabelEvents - whether edge labels are relevant for this hit test
paperEvents - whether paper clicks are relevant for this hit test
Method Detail

clear

clear()
clears the hit test data.

getBounds

GraphBounds getBounds(/*Object*/ hitInfo)
returns the bounds of the first hit for the given hit info.

getBoundsForId

GraphBounds getBoundsForId(/*String*/ id)
returns the bounds of the graph element with the given id.

getControlPoints

Object[] getControlPoints(/*String*/ edgeId)
returns the path of the edge with the given edgeId as an array of objects with x and y attributes.

getDescription

String getDescription(/*Object*/ hitInfo)
returns the URL of the first hit of the given hit info.

getElementType

String getElementType(/*Object || String*/ hitInfoOrId)
returns the type of graph element for the first hit of the given hit info or the given id. This is either 'Node', 'NodeLabel', 'Edge', 'EdgeLabel' or 'Paper'. If the given parameter is null, then null is returned.

getEmptyHitInfo

Object getEmptyHitInfo(/*Number*/ worldX, /*Number*/ worldY)
returns an empty hit info structure for the given world coordinates.

getHitCount

Number getHitCount(/*Object*/ hitInfo)
returns the number of hits for the given hit info.

getHitId

String getHitId(/*Object*/ hitInfo)
returns the id of the first hit for the given hit info or null.

getHitIds

String[] getHitIds(/*Object*/ hitInfo)
returns an array with all hit ids for the given graph info.

getHitInfo

Object getHitInfo(/*Number*/ worldX, /*Number*/ worldY, /*Boolean*/ firstHitOnly)
returns a hit info structure for the given world coordinates.
Parameters:
worldX - x-coordinate of the hit test point in world coordinates
worldY - y-coordinate of the hit test point in world coordinates
firstHitOnly - whether to stop the hit test after the first hit has been found

getLabelInfo

Object getLabelInfo(/*String*/ labelId)
returns information on the label with the given id. For the given id of a node or edge label this function returns an object with an attribute 'mainElementId', which holds the id of the node or edge the label belongs to, and an attribute 'labelIndex', which is the index of the label wrt to its main element. If there is no label for the given id, null is returned. Note that the value for the label index is cached on the client side. If it changes due to additional or deleted labels, this HitTest instance needs to be refresh()ed before it is accurate again.
Parameters:
labelId - the id of a node label or an edge label

getOverlaps

Object getOverlaps(/*Number*/ x1, /*Number*/ y1, /*Number*/ x2, /*Number*/ y2)
returns a hit info structure for the graph elements overlapping the rectangular region with upper left corner (x1,y1) and lower right corner (x2,y2).

getUrl

String getUrl(/*Object*/ hitInfo)
returns the URL of the first hit of the given hit info.

isActive

boolean isActive()
returns true, if at least one kind of graph elements is marked as relevant (see setEventTypes()).

onNewData

onNewData()
is called, if new hit test data for the current graph has been loaded.

refresh

refresh()
refreshes the hit test data for the current graph.

setCoords

setCoords(/*Object*/ info, /*float*/ x, /*float*/ y)
sets the coordinates for the given hit info.

setEdgeTestSensitivity

setEdgeTestSensitivity(/*Number*/ sensitivity)
sets the edge test sensitivity in world units.

setEventTypes

setEventTypes(/*Boolean*/ nodeEvents, /*Boolean*/ edgeEvents, /*Boolean*/ nodeLabelEvents, /*Boolean*/ edgeLabelEvents, /*Boolean*/ paperEvents)
changes the set of relevant graph elements for this hit test.
Parameters:
nodeEvents - whether nodes are relevant for this hit test
edgeEvents - whether edges are relevant for this hit test
nodeLabelEvents - whether node labels are relevant for this hit test
edgeLabelEvents - whether edge labels are relevant for this hit test
paperEvents - whether paper clicks are relevant for this hit test

setGraphParameters

setGraphParameters(/*String?*/ baseURL, /*String?*/ path, /*GraphBounds?*/ worldBounds)
changes some parameters for this hit test. Only parameters which are set are taken into account. If all parameters are unset, the hit test is left unchanged.
Parameters:
baseURL - the base path for server requests (possibly relative to the current page, default ".")
path - the symbolic name of the graph
worldBounds - the bounds for which to answer hit queries in world coordinates

Copyright © 2006-2008 yWorks GmbH. All rights reserved.