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

Source for file ToolsCollection.php

Documentation is available at ToolsCollection.php

  1. <?php
  2.  
  3. /**
  4.  * ToolsCollection class
  5.  *
  6.  * Description: Collection of Tool components
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage tools
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class ToolsCollection extends ArrayObject
  17. {
  18.  
  19.    public $chart;
  20.  
  21.    // Interceptors
  22.     function __get$property {
  23.       $method ="get{$property}";
  24.       if method_exists$this$method ) ) {
  25.         return $this->$method();
  26.       }
  27.     }
  28.  
  29.     function __set $property,$value {
  30.       $method ="set{$property}";
  31.       if method_exists$this$method ) ) {
  32.         return $this->$method($value);
  33.       }
  34.     }
  35.  
  36.    public function ToolsCollection($c)
  37.    {
  38.       parent::__construct();      
  39.       $this->chart = $c;
  40.    }
  41.  
  42.    /**
  43.    * Adds a new tool to your TChart.
  44.    * Returns the added tool instance.
  45.    * @param tool Tool
  46.    * @return int 
  47.    */
  48.    public function add($tool)
  49.    {
  50.       $tool->setChart($this->chart);
  51.       return $this->internalAdd($tool);
  52.    }
  53.  
  54.    public function internalAdd($tool)
  55.    {
  56.       if($this->indexOf($tool== - 1)
  57.       {
  58.          parent::append($tool);
  59.       }
  60.       return $tool;
  61.    }
  62.  
  63. /* TODO
  64.    public function add($type) { /* TODO throws InstantiationException,
  65.    IllegalAccessException{
  66.    return add($type . newInstance()));
  67.    }
  68. */
  69.    public function getTool($index)
  70.    {
  71.       return $this->offsetGet($index);
  72.    }
  73.  
  74.    public function setTool($index$value)
  75.    {
  76.       $this->set($index$value);
  77.    }
  78.  
  79.    /**
  80.    * Returns the corresponding point index which has the specified Value.
  81.    *
  82.    * @param Tool
  83.    * @return int 
  84.    */
  85.    public function indexOf($s)
  86.    {
  87.       for($t 0$t sizeof($this)$t++)
  88.       {
  89.          if($this->getTool($t=== $s)
  90.          {
  91.             return $t;
  92.          }
  93.       }
  94.  
  95.       return 1;
  96.    }
  97.  
  98.    /**
  99.    * Removes a tool from the TChart.
  100.    *
  101.    * @param Tool
  102.    */
  103.    public function remove($s)
  104.    {
  105.       $i $this->indexOf($s);
  106.       if($i != - 1)
  107.       {
  108.          $this->remove($i);
  109.          $this->chart->invalidate();
  110.       }
  111.    }
  112.  
  113.    /**
  114.    * Sets Chart interface to tools collection
  115.    *
  116.    * @param chart IBaseChart
  117.    */
  118.    public function setChart($chart)
  119.    {
  120.       $this->chart = $chart;
  121.  
  122.       for($t 0$t sizeof($this)$t++)
  123.       {
  124.          $this->getTool($t)->setChart($chart);
  125.       }
  126.    }
  127. }
  128.  
  129. ?>

Documentation generated on Wed, 16 Jun 2010 12:09:03 +0200 by phpDocumentor 1.4.1