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

Source for file GridBand.php

Documentation is available at GridBand.php

  1. <?php
  2.  
  3. /**
  4.  * GridBand class
  5.  *
  6.  * Description: Grid Band tool, use it to display a coloured rectangles
  7.  * (bands) at the grid lines of the specified axis and position
  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 GridBand extends ToolAxis
  18. {
  19.  
  20.    private $band1;
  21.    private $band2;
  22.    private $tmpBand;
  23.  
  24.     // Interceptors
  25.     function __get$property {
  26.       $method ="get{$property}";
  27.       if method_exists$this$method ) ) {
  28.         return $this->$method();
  29.       }
  30.     }
  31.  
  32.     function __set $property,$value {
  33.       $method ="set{$property}";
  34.       if method_exists$this$method ) ) {
  35.         return $this->$method($value);
  36.       }
  37.     }
  38.  
  39.    public function GridBand($c null)
  40.    {
  41.       parent::ToolAxis($c);
  42.  
  43.       $tmpColor new Color(000);
  44.       $this->getBand1()->setColor($tmpColor);
  45.       $this->getBand2()->setColor($tmpColor);
  46.       unset($tmpColor);
  47.    }
  48.   
  49.    /**
  50.    * Gets descriptive text.
  51.    *
  52.    * @return String 
  53.    */
  54.    public function getDescription()
  55.    {
  56.       return Language::getString("GridBandTool");
  57.    }
  58.  
  59.    /**
  60.    * Gets detailed descriptive text.
  61.    *
  62.    * @return String 
  63.    */
  64.    public function getSummary()
  65.    {
  66.       return Language::getString("GridBandSummary");
  67.    }
  68.  
  69.    /**
  70.    * The Brush characteristics of the first GridBand tool Band.
  71.    *
  72.    * @return ChartBrush 
  73.    */
  74.    public function getBand1()
  75.    {
  76.       if($this->band1 == null)
  77.       {
  78.          $this->band1 new ChartBrush($this->chart);
  79.       }
  80.       if($this->band1->getSolid())
  81.       {
  82.          $this->band1->setStyle(HatchStyle::$BACKWARDDIAGONAL);//to avoid Form serialisation issues
  83.       }
  84.       if($this->chart != null)
  85.       {
  86.          $this->chart->invalidate();//CDI because firing BeforeDrawSeriesEventArgs?
  87.       }
  88.       return $this->band1;
  89.    }
  90.  
  91.    /**
  92.    * The Brush characteristics of the second GridBand tool Band.
  93.    *
  94.    * @return ChartBrush 
  95.    */
  96.    public function getBand2()
  97.    {
  98.       if($this->band2 == null)
  99.       {
  100.          $this->band2 new ChartBrush($this->chart);
  101.       }
  102.       if($this->band2->getSolid())
  103.       {
  104.          $this->band2->setStyle(HatchStyle::$BACKWARDDIAGONAL);//to avoid Form serialisation issues
  105.       }
  106.       if($this->chart != null)
  107.       {
  108.          $this->chart->invalidate();//CDI because firing BeforeDrawSeriesEventArgs?
  109.       }
  110.       return $this->band2;
  111.    }
  112.  
  113.    private function drawBand($tmpPos1$tmpPos2)
  114.    {
  115.       $chartRect $this->chart->getChartRect();
  116.  
  117.       $g $this->chart->getGraphics3D();
  118.       $g->setBrush($this->tmpBand);
  119.       $g->getPen()->setVisible(false);
  120.  
  121.       $tmpR null;
  122.  
  123.       if($this->iAxis->getHorizontal())
  124.       {           
  125.          $tmpR Rectangle::fromLTRB($tmpPos1$chartRect->getTop()+1$tmpPos2,
  126.          $chartRect->getBottom()-2);
  127.       }
  128.       else
  129.       {
  130.          $tmpR Rectangle::fromLTRB($chartRect->getLeft(2$tmpPos1,
  131.          $chartRect->getRight(),
  132.          $tmpPos2-2);
  133.       }
  134.  
  135.       if($this->chart->getAspect()->getView3D())
  136.       {
  137.          $this->chart->getGraphics3D()->rectangleWithZ($tmpR$this->chart->getAspect()->getWidth3D());
  138.       }
  139.       else
  140.       {
  141.          $tmpR->grow(10);
  142.          $this->chart->getGraphics3D()->rectangle($tmpR);
  143.       }
  144.    }
  145.  
  146.    public function chartEvent($e)
  147.    {
  148.       parent::chartEvent($e);
  149.       if(/* TODO ($e->getID()==$tmpChartDrawEvent->PAINTING) &&*/
  150.       ($e->getDrawPart(== ChartDrawEvent::$SERIES))
  151.       {
  152.          if($this->chart != null && $this->getAxis(!= null)
  153.          {
  154.             $this->drawGrids();
  155.          }
  156.       }
  157.    }
  158.  
  159.    private function drawGrids()
  160.    {
  161.       if(!$this->getActive())
  162.       {
  163.          return;
  164.       }
  165.             
  166.       $tmp $this->iAxis->axisDraw->getNumTicks();
  167.  
  168.       if($tmp 0)
  169.       {
  170.          $this->tmpBand $this->getBand1();
  171.  
  172.          if($this->iAxis->getHorizontal())
  173.          {
  174.              if ($this->iAxis->getGridCentered())
  175.              {                 
  176.                 $tmpValue round(($this->iAxis->axisDraw->ticks[$t-1$this->iAxis->axisDraw->ticks[$t])/2);
  177.                 if($this->iAxis->axisDraw->ticks[t]+$tmpValue $this->iAxis->iEndPos)
  178.                 {
  179.                    $this->drawBand($this->iAxis->iEndPos 1$this->iAxis->axisDraw->ticks[0]+$tmpValue);
  180.                    $this->tmpBand $this->getBand2();
  181.                 }
  182.              }
  183.              else             
  184.                 if($this->iAxis->axisDraw->ticks[0$this->iAxis->iEndPos)
  185.                 {
  186.                   $this->drawBand($this->iAxis->iEndPos 1$this->iAxis->axisDraw->ticks[0]);
  187.                   $this->tmpBand $this->getBand2();
  188.                 }
  189.          }
  190.          else
  191.          {
  192.              if ($this->iAxis->getGridCentered())             
  193.              {                 
  194.                 $tmpValue round(($this->iAxis->axisDraw->ticks[$t-1$this->iAxis->axisDraw->ticks[$t])/2);                 
  195.                 if ($this->iAxis->iStartPos $this->iAxis->axisDraw->ticks[0$tmpValue)
  196.                    $this->drawBand($this->iAxis->iStartPos,$this->iAxis->axisDraw->ticks[$tmp-1]-$tmpValue);              
  197.                 $this->tmpBand $this->getBand2();
  198.              }
  199.              else
  200.                 if($this->iAxis->axisDraw->ticks[0$this->iAxis->iStartPos)
  201.                 {
  202.                    $this->drawBand($this->iAxis->iStartPos 1$this->iAxis->axisDraw->ticks[0]);
  203.                    $this->tmpBand $this->getBand2();
  204.                 }              
  205.          }
  206.  
  207.          if ($this->iAxis->getGridCentered())
  208.          {
  209.             for $t 0$t $tmp$t++{
  210.                if ($t 0{
  211.                  $tmpValue round(($this->iAxis->axisDraw->ticks[$t$this->iAxis->axisDraw->ticks[$t-1])/2);
  212.                  $this->drawBand($this->iAxis->axisDraw->ticks[$t 1]-$tmpValue,
  213.                          $this->iAxis->axisDraw->ticks[$t]-$tmpValue);
  214.  
  215.                  if($this->tmpBand === $this->getBand1())
  216.                      $this->tmpBand $this->getBand2();
  217.                  else
  218.                      $this->tmpBand $this->getBand1();                            
  219.                }
  220.             }         
  221.          }
  222.          else                
  223.          for($t 1$t $tmp++$t)
  224.          {
  225.             $this->drawBand($this->iAxis->axisDraw->ticks[$t 1],
  226.                   $this->iAxis->axisDraw->ticks[$t]);
  227.                             
  228.             if($this->tmpBand === $this->getBand1())
  229.                $this->tmpBand $this->getBand2();
  230.             else
  231.                $this->tmpBand $this->getBand1();
  232.          }
  233.          
  234.          if($this->iAxis->getHorizontal())
  235.          {
  236.              if ($this->iAxis->getGridCentered())             
  237.              {
  238.               $tmpValue round(($this->iAxis->axisDraw->ticks[$t-2$this->iAxis->axisDraw->ticks[$t-1])/2);                
  239.               if($this->iAxis->axisDraw->ticks[$tmp]-$tmpValue $this->iAxis->iStartPos)
  240.               {
  241.                     $this->drawBand($this->iAxis->axisDraw->ticks[$t-1]-$tmpValue
  242.                     $this->iAxis->axisDraw->ticks[$t-1]+$tmpValue);
  243.               }            
  244.  
  245.               if($this->tmpBand === $this->getBand1())
  246.                  $this->tmpBand $this->getBand2();
  247.               else
  248.                  $this->tmpBand $this->getBand1();
  249.  
  250.                  
  251.               $tmpValue round(($this->iAxis->axisDraw->ticks[$t-2$this->iAxis->axisDraw->ticks[$t-1])/2);                
  252.               if($this->iAxis->axisDraw->ticks[$tmp 1]+$tmpValue $this->iAxis->iStartPos)
  253.               {
  254.                  $this->drawBand($this->iAxis->axisDraw->ticks[$tmp 1]-$tmpValue$this->iAxis->iStartPos);                        
  255.               }            
  256.             }
  257.             else                         
  258.               if($this->iAxis->axisDraw->ticks[$tmp 1$this->iAxis->iStartPos)
  259.               {
  260.                  $this->drawBand($this->iAxis->axisDraw->ticks[$tmp 1]$this->iAxis->iStartPos);
  261.               }
  262.          }
  263.          else
  264.          {
  265.             if ($this->iAxis->getGridCentered())             
  266.             {
  267.               $tmpValue round(($this->iAxis->axisDraw->ticks[$t-2$this->iAxis->axisDraw->ticks[$t-1])/2);                
  268.               if($this->iAxis->axisDraw->ticks[$tmp 2]+$tmpValue $this->iAxis->iEndPos)
  269.               {
  270.                     $this->drawBand($this->iAxis->axisDraw->ticks[$tmp 2]-$tmpValue
  271.                     $this->iAxis->iEndPos);
  272.               }            
  273.  
  274.               if($this->tmpBand === $this->getBand1())
  275.                  $this->tmpBand $this->getBand2();
  276.               else
  277.                  $this->tmpBand $this->getBand1();
  278.               
  279.               if ($this->iAxis->iEndPos $this->iAxis->axisDraw->ticks[$tmp 1$tmpValue)
  280.                  $this->drawBand($this->iAxis->axisDraw->ticks[$tmp-1]-$tmpValue$this->iAxis->iEndPos);              
  281.             }
  282.             else            
  283.               if($this->iAxis->axisDraw->ticks[$tmp 1$this->iAxis->iEndPos)
  284.               {
  285.                $this->drawBand($this->iAxis->axisDraw->ticks[$tmp 1]$this->iAxis->iEndPos);
  286.               }
  287.          }
  288.       }
  289.    
  290. }
  291. ?>

Documentation generated on Wed, 16 Jun 2010 12:06:04 +0200 by phpDocumentor 1.4.1