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); } }
private function drawGrid(awDriver $driver, awColor $color, $nx, $ny, $x1, $y1, $x2, $y2, $type, $space, $hInterval, $vInterval) { list($left, $right, $top, $bottom) = $space; $width = $x2 - $x1 - $left - $right; $height = $y2 - $y1 - $top - $bottom; foreach ($nx as $key => $n) { if ($key % $vInterval === 0) { $pos = (int) round($x1 + $left + $n * $width); $driver->line($color, new awLine(new awPoint($pos, $y1), new awPoint($pos, $y2), $type)); } } foreach ($ny as $key => $n) { if ($key % $hInterval === 0) { $pos = (int) round($y1 + $top + $n * $height); $driver->line($color, new awLine(new awPoint($x1, $pos), new awPoint($x2, $pos), $type)); } } }
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { if ($this->lineMode === awLinePlot::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)); $driver->line($this->lineColor, new awLine($p1->move($inc, 0), $p2->move($inc, 0), $this->lineStyle, $this->lineThickness)); }
protected function drawTick(awDriver $driver, awPoint $p, $from, $to) { // echo $this->size.':'.$angle.'|<b>'.cos($angle).'</b>/'; // The round avoid some errors in the calcul // For example, 12.00000008575245 becomes 12 $p1 = $p; $p2 = $p; if ($from !== NULL) { $p1 = $p1->move(round($this->size * cos($from), 6), round($this->size * sin($from) * -1, 6)); } if ($to !== NULL) { $p2 = $p2->move(round($this->size * cos($to), 6), round($this->size * sin($to) * -1, 6)); } //echo $p1->x.':'.$p2->x.'('.$p1->y.':'.$p2->y.')'.'/'; $vector = new awVector($p1, $p2); $driver->line($this->color, $vector); }
protected function line(awDriver $driver) { $driver->line($this->color, $this->line); }
/** * Draws the last line of a Polygon, between the first and last point * * @param awDriver $driver A Driver object * @param awPolygon $polygon The polygon object to close */ private function closePolygon(awDriver $driver, awPolygon $polygon) { $first = $polygon->get(0); $last = $polygon->get($polygon->count() - 1); $line = new awLine($first, $last, $this->style, $polygon->getThickness()); $driver->line($this->color, $line); }