Ejemplo n.º 1
0
 private function getPolygonPoints(awPolygon $polygon)
 {
     $points = array();
     foreach ($polygon->all() as $point) {
         $points[] = $point->x + $this->x;
         $points[] = $point->y + $this->y;
     }
     return $points;
 }
Ejemplo n.º 2
0
 public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing)
 {
     $max = $this->getRealYMax();
     $min = $this->getRealYMin();
     // Get start and stop values
     list($start, $stop) = $this->getLimit();
     if ($this->lineMode === awLinePlot::MIDDLE) {
         $inc = $this->xAxis->getDistance(0, 1) / 2;
     } else {
         $inc = 0;
     }
     // Build the polygon
     $polygon = new awPolygon();
     for ($key = $start; $key <= $stop; $key++) {
         $value = $this->datay[$key];
         if ($value !== NULL) {
             $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $value));
             $p = $p->move($inc, 0);
             $polygon->set($key, $p);
         }
     }
     // Draw backgrounds
     if ($this->lineBackground instanceof awColor or $this->lineBackground instanceof awGradient) {
         $backgroundPolygon = new awPolygon();
         $p = $this->xAxisPoint($start);
         $p = $p->move($inc, 0);
         $backgroundPolygon->append($p);
         // Add others points
         foreach ($polygon->all() as $point) {
             $backgroundPolygon->append(clone $point);
         }
         $p = $this->xAxisPoint($stop);
         $p = $p->move($inc, 0);
         $backgroundPolygon->append($p);
         // Draw polygon background
         $driver->filledPolygon($this->lineBackground, $backgroundPolygon);
     }
     $this->drawArea($driver, $polygon);
     // Draw line
     $prev = NULL;
     // Line color
     if ($this->lineHide === FALSE) {
         if ($this->lineColor === NULL) {
             $this->lineColor = new awColor(0, 0, 0);
         }
         foreach ($polygon->all() as $point) {
             if ($prev !== NULL) {
                 $driver->line($this->lineColor, new awLine($prev, $point, $this->lineStyle, $this->lineThickness));
             }
             $prev = $point;
         }
     }
     // Draw marks and labels
     foreach ($polygon->all() as $key => $point) {
         $this->mark->draw($driver, $point);
         $this->label->draw($driver, $point, $key);
     }
 }
 public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing)
 {
     $count = count($this->datay);
     // Get start and stop values
     list($start, $stop) = $this->getLimit();
     // Build the polygon
     $polygon = new awPolygon();
     for ($key = 0; $key < $count; $key++) {
         $x = $this->datax[$key];
         $y = $this->datay[$key];
         if ($y !== NULL) {
             $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($x, $y));
             $polygon->set($key, $p);
         } else {
             if ($this->linkNull === FALSE) {
                 $polygon->set($key, NULL);
             }
         }
     }
     // Link points if needed
     if ($this->link) {
         $prev = NULL;
         foreach ($polygon->all() as $point) {
             if ($prev !== NULL and $point !== NULL) {
                 $driver->line($this->lineColor, new awLine($prev, $point, $this->lineStyle, $this->lineThickness));
             }
             $prev = $point;
         }
     }
     // Draw impulses
     if ($this->impulse instanceof awColor) {
         foreach ($polygon->all() as $key => $point) {
             if ($point !== NULL) {
                 $zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, 0));
                 $driver->line($this->impulse, new awLine($zero, $point, awLine::SOLID, 1));
             }
         }
     }
     // Draw marks and labels
     foreach ($polygon->all() as $key => $point) {
         $this->mark->draw($driver, $point);
         $this->label->draw($driver, $point, $key);
     }
 }
Ejemplo n.º 4
0
 /**
  * Draw a polygon with a background
  *
  * @param mixed $background Background (can be a color or a gradient)
  * @param Polygon A polygon
  */
 public function filledPolygon($background, awPolygon $polygon)
 {
     $shape = new SWFShape();
     if ($background instanceof awColor) {
         list($red, $green, $blue, $alpha) = $this->getColor($background);
         $shape->setRightFill($red, $green, $blue, $alpha);
     } elseif ($background instanceof awGradient) {
         list($flashGradient, $style) = $this->getGradient($background);
         $fill = $shape->addFill($flashGradient, $style);
         list($xMin, $xMax) = $polygon->getBoxXRange();
         list($yMin, $yMax) = $polygon->getBoxYRange();
         if ($background->angle === 0) {
             $fill->scaleTo(($yMax - $yMin) / 1600);
         } else {
             $fill->scaleTo(($xMax - $xMin) / 1600);
         }
         $fill->moveTo($xMin + ($xMax - $xMin) / 2, $yMin + ($yMax - $yMin) / 2);
         $shape->setRightFill($fill);
     }
     $points = $polygon->all();
     $count = count($points);
     if ($count > 1) {
         $prev = $points[0];
         $shape->movePenTo($prev->x, $prev->y);
         for ($i = 1; $i < $count; $i++) {
             $current = $points[$i];
             $shape->drawLineTo($current->x, $current->y);
         }
         // Close the polygon
         $shape->drawLineTo($prev->x, $prev->y);
         $this->movie->add($shape);
     }
 }