RequestOutputPlotPageNodeClass.php 5.64 KB
<?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");
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");

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);
	}

	public function getTitle()
	{
		$node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPAGE_TITLE);
		
		if (!isset($node))
		{
			$node = new RequestOutputPlotTitleNodeClass();
			$this->addChild($node);
		}
		
		return $node;
	}

	public function getMargins()
	{
		$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;
	}

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

	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);
	}
	
	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."]");
	}
}

?>