yfiles.client.tiles.widget.GraphCanvas
Class GraphCanvas

an area for displaying and interacting with a graph. There are some read-only fields which provide information on the current state of the canvas. Some of them can be set in HTML markup or during programmatic widget creation, namely path, nodeEvents, nodeLabelEvents, edgeEvents, edgeLabelEvents and baseURL. Lateron, only the setters like setPath() should be used. Changing the reported events can be done by using setEventTypes() on the HitTest instance returned by getHitTest().

 
All Parent Classes:
dijit._Widget
dijit._Templated
 
Field Summary
 String baseURL
          (read-only) base path for server requests
 Boolean edgeEvents
          (read-only) report edge events
 Boolean edgeLabelEvents
          (read-only) report edge label events
 Number height
          (read-only) the height of the canvas DOM node in pixels
 Number highlightNodeSurroundPixels
          (read-write) the surrounding pixels for a highlighted node (default 10)
 Number mouseWheelScrollFactor
          (read-write) determines the zoom change amount, if the mouse is wheeled (default 1.2)
 Boolean nodeEvents
          (read-only) report node events
 Boolean nodeLabelEvents
          (read-only) report node label events
 Boolean paperEvents
          (read-only) report paper events
 String path
          (read-only) the symbolic name of the graph displayed by the canvas
 Number tileSize
          (read-only) the width and height of the image tiles showing the graph
 Number x
          (read-only) x-coordinate of the upper right corner of the visible area (world coordinates)
 Number y
          (read-only) y-coordinate of the upper right corner of the visible area (world coordinates)
 Number zoom
          (read-only) the current zoom factor
 
Method Summary
  beforeRequest()
          hook for listeners called before a server request
  center(/*Number*/ cX, /*Number*/ cY)
          moves the visible area such that the view coordinates (cX, cY) become the new coordinates of the center of the visible area.
  clear()
          clears the display
  fitContent()
          adjusts the vieport and the zoom level such that the entire graph is displayed in the entire area
  fix()
          disables panning temporarily. This is only useful in "pan" mode.
 Graph getGraph()
          returns the current graph.
 HitTest getHitTest()
          returns the hit test instance used by this graph canvas.
 Object getLastHitInfo()
          returns the last hit info object.
 Object getMousePosition()
          returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields.
 Object getViewCoordinates(/*Number?*/ rawX, /*Number?*/ rawY)
          returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields in view coordinates (pixels).
 Object getWorldCoordinates(/*Number?*/ x, /*Number?*/ y)
          returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields in world coordinates.
  highlight(/*String*/ id)
          highlights the graph element with the given id.
 Boolean isMouseOver()
          returns true, if the mouse is over the canvas.
  onClickEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
          is called for a click event concerning an edge.
  onClickEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a click event concerning an edge label.
  onClickNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
          is called, if the user clicks a node.
  onClickNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a click event concerning a node label.
  onClickPaper(/*Object*/ info, /*Object*/ evt)
          is called for a click event which does not hit any graph element.
  onDblClickEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
          is called for a double click event concerning an edge.
  onDblClickEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a double click event concerning an edge label.
  onDblClickNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
          is called, if the user double clicks a node.
  onDblClickNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a double click event concerning a node label.
  onMouseOutEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse out event concerning an edge.
  onMouseOutEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse out event concerning an edge label.
  onMouseOutNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse out event concerning a node.
  onMouseOutNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse out event concerning a node label.
  onMouseOverEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse over event concerning an edge.
  onMouseOverEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse over event concerning an edge label.
  onMouseOverNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse over event concerning a node.
  onMouseOverNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
          is called for a mouse over event concerning a node label.
  pathSet(/*String*/ path)
          hook for listeners called after setting a path
  pushTiles()
          moves the currently visible tiles to the second layer.
  recalculateTiles(/*Boolean?*/ replaceTiles)
          calculates the tiles for the visible area and loads missing tiles from the server.
  refresh(/*Object?*/ bounds, /*Object?*/ shift, /*Boolean?*/ doNotPushTiles)
          refreshes the display, useful after changes of the graph
  release()
          enables panning again (after a call to fix()).
  requestDone(/*Boolean*/ success)
          hook for listeners called after a server request
  setBaseURL(/*String*/ baseURL)
          sets the base path for server requests (possibly relative to the current page)
  setNoInteractionMode()
          sets the interaction mode to no interaction.
  setPanMode(/*Boolean*/ replaceTiles)
          sets the interaction moode to the "normal" pan mode, where the user can pan the graph.
  setPath(/*String*/ newPath, /*Boolean?*/ reload)
          initializes the canvas for a graph given by a symbolic name, if it is set to a non-empty string.
  setViewPoint(/*Number*/ newX, /*Number*/ newY, /*Boolean?*/ fixOldTiles)
          moves the visible area, such that the view coordinates (newX, newY) become the coordinates of the upper right corner.
  setZoom(/*Number*/ zoom)
          sets the zoom factor to the specified value.
  shift(/*Number*/ dx, /*Number*/ dy, /*Boolean?*/ fixOldTiles)
          shifts the visible area by (dx, dy).
  tileLoaded(/*String*/ tileId)
          hook for listeners called after loading a tile
  unhighlight(/*String*/ id)
          unhighlights the graph elements with the given id.
  unhighlightAll()
          unhighlights all graph elements.
  updateWorldBounds(/*Object*/ newWorldBounds)
          sets new world bounds for this graph canvas.
  viewPortChanged(/*Number*/ x, /*Number*/ y, /*Number*/ width, /*Number*/ height, /*Number*/ zoom)
          hook for listeners called after a viewport change
 
