Commit c958695a6a6ec29e6a39da599f1f85099ab7602c

Authored by Benjamin Renard
1 parent f012b419

Add Params Legend definition

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -357,6 +357,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -357,6 +357,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
357 throw new Exception('Plot type not implemented.'); 357 throw new Exception('Plot type not implemented.');
358 } 358 }
359 359
  360 + //Params Legends
  361 + if (isset($panelData->{'panel-series-legend'}) && $panelData->{'panel-series-legend'}->{'legend-series-activated'})
  362 + $this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend());
  363 +
360 return $plotNode; 364 return $plotNode;
361 } 365 }
362 366
@@ -687,6 +691,61 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -687,6 +691,61 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
687 return false; 691 return false;
688 } 692 }
689 693
  694 + protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
  695 + {
  696 + //Legend type
  697 + switch ($paramsLegendData->{'legend-series-type'})
  698 + {
  699 + case 'text-line-symbol' :
  700 + $paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
  701 + break;
  702 + case 'text-only' :
  703 + default :
  704 + $paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
  705 + }
  706 +
  707 + //Show param legend
  708 + $paramsLegendNode->setShowParamInfo($paramsLegendData->{'legend-series-showparaminfo'} ? "true" : "false");
  709 +
  710 + //Show interval legend
  711 + $paramsLegendNode->setShowIntervalInfo($paramsLegendData->{'legend-series-intervalinfo-activated'} ? "true" : "false");
  712 +
  713 + //Interval info type
  714 + switch ($paramsLegendData->{'legend-series-intervalinfo-type'})
  715 + {
  716 + case 'start-stop' :
  717 + $paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
  718 + break;
  719 + case 'index' :
  720 + default :
  721 + $paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
  722 + }
  723 +
  724 + //Position
  725 + switch ($paramsLegendData->{'legend-series-position'})
  726 + {
  727 + case 'inside' :
  728 + $paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
  729 + break;
  730 + case 'outside' :
  731 + default :
  732 + $paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
  733 + }
  734 +
  735 + //Default text color
  736 + $paramsLegendNode->setDefaultTextColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-defaulttextcolor'}));
  737 +
  738 + //Border visible
  739 + $paramsLegendNode->setBorderVisible($paramsLegendData->{'legend-series-border-activated'} ? "true" : "false");
  740 +
  741 + //Border color
  742 + $paramsLegendNode->setBorderColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-border-color'}));
  743 +
  744 + //Font
  745 + if ($paramsLegendData->{'legend-series-font-activated'})
  746 + $this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
  747 + }
  748 +
