RequestOutputPlotPageNodeClass.php 3.5 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");

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

?>