Field Detail

baseURL

/*String*/ baseURL
(read-only) base path for server requests

edgeEvents

/*Boolean*/ edgeEvents
(read-only) report edge events

edgeLabelEvents

/*Boolean*/ edgeLabelEvents
(read-only) report edge label events

height

/*Number*/ height
(read-only) the height of the canvas DOM node in pixels

highlightNodeSurroundPixels

/*Number*/ highlightNodeSurroundPixels
(read-write) the surrounding pixels for a highlighted node (default 10)

mouseWheelScrollFactor

/*Number*/ mouseWheelScrollFactor
(read-write) determines the zoom change amount, if the mouse is wheeled (default 1.2)

nodeEvents

/*Boolean*/ nodeEvents
(read-only) report node events

nodeLabelEvents

/*Boolean*/ nodeLabelEvents
(read-only) report node label events

paperEvents

/*Boolean*/ paperEvents
(read-only) report paper events

path

/*String*/ path
(read-only) the symbolic name of the graph displayed by the canvas

tileSize

/*Number*/ tileSize
(read-only) the width and height of the image tiles showing the graph

x

/*Number*/ x
(read-only) x-coordinate of the upper right corner of the visible area (world coordinates)

y

/*Number*/ y
(read-only) y-coordinate of the upper right corner of the visible area (world coordinates)

zoom

/*Number*/ zoom
(read-only) the current zoom factor
 
Method Detail

beforeRequest

beforeRequest()
hook for listeners called before a server request

center

center(/*Number*/ cX, /*Number*/ cY)
moves the visible area such that the view coordinates (cX, cY) become the new coordinates of the center of the visible area.

clear

clear()
clears the display

fitContent

fitContent()
adjusts the vieport and the zoom level such that the entire graph is displayed in the entire area

fix

fix()
disables panning temporarily. This is only useful in "pan" mode.

getGraph

Graph getGraph()
returns the current graph.

getHitTest

HitTest getHitTest()
returns the hit test instance used by this graph canvas.

getLastHitInfo

Object getLastHitInfo()
returns the last hit info object. Use the static methods of HitTest like getHitId() to examine the details of the hit info.

getMousePosition

Object getMousePosition()
returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields.

getViewCoordinates

Object getViewCoordinates(/*Number?*/ rawX, /*Number?*/ rawY)
returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields in view coordinates (pixels).

getWorldCoordinates

Object getWorldCoordinates(/*Number?*/ x, /*Number?*/ y)
returns the coordinates of the last mouse position over the canvas as an object with "x" and "y" fields in world coordinates.

highlight

highlight(/*String*/ id)
highlights the graph element with the given id.
Parameters:
id - id of a node or edge

isMouseOver

Boolean isMouseOver()
returns true, if the mouse is over the canvas.

onClickEdge

onClickEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
is called for a click event concerning an edge.
Parameters:
edgeId - the id of the edge
info - the hit info
evt - the click event

onClickEdgeLabel

onClickEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a click event concerning an edge label.
Parameters:
edgeLabelId - the id of the edge label
info - the hit info
evt - the click event

onClickNode

onClickNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
is called, if the user clicks a node.
Parameters:
nodeId - the id of the clicked node
info - the hit info
evt - the click event

onClickNodeLabel

onClickNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a click event concerning a node label.
Parameters:
nodeLabelId - the id of the node label
info - the hit info
evt - the click event

onClickPaper

onClickPaper(/*Object*/ info, /*Object*/ evt)
is called for a click event which does not hit any graph element.
Parameters:
info - the hit info
evt - the click event

onDblClickEdge

onDblClickEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
is called for a double click event concerning an edge.
Parameters:
edgeId - the id of the edge
info - the hit info
evt - the double click event

onDblClickEdgeLabel

onDblClickEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a double click event concerning an edge label.
Parameters:
edgeLabelId - the id of the edge label
info - the hit info
evt - the double click event

onDblClickNode

onDblClickNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
is called, if the user double clicks a node.
Parameters:
nodeId - the id of the double clicked node
info - the hit info
evt - the double click event

onDblClickNodeLabel

onDblClickNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a double click event concerning a node label.
Parameters:
nodeLabelId - the id of the node label
info - the hit info
evt - the double click event

onMouseOutEdge

onMouseOutEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
is called for a mouse out event concerning an edge.
Parameters:
edgeId - the id of the edge
info - the hit info
evt - the mouse out event

