API Docs for:
Show:

xh Class

Defined in: XholonJsApi.js:14
Module: XholonJsApi

These methods apply to the top level of the Xholon application. All of the methods in this class MUST be preceeded by "$wnd.xh." (ex: "$wnd.xh.app();") if they are run from within the Xholon application. The "$wnd." is a GWT requirement. They MUST be preceeded by "xh." (ex: "xh.app();") if they are run using a developer's tool such as Firebug or Developer Tools.

Constructor

xh

()

Defined in XholonJsApi.js:14

Methods

app

() IApplication

Defined in XholonJsApi.js:28

Get the single app-specific IApplication instance.

Returns:

IApplication:

An instance of a subclass of org.primordion.xholon.app.Application.

Example:

var app = $wnd.xh.app();

attrs

(
  • node
)

Defined in XholonJsApi.js:50

Log all attribute name/value pairs (JavaScript properties) of a node to the browser console. This is mostly intended for debugging.

Parameters:

  • node IXholon

    An IXholon node.

Example:

var node = $wnd.xh.root();
$wnd.xh.attrs(node);

html.toggle

(
  • elementId
)

Defined in XholonJsApi.js:177

Toggle the visibility of an existing HTML element, typically a div that starts with "xh".

Parameters:

  • elementId String

    An HTML element id.

Example:

$wnd.xh.html.toggle("xhgui");

html.xhElements

() String

Defined in XholonJsApi.js:188

Get an array of top-level "xh" element id's.

Returns:

String:

a comma-delimited list (ex: "xhtop,xhgui,xhappspecific,xhconsole,xhtabs,xhchart,xhcanvas,xhgraph,xhsvg,xhimg").

Example:

$wnd.xh.html.xhElements();

param

(
  • pName
  • [pValue]
)
String

Defined in XholonJsApi.js:110

Get or set the value of an application parameter.

Parameters:

  • pName String

    The name of the parameter.

  • [pValue] String optional

    The value of the parameter.

Returns:

String:

The value of the parameter, or null, or undefined.

Example:

// set the interval between time steps as 200 milliseconds
// show the before and after values in the browser console
console.log($wnd.xh.param("TimeStepInterval"));
$wnd.xh.param("TimeStepInterval", "200");
console.log($wnd.xh.param("TimeStepInterval"));

require

(
  • scriptName
  • [scriptPath]
)

Defined in XholonJsApi.js:145

Require a single named JavaScript library. If the script is located in the Xholon application library, then only the scriptName needs to be provided.

Parameters:

  • scriptName String

    The name of a script.

  • [scriptPath] String optional

    The URL for the script.

Example:

$wnd.xh.require("d3.v2.min.js");
$wnd.xh.require("three.min.js", "http://threejs.org/build/");

root

() IXholon

Defined in XholonJsApi.js:39

Get the app-specific root of the composite structure hierarchy.

Returns:

IXholon:

An instance of a subclass of org.primordion.xholon.base.Xholon.

Example:

var root = $wnd.xh.root();

service

(
  • serviceName
)
IXholon

Defined in XholonJsApi.js:86

Get a Xholon Service.

Parameters:

  • serviceName String

    The name of a service (ex: "TimelineService").

Returns:

IXholon:

An IXholon node, or null.

Example:

var service = $wnd.xh.service("TimelineService");
console.log(service);

services

()

Defined in XholonJsApi.js:99

Display a list of names of services and their activation status, in the out tab.

Example:

$wnd.xh.services();

state

(
  • controllerState
)

Defined in XholonJsApi.js:132

Set controller state. The example below sets the controller state to CS_STEPPING, which causes the app to move forward one timestep, and then go into CS_PAUSE state.

Parameters:

  • controllerState Number

    5 is currently the only useful value.

Example:

$wnd.xh.state(5);

test

()

Defined in XholonJsApi.js:161

Run the Xholon JavaScript API unit tests, using QUnit. The tests are intended to run inside the Furcifer app: http://www.primordion.com/Xholon/gwt/XholonQUnit.html?app=Furcifer&gui=clsc See also the Information page for the Furcifer app (Help > Information).

Example:

$wnd.xh.test();

xpath

(
  • expression
  • node
)
IXholon

Defined in XholonJsApi.js:72

Evaluate an XPath 1.0 expression.

Parameters:

  • expression String

    An XPath 1.0 String expression (ex: "ancestor::HelloWorldSystem/World");

  • node IXholon

    An IXholon node.

Returns:

IXholon:

An IXholon node, or null.

Example:

var node = $wnd.xh.root().first(); // get the Hello node
$wnd.xh.xpath("ancestor::HelloWorldSystem/World", node);

xport

(
  • formatName
  • node
  • [efParams]
)

Defined in XholonJsApi.js:200

Export a node and its subtree to an external format. Because "export" is a JS keyword, we use "xport" instead.

Parameters:

  • formatName String

    The name of an external format (ex: "MindMap").

  • node IXholon

    An IXholon node.

  • [efParams] String optional

    A JSON-formatted string containing one or more key/value pairs. To determine the possible parameters for a given external format, look at the efParams object in each ef source file.

Example:

var root = $wnd.xh.root();
$wnd.xh.xport("MindMap", root);
$wnd.xh.xport("Yaml", root);
$wnd.xh.xport("_other,Newick", root);
$wnd.xh.xport("_xholon,Xhn", root);
$wnd.xh.xport("_d3,CirclePack", root);
$wnd.xh.xport("Graphviz", root, '{"layout":"neato"}');

xports

() Array

Defined in XholonJsApi.js:230

Get an array of external format names.

Returns:

Array:

An array of strings. Example: Csv GraphML Graphviz MindMap Yaml _other,ChapNetwork,ChapTree,Newick _xholon,Cd,Csh,Ih,Xhn _d3,CirclePack

Example:

var root = $wnd.xh.root();
var formatNamesArr = $wnd.xh.xports();
for (var i = 0; i < formatNamesArr.length; i++) {
  root.println(formatNamesArr[i]);
}