Widget is an object from which other GUI objects on this site inherit. This object encapsulates a common set of functionality to be used by other GUI objects.
This is an abstract object that will not be used directly. This page exists to describe the functionality contained within this object.
This number represents the current version for this implementation of the Widget object. This property can be used by scripts to check that the correct version of the object is being used.
constructor - new Widget(x, y);
This method creates a new Widget object.
x is a number that defines the x position of the upper-lefthand corner of the widget
y is a number that defines the y position of the upper-lefthand corner of the widget
init() initialized all properties for this object. Specifically, the x, y, and nodes properties are initialized.
realize() constructs the SVG DOM nodes needed to visualize this widget. Any event listeners that are used by this object will be registered by this method.
svgParentNode is an SVG DOM node. The document fragment built by the realize() method will be appended to this node. A reference to this node is stored in the parent property of the nodes property.
buildSVG() is an abstract method. Sub-classes need to override this method and are responsible for manufacturing and applying an SVG document fragment to the current SVG document.
addEventListeners() is an abstract method. Sub-classes need to override this method and are responsible for attaching all event listeners that are needed to implement the widget's functionality.
textToSVG(text); // returns SVG Document Fragment
textToSVG() converts pSVG to an SVG document fragment.
text is a string of pSVG that is to be converted to an SVG document fragment.
getUserCoordinate(node, x, y); // returns an SVGPoint
getUserCoordinate() converts an x,y value to the local coordinate system used by an SVG DOM node.
node is an SVG DOM node that will be used to establish the target coordinate system.
x is a number that represents the x-coordinate in screen coordinates.
y is a number that represents the y-coordinate in screen coordinates.
getTransformToElement(node); // returns an SVGMatrix
getTransformToElement() calculates the cummulative transformation that is being applied to an SVG DOM node.
node is an SVG DOM node. All transformations that are being applied to this node will be calculated
handleEvent() is an event dispatcher. This method tests whether the current object has a method name that matches the e.type property. If this method exists, then it is called with the e parameter passed to it.
This method allows a Widget to act as event handlers for events registered with the addEventListener() method.
e is an event object passed to this event handler.
x is the x coordinate of the upper-lefthand corner of the widget.
y is the y coordinate of the upper-lefthand corner of the widget.
nodes is an object whose properties are used to reference key SVG DOM nodes. Wdget defines the following node:
nodes.parent is the SVG parent node of the widget.