public function testRun()
 {
     $this->assertInstanceOf('WMAngledLinkGeometry', WMLinkGeometryFactory::create('angled'));
     $this->assertInstanceOf('WMCurvedLinkGeometry', WMLinkGeometryFactory::create('curved'));
     $this->setExpectedException("WMException");
     WMLinkGeometryFactory::create('antelope');
 }
 function preCalculate(&$map)
 {
     wm_debug("Link " . $this->name . ": Calculating geometry.\n");
     // don't bother doing anything if it's a template
     if ($this->isTemplate()) {
         return;
     }
     $points = array();
     list($dx, $dy) = WMUtility::calculateOffset($this->a_offset, $this->a->width, $this->a->height);
     $points[] = new WMPoint($this->a->x + $dx, $this->a->y + $dy);
     foreach ($this->vialist as $via) {
         wm_debug("VIALIST...\n");
         // if the via has a third element, the first two are relative to that node
         if (isset($via[2])) {
             $relativeTo = $map->getNode($via[2]);
             wm_debug("Relative to {$relativeTo}\n");
             $point = new WMPoint($relativeTo->x + $via[0], $relativeTo->y + $via[1]);
         } else {
             $point = new WMPoint($via[0], $via[1]);
         }
         wm_debug("Adding {$point}\n");
         $points[] = $point;
     }
     list($dx, $dy) = WMUtility::calculateOffset($this->b_offset, $this->b->width, $this->b->height);
     $points[] = new WMPoint($this->b->x + $dx, $this->b->y + $dy);
     if ($points[0]->closeEnough($points[1]) && sizeof($this->vialist) == 0) {
         wm_warn("Zero-length link " . $this->name . " skipped. [WMWARN45]");
         $this->geometry = null;
         return;
     }
     $widths = array($this->width, $this->width);
     // for bulging animations, modulate the width with the percentage value
     if ($map->widthmod || $map->get_hint('link_bulge') == 1) {
         // a few 0.1s and +1s to fix div-by-zero, and invisible links
         $widths[0] = ($widths[0] * $this->percentUsages[IN] * 1.5 + 0.1) / 100 + 1;
         $widths[1] = ($widths[1] * $this->percentUsages[OUT] * 1.5 + 0.1) / 100 + 1;
     }
     $style = $this->viastyle;
     // don't bother with any curve stuff if there aren't any Vias defined, even if the style is 'curved'
     if (count($this->vialist) == 0) {
         $style = "angled";
     }
     $this->geometry = WMLinkGeometryFactory::create($style);
     $this->geometry->Init($this, $points, $widths, $this->linkstyle == 'oneway' ? 1 : 2, $this->splitpos, $this->arrowstyle);
 }