/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * @return DOMElement The SVG Element */ 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', Format::formatSVGNumber($x1)); $line->setAttribute('x2', Format::formatSVGNumber($x2)); $line->setAttribute('y1', Format::formatSVGNumber($y1)); $line->setAttribute('y2', Format::formatSVGNumber($y2)); $line->setAttribute('style', $this->getStyle()); $this->applyAttributes($line); return $line; }
/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { $coords = $ctx->toAbsolute($this->x, $this->y); $circle = $ctx->getDocument()->createElement('circle'); $circle->setAttribute('cx', Format::formatSVGNumber($coords[0])); $circle->setAttribute('cy', Format::formatSVGNumber($coords[1])); $circle->setAttribute('r', $this->radius); $circle->setAttribute('style', $this->getStyle()); $this->applyAttributes($circle); return $circle; }
/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); $rect = $doc->createElement('rect'); list($x, $y) = $ctx->toAbsolute($this->x, $this->y); if ($this->keepRatio) { $ctx->keepRatio(); } list($width, $height) = $ctx->toAbsolute($this->width, $this->height); if ($this->keepRatio) { $ctx->ignoreRatio(); } $rect->setAttribute('x', Format::formatSVGNumber($x)); $rect->setAttribute('y', Format::formatSVGNumber($y)); $rect->setAttribute('width', Format::formatSVGNumber($width)); $rect->setAttribute('height', Format::formatSVGNumber($height)); $rect->setAttribute('style', $this->getStyle()); $this->applyAttributes($rect); $this->appendAnimation($rect, $ctx); return $rect; }
/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { list($x, $y) = $ctx->toAbsolute($this->x, $this->y); $text = $ctx->getDocument()->createElement('text'); $text->setAttribute('x', Format::formatSVGNumber($x - 15)); $text->setAttribute('style', $this->getStyle() . ';font-size:' . $this->fontSize . '; font-family: Ubuntu, Calibri, Trebuchet MS, Helvetica, Verdana, sans-serif' . ';font-weight: ' . $this->fontWeight . ';font-stretch: ' . $this->fontStretch . '; font-style: normal;' . 'text-anchor: ' . $this->alignment); $text->setAttribute('y', Format::formatSVGNumber($y)); $text->appendChild(new DOMText($this->text)); return $text; }
/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); $group = $doc->createElement('g'); $r = ($ctx->xToAbsolute($this->radius) + $ctx->yToAbsolute($this->radius)) / 2; list($x, $y) = $ctx->toAbsolute($this->x, $this->y); $slicePath = $doc->createElement('path'); $slicePath->setAttribute('d', $this->getPieSlicePath($x, $y, $r)); $slicePath->setAttribute('style', $this->getStyle()); $slicePath->setAttribute('data-icinga-graph-type', 'pieslice'); $this->applyAttributes($slicePath); $group->appendChild($slicePath); if ($this->caption != "") { $lblGroup = $this->labelGroup ? $this->labelGroup : $group; $lblGroup->appendChild($this->drawDescriptionLabel($ctx, $r)); } return $group; }
/** * Return a string containing the SVG transform attribute values for the padding * * @param RenderContext $ctx The context to determine the translation coordinates * * @return string The transformation string */ public function getInnerTransform(RenderContext $ctx) { list($translateX, $translateY) = $ctx->toAbsolute($this->padding[self::PADDING_LEFT] + $this->getX(), $this->padding[self::PADDING_TOP] + $this->getY()); list($scaleX, $scaleY) = $ctx->paddingToScaleFactor($this->padding); $scaleX *= $this->getWidth() / 100; $scaleY *= $this->getHeight() / 100; return sprintf('translate(%s, %s) scale(%s, %s)', Format::formatSVGNumber($translateX), Format::formatSVGNumber($translateY), Format::formatSVGNumber($scaleX), Format::formatSVGNumber($scaleY)); }
/** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); $group = $doc->createElement('g'); $pathDescription = ''; $tpl = self::TPL_MOVE; $lastPoint = null; foreach ($this->points as $point) { if (!$this->isAbsolute) { $point = $ctx->toAbsolute($point[0], $point[1]); } $point[0] = Format::formatSVGNumber($point[0]); $point[1] = Format::formatSVGNumber($point[1]); if ($lastPoint && $this->discrete) { $pathDescription .= sprintf($tpl, $point[0], $lastPoint[1]); } $pathDescription .= vsprintf($tpl, $point); $lastPoint = $point; $tpl = self::TPL_STRAIGHT; } $path = $doc->createElement('path'); if ($this->id) { $path->setAttribute('id', $this->id); } $path->setAttribute('d', $pathDescription); $path->setAttribute('style', $this->getStyle()); $this->applyAttributes($path); $group->appendChild($path); return $group; }