Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotYSerieErrorBarNodeClass.php 3.75 KB
26a23052   Benjamin Renard   Add Interval Tick...
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
<?php

define ("REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_NAME", "errorMinMax");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAM", "paramMin");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAMINDEX", "indexMin");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAM", "paramMax");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAMINDEX", "indexMax");

define ("REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_NAME", "errorDelta");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_PARAM", "param");
define ("REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_PARAMINDEX", "index");

define ("REQUESTOUTPUTPLOTYSERIEERRORBAR_LINE", "line");

abstract class RequestOutputPlotYSerieErrorBarTypeEnum
{
	const MINMAX = "min-max";
	const DELTA  = "delta";
}

/**
 * @class RequestOutputPlotYSerieErrorBarMinMaxNodeClass
 * @brief Definition of error bar min/max element for a yserie of a plot
 * @details
 */
class RequestOutputPlotYSerieErrorBarMinMaxNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_NAME);
	}
	
	public function setMinParam($param, $index = -1)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAM, $param);
		if ($index != -1)
			$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAMINDEX, $index);
	}
	
	public function setMaxParam($param, $index = -1)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAM, $param);
		if ($index != -1)
			$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAMINDEX, $index);
	}
966bd5f8   Benjamin Renard   Add request to ge...
46
47
48
49
50
51
	
	public function loadFromNode($xmlNode)
	{
		$this->setMinParam($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAM), $this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MINPARAMINDEX));
		$this->setMaxParam($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAM), $this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_MAXPARAMINDEX));
	}
26a23052   Benjamin Renard   Add Interval Tick...
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
}

/**
 * @class RequestOutputPlotYSerieErrorBarDeltaNodeClass
 * @brief Definition of error bar delta element for a yserie of a plot
 * @details
 */
class RequestOutputPlotYSerieErrorBarDeltaNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_NAME);
	}
	
	public function setDeltaParam($param, $index = -1)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_PARAM, $param);
		if ($index != -1)
			$this->setAttribute(REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_PARAMINDEX, $index);
	}
}

/**
 * @class RequestOutputPlotYSerieErrorBarNodeClass
 * @brief Definition of error bar element for a yserie of a plot
 * @details
 */
class RequestOutputPlotYSerieErrorBarNodeClass extends NodeClass
{
	public function __construct($name)
	{
		parent::__construct($name);
		
		//Force line node creation
		$this->getLine();
	}

	public function getLine()
	{
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTYSERIEERRORBAR_LINE);
	
		if (!isset($node))
		{
			$node = new RequestOutputPlotLineNodeClass(REQUESTOUTPUTPLOTYSERIEERRORBAR_LINE);
			$this->addChild($node);
		}
	
		return $node;
	}
	
	public function getBarByType($type)
	{
		switch ($type)
		{
			case RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX :
				$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTYSERIEERRORBARMINMAX_NAME);
	
				if (!isset($node))
				{
					$node = new RequestOutputPlotYSerieErrorBarMinMaxNodeClass();
					$this->addChild($node);
				}
	
				return $node;
			case RequestOutputPlotYSerieErrorBarTypeEnum::DELTA :
				$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTYSERIEERRORBARDELTA_NAME);
	
				if (!isset($node))
				{
					$node = new RequestOutputPlotYSerieErrorBarDeltaNodeClass();
					$this->addChild($node);
				}
	
				return $node;
		}
		return NULL;
	}
}

?>