TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file SeriesBand.php

Documentation is available at SeriesBand.php

  1. <?php
  2.  
  3. /**
  4.  * SeriesBand class
  5.  *
  6.  * Description: Series Band tool.
  7.  * method
  8.  *
  9.  * @author
  10.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  11.  * @version 1.0
  12.  * @package TeeChartPHP
  13.  * @subpackage tools
  14.  * @link http://www.steema.com
  15.  */
  16.  
  17. class SeriesBand extends ToolSeries {
  18.  
  19.     private $boundValue;
  20.     private $drawBehindSeries;
  21.     private $series2;
  22.  
  23.     private $iSerie1Drawed;
  24.     private $iSerie2Drawed;
  25.     
  26.     public function SeriesBand($c=null{
  27.         parent::ToolSeries($c);
  28.         
  29.         $this->drawBehindSeries true;
  30.     
  31.         $this->getBrush()->setColor(Color::getWhite());
  32.         $this->getPen()->setVisible(false);
  33.     }    
  34.     
  35.     /**
  36.      * Constant value to be used as one of the limits of band filled areas. <br>
  37.      * Note: BoundValue property is only used when the <see cref="Series2"/>
  38.      * property is not set (ie: is null). <br>
  39.      *
  40.      * @return double 
  41.      */
  42.     public function getBoundValue({
  43.         return (double) $this->boundValue
  44.     }
  45.     
  46.     /**
  47.      * Sets a constant value to be used as one of the limits of band
  48.      * filled areas. <br>
  49.      * Note: BoundValue property is only used when the <see cref="Series2"/>
  50.      * property is not set (ie: is null). <br>
  51.      *
  52.      * @param value double
  53.      */
  54.     public function setBoundValue($value)
  55.         $this->boundValue $value
  56.     }
  57.  
  58.    /**
  59.      * Flag which causes filling to occur before or after the series are
  60.      * displayed. <br>
  61.      * Default value: true
  62.      *
  63.      * @return boolean 
  64.      */
  65.     public function getDrawBehindSeries({
  66.         return $this->drawBehindSeries
  67.     }
  68.     
  69.     /**
  70.      * Sets a flag which causes filling to occur before or after the series are
  71.      * displayed. <br>
  72.      * Default value: true
  73.      *
  74.      * @param value boolean
  75.      */
  76.     public function setDrawBehindSeries($value){
  77.         if ($this->drawBehindSeries != $value{
  78.             $this->drawBehindSeries $value;
  79.             $this->invalidate();
  80.         }
  81.     }
  82.  
  83.     /**
  84.      * Gets descriptive text.
  85.      *
  86.      * @return String 
  87.      */
  88.     public function getDescription(
  89.         return Language::getString("SeriesBandTool");
  90.     }
  91.     
  92.     /**
  93.      * Gets detailed descriptive text.
  94.      *
  95.      * @return String 
  96.      */
  97.     public function getSummary(
  98.         return Language::getString("SeriesBandSummary");
  99.     }
  100.  
  101.     /**
  102.      * Second series associated to this tool. <br>
  103.      * SeriesBand tool needs two series to fill the area in between them. <br>
  104.      *
  105.      * @return Series 
  106.      */
  107.     public function getSeries2({
  108.         return $this->series2;
  109.     }
  110.     
  111.    
  112.     /**
  113.      * Element Brush characteristics.
  114.      * @return ChartBrush 
  115.      */
  116.     public function getBrush({
  117.         if ($this->bBrush == null{
  118.             $this->bBrush = new ChartBrush($this->chart);
  119.         }
  120.         return $this->bBrush;
  121.     }
  122.     
  123.     /**
  124.      * Set Brush characteristics.
  125.      *
  126.      * @param value ChartBrush
  127.      */
  128.     public function setBrush($value{
  129.         $this->bBrush = $value;
  130.     }
  131.     
  132.     /**
  133.      * Indicates the kind of pen used to draw Series Band.
  134.      *
  135.      * @return ChartPen 
  136.      */
  137.     public function getPen({
  138.         if ($this->pPen == null{
  139.             $this->pPen = new ChartPen($this->chartColor::BLACK());
  140.         }        
  141.         return $this->pPen;
  142.     }
  143.  
  144.     /**
  145.      * Determines the kind of pen used to draw Series Band.
  146.      *
  147.      * @param value ChartPen
  148.      */
  149.     public function setPen($value{
  150.         if ($value!=null{
  151.             $this->pPen->assign($value);
  152.         }
  153.     }
  154.  
  155.     /**
  156.      * The amount of semi-glass effect (opacity) to apply when filling the area
  157.      * between the two series as percentage.
  158.      * Default value: 0
  159.      *
  160.      * @return int 
  161.      */
  162.     public function getTransparency({
  163.         return $this->getBrush()->getTransparency();
  164.     }
  165.  
  166.     /**
  167.      * Sets the amount of semi-glass effect (opacity) to apply when filling the
  168.      * area between the two series as percentage.
  169.      * Default value: 0
  170.      *
  171.      * @param value int
  172.      */
  173.     public function setTransparency($value{
  174.         $this->getBrush()->setTransparency($value);
  175.     }
  176.     
  177.     /**
  178.      * The gradient colors used to fill the area between the two series.
  179.      *
  180.      * @return Gradient 
  181.      */
  182.     public function getGradient({
  183.         return $this->bBrush->getGradient();
  184.     }
  185.     
  186.     /**
  187.      * Sets the gradient colors used to fill the area between the two series.
  188.      *
  189.      * @param value Gradient
  190.      */
  191.     public function setGradient($value{
  192.         $this->bBrush->setGradient($value);
  193.     }
  194.  
  195.     //private members
  196.     private function setEvents($aSeries{        
  197.         if ($aSeries != null{
  198.             /* TODO
  199.             $aSeries->removeSeriesPaintListener( new SeriesPaintAdapter() {
  200.                 public void seriesPainting(ChartDrawEvent e) {  */
  201.                     $this->doBeforeDrawValues($aSeries);
  202.             /*    };
  203.  
  204.                 public void seriesPainted(ChartDrawEvent e) {*/
  205.                     $this->doAfterDrawValues($aSeries);
  206.             /*    };
  207.             });
  208.             
  209.             aSeries.addSeriesPaintListener( new SeriesPaintAdapter() {
  210.                 public void seriesPainting(ChartDrawEvent e) {
  211.                     doBeforeDrawValues(aSeries);
  212.                 };
  213.  
  214.                 public void seriesPainted(ChartDrawEvent e) {
  215.                     doAfterDrawValues(aSeries);
  216.                 };
  217.             }); */
  218.         }
  219.     }
  220.  
  221.     //protected and internal members
  222.     public function chartEvent(/*ChartDrawEvent*/ $ce{        
  223.         parent::chartEvent($ce);
  224.         if (/*(ce.getID()==ChartDrawEvent.PAINTING) &&*/
  225.               ($ce->getDrawPart(== ChartDrawEvent::$SERIES)) {
  226.             $this->iSerie1Drawed false;
  227.             $this->iSerie2Drawed false;
  228.             $this->doBeforeDrawValues($this->iSeries);            
  229.         }                
  230.         else
  231.         {
  232.             $this->doAfterDrawValues($this->iSeries);            
  233.         }    
  234.     }
  235.  
  236.     public function setSeries($value)
  237.     {
  238.         parent::setSeries($value);
  239.         $this->setEvents($this->iSeries);
  240.     }
  241.  
  242.     /**
  243.      * Sets the second series associated to this tool.<br>
  244.      * SeriesBand tool needs two series to fill the area in between them. <br>
  245.      *
  246.      * @param value Series
  247.      */    
  248.     public function setSeries2($value{
  249.         if ($this->series2 != $value{
  250.             $this->series2 $value;
  251.             $this->setEvents($this->series2);
  252.         }
  253.     }
  254.  
  255.     protected function doBeforeDrawValues($sender{
  256.         if ($this->drawBehindSeries{
  257.             if ($this->iSeries != null && $sender === $this->iSeries{
  258.                 $this->iSerie1Drawed true;
  259.             }
  260.             if ($this->series2 != null && $sender === $this->series2{
  261.                 $this->iSerie2Drawed true;
  262.             }
  263.  
  264.             if ($this->series2 != null{
  265.                 if (!($this->iSerie1Drawed && $this->iSerie2Drawed)) {
  266.                     $this->drawBandTool();
  267.                 }
  268.             }
  269.             else {
  270.                 $this->drawBandTool();
  271.             }
  272.         }
  273.     }
  274.  
  275.     protected function doAfterDrawValues($sender{
  276.         if (!$this->drawBehindSeries{
  277.             if ($this->iSeries != null && $sender === $this->iSeries
  278.                 $this->iSerie1Drawed true;
  279.             }
  280.             if ($this->series2 != null && $sender === $this->series2{
  281.                 $this->iSerie2Drawed true;
  282.             }
  283.  
  284.             if ($this->iSerie1Drawed && ($this->iSerie2Drawed || $this->series2 === null)) {
  285.                 $this->drawBandTool();
  286.             }
  287.         }
  288.     }
  289.  
  290.     protected function drawBandTool({
  291.         $l1=0;
  292.         $l2=0;
  293.         $i=0;
  294.         $tmpZ=0;
  295.        
  296.         $tmpPoints=Array();        
  297.         $g $this->getChart()->getGraphics3D();
  298.         
  299.         $tmpMax=0;
  300.         
  301.         if ($this->getActive(&& $this->chart != null && $this->iSeries != null{
  302.             $this->iSeries->calcFirstLastVisibleIndex();
  303.             if ($this->series2 != null{
  304.                 $this->series2->calcFirstLastVisibleIndex();
  305.             }
  306.  
  307.             if (($this->series2 != null && $this->iSeries->getFirstVisible(!= -&& 
  308.                     $this->series2->getFirstVisible(!= -1|| 
  309.                     $this->iSeries->getFirstVisible(!= -1{
  310.                 $l1 ($this->iSeries->getLastVisible($this->iSeries->getFirstVisible()) 1;
  311.  
  312.                 if ($this->iSeries->drawBetweenPoints && $this->iSeries->getFirstVisible(0{
  313.                         ++$l1;
  314.                 }
  315.  
  316.                 if ($this->series2 != null{
  317.                     $l2 ($this->series2->getLastVisible(
  318.                             $this->series2->getFirstVisible()) 1;
  319.  
  320.                     if ($this->iSeries->drawBetweenPoints && 
  321.                             $this->series2->getFirstVisible(0{
  322.                             ++$l2;
  323.                     }
  324.                 }
  325.                 else {
  326.                     $l2 2;
  327.                 }
  328.  
  329.                 $tmpPoints Array()//new Point[l1 + l2];
  330.                 for ($ii=0;$ii($l1+$l2);$ii++)
  331.                     $tmpPoints[]=null;
  332.  
  333.                 if (sizeof($tmpPoints)>0{                    
  334.                     $i 0;
  335.                     if ($this->iSeries->getFirstVisible(!= -1{
  336.                         $tmpMax max(0$this->iSeries->getFirstVisible(1);
  337.                         for ($t $tmpMax$t <= $this->iSeries->getLastVisible()$t++
  338.                         {
  339.                             $tmpPoints[$inew TeePoint($this->iSeries->calcXPos($t)
  340.                                     $this->iSeries->calcYPos($t));
  341.                             $i++;
  342.                         }
  343.                     }
  344.  
  345.                     if ($this->series2 != null{
  346.                         if ($this->series2->getFirstVisible(!= -1{
  347.                             $tmpMax max(0$this->series2->getFirstVisible(1);
  348.                             for ($t $this->series2->getLastVisible()$t >= $tmpMax
  349.                             $t--{
  350.                                 $tmpPoints[$inew TeePoint($this->series2->calcXPos($t),
  351.                                         $this->series2->calcYPos($t));
  352.                                 $i++;
  353.                             }
  354.                         }
  355.                     }
  356.                     else {                        
  357.                         $tmpPoints[$inew TeePoint($tmpPoints[$i 1]->x
  358.                                 $this->iSeries->calcYPosValue($this->boundValue));
  359.                         $tmpPoints[$i 1new TeePoint($tmpPoints[0]->x
  360.                                 $tmpPoints[$i]->y);
  361.                     }
  362.  
  363.                     if ($this->series2 != null{
  364.                         $tmpZ max($this->iSeries->getStartZ()
  365.                                 $this->series2->getStartZ());
  366.                     }
  367.                     else {
  368.                         $tmpZ $this->iSeries->getStartZ();
  369.                     }
  370.                     
  371.                     $g->setBrush($this->bBrush);
  372.                     $g->setPen($this->pPen);
  373.                     $g->clipCube($this->chart->getChartRect()0
  374.                             $this->chart->getAspect()->getWidth3D());
  375.                     $g->polygonZ($tmpZ$tmpPoints);
  376.                     $g->unClip();
  377.                 }                
  378.             }
  379.         }
  380.     }   
  381. }
  382. ?>

Documentation generated on Wed, 16 Jun 2010 12:07:54 +0200 by phpDocumentor 1.4.1