Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxesNodeClass.php 2.82 KB
22521f1c   Benjamin Renard   First commit
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
<?php

require_once("RequestOutputPlotTimeAxisNodeClass.php");
require_once("RequestOutputPlotDigitalAxisNodeClass.php");
require_once("RequestOutputPlotColorAxisNodeClass.php");

define ("REQUESTOUTPUTPLOTAXES_NAME", "axes");
define ("REQUESTOUTPUTPLOTAXES_XAXIS", "xAxis");
define ("REQUESTOUTPUTPLOTAXES_YAXIS", "yAxis");
define ("REQUESTOUTPUTPLOTAXES_ZAXIS", "zAxis");

abstract class RequestOutputPlotAxisTypeEnum
{
	const XAXIS = REQUESTOUTPUTPLOTAXES_XAXIS;
	const YAXIS = REQUESTOUTPUTPLOTAXES_YAXIS;
	const ZAXIS = REQUESTOUTPUTPLOTAXES_ZAXIS;
}

/**
 * @class RequestOutputPlotAxesNodeClass
 * @brief Definition of a axes element for a plot of a plot request
 * @details
 */
class RequestOutputPlotAxesNodeClass extends NodeClass
{
17f69bd1   Benjamin Renard   Add tick plot and...
26
	public function __construct($noXAxis, $noYAxis, $noZAxis)
22521f1c   Benjamin Renard   First commit
27
28
29
	{
		parent::__construct(REQUESTOUTPUTPLOTAXES_NAME);
		//create skeleton
17f69bd1   Benjamin Renard   Add tick plot and...
30
31
32
33
34
35
		if (!$noXAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_XAXIS, true);
		if (!$noYAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_YAXIS, true);
		if (!$noZAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_ZAXIS, true);
22521f1c   Benjamin Renard   First commit
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
	}

	public function addDigitalAxis($axisType,$id)
	{
		if (($axisType != RequestOutputPlotAxisTypeEnum::XAXIS) && ($axisType != RequestOutputPlotAxisTypeEnum::YAXIS))
			return NULL;

		$axisNode = $this->getChildInstanceByName($axisType);
		//add digital axis
		$digitalAxisNode = new RequestOutputPlotDigitalAxisNodeClass();
		$digitalAxisNode->setId($id);
		$axisNode->addChild($digitalAxisNode);
		return $digitalAxisNode;
	}

	public function getDigitalAxis($axisType,$id)
	{
		if (($axisType != RequestOutputPlotAxisTypeEnum::XAXIS) && ($axisType != RequestOutputPlotAxisTypeEnum::YAXIS))
			return NULL;
			
		$axisNode = $this->getChildInstanceByName($axisType);
		$digitalAxisNodes = $axisNode->getChildrenByName(REQUESTOUTPUTPLOTDIGITALAXIS_NAME);
		foreach ($digitalAxisNodes as $digitalAxisNode)
		if ($digitalAxisNode->getId() == $id)
			return $digitalAxisNode;

		return NULL;
	}

	public function getTimeAxis()
	{
		$axisNode = $this->getChildInstanceByName(RequestOutputPlotAxisTypeEnum::XAXIS);
		$timeAxisNode = $axisNode->getFirstChildByName(REQUESTOUTPUTPLOTTIMEAXIS_NAME);
		if (!isset($timeAxisNode))
		{
			$timeAxisNode = new RequestOutputPlotTimeAxisNodeClass();
			$axisNode->addChild($timeAxisNode);
		}
		
		return $timeAxisNode;
	}

	public function getColorAxis()
	{
		$axisNode = $this->getChildInstanceByName(RequestOutputPlotAxisTypeEnum::ZAXIS);
		$colorAxisNode = $axisNode->getFirstChildByName(REQUESTOUTPUTPLOTCOLORAXIS_NAME);
		if (!isset($colorAxisNode))
		{
			$colorAxisNode = new RequestOutputPlotColorAxisNodeClass();
			$axisNode->addChild($colorAxisNode);
		}
		
		return $colorAxisNode;
	}
}

?>