forked from Ben0it-T/timetracker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCaption.php
More file actions
112 lines (95 loc) · 2.76 KB
/
Caption.php
File metadata and controls
112 lines (95 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/* Libchart - PHP chart library
* Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Caption.
*
* @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
* Created on 30 july 2007
*/
class Caption {
protected $labelBoxWidth;
protected $labelBoxHeight;
// Plot
protected $plot;
// Label list
protected $labelList;
// Color set
protected $colorSet;
/**
* Constructor of Caption
*/
public function __construct() {
$this->labelBoxWidth = 15;
$this->labelBoxHeight = 15;
}
/**
* Render the caption.
*/
public function render() {
// Get graphical obects
$img = $this->plot->getImg();
$palette = $this->plot->getPalette();
$text = $this->plot->getText();
$primitive = $this->plot->getPrimitive();
// Get the caption area
$captionArea = $this->plot->getCaptionArea();
// Get the pie color set
$colorSet = $this->colorSet;
$colorSet->reset();
$i = 0;
foreach ($this->labelList as $label) {
// Get the next color
$color = $colorSet->currentColor();
$colorSet->next();
$boxX1 = $captionArea->x1;
$boxX2 = $boxX1 + $this->labelBoxWidth;
$boxY1 = $captionArea->y1 + 5 + $i * ($this->labelBoxHeight + 5);
$boxY2 = $boxY1 + $this->labelBoxHeight;
$primitive->outlinedBox($boxX1, $boxY1, $boxX2, $boxY2, $palette->axisColor[0], $palette->axisColor[1]);
imagefilledrectangle($img, $boxX1 + 2, $boxY1 + 2, $boxX2 - 2, $boxY2 - 2, $color->getColor($img));
$text->printText($img, $boxX2 + 5, $boxY1 + $this->labelBoxHeight / 2, $this->plot->getTextColor(), $label, $text->fontCondensed, $text->VERTICAL_CENTER_ALIGN);
$i++;
}
}
/**
* Sets the plot.
*
* @param Plot The plot
*/
public function setPlot($plot) {
$this->plot = $plot;
}
/**
* Sets the label list.
*
* @param Array label list
*/
public function setLabelList($labelList) {
$this->labelList = $labelList;
}
/**
* Sets the color set.
*
* @param Array Color set
*/
public function setColorSet($colorSet) {
$this->colorSet = $colorSet;
}
}
?>