RequestOutputPlotYSerieErrorBarNodeClass.php 3.31 KB
<?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);
	}
}

/**
 * @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;
	}
}

?>