onMouseOutEdgeLabel

onMouseOutEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a mouse out event concerning an edge label.
Parameters:
edgeLabelId - the id of the edge label
info - the hit info
evt - the mouse out event

onMouseOutNode

onMouseOutNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
is called for a mouse out event concerning a node.
Parameters:
nodeId - the id of the node
info - the hit info
evt - the mouse out event

onMouseOutNodeLabel

onMouseOutNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a mouse out event concerning a node label.
Parameters:
nodeLabelId - the id of the node label
info - the hit info
evt - the mouse out event

onMouseOverEdge

onMouseOverEdge(/*String*/ edgeId, /*Object*/ info, /*Object*/ evt)
is called for a mouse over event concerning an edge.
Parameters:
edgeId - the id of the edge
info - the hit info
evt - the mouse over event

onMouseOverEdgeLabel

onMouseOverEdgeLabel(/*String*/ edgeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a mouse over event concerning an edge label.
Parameters:
edgeLabelId - the id of the edge label
info - the hit info
evt - the mouse over event

onMouseOverNode

onMouseOverNode(/*String*/ nodeId, /*Object*/ info, /*Object*/ evt)
is called for a mouse over event concerning a node.
Parameters:
nodeId - the id of the node
info - the hit info
evt - the mouse over event

onMouseOverNodeLabel

onMouseOverNodeLabel(/*String*/ nodeLabelId, /*Object*/ info, /*Object*/ evt)
is called for a mouse over event concerning a node label.
Parameters:
nodeLabelId - the id of the node label
info - the hit info
evt - the mouse over event

pathSet

pathSet(/*String*/ path)
hook for listeners called after setting a path
Parameters:
path - the symbolic graph name

pushTiles

pushTiles()
moves the currently visible tiles to the second layer. While new tiles are fetched from the server the user sees the tiles on the second layer. The refresh function uses pushTiles. Calling pushTiles directly can be used in situations where the upper layer gets shifted like in the Collapsible Tree demo.

recalculateTiles

recalculateTiles(/*Boolean?*/ replaceTiles)
calculates the tiles for the visible area and loads missing tiles from the server.
Parameters:
replaceTiles - If true, existing tiles are replaced with newly loaded tiles.

refresh

refresh(/*Object?*/ bounds, /*Object?*/ shift, /*Boolean?*/ doNotPushTiles)
refreshes the display, useful after changes of the graph
Parameters:
bounds - optional new world bounds as an object with x, y, width and height attributes
shift - an optional shift for the new tiles, the tiles on the second layer are fixed
doNotPushTiles - the current tiles are pushed to the second layer in a first step, unless this is true

release

release()
enables panning again (after a call to fix()).

requestDone

requestDone(/*Boolean*/ success)
hook for listeners called after a server request
Parameters:
success - whether the request succeeded

setBaseURL

setBaseURL(/*String*/ baseURL)
sets the base path for server requests (possibly relative to the current page)

setNoInteractionMode

setNoInteractionMode()
sets the interaction mode to no interaction. The user cannot pan the graph. This is suitable, if the canvas is used for displaying a graph overview, for example.

setPanMode

setPanMode(/*Boolean*/ replaceTiles)
sets the interaction moode to the "normal" pan mode, where the user can pan the graph. This is opposed to the no interaction mode, which is more suitable, if the canvas is used for displaying a graph overview.

setPath

setPath(/*String*/ newPath, /*Boolean?*/ reload)
initializes the canvas for a graph given by a symbolic name, if it is set to a non-empty string.
Parameters:
newPath - symbolic name of the graph
reload - if true, the graph is reloaded even if it is already cached for the session (default false)

setViewPoint

setViewPoint(/*Number*/ newX, /*Number*/ newY, /*Boolean?*/ fixOldTiles)
moves the visible area, such that the view coordinates (newX, newY) become the coordinates of the upper right corner.

setZoom

setZoom(/*Number*/ zoom)
sets the zoom factor to the specified value. The graph is redrawn with the new zoom factor such that the coordinates of the center of the visible area remain the same.

shift

shift(/*Number*/ dx, /*Number*/ dy, /*Boolean?*/ fixOldTiles)
shifts the visible area by (dx, dy).

tileLoaded

tileLoaded(/*String*/ tileId)
hook for listeners called after loading a tile

unhighlight

unhighlight(/*String*/ id)
unhighlights the graph elements with the given id.
Parameters:
id - id of a node or edge

unhighlightAll

unhighlightAll()
unhighlights all graph elements.

updateWorldBounds

updateWorldBounds(/*Object*/ newWorldBounds)
sets new world bounds for this graph canvas.

viewPortChanged

viewPortChanged(/*Number*/ x, /*Number*/ y, /*Number*/ width, /*Number*/ height, /*Number*/ zoom)
hook for listeners called after a viewport change
Parameters:
x - view coordinate of the left boundary of the visible area
y - view coordinate of the upper boundary of the visible area
width - width of the visible area in pixels
height - height of the visible area in pixels
zoom - zoom factor, view units divided by world units

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