From fe1a8ddd101edc0cdfcc4b19f4645f230dc9b152 Mon Sep 17 00:00:00 2001 From: Erdogan Furkan <furkan.erdogan1205@gmail.com> Date: Tue, 26 Jul 2022 14:32:16 +0000 Subject: [PATCH] Modifications for the integration part --- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 33 ++++++++++++++++++++------------- src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php | 41 +++++++++++++++++++++++++++++++++++++++++ src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php | 6 ++---- 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index b035eef..ca0be3b 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -404,8 +404,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend()); //Text Legends - foreach ($panelData->{'text-legends'} as $textLegendData) - $this->unmarshallTextLegend($textLegendData, $plotNode->getLegends()); + foreach ($panelData->{'text-legends'} as $textLegendData) { + $legendNode = $plotNode->getLegends()->addTextLegend(); + $this->unmarshallTextLegend($textLegendData, $legendNode); + } return $plotNode; } @@ -957,7 +959,12 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass } else { $color = $this->hexColor2KernelColor($paramDrawingData->{'intervals-color'}); } - $paramNode->addIntervals($color); + + $intervalsNode = $paramNode->addIntervals($color); + $textLegendNode = $intervalsNode->addTextLegend(); + + $this->unmarshallTextLegend($paramDrawingData, $textLegendNode); + } protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes) @@ -1036,35 +1043,35 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont()); } - protected function unmarshallTextLegend($textLegendData, $legendsNode) + protected function unmarshallTextLegend($textLegendData, $parentNode) { - $legendNode = $legendsNode->addTextLegend(); //Legend text - $legendNode->setText($textLegendData->{'legend-text-value'}); + $parentNode->setText($textLegendData->{'legend-text-value'}); //Legend position switch ($textLegendData->{'legend-text-position'}) { case 'top': - $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP); + $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP); break; case 'bottom': - $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM); + $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM); break; case 'left': - $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT); + $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT); break; case 'right': default: - $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT); + $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT); } //Legend text color - $legendNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'})); + $parentNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'})); //Font - if ($textLegendData->{'legend-text-font-activated'}) - $this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont()); + if ($textLegendData->{'legend-text-font-activated'}) { + $this->unmarshallFont($textLegendData, 'legend-text-font', $parentNode->getFont()); + } } protected function unmarshallConstant($constantData, $axisNode) diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php new file mode 100644 index 0000000..d011edf --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php @@ -0,0 +1,41 @@ +<?php + +define("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals"); +define("REQUESTOUTPUTPLOTINTERVALS_COLOR", "color"); + + +/** + * @class RequestOutputPlotTextLegendNodeClass + * @brief Definition of a "text legend" element for a plot + * @details + */ +class RequestOutputPlotIntervalsNodeClass extends NodeClass +{ + public $textLegendNode = null; + public function __construct() + { + parent::__construct(REQUESTOUTPUTPLOTINTERVALS_NAME); + } + + public function setColor($color) + { + $this->setAttribute(REQUESTOUTPUTPLOTINTERVALS_COLOR, $color); + } + + public function getColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTINTERVALS_COLOR); + } + + public function addTextLegend() + { + $this->textLegendNode = new RequestOutputPlotTextLegendNodeClass(); + $this->addChild($this->textLegendNode); + return $this->textLegendNode; + } + + public function loadFromNode($xmlNode) + { + $this->setColor($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTINTERVALS_COLOR)); + } +} diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php index 685d7dc..8207a1a 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php @@ -54,8 +54,6 @@ define("REQUESTOUTPUTPLOTSTATUSBAR_COLOR", "color"); define("REQUESTOUTPUTPLOTTICKBAR_NAME", "serie"); define("REQUESTOUTPUTPLOTTICKBAR_INDEX", "index"); -define("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals"); -define("REQUESTOUTPUTPLOTINTERVALS_COLOR", "color"); /** * @class RequestOutputPlotParamNodeClass @@ -256,9 +254,9 @@ class RequestOutputPlotParamNodeClass extends NodeClass public function addIntervals($color = NULL) { - $intervalsNode = new NodeClass(REQUESTOUTPUTPLOTINTERVALS_NAME); + $intervalsNode = new RequestOutputPlotIntervalsNodeClass(); if ($color != NULL) { - $intervalsNode->setAttribute(REQUESTOUTPUTPLOTINTERVALS_COLOR, $color); + $intervalsNode->setColor($color); } $this->addChild($intervalsNode); return $intervalsNode; -- libgit2 0.21.2