Commit 70646e70a1c37997b12fe5256e58f5cbc04ffa72
1 parent
c958695a
Exists in
master
and in
66 other branches
Add text legend definition
Showing
3 changed files
with
116 additions
and
1 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -357,10 +357,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
357 | 357 | throw new Exception('Plot type not implemented.'); |
358 | 358 | } |
359 | 359 | |
360 | - //Params Legends | |
360 | + //Params Legend | |
361 | 361 | if (isset($panelData->{'panel-series-legend'}) && $panelData->{'panel-series-legend'}->{'legend-series-activated'}) |
362 | 362 | $this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend()); |
363 | 363 | |
364 | + //Text Legends | |
365 | + foreach ($panelData->{'text-legends'} as $textLegendData) | |
366 | + $this->unmarshallTextLegend($textLegendData, $plotNode->getLegends()); | |
367 | + | |
364 | 368 | return $plotNode; |
365 | 369 | } |
366 | 370 | |
... | ... | @@ -746,6 +750,38 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
746 | 750 | $this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont()); |
747 | 751 | } |
748 | 752 | |
753 | + protected function unmarshallTextLegend($textLegendData, $legendsNode) | |
754 | + { | |
755 | + $legendNode = $legendsNode->addTextLegend(); | |
756 | + | |
757 | + //Legend text | |
758 | + $legendNode->setText($textLegendData->{'legend-text-value'}); | |
759 | + | |
760 | + //Legend position | |
761 | + switch ($textLegendData->{'legend-text-position'}) | |
762 | + { | |
763 | + case 'top' : | |
764 | + $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP); | |
765 | + break; | |
766 | + case 'bottom' : | |
767 | + $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM); | |
768 | + break; | |
769 | + case 'left' : | |
770 | + $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT); | |
771 | + break; | |
772 | + case 'right' : | |
773 | + default : | |
774 | + $legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT); | |
775 | + } | |
776 | + | |
777 | + //Legend text color | |
778 | + $legendNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'})); | |
779 | + | |
780 | + //Font | |
781 | + if ($textLegendData->{'legend-text-font-activated'}) | |
782 | + $this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont()); | |
783 | + } | |
784 | + | |
749 | 785 | protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) |
750 | 786 | { |
751 | 787 | if ($inputData->{$keyPrefix.'-text'} != '') |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotLegendsNodeClass.php
... | ... | @@ -26,6 +26,13 @@ class RequestOutputPlotLegendsNodeClass extends NodeClass |
26 | 26 | |
27 | 27 | return $node; |
28 | 28 | } |
29 | + | |
30 | + public function addTextLegend() | |
31 | + { | |
32 | + $node = new RequestOutputPlotTextLegendNodeClass(); | |
33 | + $this->addChild($node); | |
34 | + return $node; | |
35 | + } | |
29 | 36 | } |
30 | 37 | |
31 | 38 | ?> |
32 | 39 | \ No newline at end of file |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTextLegendNodeClass.php
0 โ 100644
... | ... | @@ -0,0 +1,72 @@ |
1 | +<?php | |
2 | + | |
3 | +define ("REQUESTOUTPUTPLOTTEXTLEGEND_NAME", "textLegend"); | |
4 | +define ("REQUESTOUTPUTPLOTTEXTLEGEND_TEXT", "text"); | |
5 | +define ("REQUESTOUTPUTPLOTTEXTLEGEND_POSITION", "position"); | |
6 | +define ("REQUESTOUTPUTPLOTTEXTLEGEND_COLOR", "color"); | |
7 | + | |
8 | +abstract class RequestOutputPlotTextLegendPositionEnum | |
9 | +{ | |
10 | + const LEFT = "left"; | |
11 | + const RIGHT = "right"; | |
12 | + const BOTTOM = "bottom"; | |
13 | + const TOP = "top"; | |
14 | +} | |
15 | + | |
16 | +/** | |
17 | + * @class RequestOutputPlotTextLegendNodeClass | |
18 | + * @brief Definition of a "text legend" element for a plot | |
19 | + * @details | |
20 | + */ | |
21 | +class RequestOutputPlotTextLegendNodeClass extends NodeClass | |
22 | +{ | |
23 | + public function __construct() | |
24 | + { | |
25 | + parent::__construct(REQUESTOUTPUTPLOTTEXTLEGEND_NAME); | |
26 | + } | |
27 | + | |
28 | + public function setText($text) | |
29 | + { | |
30 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_TEXT, $text); | |
31 | + } | |
32 | + | |
33 | + public function getText() | |
34 | + { | |
35 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_TEXT); | |
36 | + } | |
37 | + | |
38 | + public function setPosition($position) | |
39 | + { | |
40 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_POSITION, $position); | |
41 | + } | |
42 | + | |
43 | + public function getPosition() | |
44 | + { | |
45 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_POSITION); | |
46 | + } | |
47 | + | |
48 | + public function setColor($color) | |
49 | + { | |
50 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_COLOR, $color); | |
51 | + } | |
52 | + | |
53 | + public function getColor() | |
54 | + { | |
55 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXTLEGEND_COLOR); | |
56 | + } | |
57 | + | |
58 | + public function getFont() | |
59 | + { | |
60 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPARAMSLEGEND_FONT); | |
61 | + | |
62 | + if (!isset($node)) | |
63 | + { | |
64 | + $node = new RequestOutputPlotFontNodeClass(); | |
65 | + $this->addChild($node); | |
66 | + } | |
67 | + | |
68 | + return $node; | |
69 | + } | |
70 | +} | |
71 | + | |
72 | +?> | |
0 | 73 | \ No newline at end of file |
... | ... |