コード例 #1
0
 /** split - split the Spine into two new spines, with splitIndex in the first one
  *  used by the link-drawing code to make one curve into two arrows
  *
  */
 function split($splitIndex)
 {
     $spine1 = new WMSpine();
     $spine2 = new WMSpine();
     $endCursor = $this->pointCount() - 1;
     $totalDistance = $this->totalDistance();
     for ($i = 0; $i < $splitIndex; $i++) {
         $spine1->addRawEntry($this->points[$i]);
     }
     // work backwards from the end, finishing with the same point
     // Recalculate the distance (element 1) from the other end as we go
     for ($i = $endCursor; $i > $splitIndex; $i--) {
         $newEntry = $this->points[$i];
         $newDistance = $totalDistance - $newEntry[1];
         //     wm_debug("  $totalDistance => $newDistance  \n");
         $newEntry[1] = $newDistance;
         $spine2->addRawEntry($newEntry);
     }
     return array($spine1, $spine2);
 }