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