yfiles.client.tiles.Graph
Class Graph

An instance of this class is a client side proxy for a server side graph. It encapsulates the server requests for changing the graph. Most methods which change the graph (createEdge, setLabel, ...) are asynchronous. Therefore, they do not return a result. However, there are a couple of event functions like onCreateEdge or onRemoveFailed. For the query methods getLabel and getBounds it is possible to provide custom event handlers, which are called once the asynchronous server request has finished.

 
Constructor Summary
Graph(/*String?*/ baseURL, /*String?*/ name)
           An instance of this class is a client side proxy for a server side graph.
 
Method Summary
  createEdge(/*String*/ sourceId, /*String*/ targetId, /*Boolean?*/ routeEdge)
          creates a new edge.
  createNode(/*Number*/ x, /*Number*/ y, /*String?*/ type)
          creates a new node.
 String getBaseURL()
          returns the base path for server requests for this graph
  getBounds(/*Object*/ caller, /*Function*/ success, /*Function?*/ failure, /*String?*/ sequenceId)
          gets the bounds of the graph from the server.
  getLabel(/*String*/ id, /*Object*/ caller, /*Function*/ success, /*Function?*/ failure)
          gets the label of the node or node label with the given id.
 String getName()
          returns the symbolic name of this graph.
  load(/*String*/ name, /*Boolean?*/ reload)
          loads the graph with the given symbolic name on the server side.
  moveNodes(/*String[]*/ nodeIds, /*Number*/ x, /*Number*/ y)
          moves the nodes with the given ids by (x,y) in world coordinates.
  onEdgeCreated(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*String*/ sourceId, /*String*/ targetId)
          is called if a new edge was successfully created.
  onEdgeCreationFailed(/*String*/ name, /*String*/ sourceId, /*String*/ targetId)
          is called if the creation of a new edge failed.
  onLabelSet(/*String*/ label, /*String*/ name, /*String*/ id)
          is called if setting the label of the node or node label with the given id succeeded.
  onLabelSetFailed(/*String*/ label, /*String*/ name, /*String*/ id)
          is called if setting the label of the node or node label with the given id failed.
  onLoad(/*String*/ name)
          is called, if the graph with the given symbolic name is successfully loaded on the server side.
  onLoadFailed(/*String*/ name)
          is called, if the graph with the given symbolic name failed on the server side.
  onNodeCreated(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*Number*/ x, /*Number*/ y)
          is called, if a new node was successfully created.
  onNodeCreationFailed(/*String*/ name, /*Number*/ x, /*Number*/ y)
          is called, if the creation of a new node failed.
  onNodesMoveFailed(/*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
          is called if moving the nodes with the given ids by (x,y) in world coordinates failed.
  onNodesMoved(/*Object*/ newBounds, /*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
          is called if moving the nodes with the given ids by (x,y) in world coordinates succeeded.
  onRemove(/*String[]*/ ids, /*Object*/ newBounds, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
          is called if removing all graph elements with the given ids from the graph succeeded.
  onRemoveFailed(/*String[]*/ ids, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
          is called if removing all graph elements with the given ids from the graph failed.
  remove(/*String[]*/ ids)
          removes all graph elements with the given ids from the graph.
  removeAt(/*Number*/ x, /*Number*/ y)
          removes a node or an edge at world coordinates (x,y). At most one element is removed in the order node first, then edge.
  setLabel(/*String*/ id, /*String*/ newLabel)
          sets the label of the node or node label with the given id.
 
Constructor Detail

Graph

Graph(/*String?*/ baseURL, /*String?*/ name)
An instance of this class is a client side proxy for a server side graph. It encapsulates the server requests for changing the graph. Most methods which change the graph (createEdge, setLabel, ...) are asynchronous. Therefore, they do not return a result. However, there are a couple of event functions like onCreateEdge or onRemoveFailed. For the query methods getLabel and getBounds it is possible to provide custom event handlers, which are called once the asynchronous server request has finished.
Parameters:
baseURL - the base path for server requests (possibly relative to the current page, default ".")
name - the symbolic name of the graph
Method Detail

createEdge

createEdge(/*String*/ sourceId, /*String*/ targetId, /*Boolean?*/ routeEdge)
creates a new edge. Source and target node do not need to be part of the same subgraph in the hierarchy.
Parameters:
sourceId - id of the source node for the edge
targetId - id of the target node for the edge
routeEdge - whether to route the new edge

createNode

createNode(/*Number*/ x, /*Number*/ y, /*String?*/ type)
creates a new node.
Parameters:
x - x coordinate of the center of the new node (in world coordinates)
y - y coordinate of the center of the new node (in world coordinates)
type - name of the node realizer to use

getBaseURL

String getBaseURL()
returns the base path for server requests for this graph

getBounds

getBounds(/*Object*/ caller, /*Function*/ success, /*Function?*/ failure, /*String?*/ sequenceId)
gets the bounds of the graph from the server. Since the bounds are fetched from the server this is an asynchronous call. The result is provided by a callback. There is an optional callback for the failure case.
Parameters:
caller - the object for the callback
success - the callback in the success case, which is called with the bounds and the name of the graph
failure - the callback in the failure case, which is called with the name of the graph
sequenceId - if the graph changes and browser caching of GET requests is an issue, providing a sequenceId can be used to prevent a false response from the cache.

getLabel

getLabel(/*String*/ id, /*Object*/ caller, /*Function*/ success, /*Function?*/ failure)
gets the label of the node or node label with the given id. Since the label is fetched from the server this is an asynchronous call. The result is provided by a callback. There is an optional callback for the failure case.
Parameters:
id - if fetching the label from the server fails
caller - the object for the callback
success - the callback in the success case, which is called with the label, the name of the graph and the id once the label has been fetched from the server
failure - the callback in the failure case, which is called with the name of the graph and the

getName

String getName()
returns the symbolic name of this graph.

load

load(/*String*/ name, /*Boolean?*/ reload)
loads the graph with the given symbolic name on the server side.
Parameters:
name - the symbolic name of the graph
reload - forces loading the graph even if it is already cached for the session (default false)

moveNodes

moveNodes(/*String[]*/ nodeIds, /*Number*/ x, /*Number*/ y)
moves the nodes with the given ids by (x,y) in world coordinates.
Parameters:
nodeIds - ids of the nodes to be moved
x - x-component of shift vector in world coordinates
y - y-component of shift vector in world coordinates

onEdgeCreated

onEdgeCreated(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*String*/ sourceId, /*String*/ targetId)
is called if a new edge was successfully created.
Parameters:
id - id of the new edge
newBounds - new bounds of the graph
name - symbolic name of the graph
sourceId - id of the source node for the edge
targetId - id of the target node for the edge

onEdgeCreationFailed

onEdgeCreationFailed(/*String*/ name, /*String*/ sourceId, /*String*/ targetId)
is called if the creation of a new edge failed.
Parameters:
name - symbolic name of the graph
sourceId - id of the source node for the edge
targetId - id of the target node for the edge

onLabelSet

onLabelSet(/*String*/ label, /*String*/ name, /*String*/ id)
is called if setting the label of the node or node label with the given id succeeded.
Parameters:
label - the new label to set
name - symbolic name of the graph
id - the id of a node or a node label

onLabelSetFailed

onLabelSetFailed(/*String*/ label, /*String*/ name, /*String*/ id)
is called if setting the label of the node or node label with the given id failed.
Parameters:
label - the new label to set
name - symbolic name of the graph
id - the id of a node or a node label

onLoad

onLoad(/*String*/ name)
is called, if the graph with the given symbolic name is successfully loaded on the server side.
Parameters:
name - the symbolic name of the graph

onLoadFailed

onLoadFailed(/*String*/ name)
is called, if the graph with the given symbolic name failed on the server side.
Parameters:
name - the symbolic name of the graph

onNodeCreated

onNodeCreated(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*Number*/ x, /*Number*/ y)
is called, if a new node was successfully created.
Parameters:
id - id of the new node
newBounds - new bounds of the graph
name - symbolic name of the graph
x - x coordinate of the center of the new node (in world coordinates)
y - y coordinate of the center of the new node (in world coordinates)

onNodeCreationFailed

onNodeCreationFailed(/*String*/ name, /*Number*/ x, /*Number*/ y)
is called, if the creation of a new node failed.
Parameters:
name - symbolic name of the graph
x - x coordinate of the center of the new node (in world coordinates)
y - y coordinate of the center of the new node (in world coordinates)

onNodesMoveFailed

onNodesMoveFailed(/*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
is called if moving the nodes with the given ids by (x,y) in world coordinates failed.
Parameters:
name - symbolic name of the graph
ids - ids of the nodes to be moved
x - x-component of shift vector in world coordinates
y - y-component of shift vector in world coordinates

onNodesMoved

onNodesMoved(/*Object*/ newBounds, /*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
is called if moving the nodes with the given ids by (x,y) in world coordinates succeeded.
Parameters:
newBounds - new bounds of the graph
name - symbolic name of the graph
ids - ids of the nodes to be moved
x - x-component of shift vector in world coordinates
y - y-component of shift vector in world coordinates

onRemove

onRemove(/*String[]*/ ids, /*Object*/ newBounds, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
is called if removing all graph elements with the given ids from the graph succeeded.
Parameters:
ids - ids of the elements to be removed
newBounds - new bounds of the graph
name - symbolic name of the graph
x - if this call results from an removeAt call, this is the x value given to removeAt, otherwise null
y - if this call results from an removeAt call, this is the y value given to removeAt, otherwise null

onRemoveFailed

onRemoveFailed(/*String[]*/ ids, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
is called if removing all graph elements with the given ids from the graph failed.
Parameters:
ids - ids of the elements to be removed
name - symbolic name of the graph
x - if this call results from an removeAt call, this is the x value given to removeAt, otherwise null
y - if this call results from an removeAt call, this is the y value given to removeAt, otherwise null

remove

remove(/*String[]*/ ids)
removes all graph elements with the given ids from the graph.
Parameters:
ids - ids of the elements to be removed

removeAt

removeAt(/*Number*/ x, /*Number*/ y)
removes a node or an edge at world coordinates (x,y). At most one element is removed in the order node first, then edge.
Parameters:
x - x coordinate in world coordinates
y - y coordinate in world coordinates

setLabel

setLabel(/*String*/ id, /*String*/ newLabel)
sets the label of the node or node label with the given id.
Parameters:
id - the id of a node or a node label
newLabel - the new label to set

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