1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* JPGraph v4.0.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Text; |
8
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Plot; |
10
|
|
|
use Amenadiel\JpGraph\Util; |
11
|
|
|
|
12
|
|
|
/* |
13
|
|
|
* File: JPGRAPH_TABLE.PHP |
14
|
|
|
* // Description: Classes to create basic tables of data |
15
|
|
|
* // Created: 2006-01-25 |
16
|
|
|
* // Ver: $Id: jpgraph_table.php 1514 2009-07-07 11:15:58Z ljp $ |
17
|
|
|
* // |
18
|
|
|
* // Copyright (c) Asial Corporation. All rights reserved. |
19
|
|
|
*/ |
20
|
|
|
// Style of grid lines in table |
21
|
|
|
define('TGRID_SINGLE', 1); |
22
|
|
|
define('TGRID_DOUBLE', 2); |
23
|
|
|
define('TGRID_DOUBLE2', 3); |
24
|
|
|
|
25
|
|
|
// Type of constrain for image constrain |
26
|
|
|
define('TIMG_WIDTH', 1); |
27
|
|
|
define('TIMG_HEIGHT', 2); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @class GTextTableCell |
31
|
|
|
* // Description: |
32
|
|
|
* // Internal class that represents each cell in the table |
33
|
|
|
*/ |
34
|
|
|
class GTextTableCell |
35
|
|
|
{ |
36
|
|
|
public $iColSpan = 1; |
37
|
|
|
public $iRowSpan = 1; |
38
|
|
|
public $iMarginLeft = 5; |
39
|
|
|
public $iMarginRight = 5; |
40
|
|
|
public $iMarginTop = 5; |
41
|
|
|
public $iMarginBottom = 5; |
42
|
|
|
public $iVal; |
43
|
|
|
private $iBGColor = ''; |
44
|
|
|
private $iFontColor = 'black'; |
45
|
|
|
private $iFF = FF_FONT1; |
46
|
|
|
private $iFS = FS_NORMAL; |
47
|
|
|
private $iFSize = 10; |
48
|
|
|
private $iRow = 0; |
49
|
|
|
private $iCol = 0; |
50
|
|
|
private $iVertAlign = 'bottom'; |
51
|
|
|
private $iHorAlign = 'left'; |
52
|
|
|
private $iMerged = false; |
53
|
|
|
private $iPRow; |
54
|
|
|
private $iPCol; |
55
|
|
|
private $iTable; |
56
|
|
|
private $iGridColor = ['darkgray', 'darkgray', 'darkgray', 'darkgray']; |
57
|
|
|
private $iGridWeight = [1, 1, 0, 0]; // left,top,bottom,right; |
58
|
|
|
private $iGridStyle = [TGRID_SINGLE, TGRID_SINGLE, TGRID_SINGLE, TGRID_SINGLE]; // left,top,bottom,right; |
59
|
|
|
private $iNumberFormat; |
60
|
|
|
private $iIcon; |
61
|
|
|
private $iIconConstrain = []; |
62
|
|
|
private $iCSIMtarget = ''; |
63
|
|
|
private $iCSIMwintarget = ''; |
64
|
|
|
private $iCSIMalt = ''; |
65
|
|
|
private $iCSIMArea = ''; |
66
|
|
|
|
67
|
|
|
public function __construct($aVal = '', $aRow = 0, $aCol = 0) |
68
|
|
|
{ |
69
|
|
|
$this->iVal = new Text($aVal); |
70
|
|
|
$this->iRow = $aRow; |
71
|
|
|
$this->iCol = $aCol; |
72
|
|
|
$this->iPRow = $aRow; // Initialiy each cell is its own parent |
73
|
|
|
$this->iPCol = $aCol; |
74
|
|
|
$this->iIconConstrain = [-1, -1]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function Init($aTable) |
78
|
|
|
{ |
79
|
|
|
$this->iTable = $aTable; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function SetCSIMTarget($aTarget, $aAlt = '', $aWinTarget = '') |
83
|
|
|
{ |
84
|
|
|
$this->iCSIMtarget = $aTarget; |
85
|
|
|
$this->iCSIMwintarget = $aWinTarget; |
86
|
|
|
$this->iCSIMalt = $aAlt; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function GetCSIMArea() |
90
|
|
|
{ |
91
|
|
|
if ($this->iCSIMtarget !== '') { |
92
|
|
|
return $this->iCSIMArea; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return ''; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function SetImageConstrain($aType, $aVal) |
99
|
|
|
{ |
100
|
|
|
if (!in_array($aType, [TIMG_WIDTH, TIMG_HEIGHT], true)) { |
101
|
|
|
Util\JpGraphError::RaiseL(27015); |
102
|
|
|
} |
103
|
|
|
$this->iIconConstrain = [$aType, $aVal]; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function SetCountryFlag($aFlag, $aScale = 1.0, $aMix = 100, $aStdSize = 3) |
107
|
|
|
{ |
108
|
|
|
$this->iIcon = new Plot\IconPlot(); |
109
|
|
|
$this->iIcon->SetCountryFlag($aFlag, 0, 0, $aScale, $aMix, $aStdSize); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function SetImage($aFile, $aScale = 1.0, $aMix = 100) |
113
|
|
|
{ |
114
|
|
|
$this->iIcon = new Plot\IconPlot($aFile, 0, 0, $aScale, $aMix); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function SetImageFromString($aStr, $aScale = 1.0, $aMix = 100) |
118
|
|
|
{ |
119
|
|
|
$this->iIcon = new Plot\IconPlot('', 0, 0, $aScale, $aMix); |
120
|
|
|
$this->iIcon->CreateFromString($aStr); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function SetRowColSpan($aRowSpan, $aColSpan) |
124
|
|
|
{ |
125
|
|
|
$this->iRowSpan = $aRowSpan; |
126
|
|
|
$this->iColSpan = $aColSpan; |
127
|
|
|
$this->iMerged = true; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function SetMerged($aPRow, $aPCol, $aFlg = true) |
131
|
|
|
{ |
132
|
|
|
$this->iMerged = $aFlg; |
133
|
|
|
$this->iPRow = $aPRow; |
134
|
|
|
$this->iPCol = $aPCol; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function IsMerged() |
138
|
|
|
{ |
139
|
|
|
return $this->iMerged; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function SetNumberFormat($aF) |
143
|
|
|
{ |
144
|
|
|
$this->iNumberFormat = $aF; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function Set($aTxt) |
148
|
|
|
{ |
149
|
|
|
$this->iVal->Set($aTxt); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function SetFont($aFF, $aFS, $aFSize) |
153
|
|
|
{ |
154
|
|
|
$this->iFF = $aFF; |
155
|
|
|
$this->iFS = $aFS; |
156
|
|
|
$this->iFSize = $aFSize; |
157
|
|
|
$this->iVal->SetFont($aFF, $aFS, $aFSize); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function SetFillColor($aColor) |
161
|
|
|
{ |
162
|
|
|
$this->iBGColor = $aColor; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function SetFontColor($aColor) |
166
|
|
|
{ |
167
|
|
|
$this->iFontColor = $aColor; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function SetGridColor($aLeft, $aTop = null, $aBottom = null, $aRight = null) |
171
|
|
|
{ |
172
|
|
|
if ($aLeft !== null) { |
173
|
|
|
$this->iGridColor[0] = $aLeft; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
if ($aTop !== null) { |
177
|
|
|
$this->iGridColor[1] = $aTop; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
if ($aBottom !== null) { |
181
|
|
|
$this->iGridColor[2] = $aBottom; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
if ($aRight !== null) { |
185
|
|
|
$this->iGridColor[3] = $aRight; |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function SetGridStyle($aLeft, $aTop = null, $aBottom = null, $aRight = null) |
190
|
|
|
{ |
191
|
|
|
if ($aLeft !== null) { |
192
|
|
|
$this->iGridStyle[0] = $aLeft; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
if ($aTop !== null) { |
196
|
|
|
$this->iGridStyle[1] = $aTop; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
if ($aBottom !== null) { |
200
|
|
|
$this->iGridStyle[2] = $aBottom; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
if ($aRight !== null) { |
204
|
|
|
$this->iGridStyle[3] = $aRight; |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function SetGridWeight($aLeft = null, $aTop = null, $aBottom = null, $aRight = null) |
209
|
|
|
{ |
210
|
|
|
if ($aLeft !== null) { |
211
|
|
|
$this->iGridWeight[0] = $aLeft; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
if ($aTop !== null) { |
215
|
|
|
$this->iGridWeight[1] = $aTop; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
if ($aBottom !== null) { |
219
|
|
|
$this->iGridWeight[2] = $aBottom; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
if ($aRight !== null) { |
223
|
|
|
$this->iGridWeight[3] = $aRight; |
224
|
|
|
} |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
public function SetMargin($aLeft, $aRight, $aTop, $aBottom) |
228
|
|
|
{ |
229
|
|
|
$this->iMarginLeft = $aLeft; |
230
|
|
|
$this->iMarginRight = $aRight; |
231
|
|
|
$this->iMarginTop = $aTop; |
232
|
|
|
$this->iMarginBottom = $aBottom; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
public function GetWidth($aImg) |
236
|
|
|
{ |
237
|
|
|
if ($this->iIcon !== null) { |
238
|
|
|
if ($this->iIconConstrain[0] == TIMG_WIDTH) { |
239
|
|
|
$this->iIcon->SetScale(1); |
240
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
241
|
|
|
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[0]); |
242
|
|
|
} elseif ($this->iIconConstrain[0] == TIMG_HEIGHT) { |
243
|
|
|
$this->iIcon->SetScale(1); |
244
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
245
|
|
|
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[1]); |
246
|
|
|
} |
247
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
248
|
|
|
$iwidth = $tmp[0]; |
249
|
|
|
} else { |
250
|
|
|
$iwidth = 0; |
251
|
|
|
} |
252
|
|
|
if ($this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 0) { |
253
|
|
|
$pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetWidth($aImg); |
254
|
|
|
} elseif ($this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 90) { |
255
|
|
|
$pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetFontHeight($aImg) + 2; |
256
|
|
|
} else { |
257
|
|
|
$pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetWidth($aImg) + 2; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
$pcolspan = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iColSpan; |
261
|
|
|
|
262
|
|
|
return round(max($iwidth, $pwidth) / $pcolspan) + $this->iMarginLeft + $this->iMarginRight; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
public function GetHeight($aImg) |
266
|
|
|
{ |
267
|
|
|
if ($this->iIcon !== null) { |
268
|
|
|
if ($this->iIconConstrain[0] == TIMG_WIDTH) { |
269
|
|
|
$this->iIcon->SetScale(1); |
270
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
271
|
|
|
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[0]); |
272
|
|
|
} elseif ($this->iIconConstrain[0] == TIMG_HEIGHT) { |
273
|
|
|
$this->iIcon->SetScale(1); |
274
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
275
|
|
|
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[1]); |
276
|
|
|
} |
277
|
|
|
$tmp = $this->iIcon->GetWidthHeight(); |
278
|
|
|
$iheight = $tmp[1]; |
279
|
|
|
} else { |
280
|
|
|
$iheight = 0; |
281
|
|
|
} |
282
|
|
|
if ($this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 0) { |
283
|
|
|
$pheight = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetHeight($aImg); |
284
|
|
|
} else { |
285
|
|
|
$pheight = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetHeight($aImg) + 1; |
286
|
|
|
} |
287
|
|
|
$prowspan = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iRowSpan; |
288
|
|
|
|
289
|
|
|
return round(max($iheight, $pheight) / $prowspan) + $this->iMarginTop + $this->iMarginBottom; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
public function SetAlign($aHorAlign = 'left', $aVertAlign = 'bottom') |
293
|
|
|
{ |
294
|
|
|
$aHorAlign = strtolower($aHorAlign); |
295
|
|
|
$aVertAlign = strtolower($aVertAlign); |
296
|
|
|
$chk = ['left', 'right', 'center', 'bottom', 'top', 'middle']; |
297
|
|
|
if (!in_array($aHorAlign, $chk, true) || !in_array($aVertAlign, $chk, true)) { |
298
|
|
|
Util\JpGraphError::RaiseL(27011, $aHorAlign, $aVertAlign); |
299
|
|
|
} |
300
|
|
|
$this->iVertAlign = $aVertAlign; |
301
|
|
|
$this->iHorAlign = $aHorAlign; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
public function AdjustMarginsForGrid() |
305
|
|
|
{ |
306
|
|
|
if ($this->iCol > 0) { |
307
|
|
|
switch ($this->iGridStyle[0]) { |
308
|
|
|
case TGRID_SINGLE: |
309
|
|
|
$wf = 1; |
310
|
|
|
|
311
|
|
|
break; |
312
|
|
|
case TGRID_DOUBLE: |
313
|
|
|
$wf = 3; |
314
|
|
|
|
315
|
|
|
break; |
316
|
|
|
case TGRID_DOUBLE2: |
317
|
|
|
$wf = 4; |
318
|
|
|
|
319
|
|
|
break; |
320
|
|
|
} |
321
|
|
|
$this->iMarginLeft += $this->iGridWeight[0] * $wf; |
|
|
|
|
322
|
|
|
} |
323
|
|
|
if ($this->iRow > 0) { |
324
|
|
|
switch ($this->iGridStyle[1]) { |
325
|
|
|
case TGRID_SINGLE: |
326
|
|
|
$wf = 1; |
327
|
|
|
|
328
|
|
|
break; |
329
|
|
|
case TGRID_DOUBLE: |
330
|
|
|
$wf = 3; |
331
|
|
|
|
332
|
|
|
break; |
333
|
|
|
case TGRID_DOUBLE2: |
334
|
|
|
$wf = 4; |
335
|
|
|
|
336
|
|
|
break; |
337
|
|
|
} |
338
|
|
|
$this->iMarginTop += $this->iGridWeight[1] * $wf; |
339
|
|
|
} |
340
|
|
|
if ($this->iRow + $this->iRowSpan - 1 < $this->iTable->iSize[0] - 1) { |
341
|
|
|
switch ($this->iGridStyle[2]) { |
342
|
|
|
case TGRID_SINGLE: |
343
|
|
|
$wf = 1; |
344
|
|
|
|
345
|
|
|
break; |
346
|
|
|
case TGRID_DOUBLE: |
347
|
|
|
$wf = 3; |
348
|
|
|
|
349
|
|
|
break; |
350
|
|
|
case TGRID_DOUBLE2: |
351
|
|
|
$wf = 4; |
352
|
|
|
|
353
|
|
|
break; |
354
|
|
|
} |
355
|
|
|
$this->iMarginBottom += $this->iGridWeight[2] * $wf; |
356
|
|
|
} |
357
|
|
|
if ($this->iCol + $this->iColSpan - 1 < $this->iTable->iSize[1] - 1) { |
358
|
|
|
switch ($this->iGridStyle[3]) { |
359
|
|
|
case TGRID_SINGLE: |
360
|
|
|
$wf = 1; |
361
|
|
|
|
362
|
|
|
break; |
363
|
|
|
case TGRID_DOUBLE: |
364
|
|
|
$wf = 3; |
365
|
|
|
|
366
|
|
|
break; |
367
|
|
|
case TGRID_DOUBLE2: |
368
|
|
|
$wf = 4; |
369
|
|
|
|
370
|
|
|
break; |
371
|
|
|
} |
372
|
|
|
$this->iMarginRight += $this->iGridWeight[3] * $wf; |
373
|
|
|
} |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1) |
377
|
|
|
{ |
378
|
|
|
// Left or right grid line |
379
|
|
|
// For the right we increase the X-pos and for the right we decrease it. This is |
380
|
|
|
// determined by the direction argument. |
381
|
|
|
$idx = $aDir == 1 ? 0 : 3; |
382
|
|
|
|
383
|
|
|
// We don't stroke the grid lines that are on the edge of the table since this is |
384
|
|
|
// the place of the border. |
385
|
|
|
if ((($this->iCol > 0 && $idx == 0) || ($this->iCol + $this->iColSpan - 1 < $this->iTable->iSize[1] - 1 && $idx == 3)) |
|
|
|
|
386
|
|
|
&& $this->iGridWeight[$idx] > 0) { |
387
|
|
|
$x = $aDir == 1 ? $aX : $aX + $aWidth - 1; |
388
|
|
|
$y = $aY + $aHeight - 1; |
389
|
|
|
$aImg->SetColor($this->iGridColor[$idx]); |
390
|
|
|
switch ($this->iGridStyle[$idx]) { |
391
|
|
|
case TGRID_SINGLE: |
392
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
393
|
|
|
$aImg->Line($x + $i * $aDir, $aY, $x + $i * $aDir, $y); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
break; |
397
|
|
|
case TGRID_DOUBLE: |
398
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
399
|
|
|
$aImg->Line($x + $i * $aDir, $aY, $x + $i * $aDir, $y); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
$x += $this->iGridWeight[$idx] * 2; |
403
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
404
|
|
|
$aImg->Line($x + $i * $aDir, $aY, $x + $i * $aDir, $y); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
break; |
408
|
|
|
case TGRID_DOUBLE2: |
409
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx] * 2; ++$i) { |
410
|
|
|
$aImg->Line($x + $i * $aDir, $aY, $x + $i * $aDir, $y); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
$x += $this->iGridWeight[$idx] * 3; |
414
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
415
|
|
|
$aImg->Line($x + $i * $aDir, $aY, $x + $i * $aDir, $y); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
break; |
419
|
|
|
} |
420
|
|
|
} |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1) |
424
|
|
|
{ |
425
|
|
|
// Top or bottom grid line |
426
|
|
|
// For the left we increase the X-pos and for the right we decrease it. This is |
427
|
|
|
// determined by the direction argument. |
428
|
|
|
$idx = $aDir == 1 ? 1 : 2; |
429
|
|
|
|
430
|
|
|
// We don't stroke the grid lines that are on the edge of the table since this is |
431
|
|
|
// the place of the border. |
432
|
|
|
if ((($this->iRow > 0 && $idx == 1) || ($this->iRow + $this->iRowSpan - 1 < $this->iTable->iSize[0] - 1 && $idx == 2)) |
|
|
|
|
433
|
|
|
&& $this->iGridWeight[$idx] > 0) { |
434
|
|
|
$y = $aDir == 1 ? $aY : $aY + $aHeight - 1; |
435
|
|
|
$x = $aX + $aWidth - 1; |
436
|
|
|
$aImg->SetColor($this->iGridColor[$idx]); |
437
|
|
|
switch ($this->iGridStyle[$idx]) { |
438
|
|
|
case TGRID_SINGLE: |
439
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
440
|
|
|
$aImg->Line($aX, $y + $i, $x, $y + $i); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
break; |
444
|
|
|
case TGRID_DOUBLE: |
445
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
446
|
|
|
$aImg->Line($aX, $y + $i, $x, $y + $i); |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
$y += $this->iGridWeight[$idx] * 2; |
450
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
451
|
|
|
$aImg->Line($aX, $y + $i, $x, $y + $i); |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
break; |
455
|
|
|
case TGRID_DOUBLE2: |
456
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx] * 2; ++$i) { |
457
|
|
|
$aImg->Line($aX, $y + $i, $x, $y + $i); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
$y += $this->iGridWeight[$idx] * 3; |
461
|
|
|
for ($i = 0; $i < $this->iGridWeight[$idx]; ++$i) { |
462
|
|
|
$aImg->Line($aX, $y + $i, $x, $y + $i); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
break; |
466
|
|
|
} |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight) |
471
|
|
|
{ |
472
|
|
|
// If this is a merged cell we only stroke if it is the parent cell. |
473
|
|
|
// The parent cell holds the merged cell block |
474
|
|
|
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) { |
475
|
|
|
return; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
if ($this->iBGColor != '') { |
479
|
|
|
$aImg->SetColor($this->iBGColor); |
480
|
|
|
$aImg->FilledRectangle($aX, $aY, $aX + $aWidth - 1, $aY + $aHeight - 1); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
$coords = $aX . ',' . $aY . ',' . ($aX + $aWidth - 1) . ',' . $aY . ',' . ($aX + $aWidth - 1) . ',' . ($aY + $aHeight - 1) . ',' . $aX . ',' . ($aY + $aHeight - 1); |
484
|
|
|
if (!empty($this->iCSIMtarget)) { |
485
|
|
|
$this->iCSIMArea = '<area shape="poly" coords="' . $coords . '" href="' . $this->iCSIMtarget . '"'; |
486
|
|
|
if (!empty($this->iCSIMwintarget)) { |
487
|
|
|
$this->iCSIMArea .= ' target="' . $this->iCSIMwintarget . '"'; |
488
|
|
|
} |
489
|
|
|
if (!empty($this->iCSIMalt)) { |
490
|
|
|
$this->iCSIMArea .= ' alt="' . $this->iCSIMalt . '" title="' . $this->iCSIMalt . '" '; |
491
|
|
|
} |
492
|
|
|
$this->iCSIMArea .= " />\n"; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
$this->StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight); |
496
|
|
|
$this->StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, -1); |
497
|
|
|
$this->StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight); |
498
|
|
|
$this->StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, -1); |
499
|
|
|
|
500
|
|
|
if ($this->iIcon !== null) { |
501
|
|
|
switch ($this->iHorAlign) { |
502
|
|
|
case 'left': |
503
|
|
|
$x = $aX + $this->iMarginLeft; |
504
|
|
|
$hanchor = 'left'; |
505
|
|
|
|
506
|
|
|
break; |
507
|
|
|
case 'center': |
508
|
|
|
case 'middle': |
509
|
|
|
$x = $aX + $this->iMarginLeft + round(($aWidth - $this->iMarginLeft - $this->iMarginRight) / 2); |
510
|
|
|
$hanchor = 'center'; |
511
|
|
|
|
512
|
|
|
break; |
513
|
|
|
case 'right': |
514
|
|
|
$x = $aX + $aWidth - $this->iMarginRight - 1; |
515
|
|
|
$hanchor = 'right'; |
516
|
|
|
|
517
|
|
|
break; |
518
|
|
|
default: |
519
|
|
|
Util\JpGraphError::RaiseL(27012, $this->iHorAlign); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
switch ($this->iVertAlign) { |
523
|
|
|
case 'top': |
524
|
|
|
$y = $aY + $this->iMarginTop; |
525
|
|
|
$vanchor = 'top'; |
526
|
|
|
|
527
|
|
|
break; |
528
|
|
|
case 'center': |
529
|
|
|
case 'middle': |
530
|
|
|
$y = $aY + $this->iMarginTop + round(($aHeight - $this->iMarginTop - $this->iMarginBottom) / 2); |
531
|
|
|
$vanchor = 'center'; |
532
|
|
|
|
533
|
|
|
break; |
534
|
|
|
case 'bottom': |
535
|
|
|
$y = $aY + $aHeight - 1 - $this->iMarginBottom; |
536
|
|
|
$vanchor = 'bottom'; |
537
|
|
|
|
538
|
|
|
break; |
539
|
|
|
default: |
540
|
|
|
Util\JpGraphError::RaiseL(27012, $this->iVertAlign); |
541
|
|
|
} |
542
|
|
|
$this->iIcon->SetAnchor($hanchor, $vanchor); |
|
|
|
|
543
|
|
|
$this->iIcon->_Stroke($aImg, $x, $y); |
|
|
|
|
544
|
|
|
} |
545
|
|
|
$this->iVal->SetColor($this->iFontColor); |
546
|
|
|
$this->iVal->SetFont($this->iFF, $this->iFS, $this->iFSize); |
547
|
|
|
switch ($this->iHorAlign) { |
548
|
|
|
case 'left': |
549
|
|
|
$x = $aX + $this->iMarginLeft; |
550
|
|
|
|
551
|
|
|
break; |
552
|
|
|
case 'center': |
553
|
|
|
case 'middle': |
554
|
|
|
$x = $aX + $this->iMarginLeft + round(($aWidth - $this->iMarginLeft - $this->iMarginRight) / 2); |
555
|
|
|
|
556
|
|
|
break; |
557
|
|
|
case 'right': |
558
|
|
|
$x = $aX + $aWidth - $this->iMarginRight - 1; |
559
|
|
|
|
560
|
|
|
break; |
561
|
|
|
default: |
562
|
|
|
Util\JpGraphError::RaiseL(27012, $this->iHorAlign); |
563
|
|
|
} |
564
|
|
|
// A workaround for the shortcomings in the TTF font handling in GD |
565
|
|
|
// The anchor position for rotated text (=90) is to "short" so we add |
566
|
|
|
// an offset based on the actual font size |
567
|
|
|
if ($this->iVal->dir != 0 && $this->iVal->font_family >= 10) { |
568
|
|
|
$aY += 4 + round($this->iVal->font_size * 0.8); |
569
|
|
|
} |
570
|
|
|
switch ($this->iVertAlign) { |
571
|
|
|
case 'top': |
572
|
|
|
$y = $aY + $this->iMarginTop; |
573
|
|
|
|
574
|
|
|
break; |
575
|
|
|
case 'center': |
576
|
|
|
case 'middle': |
577
|
|
|
$y = $aY + $this->iMarginTop + round(($aHeight - $this->iMarginTop - $this->iMarginBottom) / 2); |
578
|
|
|
//$y -= round($this->iVal->GetFontHeight($aImg)/2); |
579
|
|
|
$y -= round($this->iVal->GetHeight($aImg) / 2); |
580
|
|
|
|
581
|
|
|
break; |
582
|
|
|
case 'bottom': |
583
|
|
|
//$y = $aY+$aHeight-1-$this->iMarginBottom-$this->iVal->GetFontHeight($aImg); |
584
|
|
|
$y = $aY + $aHeight - $this->iMarginBottom - $this->iVal->GetHeight($aImg); |
585
|
|
|
|
586
|
|
|
break; |
587
|
|
|
default: |
588
|
|
|
Util\JpGraphError::RaiseL(27012, $this->iVertAlign); |
589
|
|
|
} |
590
|
|
|
$this->iVal->SetAlign($this->iHorAlign, 'top'); |
591
|
|
|
if ($this->iNumberFormat !== null && is_numeric($this->iVal->t)) { |
592
|
|
|
$this->iVal->t = sprintf($this->iNumberFormat, $this->iVal->t); |
593
|
|
|
} |
594
|
|
|
$this->iVal->Stroke($aImg, $x, $y); |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
/* |
599
|
|
|
EOF |
600
|
|
|
*/ |
601
|
|
|
|