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.

 
All Parent Classes:
dojo/Evented
 
Constructor Summary
HitTest(String baseURL, String path, yfiles/client/tiles/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.

 yfiles/client/tiles/GraphBounds getBounds(Object hitInfo)           

returns the bounds of the first hit for the given hit info.

 yfiles/client/tiles/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.

 Array getEdgeLabels()           

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each edge label.

 Array getEdges()           

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each edge.

 String getElementType(Object || String hitInfoOrId)           

returns the type of graph element for the first hit of the given hit info or the given id.

 yfiles/client/support/HitInfo getEmptyHitInfo(Number worldX, Number worldY)           

returns an empty hit info structure for the given world coordinates.

 Number 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.

 yfiles/client/support/HitInfo 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.

 Array getNodeLabels()           

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each node label.

 Array getNodes()           

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each nodes.

 yfiles/client/support/HitInfo 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, Number x, Number y)           

sets the coordinates for the given hit info.

  setData(Object hitTestData, Function callback, String baseURL, String path, yfiles/client/tiles/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, yfiles/client/tiles/GraphBounds worldBounds, Function callback)           

changes some parameters for this hit test.

 
Constructor Detail

HitTest

HitTest(String baseURL, String path, yfiles/client/tiles/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

yfiles/client/tiles/GraphBounds getBounds(Object hitInfo)

returns the bounds of the first hit for the given hit info.

Parameters:
hitInfo -

The hit info object whose bounds are requested.


getBoundsForId

yfiles/client/tiles/GraphBounds getBoundsForId(String id)

returns the bounds of the graph element with the given id.

Parameters:
id -

The id of the node, edge, node label or edge label whose bounds are requested.


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.

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.

Parameters:
edgeId -

The edge whose control points are requested.


getDescription

String getDescription(Object hitInfo)

returns the URL of the first hit of the given hit info.

Parameters:
hitInfo -

The hit info object whose description is requested.


getEdgeLabels

Array getEdgeLabels()

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each edge label.


getEdges

Array getEdges()

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each edge.


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.

Parameters:
hitInfoOrId -

Can be either a string or a hit info object. If it is a string, then it is the id of the element whose type is requested.


getEmptyHitInfo

yfiles/client/support/HitInfo getEmptyHitInfo(Number worldX, Number worldY)

returns an empty hit info structure for the given world coordinates.

Parameters:
worldX -

The x world coordinate.

worldY -

The y world coordinate.


getEventMask

Number 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.

Parameters:
hitInfo -

The hit info object whose hit count is requested.


getHitId

String getHitId(Object hitInfo)

returns the id of the first hit for the given hit info or null.

Parameters:
hitInfo -

The hit info object whose first id is requested.


getHitIds

String[] getHitIds(Object hitInfo)

returns an array with all hit ids for the given graph info.

Parameters:
hitInfo -

The hit info object whose ids are requested.


getHitInfo

yfiles/client/support/HitInfo 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


getNodeLabels

Array getNodeLabels()

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each node label.


getNodes

Array getNodes()

returns an array of yfiles/client/support/HitInfoData items that define the hit test information for each nodes.


getOverlaps

yfiles/client/support/HitInfo 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).

Parameters:
x1 -

left side of the rectangle.

y1 -

upper side of the rectangle.

x2 -

right side of the rectangle.

y2 -

lower side of the rectangle.


getUrl

String getUrl(Object hitInfo)

returns the URL of the first hit of the given hit info.

Parameters:
hitInfo -

The hit info object whose url is requested.


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, Number x, Number y)

sets the coordinates for the given hit info.

Parameters:
info -

The hit info object whose coordinates should be set.

x -

The x coordinate of the hit info.

y -

The y coordinate of the hit info.


setData

 setData(Object hitTestData, Function callback, String baseURL, String path, yfiles/client/tiles/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 callback to this function.

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.

Parameters:
sensitivity -

the new 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, yfiles/client/tiles/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-2013 yWorks GmbH. All rights reserved.