| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
class csText extends csBaseShape |
|---|
| 10 |
{ |
|---|
| 11 |
|
|---|
| 12 |
protected |
|---|
| 13 |
$text_content = NULL, |
|---|
| 14 |
$xml_node_name = 'text'; |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
* Class constructor |
|---|
| 18 |
* |
|---|
| 19 |
* @param mixed $x |
|---|
| 20 |
* @param mixed $y |
|---|
| 21 |
* @param mixed $content |
|---|
| 22 |
*/ |
|---|
| 23 |
public function __construct($x=null, $y=null, $content=null, $attrs=array()) |
|---|
| 24 |
{ |
|---|
| 25 |
$this->setX($x); |
|---|
| 26 |
$this->setY($y); |
|---|
| 27 |
$this->setContent($content); |
|---|
| 28 |
$this->attributes = array_merge($attrs, $this->attributes); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
* Computes DOMXML Node |
|---|
| 33 |
* |
|---|
| 34 |
* @param boolean $embedded Is SVG element embedded ? |
|---|
| 35 |
* @return DOMElement |
|---|
| 36 |
*/ |
|---|
| 37 |
public function compile($embedded=false) |
|---|
| 38 |
{ |
|---|
| 39 |
$node = parent::compile($embedded); |
|---|
| 40 |
$dom = $this->getDomDocument(); |
|---|
| 41 |
if (!is_null($this->text_content)) |
|---|
| 42 |
{ |
|---|
| 43 |
$content_node = $dom->createTextNode($this->text_content); |
|---|
| 44 |
$node->appendChild($content_node); |
|---|
| 45 |
} |
|---|
| 46 |
return $node; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
* Sets the text content |
|---|
| 51 |
* |
|---|
| 52 |
* @param string $content |
|---|
| 53 |
*/ |
|---|
| 54 |
public function setContent($content) |
|---|
| 55 |
{ |
|---|
| 56 |
if (!is_null($content)) |
|---|
| 57 |
{ |
|---|
| 58 |
$this->text_content = $content; |
|---|
| 59 |
} |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
* Sets the font family |
|---|
| 64 |
* |
|---|
| 65 |
* @param mixed $font_family |
|---|
| 66 |
* @link http://www.w3.org/TR/SVG11/text.html#FontSizeProperty |
|---|
| 67 |
*/ |
|---|
| 68 |
public function setFontFamily($font_family) |
|---|
| 69 |
{ |
|---|
| 70 |
$this->setAttribute('font-family', $font_family); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
* Sets the font size |
|---|
| 75 |
* |
|---|
| 76 |
* @param mixed $font_size |
|---|
| 77 |
* @link http://www.w3.org/TR/SVG11/text.html#FontSizeProperty |
|---|
| 78 |
*/ |
|---|
| 79 |
public function setFontSize($font_size) |
|---|
| 80 |
{ |
|---|
| 81 |
$this->setAttribute('font-size', $font_size); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
* Sets the font size-adjust |
|---|
| 86 |
* |
|---|
| 87 |
* @param mixed $font_size_adjust |
|---|
| 88 |
* @link http://www.w3.org/TR/SVG11/text.html#FontSizeAdjustProperty |
|---|
| 89 |
*/ |
|---|
| 90 |
public function setFontSizeAdjust($font_size_adjust) |
|---|
| 91 |
{ |
|---|
| 92 |
$this->setAttribute('font-size-adjust', $font_size_adjust); |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
* Sets the font stretch |
|---|
| 97 |
* |
|---|
| 98 |
* @param mixed $font_stretch |
|---|
| 99 |
* @link http://www.w3.org/TR/SVG11/text.html#FontStretchProperty |
|---|
| 100 |
*/ |
|---|
| 101 |
public function setFontStretch($font_stretch) |
|---|
| 102 |
{ |
|---|
| 103 |
$this->setAttribute('font-stretch', $font_stretch); |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
* Sets the font style |
|---|
| 108 |
* |
|---|
| 109 |
* @param mixed $font_style |
|---|
| 110 |
* @link http://www.w3.org/TR/SVG11/text.html#FontStyleProperty |
|---|
| 111 |
*/ |
|---|
| 112 |
public function setFontStyle($font_style) |
|---|
| 113 |
{ |
|---|
| 114 |
$this->setAttribute('font-style', $font_style); |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
* Sets the font variant |
|---|
| 119 |
* |
|---|
| 120 |
* @param mixed $font_variant |
|---|
| 121 |
* @link http://www.w3.org/TR/SVG11/text.html#FontVariantProperty |
|---|
| 122 |
*/ |
|---|
| 123 |
public function setFontVariant($font_variant) |
|---|
| 124 |
{ |
|---|
| 125 |
$this->setAttribute('font-variant', $font_variant); |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
* Sets the font weight |
|---|
| 130 |
* |
|---|
| 131 |
* @param mixed $font_weight |
|---|
| 132 |
* @link http://www.w3.org/TR/SVG11/text.html#FontWeightProperty |
|---|
| 133 |
*/ |
|---|
| 134 |
public function setFontWeight($font_weight) |
|---|
| 135 |
{ |
|---|
| 136 |
$this->setAttribute('font-weight', $font_weight); |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
* The start x-axis coordinate of the text |
|---|
| 141 |
* |
|---|
| 142 |
*/ |
|---|
| 143 |
public function setX($x) |
|---|
| 144 |
{ |
|---|
| 145 |
$this->setAttribute('x', $x); |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
* The start y-axis coordinate of the text |
|---|
| 150 |
* |
|---|
| 151 |
*/ |
|---|
| 152 |
public function setY($y) |
|---|
| 153 |
{ |
|---|
| 154 |
$this->setAttribute('y', $y); |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
} |
|---|
| 158 |
|
|---|