|
|||||
SUMMARY: FIELD | CONSTR | METHOD| EVENT | DETAIL: FIELD | CONSTR | METHOD| EVENT |
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. In order to identify requests, there is an optional parameter customData, which is passed to the callback when the server response arrives. It is also passed to the error callback.
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, anything customData)
creates a new edge. |
|
createNode(Number x, Number y, String type, anything customData)
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, anything customData)
gets the bounds of the graph from the server. |
|
getLabel(String id, Object caller, Function success, Function failure, anything customData)
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, anything customData)
loads the graph with the given symbolic name on the server side. |
|
moveNodes(String[] nodeIds, Number x, Number y, Boolean routeEdges, anything customData)
moves the nodes with the given ids by (x,y) in world coordinates. |
|
onEdgeCreated(String id, Object newBounds, String name, String sourceId, String targetId, anything customData)
is called if a new edge was successfully created. |
|
onEdgeCreationFailed(String name, String sourceId, String targetId, anything customData)
is called if the creation of a new edge failed. |
|
onLabelSet(String label, String name, String id, anything customData)
is called if setting the label of the node or node label with the given id succeeded. |
|
onLabelSetFailed(String label, String name, String id, anything customData)
is called if setting the label of the node or node label with the given id failed. |
|
onLoad(String name, anything customData)
is called, if the graph with the given symbolic name is successfully loaded on the server side. |
|
onLoadFailed(String name, anything customData)
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, anything customData)
is called, if a new node was successfully created. |
|
onNodeCreationFailed(String name, Number x, Number y, anything customData)
is called, if the creation of a new node failed. |
|
onNodesMoveFailed(String name, String[] ids, Number x, Number y, anything customData)
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, anything customData)
is called if moving the nodes with the given ids by (x,y) in world coordinates succeeded. |
|
onNodesResizeFailed(String name, String[] ids, String mode, Number deltaWidth, Number deltaHeight, anything customData)
is called if resizing nodes failed. |
|
onNodesResized(Object newBounds, String name, String[] ids, String mode, Number deltaWidth, Number deltaHeight, anything customData)
is called if resizing nodes succeeded. |
|
onRemove(String[] ids, Object newBounds, String name, Number x, Number y, anything customData)
is called if removing all graph elements with the given ids from the graph succeeded. |
|
onRemoveFailed(String[] ids, String name, Number x, Number y, anything customData)
is called if removing all graph elements with the given ids from the graph failed. |
|
remove(String[] ids, anything customData)
removes all graph elements with the given ids from the graph. |
|
removeAt(Number x, Number y, anything customData)
removes a node or an edge at world coordinates (x,y). At most one element is removed in the order node first, then edge. |
|
resizeNodes(String[] nodeIds, String mode, Number deltaWidth, deltaHeight deltaHeight, Boolean routeEdges, anything customData)
resizes a set of nodes by given deltas. |
|
setLabel(String id, String newLabel, anything customData)
sets the label of the node or node label with the given id. |
Constructor Detail |
---|
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. In order to identify requests, there is an optional parameter customData, which is passed to the callback when the server response arrives. It is also passed to the error callback.
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, anything customData)
creates a new edge.
Source and target node do not need to be part of the same subgraph in the hierarchy.
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
customData
- is passed to the callback (also in the failure case)
createNode(Number x, Number y, String type, anything customData)
creates a new node.
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
customData
- is passed to the callback (also in the failure case)
String getBaseURL()
returns the base path for server requests for this graph
getBounds(Object caller, Function success, Function failure, String sequenceId, anything customData)
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.
caller
- the object for the callback
success
- the callback in the success case, which is called with the bounds, the name of the graph and the custom data
failure
- the callback in the failure case, which is called with the name of the graph and the custom data
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.
customData
- is passed to the callback (also in the failure case)
getLabel(String id, Object caller, Function success, Function failure, anything customData)
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.
id
- the id of a node or a node label
caller
- the object for the callback
success
- the callback in the success case, which is called with the label, the name of the graph, the id and the custom data 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, the id and the custom data, if fetching the label from the server fails
customData
- is passed to the callback (also in the failure case)
String getName()
returns the symbolic name of this graph.
load(String name, Boolean reload, anything customData)
loads the graph with the given symbolic name on the server side.
name
- the symbolic name of the graph
reload
- forces loading the graph even if it is already cached for the session (default false)
customData
- is passed to the callback (also in the failure case)
moveNodes(String[] nodeIds, Number x, Number y, Boolean routeEdges, anything customData)
moves the nodes with the given ids by (x,y) in world coordinates.
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
routeEdges
- whether to route the affected edges
customData
- is passed to the callback (also in the failure case)
onEdgeCreated(String id, Object newBounds, String name, String sourceId, String targetId, anything customData)
is called if a new edge was successfully created.
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
customData
- custom data from the request
onEdgeCreationFailed(String name, String sourceId, String targetId, anything customData)
is called if the creation of a new edge failed.
name
- symbolic name of the graph
sourceId
- id of the source node for the edge
targetId
- id of the target node for the edge
customData
- custom data from the request
onLabelSet(String label, String name, String id, anything customData)
is called if setting the label of the node or node label with the given id succeeded.
label
- the new label to set
name
- symbolic name of the graph
id
- the id of a node or a node label
customData
- custom data from the request
onLabelSetFailed(String label, String name, String id, anything customData)
is called if setting the label of the node or node label with the given id failed.
label
- the new label to set
name
- symbolic name of the graph
id
- the id of a node or a node label
customData
- custom data from the request
onLoad(String name, anything customData)
is called, if the graph with the given symbolic name is successfully loaded on the server side.
name
- the symbolic name of the graph
customData
- custom data from the request
onLoadFailed(String name, anything customData)
is called, if the graph with the given symbolic name failed on the server side.
name
- the symbolic name of the graph
customData
- custom data from the request
onNodeCreated(String id, Object newBounds, String name, Number x, Number y, anything customData)
is called, if a new node was successfully created.
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)
customData
- custom data from the request
onNodeCreationFailed(String name, Number x, Number y, anything customData)
is called, if the creation of a new node failed.
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)
customData
- custom data from the request
onNodesMoveFailed(String name, String[] ids, Number x, Number y, anything customData)
is called if moving the nodes with the given ids by (x,y) in world coordinates failed.
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
customData
- custom data from the request
onNodesMoved(Object newBounds, String name, String[] ids, Number x, Number y, anything customData)
is called if moving the nodes with the given ids by (x,y) in world coordinates succeeded.
newBounds
- new bounds of the graph
name
- symbolic name of the graph
ids
- ids of the moved nodes
x
- x-component of shift vector in world coordinates
y
- y-component of shift vector in world coordinates
customData
- custom data from the request
onNodesResizeFailed(String name, String[] ids, String mode, Number deltaWidth, Number deltaHeight, anything customData)
is called if resizing nodes failed.
name
- symbolic name of the graph
ids
- ids of the nodes to be resized
mode
- either "NW", "N", "NE", "W", "E", "SW", "S" or "SE"
deltaWidth
- the change of the width (world units)
deltaHeight
- the change of the height (world units)
customData
- custom data from the request
onNodesResized(Object newBounds, String name, String[] ids, String mode, Number deltaWidth, Number deltaHeight, anything customData)
is called if resizing nodes succeeded.
newBounds
- new bounds of the graph
name
- symbolic name of the graph
ids
- ids of the resized nodes
mode
- either "NW", "N", "NE", "W", "E", "SW", "S" or "SE"
deltaWidth
- the change of the width (world units)
deltaHeight
- the change of the height (world units)
customData
- custom data from the request
onRemove(String[] ids, Object newBounds, String name, Number x, Number y, anything customData)
is called if removing all graph elements with the given ids from the graph succeeded.
ids
- ids of the removed elements
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
customData
- custom data from the request
onRemoveFailed(String[] ids, String name, Number x, Number y, anything customData)
is called if removing all graph elements with the given ids from the graph failed.
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
customData
- custom data from the request
remove(String[] ids, anything customData)
removes all graph elements with the given ids from the graph.
ids
- ids of the elements to be removed
customData
- is passed to the callback (also in the failure case)
removeAt(Number x, Number y, anything customData)
removes a node or an edge at world coordinates (x,y). At most one element is removed in the order node first, then edge.
x
- x coordinate in world coordinates
y
- y coordinate in world coordinates
customData
- is passed to the callback (also in the failure case)
resizeNodes(String[] nodeIds, String mode, Number deltaWidth, deltaHeight deltaHeight, Boolean routeEdges, anything customData)
resizes a set of nodes by given deltas.
The size change is specified by the mode and the delta values for width and height. The mode specifies the changing corner or side of the bounding boxes of the resized nodes.
nodeIds
- ids of the nodes to be moved
mode
- either "NW", "N", "NE", "W", "E", "SW", "S" or "SE"
deltaWidth
- the change of the width (world units)
deltaHeight
- the change of the height (world units)
routeEdges
- whether to route the affected edges (default false)
customData
- is passed to the callback (also in the failure case)
setLabel(String id, String newLabel, anything customData)
sets the label of the node or node label with the given id.
id
- the id of a node or a node label
newLabel
- the new label to set
customData
- is passed to the callback (also in the failure case)