function testGraphDepthSpread() { $root = new TreemapNode("root", "test"); $root->putChild(new TreemapNode("child", "test")); $childOne = new TreemapNode("child1", "test"); $childTwo = new TreemapNode("child2", "test"); $childThree = new TreemapNode("child3", "test"); $childFour = new TreemapNode("child4", "test"); $childFive = new TreemapNode("child5", "test"); $childSix = new TreemapNode("child6", "test"); $childFour->putChild($childFive); $childFour->putChild($childSix); $this->assertEqual($childFour->getSize(), 2); $this->assertEqual($childFour->getTotalSize(), 2); $childThree->putChild($childFour); $this->assertEqual($childThree->getSize(), 1); $this->assertEqual($childThree->getTotalSize(), 3); $childTwo->putChild($childThree); $this->assertEqual($childTwo->getSize(), 1); $this->assertEqual($childTwo->getTotalSize(), 4); $childOne->putChild($childTwo); $root->putChild($childOne); $this->assertEqual($root->getSize(), 2); $this->assertEqual($root->getTotalSize(), 7); }
/** * divides the test results based on a slice and dice algorithm * * @param TreemapNode $map sorted * @param boolean $aspect flips the aspect between horizontal and vertical * @private */ function divideMapNodes($map, $aspect) { $aspect = !$aspect; $divisions = $map->getSize(); $total = $map->getTotalSize(); foreach ($map->getChildren() as $node) { if (!$node->isLeaf()) { $dist = $node->getTotalSize() / $total * 100; } else { $dist = 1 / $total * 100; } if ($aspect) { $horiz = $dist; $vert = 100; } else { $horiz = 100; $vert = $dist; } $this->paintRectangleStart($node, $horiz, $vert); $this->divideMapNodes($node, $aspect); $this->paintRectangleEnd(); } }