ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilChartLegend.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $position; // [string]
14 protected $columns; // [int]
15 protected $margin_x; // [int]
16 protected $margin_y; // [int]
17 protected $background; // [color]
18 protected $opacity; // [float] 0-1
19 protected $border; // [color]
20 protected $container; // [string]
21
25 public function __construct()
26 {
27 $this->setPosition("ne");
28 $this->setColumns(1);
29 $this->setMargin(5, 5);
30 $this->setBackground("#888");
31 $this->setOpacity(0.1);
32 $this->setLabelBorder("#bbb");
33 }
34
40 public function setPosition($a_position)
41 {
42 $all = array("ne", "nw", "se", "sw");
43 if (in_array((string) $a_position, $all)) {
44 $this->position = (string) $a_position;
45 }
46 }
47
53 public function getPosition()
54 {
55 return $this->position;
56 }
57
63 public function setColumns($a_value)
64 {
65 $this->columns = (int) $a_value;
66 }
67
73 public function getColumns()
74 {
75 return $this->columns;
76 }
77
84 public function setMargin($a_x, $a_y)
85 {
86 $this->margin_x = (int) $a_x;
87 $this->margin_y = (int) $a_y;
88 }
89
95 public function getMargin()
96 {
97 return array("x"=>$this->margin_x, "y"=>$this->margin_y);
98 }
99
105 public function setBackground($a_color)
106 {
107 if (ilChart::isValidColor($a_color)) {
108 $this->background = $a_color;
109 }
110 }
111
117 public function getBackground()
118 {
119 return $this->background;
120 }
121
127 public function setOpacity($a_value)
128 {
129 $a_value = (float) $a_value;
130 if ($a_value >= 0 && $a_value <= 1) {
131 $this->opacity = $a_value;
132 }
133 }
134
140 public function getOpacity()
141 {
142 return $this->opacity;
143 }
144
150 public function setLabelBorder($a_color)
151 {
152 if (ilChart::isValidColor($a_color)) {
153 $this->border = $a_color;
154 }
155 }
156
162 public function getLabelBorder()
163 {
164 return $this->border;
165 }
166
172 public function setContainer($a_value)
173 {
174 $this->container = trim($a_value);
175 }
176
182 public function getContainer()
183 {
184 return $this->container;
185 }
186
192 public function parseOptions(stdClass $a_options)
193 {
194 $a_options->show = true;
195
196 $a_options->noColumns = $this->getColumns();
197 $a_options->position = $this->getPosition();
198
199 $margin = $this->getMargin();
200 $a_options->margin = array($margin["x"], $margin["y"]);
201
202 $a_options->backgroundColor = ilChart::renderColor($this->getBackground());
203 $a_options->backgroundOpacity = str_replace(",", ".", $this->getOpacity());
204 $a_options->labelBoxBorderColor = ilChart::renderColor($this->getLabelBorder());
205
206 $container = $this->getContainer();
207 if ($container) {
208 $a_options->container = '#' . $container;
209 }
210 }
211}
An exception for terminatinating execution or to throw for unit testing.
setColumns($a_value)
Set number of columns.
setMargin($a_x, $a_y)
Set margins.
setLabelBorder($a_color)
Set label border.
getPosition()
Get Position.
setContainer($a_value)
Set container id.
setOpacity($a_value)
Set Opacity.
parseOptions(stdClass $a_options)
Convert (global) properties to flot config.
getLabelBorder()
Get label border.
setPosition($a_position)
Set Position.
getColumns()
Get number of columns.
getBackground()
Get background color.
getContainer()
Get container id.
getOpacity()
Get opacity.
getMargin()
Get margins.
setBackground($a_color)
Set background color.
__construct()
Constructor.
static renderColor($a_value, $a_opacity=1)
Render html color code.
static isValidColor($a_value)
Validate html color code.