|
|||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||
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(/*String?*/ baseURL, /*String?*/ name)
baseURL - the base path for server requests (possibly relative to the current page, default ".")
name - the symbolic name of the graph
| Method Detail |
|---|
createEdge(/*String*/ sourceId, /*String*/ targetId, /*Boolean?*/ routeEdge)
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(/*Number*/ x, /*Number*/ y, /*String?*/ type)
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
String getBaseURL()
getBounds(/*Object*/ caller, /*Function*/ success, /*Function?*/ failure, /*String?*/ sequenceId)
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(/*String*/ id, /*Object*/ caller, /*Function*/ success, /*Function?*/ failure)
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
String getName()
load(/*String*/ name, /*Boolean?*/ reload)
name - the symbolic name of the graph
reload - forces loading the graph even if it is already cached for the session (default false)
moveNodes(/*String[]*/ nodeIds, /*Number*/ x, /*Number*/ y)
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(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*String*/ sourceId, /*String*/ targetId)
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(/*String*/ name, /*String*/ sourceId, /*String*/ targetId)
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(/*String*/ label, /*String*/ name, /*String*/ id)
label - the new label to set
name - symbolic name of the graph
id - the id of a node or a node label
onLabelSetFailed(/*String*/ label, /*String*/ name, /*String*/ id)
label - the new label to set
name - symbolic name of the graph
id - the id of a node or a node label
onLoad(/*String*/ name)
name - the symbolic name of the graph
onLoadFailed(/*String*/ name)
name - the symbolic name of the graph
onNodeCreated(/*String*/ id, /*Object*/ newBounds, /*String*/ name, /*Number*/ x, /*Number*/ y)
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(/*String*/ name, /*Number*/ x, /*Number*/ y)
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(/*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
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(/*Object*/ newBounds, /*String*/ name, /*String[]*/ ids, /*Number*/ x, /*Number*/ y)
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(/*String[]*/ ids, /*Object*/ newBounds, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
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(/*String[]*/ ids, /*String*/ name, /*Number?*/ x, /*Number?*/ y)
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(/*String[]*/ ids)
ids - ids of the elements to be removed
removeAt(/*Number*/ x, /*Number*/ y)
x - x coordinate in world coordinates
y - y coordinate in world coordinates
setLabel(/*String*/ id, /*String*/ newLabel)
id - the id of a node or a node label
newLabel - the new label to set