API Docs for:
Show:

ixholon Class

Defined in: XholonJsApi.js:469
Module: XholonJsApi

These methods apply to individual IXholon nodes in the Xholon application. A Xholon is a node within a hierarchical tree structure, and builds on the capabilities of tree nodes. A tree node is a node in a tree. It has one parent (none if it's the root), and may have one or more children, and one or more siblings. A Xholon is both a whole, and a part of some other Xholon, at the same time. A Xholon is an instance of a IXholonClass. A Xholon can be an active object, a passive object, a container, or any combination of these three, as defined by its IXholonClass.

Constructor

ixholon

()

Defined in XholonJsApi.js:469

Methods

_id

(
  • an
)

Defined in XholonJsApi.js:807

_id (in general, this is for system use only)

Parameters:

  • an Number

    integer or no param

Returns:

the node's current id, or the node itself

action

(
  • action
)
IXholon chainable

Defined in XholonJsApi.js:1152

Do a specific action that this xholon knows how to do.

Parameters:

  • action String

    The name of a specific action.

Returns:

IXholon:

this

Example:

node.action("Do your thing");

actions

() String

Defined in XholonJsApi.js:1140

Get a list of actions that this xholon can do. These actions can be presented to users in a GUI, or used for other purposes.

Returns:

String:

A list of actions, or null.

Example:

console.log(node.actions());

after

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:716

Insert a node after this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.after(otherNode.remove());
node.after('<One/>');
node.after('<One><Two roleName="subtreeNode"/></One>');

anno

(
  • [annotation]
)
String chainable

Defined in XholonJsApi.js:941

Get or set the contents of the annotation for this Xholon. The annotation is intended to be read by a human user.

Parameters:

  • [annotation] String optional

    Some text.

Returns:

String:

Some text, or null. Or {IXholon} this

Example:

console.log(node.anno());
node.anno("Here is my new description of the current node.");
console.log(node.anno());

append

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:602

Append a node as the last child of this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.append(otherNode.remove());
node.append('<One/>');
node.append('<One><Two roleName="subtreeNode"/></One>');

appendTo

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:626

Append this node as the last child of its new parent node.

Parameters:

  • target IXholon

    New parent of this node.

Returns:

IXholon:

this

Example:

node.remove().appendTo(target);

arrayify

() IXholon

Defined in XholonJsApi.js:1710

arrayify

Returns:

IXholon:

this

Example:

console.log($wnd.xh.root().first().first().next().arrayify());

attr

(
  • attrName
  • [attrVal]
)
String | IXholon chainable

Defined in XholonJsApi.js:1293

Get or set the value of an attribute. setter ex: root.attr("State", "9"); setter ex: root.attr("State", 17); getter ex: Number(root.attr("state")) + 11;

Parameters:

  • attrName String

    An attribute name.

  • [attrVal] String optional

    An attribute value.

Returns:

String | IXholon:

An attribute value, or null, or this.

Example:

console.log(node.attr("myAttr"));
node.attr("myAttr", "myAttrVal");
console.log(node.attr("myAttr"));

attrs

(
  • returnAll
)
Object[]

Defined in XholonJsApi.js:1336

Get all app-specific attributes.

Parameters:

  • returnAll Boolean

    Whether to return just the app-specific attributes (false), or also the attributes of base superclasses (true).

Returns:

Object[]:

Example:

console.log(node.attrs(false));

attrz

(
  • javaAttrs
  • jsAttrs
  • returnAll
  • noDollar
)

Defined in XholonJsApi.js:1352

Get attributes. usage: xh.root().attrz(false, true, false, true); example of returned Object: {first_: "Bob", last_: "Bo"}

Parameters:

  • javaAttrs Boolean
  • jsAttrs Boolean
  • returnAll Boolean
  • noDollar Boolean

before

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:678

Insert a node before this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.before(otherNode.remove());
node.before('<One/>');
node.before('<One><Two roleName="subtreeNode"/></One>');

bool

(
  • [val]
)
Boolean chainable

Defined in XholonJsApi.js:1047

Get or set the value of a boolean maintained by this xholon instance.

Parameters:

  • [val] Boolean optional

    Some text.

Returns:

Boolean:

Some text, or null. Or {IXholon} this

Example:

console.log(node.bool());
node.bool(true);
console.log(node.bool());

btleft

() IXholon

Defined in XholonJsApi.js:554

Binary Tree left.

Returns:

IXholon:

a node

Example:

console.log(node.btleft());
console.log(temp0.btleft().name()); // cellBilayer_5

btparent

() IXholon

Defined in XholonJsApi.js:541

Binary Tree parent.

Returns:

IXholon:

a node

Example:

console.log(node.btparent());
console.log(temp0.btparent().name()); // eukaryoticCell_3

btright

() IXholon

Defined in XholonJsApi.js:567

Binary Tree right.

Returns:

IXholon:

a node

Example:

console.log(node.btright());
console.log(temp0.btright().name()); // cytoplasm_6

cache

(
  • destination
)
IXholon

Defined in XholonJsApi.js:1789

cache - move children to an array 2 possibilities: (1) move children to this.arrayify() (2) move children to a new array called ccache TODO Avatar can crash the page if it tries to exit from a cache; it retains its contextNode

Parameters:

  • destination IXholon

Returns:

IXholon:

this

Example:

var childarr = xh.root().cache();

call

(
  • signal
  • data
  • sender
  • [index]
)
Object

Defined in XholonJsApi.js:1112

Send a Synchronous message to a receiving IXholon instance.

Parameters:

  • signal Number

    A distinguishing identifier for this message.

  • data Object

    Any data that needs to be sent, or null.

  • sender IXholon

    The sender of the message.

  • [index] Number optional

    The index of a replicated port.

Returns:

Object:

A response message, or null.

Example:

var responseMsg = receiverNode.call(102, "What is 2 + 3 ?", thisNode);
console.log(responseMsg.data);

childrenAsArray

() Array

Defined in XholonJsApi.js:1746

childrenAsArray

Returns:

Array:

Example:

var childarr = xh.root().childrenAsArray();

childrenAsCsv

(
  • nameTemplate
  • separator
)
String

Defined in XholonJsApi.js:1662

childrenAsCsv

Parameters:

  • nameTemplate String
  • separator String

Returns:

String:

csv

Example:

var root = xh.root();
console.log(root.first().childrenAsCsv());
console.log(root.first().childrenAsCsv("R^^^^^","|"));
console.log(root.first().childrenAsCsv("R^^^^^").split(","));
console.log(root.first().childrenAsCsv("R^^^^^").split(",").sort());

classAttr

(
  • attrName
  • attrVal
)
Object

Defined in XholonJsApi.js:1388

Search XholonClass hierarchy (this.xhc() and this.xhc() ancestors) for a named attribute getter and setter

Parameters:

  • attrName String
  • attrVal Object

Returns:

Object:

an attribute value or null

cloneAfter

()

Defined in XholonJsApi.js:776

Clone after.

cloneBefore

()

Defined in XholonJsApi.js:785

Clone before.

cloneFirstChild

()

Defined in XholonJsApi.js:767

Clone first child.

cloneLastChild

() chainable

Defined in XholonJsApi.js:754

Clone current node including its entire subtree, as this current node's new last child.

Returns:

the current node

Example:

console.log(node.cloneLastChild().last().name()); // 

color

(
  • val
)
String

Defined in XholonJsApi.js:1511

color

Parameters:

  • val String

Returns:

String:

color or {IXholon} this

Example:

var color = node.color();
var color = node.xhc().color();
node.color("0x00ff00"); node.color("#ff0000");
node.xhc().color("rgba(0,255,0,0.5)");

dec

(
  • decAmount
)
IXholon chainable

Defined in XholonJsApi.js:1005

Decrement an internal number by a specified amount. This is a convenience method.

Parameters:

  • decAmount Number

    Decrement amount.

Returns:

IXholon:

this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.dec(1111.1111);
console.log(node.val());

first

() IXholon

Defined in XholonJsApi.js:497

Get first (leftmost) child of this node.

Returns:

IXholon:

First child, or null.

Example:

var f = node.first();

font

(
  • val
)
String

Defined in XholonJsApi.js:1548

font

Parameters:

  • val String

Returns:

String:

font or {IXholon} this

format

(
  • val
)
String

Defined in XholonJsApi.js:1614

format

Parameters:

  • val String

Returns:

String:

format or {IXholon} this

geo

(
  • val
)
String

Defined in XholonJsApi.js:1630

geo

Parameters:

  • val String

Returns:

String:

geo or {IXholon} this

hasClass

(
  • className
)
Boolean

Defined in XholonJsApi.js:1377

Report whether or not this node has the specified Xholon class.

Parameters:

  • className String

    The name of a XholonClass (xhc).

Returns:

Boolean:

true if the node's XholonClass (xhc) matches the className, or if any ancestor (superclass) of the xhc matches.

Example:

var x = $wnd.xh.root().first().hasClass("Hello");

hashify

(
  • type
)
String

Defined in XholonJsApi.js:1411

Parameters:

  • type String

Returns:

String:

???

Example:

hashify("newick") hashify("sxpres") hashify("parenth")

icon

(
  • val
)
String

Defined in XholonJsApi.js:1564

icon

Parameters:

  • val String

Returns:

String:

icon or {IXholon} this

Example:

me.icon("https://github.com/favicon.ico");

id

() Number

Defined in XholonJsApi.js:795

Get ID of this IXholon instance.

Returns:

Number:

An integer ID, unique within this application, that is assigned when the IXholon is created.

Example:

var id = node.id();
console.log("The id for node " + node.toString() + " is " + id);

identity

()

Defined in XholonJsApi.js:823

identity

Returns:

the node's identity (typically just the id)

inc

(
  • incAmount
)
IXholon chainable

Defined in XholonJsApi.js:987

Increment an internal number by a specified amount. This is a convenience method.

Parameters:

  • incAmount Number

    Increment amount.

Returns:

IXholon:

this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.inc(1111.1111);
console.log(node.val());

includes

(
  • targetStr
  • nameTemplate
  • separator
)
Boolean

Defined in XholonJsApi.js:1696

includes

Parameters:

  • targetStr String
  • nameTemplate String
  • separator String

Returns:

Boolean:

true or false

Example:

var bool = node.includes("one,two", "R^^^^^", ",");
var bool = root.first().includes("one,three,two", "R^^^^^", ","); bool // true
var bool = root.first().includes("example,example,example", "^^c^^^", ","); bool // true

insertAfter

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:740

Insert this node after its new previous sibling node.

Parameters:

  • target IXholon

    New previous sibling of this node.

Returns:

IXholon:

this

Example:

node.insertAfter(target);

insertBefore

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:702

Insert this node before its new next sibling node.

Parameters:

  • target IXholon

    New next sibling of this node.

Returns:

IXholon:

this

Example:

node.insertBefore(target);

isAttr

(
  • attrName
)
Boolean

Defined in XholonJsApi.js:1321

Is there an attribute with the specified name.

Parameters:

  • attrName String

    An attribute name.

Returns:

Boolean:

true or false

Example:

console.log(node.isAttr("myAttr"));

javaClassnames

(
  • superclasses
)
String

Defined in XholonJsApi.js:1853

Get Java class name, and optionally all Java superclass names

Parameters:

  • superclasses Boolean

    true or false whether or not to include superclass names

Returns:

String:

comma-separated string ex:
"org.primordion.user.app.helloworldjnlp.XhHelloWorld,org.primordion.xholon.base.XholonWithPorts,org.primordion.xholon.base.Xholon,java.lang.Object"

Example:

$wnd.xh.app().javaClassnames(true).split(",").reverse();

last

() IXholon

Defined in XholonJsApi.js:508

Get last (rightmost) child of this node.

Returns:

IXholon:

Last child, or null.

Example:

var f = node.last();

msg

(
  • signal
  • data
  • sender
  • [index]
)
IXholon chainable

Defined in XholonJsApi.js:1089

Send a message to a receiving IXholon instance.

Parameters:

  • signal Number

    A distinguishing identifier for this message.

  • data Object

    Any data that needs to be sent, or null.

  • sender IXholon

    The sender of the message.

  • [index] Number optional

    The index of a replicated port.

Returns:

IXholon:

this

Example:

receiverNode.msg(101, "This is some data", thisNode);

name

(
  • [template="r:c_i^"]
)
String

Defined in XholonJsApi.js:832

Get name, unique within this application, of this Xholon instance. The name is a concatenation of the IXholonClass name and the Xholon unique ID. The first letter is converted to lowercase, and a "_" is used to separate the name and ID (ex: "helloWorld_123"). If the Xholon instance has a roleName, it is included in front of the other two elements, and separated from the IXholonClass name by a ":" (ex: "helloRole:helloWorld_123").

Parameters:

  • [template="r:c_i^"] String optional

    A fixed length template that specifies what elements are included as part of the name. ex: "r:c_i^" is roleName + ":" + className with first letter lowercase + "_" + id The template fields are in fixed positions, and may have the following values: (1) r include roleName, ^ don't include role name (2) : ^ (3) c className lowercase, C classname lowercase, l local part, L local part (4) _ ^ (5) i include id (6) ^ If an invalid template is input, then the returned name will be in the default format, as defined by the GETNAME_DEFAULT constant. The default format is exactly the same as what would be returned by calling getName() without specifying a template.

Returns:

String:

The default or formatted name of this IXholon instance.

Example:

var name = node.name();
console.log(name);
name = node.name("R^^^^^");
console.log(name);

neighbors

()

Defined in XholonJsApi.js:1286

Return a collection of neighbors.

Returns:

next

() IXholon

Defined in XholonJsApi.js:519

Get next (right) sibling of this node.

Returns:

IXholon:

Next sibling, or null.

Example:

var n = node.next();

numbering

()

Defined in XholonJsApi.js:1902

Get this node's numbering.

Returns:

numChildren

(
  • deep
)

Defined in XholonJsApi.js:1887

Get number of immediate children.

Parameters:

  • deep Boolean

Returns:

obj

(
  • [val]
)
Object chainable

Defined in XholonJsApi.js:1069

Get or set the value of a Object maintained by this xholon instance.

Parameters:

  • [val] Object optional

    An object.

Returns:

Object:

An object. Or {IXholon} this

Example:

var obj = node.obj();

opacity

(
  • val
)
String

Defined in XholonJsApi.js:1532

opacity

Parameters:

  • val String

Returns:

String:

opacity or {IXholon} this

parent

() IXholon

Defined in XholonJsApi.js:486

Get parent of this node.

Returns:

IXholon:

This node's current parent, or null if this is a root node.

Example:

var p = node.parent();

port

(
  • portName
  • [portRef]
)
IXholon chainable

Defined in XholonJsApi.js:1191

Get or set the node referenced by a port with a specified name or index (0-based).

Parameters:

  • portName String | Number

    The name of the port, or the index of the port within this Xholon's port array.

  • [portRef] IXholon optional

    The IXholon instance that can be accessed through this port.

Returns:

IXholon:

A reference to an IXholon instance that can be accessed through this port, or null, or this.

Example:

console.log(node.port("world"));
console.log(node.port(1));
node
  .port(0, nodeA)
  .port(1, nodeB)
  .port("world", nodeC);

portNames

() String

Defined in XholonJsApi.js:1263

Get the names of all ports.

Returns:

String:

A comma-separated list of port names and indexes.

Example:

console.log(node.portNames());

ports

() PortInformation

Defined in XholonJsApi.js:1241

Get all ports as an array.

Returns:

PortInformation:

An array of PortInformation objects, or an empty array.

Example:

console.log(node.ports()[0].obj().reffedNode.toString());

portSpec

() PortInformation

Defined in XholonJsApi.js:1252

Get all ports as an array.

Returns:

PortInformation:

An array of PortInformation objects, or an empty array.

Example:

console.log(node.portSpec()[0].obj().reffedNode.toString());

prepend

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:640

Insert a node as the first child of this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.prepend(otherNode.remove());
node.prepend('<One/>');
node.prepend('<One><Two roleName="subtreeNode"/></One>');

prependTo

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:664

Insert this node as the first child of its new parent node.

Parameters:

  • target IXholon

    New parent of this node.

Returns:

IXholon:

this

Example:

node.remove().prependTo(target);

prev

() IXholon

Defined in XholonJsApi.js:530

Get previous (left) sibling of this node. (may be expensive in processing time)

Returns:

IXholon:

Previous sibling, or null.

Example:

var p = node.prev();

print

(
  • obj
)
IXholon chainable

Defined in XholonJsApi.js:901

Write an object to the out tab.

Parameters:

  • obj Object

    The object to write. Currently, this must be a String.

Returns:

IXholon:

this

Example:

node.print("Hello ");

println

(
  • obj
)
IXholon chainable

Defined in XholonJsApi.js:915

Write an object to the out tab, terminated with an end-of-line.

Parameters:

  • obj Object

    The object to write. Currently, this must be a String.

Returns:

IXholon:

this

Example:

node.println("World");

remove

() IXholon chainable

Defined in XholonJsApi.js:582

Detach this node from its parent and from any siblings. Any siblings are reattached to each other. If there was a previous sibling and a next sibling, these will be attached to each other. If there was only a previous sibling, it's next sibling will now be null. If this node was the parent's firstChild, the parent's firstChild link will be appropriately adjusted. Any children are left intact. The entire subtree is detached.

Returns:

IXholon:

this

Example:

node.remove().appendTo(target);

role

(
  • [roleName]
)
String chainable

Defined in XholonJsApi.js:871

Get or set the name of the role played by this Xholon within a specific context.

Parameters:

  • [roleName] String optional

    An optional string that identifies the role.

Returns:

String:

A name that identifies the role, or null.

Example:

console.log(node.role());
node.role("myNewRole");
console.log(node.role());

select

()

Defined in XholonJsApi.js:1446

select

Returns:

siblingsAsCsv

(
  • nameTemplate
  • separator
)
String

Defined in XholonJsApi.js:1681

siblingsAsCsv

Parameters:

  • nameTemplate String
  • separator String

Returns:

String:

csv

Example:

$wnd.xh.root().first().first().next().siblingsAsCsv("R^^^^^","|").split("|").sort();

sound

(
  • val
)
String

Defined in XholonJsApi.js:1646

sound

Parameters:

  • val String

Returns:

String:

sound or {IXholon} this

subtree

(
  • stName
)

Defined in XholonJsApi.js:1472

subtree

Parameters:

  • stName String

Returns:

subtreeAsArray

() Array

Defined in XholonJsApi.js:1768

subtreeAsArray

Returns:

Array:

Example:

var childarr = xh.root().subtreeAsArray();

subtreez

(
  • stNames
)

Defined in XholonJsApi.js:1456

subtreez function name uses "z" instead of "s", so it doesn't conflict with the "subtrees" attribute

Parameters:

  • stNames String

Returns:

symbol

(
  • val
)
String

Defined in XholonJsApi.js:1598

symbol

Parameters:

  • val String

Returns:

String:

symbol or {IXholon} this

text

(
  • [val]
)
String chainable

Defined in XholonJsApi.js:1023

Get or set the value of a String maintained by this xholon instance. The text is intended to be read and processed by the application, for its own internal purposes.

Parameters:

  • [val] String optional

    Some text.

Returns:

String:

Some text, or null. Or {IXholon} this

Example:

console.log(node.text());
node.val("one,two.three");
console.log(node.text());

tick

(
  • a
)
Object

Defined in XholonJsApi.js:1166

Interact with a node every time step.

Parameters:

  • a Object

    JS Object for the node to process

Returns:

Object:

toolTip

(
  • val
)
String

Defined in XholonJsApi.js:1582

toolTip

Parameters:

  • val String

Returns:

String:

toolTip or {IXholon} this

treeSize

(
  • deep
)
Number

Defined in XholonJsApi.js:1877

Get size of complete subtree including this node.

Parameters:

  • deep Boolean

Returns:

Number:

uid

(
  • uidArg
)
String

Defined in XholonJsApi.js:1489

uid

Parameters:

  • uidArg String

Returns:

String:

uid or {IXholon} this

unarrayify

() IXholon

Defined in XholonJsApi.js:1728

unarrayify - reverse the effect of arrayify()

Returns:

IXholon:

this

Example:

console.log($wnd.xh.root().first().first().next().unarrayify());

uncache

(
  • source
)
IXholon

Defined in XholonJsApi.js:1821

uncache - reverse the effects of cache()

Parameters:

  • source String

    "ccache" or "arrayify"

Returns:

IXholon:

this

val

(
  • [val]
)
Number chainable

Defined in XholonJsApi.js:964

Get or set a numeric value maintained by this xholon instance. If a class that implements this interface does not maintain a numeric value, it should return 0.0

Parameters:

  • [val] Number optional

    A number.

Returns:

Number:

A number. Or {IXholon} this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());

visit

(
  • visitee
)

Defined in XholonJsApi.js:1179

Process a visit, and return a result (true or false). ???

Parameters:

  • visitee Object

Returns:

Example:

// TODO

xhc

() IXholonClass

Defined in XholonJsApi.js:929

Get the IXholonClass to which this Xholon instance is a member.

Returns:

IXholonClass:

The IXholonClass, which is a subclass of IXholon.

Example:

var xhc = node.xhc();
console.log(xhc.name());

xhconsole

() IXholon

Defined in XholonJsApi.js:1429

Open a XholonConsole on a node.

Returns:

IXholon:

an instance of XholonConsole, or null.

Example:

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

xhType

() Number

Defined in XholonJsApi.js:892

Get the node's xh type (1 2 3 4).

Returns:

Number:

1, 2, 3, or 4.

xpath

(
  • expression
)
IXholon

Defined in XholonJsApi.js:1364

Evaluate an XPath 1.0 expression.

Parameters:

  • expression String

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

Returns:

IXholon:

An IXholon node, or null.

Example:

var hello = $wnd.xh.root().first();
var world = hello.xpath("ancestor::HelloWorldSystem/World");