19 require_once(BASE.
"wcmf/lib/visitor/class.Visitor.php");
20 require_once(BASE.
"wcmf/lib/util/class.Position.php");
24 define(
"MAPTYPE_HORIZONTAL", 0);
25 define(
"MAPTYPE_VERTICAL", 1);
70 foreach($this->_map as $key => $position)
73 $position->x = $position->y;
75 $this->_map[$key] = $position;
78 $this->_map[
"type"] = 1-$this->_map[
"type"];
87 $parent = & $obj->getParent();
96 $parentPos = $this->_map[$parent->getOID()];
97 $position->y = $parentPos->y + 1;
98 $position->z = $parentPos->z + 1;
100 $siblings = $parent->getChildren();
101 if ($siblings[0]->getOID() == $obj->getOID())
103 $position->x = $parentPos->x;
108 for ($i=0;$i<sizeOf($siblings);$i++)
110 if ($siblings[$i]->getOID() == $obj->getOID())
112 $leftSibling = & $siblings[$i-1];
118 while(!($nIter->isEnd()))
120 $curObject = & $nIter->getCurrentObject();
121 $curPosition = $this->_map[$curObject->getOID()];
122 if ($curPosition->x >= $maxX)
123 $maxX = $curPosition->x;
126 $position->x = $maxX+2;
128 while ($parent != null)
130 $this->_map[$parent->getOID()]->x += 1;
131 $parent = & $parent->getParent();
Visitor is used to extend an object's functionality by not extending its interface. Classes to use with the Visitor must implement the acceptVisitor() method. Visitor implements the 'Visitor Pattern'. It implements the 'Template Method Pattern' to allow subclasses to do any Pre- and Post Visit operations (doPreVisit() and doPostVisit() methods). The abstract base class Visitor defines the interface for all specialized Visitor classes.
NodeIterator is used to iterate over a tree/list build of objects using a Depth-First-Algorithm. Classes used with the NodeIterator must implement the getChildren() and getOID() methods. NodeIterator implements the 'Iterator Pattern'. The base class NodeIterator defines the interface for all specialized Iterator classes.
The LayoutVisitor is used to position a tree of objects on a plane (the objects must implement the ge...
The Position class stores a coordinate tuple for use with the LayoutVisitor.