ixholon Class
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
()
Item Index
Methods
- _id
- action
- actions
- after
- anno
- append
- appendTo
- arrayify
- attr
- attrs
- attrz
- before
- bool
- btleft
- btparent
- btright
- cache
- call
- childrenAsArray
- childrenAsCsv
- classAttr
- cloneAfter
- cloneBefore
- cloneFirstChild
- cloneLastChild
- color
- dec
- first
- font
- format
- geo
- hasClass
- hashify
- icon
- id
- identity
- inc
- includes
- insertAfter
- insertBefore
- isAttr
- javaClassnames
- last
- links
- msg
- name
- neighbors
- next
- numbering
- numChildren
- obj
- opacity
- parent
- port
- portNames
- ports
- portSpec
- prepend
- prependTo
- prev
- println
- remove
- role
- select
- siblingsAsCsv
- sound
- subtree
- subtreeAsArray
- subtreez
- symbol
- text
- tick
- toolTip
- treeSize
- uid
- unarrayify
- uncache
- val
- visit
- xhc
- xhconsole
- xhType
- xpath
Methods
_id
-
an
_id (in general, this is for system use only)
Parameters:
-
anNumberinteger or no param
Returns:
the node's current id, or the node itself
action
-
action
Do a specific action that this xholon knows how to do.
Parameters:
-
actionStringThe name of a specific action.
Returns:
this
Example:
node.action("Do your thing");
actions
()
String
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:
A list of actions, or null.
Example:
console.log(node.actions());
after
-
content
Insert a node after this node.
Parameters:
-
contentIXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.after(otherNode.remove());
node.after('<One/>');
node.after('<One><Two roleName="subtreeNode"/></One>');
anno
-
[annotation]
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 optionalSome text.
Returns:
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
Append a node as the last child of this node.
Parameters:
-
contentIXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.append(otherNode.remove());
node.append('<One/>');
node.append('<One><Two roleName="subtreeNode"/></One>');
appendTo
-
target
Append this node as the last child of its new parent node.
Parameters:
-
targetIXholonNew parent of this node.
Returns:
this
Example:
node.remove().appendTo(target);
arrayify
()
IXholon
arrayify
Returns:
this
Example:
console.log($wnd.xh.root().first().first().next().arrayify());
attr
-
attrName -
[attrVal]
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:
-
attrNameStringAn attribute name.
-
[attrVal]String optionalAn attribute value.
Returns:
An attribute value, or null, or this.
Example:
console.log(node.attr("myAttr"));
node.attr("myAttr", "myAttrVal");
console.log(node.attr("myAttr"));
attrs
-
returnAll
Get all app-specific attributes.
Parameters:
-
returnAllBooleanWhether to return just the app-specific attributes (false), or also the attributes of base superclasses (true).
Returns:
Example:
console.log(node.attrs(false));
attrz
-
javaAttrs -
jsAttrs -
returnAll -
noDollar
Get attributes. usage: xh.root().attrz(false, true, false, true); example of returned Object: {first_: "Bob", last_: "Bo"}
Parameters:
-
javaAttrsBoolean -
jsAttrsBoolean -
returnAllBoolean -
noDollarBoolean
before
-
content
Insert a node before this node.
Parameters:
-
contentIXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.before(otherNode.remove());
node.before('<One/>');
node.before('<One><Two roleName="subtreeNode"/></One>');
bool
-
[val]
Get or set the value of a boolean maintained by this xholon instance.
Parameters:
-
[val]Boolean optionalSome text.
Returns:
Some text, or null. Or {IXholon} this
Example:
console.log(node.bool());
node.bool(true);
console.log(node.bool());
btleft
()
IXholon
Binary Tree left.
Returns:
a node
Example:
console.log(node.btleft());
console.log(temp0.btleft().name()); // cellBilayer_5
btparent
()
IXholon
Binary Tree parent.
Returns:
a node
Example:
console.log(node.btparent());
console.log(temp0.btparent().name()); // eukaryoticCell_3
btright
()
IXholon
Binary Tree right.
Returns:
a node
Example:
console.log(node.btright());
console.log(temp0.btright().name()); // cytoplasm_6
cache
-
destination
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:
-
destinationIXholon
Returns:
this
Example:
var childarr = xh.root().cache();
call
-
signal -
data -
sender -
[index]
Send a Synchronous message to a receiving IXholon instance.
Parameters:
-
signalNumberA distinguishing identifier for this message.
-
dataObjectAny data that needs to be sent, or null.
-
senderIXholonThe sender of the message.
-
[index]Number optionalThe index of a replicated port.
Returns:
A response message, or null.
Example:
var responseMsg = receiverNode.call(102, "What is 2 + 3 ?", thisNode);
console.log(responseMsg.data);
childrenAsArray
()
Array
childrenAsArray
Returns:
Example:
var childarr = xh.root().childrenAsArray();
childrenAsCsv
-
nameTemplate -
separator
childrenAsCsv
Parameters:
-
nameTemplateString -
separatorString
Returns:
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
Search XholonClass hierarchy (this.xhc() and this.xhc() ancestors) for a named attribute getter and setter
Parameters:
-
attrNameString -
attrValObject
Returns:
an attribute value or null
cloneAfter
()
Clone after.
cloneBefore
()
Clone before.
cloneFirstChild
()
Clone first child.
cloneLastChild
()
chainable
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
color
Parameters:
-
valString
Returns:
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
Decrement an internal number by a specified amount. This is a convenience method.
Parameters:
-
decAmountNumberDecrement amount.
Returns:
this
Example:
console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.dec(1111.1111);
console.log(node.val());
first
()
IXholon
Get first (leftmost) child of this node.
Returns:
First child, or null.
Example:
var f = node.first();
font
-
val
font
Parameters:
-
valString
Returns:
font or {IXholon} this
format
-
val
format
Parameters:
-
valString
Returns:
format or {IXholon} this
geo
-
val
geo
Parameters:
-
valString
Returns:
geo or {IXholon} this
hasClass
-
className
Report whether or not this node has the specified Xholon class.
Parameters:
-
classNameStringThe name of a XholonClass (xhc).
Returns:
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
Parameters:
-
typeString
Returns:
???
Example:
hashify("newick") hashify("sxpres") hashify("parenth")
icon
-
val
icon
Parameters:
-
valString
Returns:
icon or {IXholon} this
Example:
me.icon("https://github.com/favicon.ico");
id
()
Number
Get ID of this IXholon instance.
Returns:
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
()
identity
Returns:
the node's identity (typically just the id)
inc
-
incAmount
Increment an internal number by a specified amount. This is a convenience method.
Parameters:
-
incAmountNumberIncrement amount.
Returns:
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
includes
Parameters:
-
targetStrString -
nameTemplateString -
separatorString
Returns:
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
Insert this node after its new previous sibling node.
Parameters:
-
targetIXholonNew previous sibling of this node.
Returns:
this
Example:
node.insertAfter(target);
insertBefore
-
target
Insert this node before its new next sibling node.
Parameters:
-
targetIXholonNew next sibling of this node.
Returns:
this
Example:
node.insertBefore(target);
isAttr
-
attrName
Is there an attribute with the specified name.
Parameters:
-
attrNameStringAn attribute name.
Returns:
true or false
Example:
console.log(node.isAttr("myAttr"));
javaClassnames
-
superclasses
Get Java class name, and optionally all Java superclass names
Parameters:
-
superclassesBooleantrue or false whether or not to include superclass names
Returns:
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
Get last (rightmost) child of this node.
Returns:
Last child, or null.
Example:
var f = node.last();
links
-
placeGraph -
linkGraph
Use JavaScript to return an array of all links/references from this node to other Xholon nodes.
Parameters:
-
placeGraphBooleanWhether or not to include place-graph links (parent, first, next, xhc, app)
-
linkGraphBooleanWhether or not to include link-graph links (ports, etc.)
Returns:
An array of objects. This is the same format as calling: node.ports()[0].obj();
msg
-
signal -
data -
sender -
[index]
Send a message to a receiving IXholon instance.
Parameters:
-
signalNumberA distinguishing identifier for this message.
-
dataObjectAny data that needs to be sent, or null.
-
senderIXholonThe sender of the message.
-
[index]Number optionalThe index of a replicated port.
Returns:
this
Example:
receiverNode.msg(101, "This is some data", thisNode);
name
-
[template="r:c_i^"]
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 optionalA 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:
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
()
Return a collection of neighbors.
Returns:
next
()
IXholon
Get next (right) sibling of this node.
Returns:
Next sibling, or null.
Example:
var n = node.next();
numbering
()
Get this node's numbering.
Returns:
numChildren
-
deep
Get number of immediate children.
Parameters:
-
deepBoolean
Returns:
obj
-
[val]
Get or set the value of a Object maintained by this xholon instance.
Parameters:
-
[val]Object optionalAn object.
Returns:
An object. Or {IXholon} this
Example:
var obj = node.obj();
opacity
-
val
opacity
Parameters:
-
valString
Returns:
opacity or {IXholon} this
parent
()
IXholon
Get parent of this node.
Returns:
This node's current parent, or null if this is a root node.
Example:
var p = node.parent();
port
-
portName -
[portRef]
Get or set the node referenced by a port with a specified name or index (0-based).
Parameters:
-
portNameString | NumberThe name of the port, or the index of the port within this Xholon's port array.
-
[portRef]IXholon optionalThe IXholon instance that can be accessed through this port.
Returns:
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
Get the names of all ports.
Returns:
A comma-separated list of port names and indexes.
Example:
console.log(node.portNames());
ports
()
PortInformation
Get all ports as an array.
Returns:
An array of PortInformation objects, or an empty array.
Example:
console.log(node.ports()[0].obj().reffedNode.toString());
portSpec
()
PortInformation
Get all ports as an array.
Returns:
An array of PortInformation objects, or an empty array.
Example:
console.log(node.portSpec()[0].obj().reffedNode.toString());
prepend
-
content
Insert a node as the first child of this node.
Parameters:
-
contentIXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.prepend(otherNode.remove());
node.prepend('<One/>');
node.prepend('<One><Two roleName="subtreeNode"/></One>');
prependTo
-
target
Insert this node as the first child of its new parent node.
Parameters:
-
targetIXholonNew parent of this node.
Returns:
this
Example:
node.remove().prependTo(target);
prev
()
IXholon
Get previous (left) sibling of this node. (may be expensive in processing time)
Returns:
Previous sibling, or null.
Example:
var p = node.prev();
print
-
obj
Write an object to the out tab.
Parameters:
-
objObjectThe object to write. Currently, this must be a String.
Returns:
this
Example:
node.print("Hello ");
println
-
obj
Write an object to the out tab, terminated with an end-of-line.
Parameters:
-
objObjectThe object to write. Currently, this must be a String.
Returns:
this
Example:
node.println("World");
remove
()
IXholon
chainable
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:
this
Example:
node.remove().appendTo(target);
role
-
[roleName]
Get or set the name of the role played by this Xholon within a specific context.
Parameters:
-
[roleName]String optionalAn optional string that identifies the role.
Returns:
A name that identifies the role, or null.
Example:
console.log(node.role());
node.role("myNewRole");
console.log(node.role());
select
()
select
Returns:
siblingsAsCsv
-
nameTemplate -
separator
siblingsAsCsv
Parameters:
-
nameTemplateString -
separatorString
Returns:
csv
Example:
$wnd.xh.root().first().first().next().siblingsAsCsv("R^^^^^","|").split("|").sort();
sound
-
val
sound
Parameters:
-
valString
Returns:
sound or {IXholon} this
subtree
-
stName
subtree
Parameters:
-
stNameString
Returns:
subtreeAsArray
()
Array
subtreeAsArray
Returns:
Example:
var childarr = xh.root().subtreeAsArray();
subtreez
-
stNames
subtreez function name uses "z" instead of "s", so it doesn't conflict with the "subtrees" attribute
Parameters:
-
stNamesString
Returns:
symbol
-
val
symbol
Parameters:
-
valString
Returns:
symbol or {IXholon} this
text
-
[val]
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 optionalSome text.
Returns:
Some text, or null. Or {IXholon} this
Example:
console.log(node.text());
node.val("one,two.three");
console.log(node.text());
tick
-
a
Interact with a node every time step.
Parameters:
-
aObjectJS Object for the node to process
Returns:
toolTip
-
val
toolTip
Parameters:
-
valString
Returns:
toolTip or {IXholon} this
treeSize
-
deep
Get size of complete subtree including this node.
Parameters:
-
deepBoolean
Returns:
uid
-
uidArg
uid
Parameters:
-
uidArgString
Returns:
uid or {IXholon} this
unarrayify
()
IXholon
unarrayify - reverse the effect of arrayify()
Returns:
this
Example:
console.log($wnd.xh.root().first().first().next().unarrayify());
uncache
-
source
uncache - reverse the effects of cache()
Parameters:
-
sourceString"ccache" or "arrayify"
Returns:
this
val
-
[val]
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 optionalA number.
Returns:
A number. Or {IXholon} this
Example:
console.log(node.val());
node.val(1234.5678);
console.log(node.val());
visit
-
visitee
Process a visit, and return a result (true or false). ???
Parameters:
-
visiteeObject
Returns:
Example:
// TODO
xhc
()
IXholonClass
Get the IXholonClass to which this Xholon instance is a member.
Returns:
The IXholonClass, which is a subclass of IXholon.
Example:
var xhc = node.xhc();
console.log(xhc.name());
xhconsole
()
IXholon
Open a XholonConsole on a node.
Returns:
an instance of XholonConsole, or null.
Example:
var cons = $wnd.xh.root().xhconsole();
xhType
()
Number
Get the node's xh type (1 2 3 4).
Returns:
1, 2, 3, or 4.
xpath
-
expression
Evaluate an XPath 1.0 expression.
Parameters:
-
expressionStringAn XPath 1.0 String expression (ex: "ancestor::HelloWorldSystem/World");
Returns:
An IXholon node, or null.
Example:
var hello = $wnd.xh.root().first();
var world = hello.xpath("ancestor::HelloWorldSystem/World");
