* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Chart\Primitive; use Icinga\Chart\Render\RenderContext; class Line extends Styleable implements Drawable { public $strokeWidth = 1; private $xStart = 0; private $xEnd = 0; private $yStart = 0; private $yEnd = 0; public function __construct($x1, $y1, $x2, $y2) { $this->xStart = $x1; $this->xEnd = $x2; $this->yStart = $y1; $this->yEnd = $y2; } public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); list($x1, $y1) = $ctx->toAbsolute($this->xStart, $this->yStart); list($x2, $y2) = $ctx->toAbsolute($this->xEnd, $this->yEnd); $line = $doc->createElement('line'); $line->setAttribute('x1', $x1); $line->setAttribute('x2', $x2); $line->setAttribute('y1', $y1); $line->setAttribute('y2', $y2); $line->setAttribute('style', $this->getStyle()); return $line; } }