Exemplo n.º 1
0
 /**
  * Create a new awimage
  */
 function create()
 {
     if ($this->resource === NULL) {
         // Create image
         $this->resource = imagecreatetruecolor($this->width, $this->height);
         if (!$this->resource) {
             trigger_error("Unable to create a graph", E_USER_ERROR);
         }
         imagealphablending($this->resource, TRUE);
         if ($this->antiAliasing and function_exists('imageantialias')) {
             imageantialias($this->resource, TRUE);
         }
         $this->drawer = new awDrawer($this->resource);
         $this->drawer->setImageSize($this->width, $this->height);
         // Original color
         $this->drawer->filledRectangle(new awWhite(), new awLine(new awPoint(0, 0), new awPoint($this->width, $this->height)));
         $shadow = $this->shadow->getSpace();
         $p1 = new awPoint($shadow->left, $shadow->top);
         $p2 = new awPoint($this->width - $shadow->right - 1, $this->height - $shadow->bottom - 1);
         // Draw image background
         $this->drawer->filledRectangle($this->background, new awLine($p1, $p2));
         $this->background->free();
         // Draw image border
         $this->border->rectangle($this->drawer, $p1, $p2);
     }
 }
Exemplo n.º 2
0
 /**
  * Draw grids
  *
  * @param $drawer A drawer object
  * @param int $x1
  * @param int $y1
  * @param int $x2
  * @param int $y2
  */
 function draw($drawer, $x1, $y1, $x2, $y2)
 {
     if (is_a($this->background, 'awColor')) {
         // Draw background color
         $drawer->filledRectangle($this->background, awLine::build($x1, $y1, $x2, $y2));
         $this->background->free();
     }
     if ($this->hide === FALSE) {
         $this->drawGrid($drawer, $this->color, $this->hideVertical ? array() : $this->xgrid, $this->hideHorizontal ? array() : $this->ygrid, $x1, $y1, $x2, $y2, $this->type, $this->space, $this->interval[0], $this->interval[1]);
     }
     $this->color->free();
 }
 public function drawComponent(awDrawer $drawer, $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) {
                 $drawer->line($this->lineColor, new awLine($prev, $point, $this->lineStyle, $this->lineThickness));
             }
             $prev = $point;
         }
         $this->lineColor->free();
     }
     // 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));
                 $drawer->line($this->impulse, new awLine($zero, $point, awLine::SOLID, 1));
             }
         }
     }
     // Draw marks and labels
     foreach ($polygon->all() as $key => $point) {
         $this->mark->draw($drawer, $point);
         $this->label->draw($drawer, $point, $key);
     }
 }
 /**
  * Free memory used by the colors of the gradient
  */
 public function free()
 {
     $this->from->free();
     $this->to->free();
 }
 function drawComponent($drawer, $x1, $y1, $x2, $y2, $aliasing)
 {
     if ($this->lineMode === LINEPLOT_MIDDLE) {
         $inc = $this->xAxis->getDistance(0, 1) / 2;
     } else {
         $inc = 0;
     }
     $p1 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStart, $this->lineValue));
     $p2 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStop, $this->lineValue));
     $drawer->line($this->lineColor, new awLine($p1->move($inc, 0), $p2->move($inc, 0), $this->lineStyle, $this->lineThickness));
     $this->lineColor->free();
 }