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 later on 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.
 mixed 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.
  getEventMask()
          returns an integer which encodes the types of elements considered by this hit test.
 String getGraphName()
          returns the symbolic name of the graph.
 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 by means of a server call.
  setCoords(/*Object*/ info, /*float*/ x, /*float*/ y)
          sets the coordinates for the given hit info.
  setData(/*Object*/ hitTestData, /*Function?*/ callback, /*String?*/ baseURL, /*String?*/ path, /*GraphBounds?*/ worldBounds)
          sets new hit test data for this hit test and optionally changes parameters.
  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, /*Function?*/ callback)
          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 later on 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

mixed getControlPoints(/*String*/ edgeId)
returns the path of the edge with the given edgeId as an array of objects with x and y attributes. If there is no hit test info for the given id or the info indicates, that it is not an edge, then null is returned.

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.

getEventMask

getEventMask()
returns an integer which encodes the types of elements considered by this hit test.

getGraphName

String getGraphName()
returns the symbolic name of the graph.

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 by means of a server call.

setCoords

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

setData

setData(/*Object*/ hitTestData, /*Function?*/ callback, /*String?*/ baseURL, /*String?*/ path, /*GraphBounds?*/ worldBounds)
sets new hit test data for this hit test and optionally changes parameters. In order to get new hit test data from the server you can call setGraphParameters or refresh. If new hit test data is already present at the client side in the format delivered by the server, you can call this function instead and optionally also change some of the parameters. The new hit test data is set in any case, even if all parameters (baseURL, path, worldBounds) are null. Only parameters which are not null are changed. Note that although this is a client side operation it is asynchronous. In order to execute code depending on the hit test data being all set, connect to the onNewData event or provide a
Parameters:
hitTestData - an object with hit test data in the same format as the hit test data returned by the server
callback - is called with the new baseURL, path and bounds when setting the the new data is done
baseURL - the base path for server requests
path - the symbolic name of the graph
worldBounds - the bounds for which to answer hit queries in world coordinates

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, /*Function?*/ callback)
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
path - the symbolic name of the graph
worldBounds - the bounds for which to answer hit queries in world coordinates
callback - is called with the new baseURL, path and bounds when setting the parameters and loading new data if necessary is done

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