4 * @link http://github.com/PhenX/php-svg-lib
5 * @author Fabien M�nager <fabien.menager@gmail.com>
6 * @license GNU LGPLv3+ http://www.gnu.org/copyleft/lesser.html
11 class UseTag
extends AbstractTag
18 /** @var AbstractTag */
21 protected function before($attributes)
23 if (isset($attributes['x'])) {
24 $this->x
= $attributes['x'];
26 if (isset($attributes['y'])) {
27 $this->y
= $attributes['y'];
30 if (isset($attributes['width'])) {
31 $this->width
= $attributes['width'];
33 if (isset($attributes['height'])) {
34 $this->height
= $attributes['height'];
37 parent
::before($attributes);
39 $document = $this->getDocument();
41 $link = $attributes["xlink:href"];
42 $this->reference
= $document->getDef($link);
44 if ($this->reference
) {
45 $this->reference
->before($attributes);
48 $surface = $document->getSurface();
51 $surface->translate($this->x
, $this->y
);
54 protected function after() {
57 if ($this->reference
) {
58 $this->reference
->after();
61 $this->getDocument()->getSurface()->restore();
64 public function handle($attributes)
66 parent
::handle($attributes);
68 if (!$this->reference
) {
72 $attributes = array_merge($this->reference
->attributes
, $attributes);
74 $this->reference
->handle($attributes);
76 foreach ($this->reference
->children
as $_child) {
77 $_attributes = array_merge($_child->attributes
, $attributes);
78 $_child->handle($_attributes);
82 public function handleEnd()
86 if (!$this->reference
) {
90 $this->reference
->handleEnd();
92 foreach ($this->reference
->children
as $_child) {