690 protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) 749 protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
691 { 750 {
692 if ($inputData->{$keyPrefix.'-text'} != '') 751 if ($inputData->{$keyPrefix.'-text'} != '')
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementNodeClass.php
1 <?php 1 <?php
2 2
3 -//require_once("RequestOutputPlotLegendsNodeClass.php"); 3 +require_once("RequestOutputPlotLegendsNodeClass.php");
4 require_once("RequestOutputPlotParamsNodeClass.php"); 4 require_once("RequestOutputPlotParamsNodeClass.php");
5 require_once("RequestOutputPlotAxesNodeClass.php"); 5 require_once("RequestOutputPlotAxesNodeClass.php");
6 //require_once("RequestOutputPlotAdditionalObjectsNodeClass.php"); 6 //require_once("RequestOutputPlotAdditionalObjectsNodeClass.php");
7 //require_once("RequestOutputPlotFillsNodeClass.php"); 7 //require_once("RequestOutputPlotFillsNodeClass.php");
8 8
  9 +define ("REQUESTOUTPUTPLOTLEGENDS_NAME", "legends");
  10 +
9 /** 11 /**
10 * @class RequestOutputPlotElementNodeClass 12 * @class RequestOutputPlotElementNodeClass
11 * @brief Definition of a plot element for a panel of a plot request 13 * @brief Definition of a plot element for a panel of a plot request
@@ -18,12 +20,11 @@ class RequestOutputPlotElementNodeClass extends NodeClass @@ -18,12 +20,11 @@ class RequestOutputPlotElementNodeClass extends NodeClass
18 parent::__construct($plotElementName); 20 parent::__construct($plotElementName);
19 //create plot element skeleton 21 //create plot element skeleton
20 22
21 - //ToDo legends if needed  
22 - /*if ($defineLegends)  
23 - {  
24 - $node = new RequestOutputPlotLegendsNodeClass();  
25 - $this->addChild($node);  
26 - }*/ 23 + if ($defineLegends)
  24 + {
  25 + $node = new RequestOutputPlotLegendsNodeClass(REQUESTOUTPUTPLOTLEGENDS_NAME);
  26 + $this->addChild($node);
  27 + }
27 28
28 //params 29 //params
29 $node = new RequestOutputPlotParamsNodeClass(); 30 $node = new RequestOutputPlotParamsNodeClass();
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotLegendsNodeClass.php 0 โ†’ 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +<?php
  2 +
  3 +require_once("RequestOutputPlotParamsLegendNodeClass.php");
  4 +
  5 +/**
  6 + * @class RequestOutputPlotLegendsNodeClass
  7 + * @brief Definition of legends element for a plot
  8 + * @details
  9 + */
  10 +class RequestOutputPlotLegendsNodeClass extends NodeClass
  11 +{
  12 + public function __construct($name)
  13 + {
  14 + parent::__construct($name);
  15 + }
  16 +
  17 + public function getParamsLegend()
  18 + {
  19 + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPARAMSLEGEND_NAME);
  20 +
  21 + if (!isset($node))
  22 + {
  23 + $node = new RequestOutputPlotParamsLegendNodeClass();
  24 + $this->addChild($node);
  25 + }
  26 +
  27 + return $node;
  28 + }
  29 +}
  30 +
  31 +?>
0 \ No newline at end of file 32 \ No newline at end of file
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsLegendNodeClass.php 0 โ†’ 100644
@@ -0,0 +1,137 @@ @@ -0,0 +1,137 @@
  1 +<?php
  2 +
  3 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_NAME", "paramsLegend");
  4 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_TYPE", "type");
  5 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWPARAMINFO", "showParamInfo");
  6 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWINTERVALINFO", "showIntervalInfo");
  7 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_INTERVALINFOTYPE", "intervalInfoType");
  8 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_POSITION", "position");
  9 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_DEFAULTTEXTCOLOR", "defaultTextColor");
  10 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERVISIBLE", "borderVisible");
  11 +define ("REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERCOLOR", "borderColor");
  12 +
  13 +abstract class RequestOutputPlotParamsLegendTypeEnum
  14 +{
  15 + const TEXTLINESYMBOL = "text-line-symbol";
  16 + const TEXTONLY = "text-only";
  17 +}
  18 +
  19 +abstract class RequestOutputPlotParamsLegendPositionEnum
  20 +{
  21 + const INSIDE = "inside";
  22 + const OUTSIDE = "outside";
  23 +}
  24 +
  25 +abstract class RequestOutputPlotParamsLegendIntervalInfoTypeEnum
  26 +{
  27 + const INDEX = "index";
  28 + const STARTSTOP = "start-stop";
  29 +}
  30 +
  31 +/**
  32 + * @class RequestOutputPlotParamsLegendNodeClass
  33 + * @brief Definition of a "params legend" element for a plot
  34 + * @details
  35 + */
  36 +class RequestOutputPlotParamsLegendNodeClass extends NodeClass
  37 +{
  38 + public function __construct()
  39 + {
  40 + parent::__construct(REQUESTOUTPUTPLOTPARAMSLEGEND_NAME);
  41 + }
  42 +
  43 + public function setType($type)
  44 + {
  45 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_TYPE, $type);
  46 + }
  47 +
  48 + public function getType()
  49 + {
  50 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_TYPE);
  51 + }
  52 +
  53 + public function setShowParamInfo($show)
  54 + {
  55 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWPARAMINFO, $show);
  56 + }
  57 +
  58 + public function getShowParamInfo()
  59 + {
  60 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWPARAMINFO);
  61 + }
  62 +
  63 + public function setShowIntervalInfo($show)
  64 + {
  65 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWINTERVALINFO, $show);
  66 + }
  67 +
  68 + public function getShowIntervalInfo()
  69 + {
  70 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_SHOWINTERVALINFO);
  71 + }
  72 +
  73 + public function setIntervalInfoType($type)
  74 + {
  75 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_INTERVALINFOTYPE, $type);
  76 + }
  77 +
  78 + public function getIntervalInfoType()
  79 + {
  80 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_INTERVALINFOTYPE);
  81 + }
  82 +
  83 + public function setPosition($position)
  84 + {
  85 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_POSITION, $position);
  86 + }
  87 +
  88 + public function getPosition()
  89 + {
  90 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_POSITION);
  91 + }
  92 +
  93 + public function setDefaultTextColor($color)
  94 + {
  95 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_DEFAULTTEXTCOLOR, $color);
  96 + }
  97 +
  98 + public function getDefaultTextColor()
  99 + {
  100 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_DEFAULTTEXTCOLOR);
  101 + }
  102 +
  103 + public function setBorderVisible($visible)
  104 + {
  105 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERVISIBLE, $visible);
  106 + }
  107 +
  108 + public function getBorderVisible()
  109 + {
  110 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERVISIBLE);
  111 + }
  112 +
  113 + public function setBorderColor($color)
  114 + {
  115 + $this->setAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERCOLOR, $color);
  116 + }
  117 +
  118 + public function getBorderColor()
  119 + {
  120 + return $this->getAttribute(REQUESTOUTPUTPLOTPARAMSLEGEND_BORDERCOLOR);
  121 + }
  122 +
  123 + public function getFont()
  124 + {
  125 + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPARAMSLEGEND_FONT);
  126 +
  127 + if (!isset($node))
  128 + {
  129 + $node = new RequestOutputPlotFontNodeClass();
  130 + $this->addChild($node);
  131 + }
  132 +
  133 + return $node;
  134 + }
  135 +}
  136 +
  137 +?>
0 \ No newline at end of file 138 \ No newline at end of file