2 /* Libchart - PHP chart library
3 * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
24 * Created on 30 july 2007
27 protected $labelBoxWidth;
28 protected $labelBoxHeight;
40 * Constructor of Caption
42 public function Caption() {
43 $this->labelBoxWidth = 15;
44 $this->labelBoxHeight = 15;
50 public function render() {
51 // Get graphical obects
52 $img = $this->plot->getImg();
53 $palette = $this->plot->getPalette();
54 $text = $this->plot->getText();
55 $primitive = $this->plot->getPrimitive();
57 // Get the caption area
58 $captionArea = $this->plot->getCaptionArea();
60 // Get the pie color set
61 $colorSet = $this->colorSet;
65 foreach ($this->labelList as $label) {
67 $color = $colorSet->currentColor();
70 $boxX1 = $captionArea->x1;
71 $boxX2 = $boxX1 + $this->labelBoxWidth;
72 $boxY1 = $captionArea->y1 + 5 + $i * ($this->labelBoxHeight + 5);
73 $boxY2 = $boxY1 + $this->labelBoxHeight;
75 $primitive->outlinedBox($boxX1, $boxY1, $boxX2, $boxY2, $palette->axisColor[0], $palette->axisColor[1]);
76 imagefilledrectangle($img, $boxX1 + 2, $boxY1 + 2, $boxX2 - 2, $boxY2 - 2, $color->getColor($img));
78 $text->printText($img, $boxX2 + 5, $boxY1 + $this->labelBoxHeight / 2, $this->plot->getTextColor(), $label, $text->fontCondensed, $text->VERTICAL_CENTER_ALIGN);
87 * @param Plot The plot
89 public function setPlot($plot) {
94 * Sets the label list.
96 * @param Array label list
98 public function setLabelList($labelList) {
99 $this->labelList = $labelList;
104 * Sets the color set.
106 * @param Array Color set
108 public function setColorSet($colorSet) {
109 $this->colorSet = $colorSet;