cvs: pear /Image_GIS package.xml /Image_GIS/GIS/Renderer SVG.php

From: Date: Mon, 29 Sep 2003 05:12:27 +0000
Subject: cvs: pear /Image_GIS package.xml /Image_GIS/GIS/Renderer SVG.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13163@lists.php.net to get a copy of this message
sebastian Mon Sep 29 01:12:27 2003 EDT Modified files: /pear/Image_GIS package.xml /pear/Image_GIS/GIS/Renderer SVG.php Log: Use XML_SVG instead of XML_Tree in SVG renderer. Index: pear/Image_GIS/package.xml diff -u pear/Image_GIS/package.xml:1.11 pear/Image_GIS/package.xml:1.12 --- pear/Image_GIS/package.xml:1.11 Sun Sep 28 17:17:40 2003 +++ pear/Image_GIS/package.xml Mon Sep 29 01:12:26 2003 @@ -43,6 +43,9 @@ Note: This breaks backwards compatibility. +* The SVG renderer now uses the XML_SVG package instead of the + XML_Tree package. + * Factored the handling of Line Sets out into a separate class. * Fixed a bug that kept a debugging message from beeing printed. @@ -74,7 +77,7 @@ <dep type="ext" rel="has">gd</dep> <dep type="pkg" rel="has">Cache_Lite</dep> <dep type="pkg" rel="has">Image_Color</dep> - <dep type="pkg" rel="has">XML_Tree</dep> + <dep type="pkg" rel="has">XML_SVG</dep> </deps> </release> <changelog> Index: pear/Image_GIS/GIS/Renderer/SVG.php diff -u pear/Image_GIS/GIS/Renderer/SVG.php:1.3 pear/Image_GIS/GIS/Renderer/SVG.php:1.4 --- pear/Image_GIS/GIS/Renderer/SVG.php:1.3 Sat Jan 18 13:01:30 2003 +++ pear/Image_GIS/GIS/Renderer/SVG.php Mon Sep 29 01:12:26 2003 @@ -13,32 +13,32 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: SVG.php,v 1.3 2003/01/18 18:01:30 sebastian Exp $ +// $Id: SVG.php,v 1.4 2003/09/29 05:12:26 sebastian Exp $ // require_once 'Image/GIS/Renderer.php'; -require_once 'XML/Tree.php'; +require_once 'XML/SVG.php'; /** * SVG Renderer. * -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @since Image_GIS 1.0.0 */ class Image_GIS_Renderer_SVG extends Image_GIS_Renderer { /** * SVG Document. * - * @var XML_Tree $svg + * @var XML_SVG $svg */ var $svg; /** - * SVG Document Root. + * SVG Groups. * - * @var XML_Tree_Node $root + * @var XML_SVG_Group[] */ - var $root; + var $svgGroups = array(); /** * Constructor. @@ -51,13 +51,10 @@ function Image_GIS_Renderer_SVG($width, $height, $debug) { $this->Image_GIS_Renderer($width, $height, $debug); - $this->svg = new XML_Tree; - $this->root = &$this->svg->addRoot( - 'svg', - '', + $this->svg = new XML_SVG_Document( array( - 'width' => $this->width, - 'height' => $this->height + 'width' => $width, + 'height' => $height ) ); } @@ -76,22 +73,34 @@ * @access public */ function drawLine($x1, $y1, $x2, $y2, $r, $g, $b) { - $line = &$this->root->addChild( - 'line', - '', + $group = md5($r . $g . $b); + + if (!isset($this->svgGroups[$group])) { + $this->svgGroups[$group] = new XML_SVG_Group( + array( + 'style' => sprintf( + 'stroke:rgb(%s, %s, %s)', + + $r, + $g, + $b + ) + ) + ); + + $this->svgGroups[$group]->addParent($this->svg); + } + + $line = new XML_SVG_Line( array( 'x1' => $x1, 'y1' => $y1, 'x2' => $x2, 'y2' => $y2, - 'style' => sprintf( - 'stroke:rgb(%s, %s, %s)', - $r, - $g, - $b - ) ) ); + + $this->svgGroups[$group]->addChild($line); } /** @@ -103,7 +112,7 @@ */ function saveImage($filename) { if ($fp = @fopen($filename, 'w')) { - @fputs($fp, $this->root->get()); + @fputs($fp, $this->svg->bufferObject()); @fclose($fp); return true; @@ -118,8 +127,7 @@ * @access public */ function showImage() { - header('Content-Type: image/svg+xml'); - echo $this->root->get(); + $this->svg->printElement(); } } ?>

« previous php.pear.cvs (#13163) next »