The LzNode class is the ultimate parent of all LZX classes. It defines attributes, methods, and events that are inherited by all LZX objects. Here is the LzNode class’s constructor:
LzNode(parent, args)
Here, parent is the parent of the new LzNode object and args is a collection of attribute name/value pairs that are to be applied to the new object.
The more important child classes of LzNode are shown in Figure 1.7.
These classes will be discussed in Chapter 2 and subsequent chapters.
We will now examine the attributes and methods of the LzNode class. Table 1.1 lists the attributes of the LzNode class. You will use this as a reference, so don’t worry if you do not understand them the first time you read this. For now, bear in mind there are two important attributes that identify an LzNode object: id and name. The id attribute must be unique throughout the application and provides a convenient way of referencing an object. The name attribute must be unique within a context and you must qualify its parents to reference it.
Note
JS in the Usage column in Table 1.1 indicates Javascript.
Here are the methods of the LzNode class
animate(property, to, duration, isRelative, args)
Animates a property. The parameters are as follows.
property. Specifies the property to animate.
to. The end value of the animation.
duration. The duration of the animation in milliseconds.
isRelative. Specifies if the value of the to argument is applied relative to the current value.
args. A dictionary of attributes to pass to the LzAnimator constructor. See Chapter 7, “Animation” for a complete discussion of animation.
applyConstraint(property, cFunction, dep)
Applies a constraint to the specified attribute. The arguments are as follows.
property. The attribute to which this constraint is to be applied.
cFunction. The function that specifies the constraint.
dep. An array of attribute pairs on which the constraint depends.
applyData(data)
Invoked on this LzNode if its datapath matches a terminal selector, such as text() or @attribute when the matching data changes.
childOf(node)
Tests if the specified node is a parent (either direct or indirect) of this node. Returns either true or false.
completeInstantiation()
Ensures this node’s children have been created and this node initialized.
construct(parent, args)
This method is the first method to be called when this LzNode is constructed. If you override this method, you must call super.construct(parent, args).
The arguments are as follows.
parent. The parent of this node, i.e. the node to which to attach this node.
args. A dictionary of attribute name/value pairs used to initialize this node.
createChildren(children)
Instantiates the subnodes. The argument children is an array of children.
dataBindAttribute(attribute, path)
Binds the named attribute to the specified path, relative to this node’s datapath. This method is called when the $path{} constraint is present. The arguments are as follows.
attr. The name of the attribute to bind to the specified path.
path. The xpath to which to bind the attribute.
destroy(recursive)
Deletes the node and all the subnodes. The recursive argument is either true or false and is for internal use only.
determinePlacement(subnode, placement, args)
Returns the immediate parent of the specified subnode, which must be a direct or an indirect child of this node. The arguments are
subnode. The subnode whose immediate parent is to be determined.
placement. The placement attribute for the returned subnode.
args. A dictionary of attribute name/value pairs for the returned subnode.
getAttribute(attribute)
Returns the value of the specified attribute.
getOption(key)
Returns the value of the specified key.
getUID()
Returns this node’s unique identifier.
init()
This method is invoked when the oninit event is raised.
lookupSourceLocator(sourceLocator)
Returns the LzNode that matches the sourceLocator argument. If no match was found, returns undefined.
searchSubnodes(attribute, value)
Returns the subnode that matches the specified attribute and value.
setAttribute(attribute, value)
Assigned the specified value to the specified attribute.
setDatapath(xpath)
Sets the datacontext for the node to the specified xpath.
setID(id)
Assigns the specified identifier to this node.
setName(name)
Sets the name of this node.
setOption(key, value)
Sets the specified key with the specified value.