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

Source for file ColorBand.php

Documentation is available at ColorBand.php

  1. <?php
  2.  
  3. /**
  4.  * ColorBand class
  5.  *
  6.  * Description: Color band tool, use it to display a coloured rectangle
  7.  * (band) at 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 ColorBand extends ToolAxis {
  18.  
  19.     private $drawBehind true;
  20.     private $end;
  21.     private $start;
  22.  
  23.     private $boundsRect;
  24.     private $fLineEnd;
  25.     private $fLineStart;
  26.  
  27.  
  28.     // Interceptors
  29.     function __get$property {
  30.       $method ="get{$property}";
  31.       if method_exists$this$method ) ) {
  32.         return $this->$method();
  33.       }
  34.     }
  35.  
  36.     function __set $property,$value {
  37.       $method ="set{$property}";
  38.       if method_exists$this$method ) ) {
  39.         return $this->$method($value);
  40.       }
  41.     }
  42.  
  43.     public function ColorBand($c=null{
  44.         parent::ToolAxis($c);
  45.  
  46.         $this->fLineEnd $this->newColorLine();
  47.         $this->fLineStart $this->newColorLine();
  48.         $this->setLines();
  49.     }
  50.  
  51.     private function newColorLine({
  52.         $result new ColorLine();
  53.         $result->setActive(false);
  54.         $result->setDragRepaint(true);
  55.         $result->setDraw3D(false);
  56.         $result->setDrawBehind(true);
  57.  
  58.         return $result;
  59.     }
  60.  
  61.     private function setLines({
  62.         $this->fLineEnd->setValue($this->getEnd());
  63.         $this->fLineStart->setValue($this->getStart());
  64.         $this->invalidate();
  65.     }
  66.  
  67.     public function mouseEvent($e$c{
  68.         if($this->fLineEnd->getActive()) {
  69.             $c $this->fLineEnd->mouseEvent($e$c);
  70.         }
  71.         if($this->fLineStart->getActive()) {
  72.             $c $this->fLineStart->mouseEvent($e$c);
  73.         }
  74.  
  75.         return $c;
  76.     }
  77.  
  78.      public function setAxis($value{
  79.          parent::setAxis($value);
  80.          $this->fLineEnd->setAxis($value);
  81.          $this->fLineStart->setAxis($value);
  82.  
  83.      }
  84.  
  85.  
  86.         /**
  87.           * Gets descriptive text.
  88.           *
  89.           * @return String 
  90.           */
  91.     public function getDescription({
  92.         return Language::getString("ColorBandTool");
  93.     }
  94.  
  95.         /**
  96.           * Gets detailed descriptive text.
  97.           *
  98.           * @return String 
  99.           */
  100.     public function getSummary({
  101.         return Language::getString("ColorBandSummary");
  102.     }
  103.  
  104.         /**
  105.           * Draws the Colorband behind the series values when true.<br>
  106.           * Default value: true
  107.           *
  108.           * @return boolean 
  109.           */
  110.     public function getDrawBehind({
  111.         return $this->drawBehind;
  112.     }
  113.  
  114.         /**
  115.           * Draws the Colorband behind the series values when true.<br>
  116.           * Default value: true
  117.           *
  118.           * @param value boolean
  119.           */
  120.     public function setDrawBehind($value{
  121.         $this->drawBehind $this->setBooleanProperty($this->drawBehind$value);
  122.         $this->fLineEnd->setDrawBehind($value);
  123.         $this->fLineStart->setDrawBehind($value);
  124.     }
  125.  
  126.         /**
  127.           * The Start Axis value of colorband.
  128.           *
  129.           * @return double 
  130.           */
  131.     public function getStart({
  132.         return $this->start;
  133.     }
  134.  
  135.         /**
  136.           * Sets Start Axis value of colorband.
  137.           *
  138.           * @param value double
  139.           */
  140.     public function setStart($value{
  141.         $this->start $this->setDoubleProperty($this->start$value);
  142.         $this->setLines();
  143.     }
  144.  
  145.         /**
  146.           * The End Axis value of colorband.
  147.           *
  148.           * @return double 
  149.           */
  150.     public function getEnd({
  151.         return $this->end;
  152.     }
  153.  
  154.         /**
  155.           * Sets End Axis value of colorband.
  156.           *
  157.           * @param value double
  158.           */
  159.     public function setEnd($value{
  160.         $this->end $this->setDoubleProperty($this->end$value);
  161.         $this->setLines();
  162.     }
  163.  
  164.         /**
  165.           * The Transparency of ColorBand as percentage.<br>
  166.           * Default value: 0
  167.           *
  168.           * @return int 
  169.           */
  170.     public function getTransparency({
  171.         return $this->getBrush()->getTransparency();
  172.     }
  173.  
  174.         /**
  175.           * Sets the Transparency of ColorBand as percentage.<br>
  176.           * Default value: 0
  177.           *
  178.           * @param value int
  179.           */
  180.     public function setTransparency($value{
  181.         $this->getBrush()->setTransparency($value);
  182.     }
  183.  
  184.         /**
  185.           * Sets Band colour gradient.
  186.           *
  187.           * @return Gradient 
  188.           */
  189.     public function getGradient({
  190.         return $this->bBrush->getGradient();
  191.     }
  192.  
  193.         /**
  194.           * SThe Band Color.
  195.           *
  196.           * @return Color 
  197.           */
  198.     public function getColor({
  199.         return $this->bBrush->getColor();
  200.     }
  201.  
  202.         /**
  203.           * Sets Band Color.
  204.           *
  205.           * @param value Color
  206.           */
  207.     public function setColor($value{
  208.         $this->bBrush->setColor($value);
  209.     }
  210.  
  211.         /**
  212.           * Element Brush characteristics.
  213.           *
  214.           * @return ChartBrush 
  215.           */
  216.     public function getBrush({
  217.         if ($this->bBrush == null{
  218.             $this->bBrush = new ChartBrush($this->chart);
  219.         }
  220.         return $this->bBrush;
  221.     }
  222.  
  223.         /**
  224.           * Contains formatting properties for the automatic line used to drag the start value of the ColorBand tool at runtime.
  225.           *
  226.           * @return ColorLine 
  227.           */
  228.     public function getStartLine({
  229.             return $this->fLineStart;
  230.     }
  231.  
  232.         /**
  233.           * Contains formatting properties for the automatic line used to drag the end value of the ColorBand tool at runtime.
  234.           *
  235.           * @return ColorLine 
  236.           */
  237.     public function getEndLine({
  238.             return $this->fLineEnd;
  239.     }
  240.  
  241.         /**
  242.         * Gets or sets if the ColorBand tool allows mouse dragging of the edge corresponding to the end value.
  243.         *
  244.       * @return boolean 
  245.       *  */
  246.     public function getResizeEnd({
  247.             return $this->getEndLine()->getActive();
  248.     }
  249.  
  250.     public function setResizeEnd($value)
  251.         {
  252.                 getEndLine().setChart(chart);
  253.                 getEndLine().setActive(value);
  254.                 this.invalidate();
  255.         }
  256.  
  257.         /*
  258.         * Gets or sets if the ColorBand tool allows mouse dragging of the edge corresponding to the start value.
  259.         *
  260.         * @return boolean
  261.         */
  262.     public function getResizeStart({
  263.         return $this->getStartLine()->getActive();
  264.     }
  265.  
  266.     public function setResizeStart($value)
  267.         {
  268.                 getStartLine().setChart(chart);
  269.                 getStartLine().setActive(value);
  270.                 this.invalidate();
  271.         }
  272.  
  273.         /*
  274.         * Pen used to draw the starting line of the color band tool.
  275.         *
  276.         * @return ChartPen
  277.         */
  278.     public function getStartLinePen({
  279.             return $this->getStartLine()->getPen();
  280.     }
  281.  
  282.         /*
  283.         * Pen used to draw the ending line of the color band tool.
  284.         *
  285.         * @return ChartPen
  286.         */
  287.     public function getEndLinePen({
  288.             return $this->getEndLine()->getPen();
  289.     }
  290.  
  291.     private function paintBand({
  292.         if ($this->iAxis != null{
  293.             $tmpRect $this->chart->getChartRect();
  294.             $r new Rectangle($tmpRect->getX(),$tmpRect->getY(),$tmpRect->getWidth(),$tmpRect->getHeight());
  295.             $tmp0 $this->start;
  296.             $tmp1 $this->end;
  297.  
  298.             if ($this->iAxis->getInverted()) {
  299.                 if ($tmp0 $tmp1{
  300.                     $tmp $tmp0;
  301.                     $tmp0 $tmp1;
  302.                     $tmp1 $tmp;
  303.                 }
  304.                 $tmpDraw ($tmp1 <= $this->iAxis->getMaximum()) && ($tmp0 >= $this->iAxis->getMinimum());
  305.             else {
  306.                 if ($tmp0 $tmp1{
  307.                     $tmp $tmp0;
  308.                     $tmp0 $tmp1;
  309.                     $tmp1 $tmp;
  310.                 }
  311.                 $tmpDraw ($tmp0 <= $this->iAxis->getMaximum()) && ($tmp1 >= $this->iAxis->getMinimum());
  312.             }
  313.  
  314.             if ($tmpDraw{
  315.                 if ($this->iAxis->getHorizontal()) {
  316.                     $r->max($this->iAxis->iStartPos$this->iAxis->calcPosValue($tmp0));
  317.                     $r->width min($this->iAxis->iEndPos$this->iAxis->calcPosValue($tmp1)) -
  318.                               $r->x;
  319.                     if (!$this->getPen()->getVisible()) {
  320.                         $r->width++;
  321.                     }
  322.                 else {
  323.                     $r->max($this->iAxis->iStartPos$this->iAxis->calcPosValue($tmp1));
  324.                     $r->height min($this->iAxis->iEndPos$this->iAxis->calcPosValue($tmp0)) -
  325.                                $r->y;
  326.                     $r->x++;
  327.                     if (!$this->getPen()->getVisible()) {
  328.                         $r->height++;
  329.                         $r->width++;
  330.                     }
  331.                 }
  332.  
  333.                 $g $this->chart->getGraphics3D();
  334.                 $g->setBrush($this->getBrush());
  335.                 $g->setPen($this->getPen());
  336.  
  337.                 if $this->getGradient()->getVisible(&& $this->chart->getAspect()->getOrthogonal() ) {
  338.                   $this->tmpR=$r;
  339.                   $this->tmpR->width--;
  340.                   $this->tmpR->height--;
  341.                   $this->getGradient()->draw($g,$g->calcRect3D($this->tmpR,$this->chart->getAspect()->getWidth3D()));
  342.                   $this->getBrush()->setVisible(false);
  343.                 }
  344.  
  345.  
  346.                 if (($this->chart->getAspect()->getView3D()) && ($this->drawBehind)) {
  347.                     $g->rectangle($r$this->chart->getAspect()->getWidth3D());
  348.                 else {
  349.                     $g->rectangle($r);
  350.                 }
  351.             }
  352.         }
  353.     }
  354.  
  355.     public function chartEvent($e{
  356.         parent::chartEvent($e);
  357.         if (((/*($e->getID()==$tmpChartDrawEvent->PAINTING) &&*/
  358.               ($e->getDrawPart()==ChartDrawEvent::$SERIES)) && $this->drawBehind||
  359.             ((/* TODO ($e->getID()==ChartDrawEvent::$PAINTED) &&*/
  360.               ($e->getDrawPart()==ChartDrawEvent::$CHART)) && (!$this->drawBehind))) {
  361.             $this->paintBand();
  362.         }
  363.     }
  364. }
  365.  
  366. ?>

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