Subversion Repositories Applications.gtt

Rev

Rev 61 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 jpm 1
<?php
2
/*
3
 * This work is hereby released into the Public Domain.
4
 * To view a copy of the public domain dedication,
5
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
6
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
7
 *
8
 */
9
 
10
require_once dirname(__FILE__)."/../Graph.class.php";
11
 
12
/**
13
 * To handle text
14
 *
15
 * @package Artichow
16
 */
17
class awText {
18
 
19
	/**
20
	 * Your text
21
	 *
22
	 * @var string
23
	 */
24
	private $text;
25
 
26
	/**
27
	 * Text font
28
	 *
29
	 * @var Font
30
	 */
31
	private $font;
32
 
33
	/**
34
	 * Text angle
35
	 * Can be 0 or 90
36
	 *
37
	 * @var int
38
	 */
39
	private $angle;
40
 
41
	/**
42
	 * Text color
43
	 *
44
	 * @var Color
45
	 */
46
	private $color;
47
 
48
	/**
49
	 * Text background
50
	 *
51
	 * @var Color, Gradient
52
	 */
53
	private $background;
54
 
55
	/**
56
	 * Padding
57
	 *
58
	 * @var array Array for left, right, top and bottom paddings
59
	 */
60
	private $padding;
61
 
62
	/**
63
	 * Text border
64
	 *
65
	 * @var Border
66
	 */
67
	public $border;
68
 
69
	/**
70
	 * Build a new awtext
71
	 *
72
	 * @param string $text Your text
73
	 */
74
	public function __construct($text, $font = NULL, $color = NULL, $angle = 0) {
75
 
76
		if(is_null($font)) {
77
			$font = new awFont2;
78
		}
79
 
80
		$this->setText($text);
81
		$this->setFont($font);
82
 
83
		// Set default color to black
84
		if($color === NULL) {
85
			$color = new awColor(0, 0, 0);
86
		}
87
 
88
		$this->setColor($color);
89
		$this->setAngle($angle);
90
 
91
		$this->border = new awBorder;
92
		$this->border->hide();
93
 
94
	}
95
 
96
	/**
97
	 * Get text
98
	 *
99
	 * @return string
100
	 */
101
	public function getText() {
102
		return $this->text;
103
	}
104
 
105
	/**
106
	 * Change text
107
	 *
108
	 * @param string $text New text
109
	 */
110
	public function setText($text) {
111
		$this->text = (string)$text;
112
		$this->text = str_replace("\r", "", $text);
113
	}
114
 
115
	/**
116
	 * Change text font
117
	 *
118
	 * @param Font
119
	 */
120
	public function setFont(awFont $font) {
121
		$this->font = $font;
122
	}
123
 
124
	/**
125
	 * Get text font
126
	 *
127
	 * @return int
128
	 */
129
	public function getFont() {
130
		return $this->font;
131
	}
132
 
133
	/**
134
	 * Change text angle
135
	 *
136
	 * @param int
137
	 */
138
	public function setAngle($angle) {
139
		$this->angle = (int)$angle;
140
	}
141
 
142
	/**
143
	 * Get text angle
144
	 *
145
	 * @return int
146
	 */
147
	public function getAngle() {
148
		return $this->angle;
149
	}
150
 
151
	/**
152
	 * Change text color
153
	 *
154
	 * @param Color
155
	 */
156
	public function setColor(awColor $color) {
157
		$this->color = $color;
158
	}
159
 
160
	/**
161
	 * Get text color
162
	 *
163
	 * @return Color
164
	 */
165
	public function getColor() {
166
		return $this->color;
167
	}
168
 
169
	/**
170
	 * Change text background
171
	 *
172
	 * @param mixed $background
173
	 */
174
	public function setBackground($background) {
175
		if($background instanceof awColor) {
176
			$this->setBackgroundColor($background);
177
		} elseif($background instanceof awGradient) {
178
			$this->setBackgroundGradient($background);
179
		}
180
	}
181
 
182
	/**
183
	 * Change text background color
184
	 *
185
	 * @param awColor $color
186
	 */
187
	public function setBackgroundColor(awColor $color) {
188
		$this->background = $color;
189
	}
190
 
191
	/**
192
	 * Change text background gradient
193
	 *
194
	 * @param awGradient $gradient
195
	 */
196
	public function setBackgroundGradient(awGradient $gradient) {
197
		$this->background = $gradient;
198
	}
199
 
200
	/**
201
	 * Get text background
202
	 *
203
	 * @return Color, Gradient
204
	 */
205
	public function getBackground() {
206
		return $this->background;
207
	}
208
 
209
	/**
210
	 * Change padding
211
	 *
212
	 * @param int $left Left padding
213
	 * @param int $right Right padding
214
	 * @param int $top Top padding
215
	 * @param int $bottom Bottom padding
216
	 */
217
	public function setPadding($left, $right, $top, $bottom) {
218
		$this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom);
219
	}
220
 
221
	/**
222
	 * Get current padding
223
	 *
224
	 * @return array
225
	 */
226
	public function getPadding() {
227
		return $this->padding;
228
	}
229
 
230
}
231
 
232
registerClass('Text');
233
?>