Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPageNodeClass.php 7.59 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
<?php

require_once("RequestOutputPlotPanelNodeClass.php");
require_once("RequestOutputPlotLayoutNodeClass.php");

define ("REQUESTOUTPUTPLOTPAGE_NAME", "page");
define ("REQUESTOUTPUTPLOTPAGE_TITLE", "title");
define ("REQUESTOUTPUTPLOTPAGE_FORMAT", "format");
define ("REQUESTOUTPUTPLOTPAGE_DIMENSION", "dimension");
define ("REQUESTOUTPUTPLOTPAGE_ORIENTATION", "orientation");
define ("REQUESTOUTPUTPLOTPAGE_MODE", "mode");
c0e7e5be   Benjamin Renard   Add integration f...
12
13
14
15
16
17
18
define ("REQUESTOUTPUTPLOTPAGE_SUPERPOSEMODE", "superposeMode");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTWIDTH", "defaultTimePlotWidth");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTHEIGHT", "defaultTimePlotHeight");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTWIDTH", "defaultXYPlotWidth");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTHEIGHT", "defaultXYPlotHeight");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTXMARGIN", "defaultTimePlotXMargin");
define ("REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTXMARGIN", "defaultXYPlotXMargin");
22521f1c   Benjamin Renard   First commit
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

abstract class RequestOutputPlotPageFormatEnum
{
	const PNG = "png";
	const PDF = "pdf";
	const PS  = "ps";
	const SVG = "svg";
}

abstract class RequestOutputPlotPageDimensionEnum
{
	const ISO_A4 = "ISO A4";
	const US_LETTER = "US letter";
}

abstract class RequestOutputPlotPageOrientationEnum
{
	const LANDSCAPE = "landscape";
	const PORTRAIT  = "portrait";
}

abstract class RequestOutputPlotPageModeEnum
{
	const COLOR     = "color";
	const GRAYSCALE = "grayscale";
}

/**
 * @class RequestOutputPlotNodeClass
 * @brief Definition of a page for a plot request
 * @details
 */
class RequestOutputPlotPageNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOTPAGE_NAME);
		//default attributes
		$this->setFormat(RequestOutputPlotPageFormatEnum::PNG);
		$this->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4);
		$this->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT);
		$this->setMode(RequestOutputPlotPageModeEnum::COLOR);
	}

8c57155b   Benjamin Renard   Integration for t...
63
	public function getTitle()
22521f1c   Benjamin Renard   First commit
64
	{
8c57155b   Benjamin Renard   Integration for t...
65
66
67
68
69
70
71
72
73
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPAGE_TITLE);
		
		if (!isset($node))
		{
			$node = new RequestOutputPlotTitleNodeClass();
			$this->addChild($node);
		}
		
		return $node;
22521f1c   Benjamin Renard   First commit
74
75
	}

8c57155b   Benjamin Renard   Integration for t...
76
	public function getMargins()
22521f1c   Benjamin Renard   First commit
77
	{
8c57155b   Benjamin Renard   Integration for t...
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTMARGINS_NAME);
		
		if (!isset($node))
		{
			$node = new RequestOutputPlotMarginsNodeClass();
			$this->addChild($node);
		}
		
		return $node;
	}
	
	public function getFont()
	{
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTFONT_NODENAME);
	
		if (!isset($node))
		{
			$node = new RequestOutputPlotFontNodeClass();
			$this->addChild($node);
		}
	
		return $node;
22521f1c   Benjamin Renard   First commit
100
	}
22521f1c   Benjamin Renard   First commit
101
102
103
104
105
106
107
108
109
110
111
112
113
114

	public function getLayout()
	{
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTLAYOUT_NAME);
		
		if (!isset($node))
		{
			$node = new RequestOutputPlotLayoutNodeClass();
			$this->addChild($node);
		}
		
		return $node;
	}

22521f1c   Benjamin Renard   First commit
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
	public function addPanel()
	{
		$node = new RequestOutputPlotPanelNodeClass();
		$this->addChild($node);
		return $node;
	}

	public function getPanels()
	{
		return $this->getChildrenByName(REQUESTOUTPUTPLOTPANEL_NAME);
	}

	public function setFormat($format)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_FORMAT, $format);
	}

	public function getFormat()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_FORMAT);
	}

	public function setDimension($dimension)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DIMENSION, $dimension);
	}

	public function getDimension()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_DIMENSION);
	}

	public function setOrientation($orientation)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_ORIENTATION, $orientation);
	}

	public function getOrientation()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_ORIENTATION);
	}

	public function setMode($mode)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_MODE, $mode);
	}

	public function getMode()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_MODE);
	}
c0e7e5be   Benjamin Renard   Add integration f...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
	
	public function setSuperposeMode($superposeMode)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_SUPERPOSEMODE, $superposeMode);
	}
	
	public function getSuperposeMode()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_SUPERPOSEMODE);
	}
	
	public function setDefaultTimePlotWidth($width)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTWIDTH, $width);
	}
	
	public function getDefaultTimePlotWidth()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTWIDTH);
	}
	
	public function setDefaultTimePlotHeight($height)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTHEIGHT, $height);
	}
	
	public function getDefaultTimePlotHeight()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTHEIGHT);
	}
	
	public function setDefaultXYPlotWidth($width)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTWIDTH, $width);
	}
	
	public function getDefaultXYPlotWidth()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTWIDTH);
	}
	
	public function setDefaultXYPlotHeight($height)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTHEIGHT, $height);
	}
	
	public function getDefaultXYPlotHeight()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTHEIGHT);
	}
	
	public function setDefaultTimePlotXMargin($left, $right)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTXMARGIN, "[".$left.",".$right."]");
	}
	
	public function setDefaultXYPlotXMargin($left, $right)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTXMARGIN, "[".$left.",".$right."]");
	}
966bd5f8   Benjamin Renard   Add request to ge...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
	
	public function loadFromNode($xmlNode)
	{
		$titleXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTPAGE_TITLE);
		if (isset($titleXmlNode))
			$this->getTitle()->loadFromNode($titleXmlNode);
		
		$marginsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTMARGINS_NAME);
		if (isset($marginsXmlNode))
			$this->getMargins()->loadFromNode($marginsXmlNode);
		
		$fontXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTFONT_NODENAME);
		if (isset($fontXmlNode))
			$this->getFont()->loadFromNode($fontXmlNode);
		
		$layoutXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTLAYOUT_NAME);
		if (isset($layoutXmlNode))
			$this->getLayout()->loadFromNode($layoutXmlNode);
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTPLOTPANEL_NAME) as $panelXmlNode) {
			$this->addPanel()->loadFromNode($panelXmlNode);
		}
		
		$this->setFormat($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_FORMAT));
		$this->setDimension($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DIMENSION));
		$this->setOrientation($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_ORIENTATION));
		$this->setMode($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_MODE));
		$this->setSuperposeMode($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_SUPERPOSEMODE));
		$this->setDefaultTimePlotWidth($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTWIDTH));
		$this->setDefaultTimePlotHeight($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTHEIGHT));
		$this->setDefaultXYPlotWidth($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTWIDTH));
		$this->setDefaultXYPlotHeight($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DEFAULTXYPLOTHEIGHT));
		$this->setDefaultTimePlotXMargin($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPAGE_DEFAULTTIMEPLOTXMARGIN));
	}
22521f1c   Benjamin Renard   First commit
260
261
262
}

?>