1<?php
2
3/**
4 * @brief Holds Metadata for the data set (name, unit, type etc.)
5 *
6 * The data description assumes we have X and Y axes, which isn't
7 * necessarily the case (e.g. if we are generating a pie chart). This
8 * is probably a design flaw.
9 */
10class DataDescription {
11	public function __construct($position, $xFormat, $yFormat, $xUnit, $yUnit) {
12		$this->position = $position;
13		$this->xFormat = $xFormat;
14		$this->yFormat = $yFormat;
15		$this->xUnit = $xUnit;
16		$this->yUnit = $yUnit;
17
18		$this->xAxisName = '';
19		$this->yAxisName = '';
20	}
21
22	/**
23	 * @todo I don't know exactly what the Position does
24	 */
25	public function setPosition($position) {
26		if (!is_string($position)) {
27			throw new InvalidArgumentException("Non-string argument passed to setPosition");
28		}
29
30		$this->position = $position;
31	}
32
33	public function getPosition() {
34		return $this->position;
35	}
36
37	public function setXAxisName($name) {
38		if (!is_string($name)) {
39			throw new InvalidArgumentException("Non-string argument passed to DataDescription::setXAxisName()");
40		}
41
42		$this->xAxisName = $name;
43	}
44
45	public function getXAxisName() {
46		return $this->xAxisName;
47	}
48
49	public function setYAxisName($name) {
50		if (!is_string($name)) {
51			throw new InvalidArgumentException("Non-string argument passed to DataDescription::setYAxisName()");
52		}
53		$this->yAxisName = $name;
54	}
55
56	public function getYAxisName() {
57		return $this->yAxisName;
58	}
59
60	/**
61	 * @todo Not sure I'm happy with the name of this - should it be
62	 * setXAxisFormat()?
63	 */
64	public function setXFormat($format) {
65		/** @todo Check that $format is a recognised format value here */
66		$this->xFormat = $format;
67	}
68
69	public function getXFormat() {
70		return $this->xFormat;
71	}
72
73	public function setYFormat($format) {
74		$this->yFormat = $format;
75	}
76
77	public function getYFormat() {
78		return $this->yFormat;
79	}
80
81	public function setXUnit($unit) {
82		$this->xUnit = $unit;
83	}
84
85	public function getXUnit() {
86		return $this->xUnit;
87	}
88
89	public function setYUnit($unit) {
90		$this->yUnit = $unit;
91	}
92
93	public function getYUnit() {
94		return $this->yUnit;
95	}
96
97	public function getColumnIndex($columnName) {
98		$ID = 0;
99		foreach (array_keys($this->description) as $keyI) {
100			if ($keyI == $columnName) {
101				return $ID;
102			}
103
104			$ID ++;
105		}
106	}
107
108	private $position;
109	private $xFormat;
110	private $yFormat;
111	private $xUnit;
112	private $yUnit;
113	private $xAxisName;
114	private $yAxisName;
115
116	/**
117	 * @todo This shouldn't be a public member, this is a transitional
118	 * step while refactoring
119	 */
120	public $values = array();
121
122	public $description;
123
124	public $seriesSymbols = array();
125}