IBM ILOG Dojo Diagrammer 1.1 API Documentation
Legend: Array Boolean Constructor Date DomNode Error Function Namespace Number Object RegExp Singleton String

ibm_ilog.diagram.graphlayout.WebWorkerLayout

Object » ibm_ilog.diagram.graphlayout._AsynchronousLayout » ibm_ilog.diagram.graphlayout.WebWorkerLayout
dojo.require("ibm_ilog.diagram.graphlayout.WebWorkerLayout");

The WebWorkerLayout class is similar to the ServerSideLayout class, but instead of sending a request to a REST service on a remote server, it executes the graph layout on the client asynchronously using an HTML 5 Web Worker. This class can be used only if the browser supports web workers (which is not the case of Internet Explorer, for example). The main advantage of executing a graph layout in a Web Worker is that the browser UI is not blocked while the layout is executed. On the other hand, executing the layout in a worker thread has a cost, mainly due to the initialization of the worker which must load its own version of Dojo and the graph layout code before the layout can be executed. In addition, the graph topology is sent to the web worker and returned back to the calling thread by serializing the whole graph as a JSON string, which takes some additional time for big graphs. A WebWorkerLayout object is constructed with a Graph object. To execute a layout, the user must select the algorithm with the standard client-side GraphLayout API: graph.setNodeLayout(x); graph.setLinkLayout(y); After this, the WebWorkerLayout object can be used to execute these algorithms in a web worker by calling: webWorkerLayout.layout(); This will obtain the currently configured layouts on the graph object, including optional settings for laying out internal subgraphs, gather their configured parameters and requesting the equivalent layout in the web worker. Each time a layout is requested, the graph and the layout settings are serialized into a JSON object sent in the request. The layout() method returns a dojo.Deferred which is signaled after the execution is complete. The web worker is reused if possible when the same WebWorkerLayout object is called several times on the same graph. The first layout execution will take more time due to the fact that the worker must load Dojo and the graph layout code. Subsequent layout executions will be faster. The WebWorkerLayout class cannot be used if Dojo is loaded from a CDN, so you must have a local copy of Dojo on your web site.

ibm_ilog.diagram.graphlayout._AsynchronousLayout

Property Summary

  • dojoDir The parent directory of dojo/, relative to the ibm_ilog/diagram/graphlayout/webworker/ directory. This will be passed to the Web Worker thread to load Dojo. If not specified, this will be computed from the document URL and the dojo.baseUrl.

Method Summary

  • constructor(graph) Creates and configures an AsynchronousLayout object.
  • isLocalParametersEnabled() returns Boolean Returns 'true' if the local (per node and per link) layout parameters are enabled.
  • isRunning() Returns true if the layout is currently running.
  • layout() returns dojo.Deferred Requests the layout and applies the results.
  • setLocalParametersEnabled(enabled) Sets whether the local (per node and per link) layout parameters are sent to the server-side layout service or to the web worker. enable: Boolean 'true' to enable the local parameters or 'false' to disable it.
  • stop() Stops the execution of the layout.

Attached Objects

Properties

dojoDir
The parent directory of dojo/, relative to the ibm_ilog/diagram/graphlayout/webworker/ directory. This will be passed to the Web Worker thread to load Dojo. If not specified, this will be computed from the document URL and the dojo.baseUrl.

Methods

constructor
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout
Creates and configures an AsynchronousLayout object.
ParameterTypeDescription
graphGraphThe graph to be laid out.
isLocalParametersEnabled
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout
Returns Boolean: 'true' if the local (per node and per link) layout parameters are enabled.
Returns 'true' if the local (per node and per link) layout parameters are enabled.
isRunning
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout
Returns true if the layout is currently running.
layout
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout
Returns dojo.Deferred: a dojo.Deferred to signal when the process finishes.
Requests the layout and applies the results.
setLocalParametersEnabled
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout
Sets whether the local (per node and per link) layout parameters are sent to the server-side layout service or to the web worker. enable: Boolean 'true' to enable the local parameters or 'false' to disable it.
ParameterTypeDescription
enabled
stop
Defined by ibm_ilog.diagram.graphlayout._AsynchronousLayout

If a graph layout is currently running, calling this method will stop the graph layout execution. No result is applied and the graph stays unchanged.