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

Source for file Axes.php

Documentation is available at Axes.php

  1. <?php
  2.  
  3. /**
  4.  * Axes Class
  5.  *
  6.  * Description: Accesses list of all TChart Axes. Includes Custom and Depth
  7.  *
  8.  * @author
  9.  * @copyright Copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage axis
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class Axes extends TeeBase {
  17.  
  18.     private static $STANDARD_AXES 5;
  19.     private $left;
  20.     private $right;
  21.     private $top;
  22.     private $bottom;
  23.     private $visible true;
  24.     private $drawBehind true;
  25.  
  26.     protected $custom;
  27.     protected $depth;
  28.     protected $depthTop;
  29.  
  30.     // Interceptors
  31.     function __get$property {
  32.       $method ="get{$property}";
  33.       if method_exists$this$method ) ) {
  34.         return $this->$method();
  35.       }
  36.     }
  37.  
  38.     function __set $property,$value {
  39.       $method ="set{$property}";
  40.       if method_exists$this$method ) ) {
  41.         return $this->$method($value);
  42.       }
  43.     }
  44.  
  45.     /**
  46.     * The class constructor.
  47.     */
  48.     public function Axes($c=null{
  49.  
  50.         $this->custom = new CustomAxes();
  51.  
  52.         parent::__construct($c);
  53.  
  54.         $this->custom->setChart($this->chart);
  55.  
  56.         $this->left new Axis(nullnull$this->chart);
  57.         $this->left->getTitle()->setInitialAngle(90);
  58.  
  59.         $this->right new Axis(falsetrue$this->chart);
  60.         $this->right->setZPosition(100);
  61.         $this->right->getGrid()->setZPosition(100);
  62.         $this->right->getTitle()->setInitialAngle(270);
  63.  
  64.         $this->top new Axis(truetrue$this->chart);
  65.         $this->top->setZPosition(100);
  66.         $this->top->getGrid()->setZPosition(100);
  67.  
  68.         $this->bottom new Axis(truefalse$this->chart);
  69.         $this->depth = new DepthAxis(falsetrue$this->chart);
  70.         $this->depthTop = new DepthAxis(falsefalse$this->chart);
  71.     }
  72.  
  73.     /**
  74.      * @return Axis 
  75.      * @see Axis
  76.      */
  77.     static public function createNewAxis($chart{
  78.         return new Axis(nullnull$chart);
  79.     }
  80.  
  81.     /**
  82.      * @return String[] 
  83.      */
  84.     public function stringItems({
  85.         $names array();
  86.  
  87.         $names[0Language::getString("LeftAxis");
  88.         $names[1Language::getString("TopAxis");
  89.         $names[2Language::getString("RightAxis");
  90.         $names[3Language::getString("BottomAxis");
  91.  
  92.         for ($t 0$t sizeof($this->custom)$t++{
  93.             $names[$t"Custom " $t;
  94.         }
  95.  
  96.         return $names;
  97.     }
  98.  
  99.     /**
  100.      * @return Int 
  101.      */
  102.     public function indexOf($a{
  103.         if ($a == $this->left{
  104.             return 0;
  105.         else if ($a == $this->top{
  106.             return 1;
  107.         else if ($a == $this->right{
  108.             return 2;
  109.         else if ($a == $this->bottom{
  110.             return 3;
  111.         else if ($a == $this->depth{
  112.             return 4;
  113.         else if ($a == $this->depthTop{
  114.             return 5;
  115.         else {
  116.             return $this->custom->indexOf($aself::$STANDARD_AXES;
  117.         }
  118.     }
  119.  
  120.     /**
  121.      * Accesses indexed axis
  122.      *
  123.      * @param index int
  124.      * @return Axis 
  125.      */
  126.     public function getAxis($index{
  127.  
  128.         if ($index <= $this->getCount()) {
  129.             if ($index 6{
  130.                 switch ($index{
  131.                 case 0:
  132.                     return $this->left;
  133.                 case 1:
  134.                     return $this->top;
  135.                 case 2:
  136.                     return $this->right;
  137.                 case 3:
  138.                     return $this->bottom;
  139.                 case 4:
  140.                     return $this->depth;
  141.                 case 5:
  142.                     return $this->depthTop;
  143.                 }
  144.             else {
  145.                 return $this->custom->getAxis($index self::$STANDARD_AXES);
  146.             }
  147.         }
  148.         return null;
  149.     }
  150.  
  151.     /**
  152.      * Returns the number of axes.
  153.      *
  154.      * @return int Number of axes
  155.      */
  156.     public function getCount({
  157.         return sizeof($this->customself::$STANDARD_AXES;
  158.     }
  159.  
  160.     /**
  161.      * Draws axes behind or in front of Series.<br>
  162.      * Enables/disables the painting of the Axes before the Series.<br>
  163.      * When false, the Axes will appear over the Chart Series.<br>
  164.      * Default value: true
  165.      *
  166.      * @return boolean 
  167.      */
  168.     public function getDrawBehind({
  169.         return $this->drawBehind;
  170.     }
  171.  
  172.     /**
  173.      * Draws axes behind the Series when true.
  174.      *
  175.      * @param value boolean
  176.      */
  177.     public function setDrawBehind($value{
  178.         $this->drawBehind $this->setBooleanProperty($this->drawBehind$value);
  179.     }
  180.  
  181.     public function doZoom($x0$y0$x1$y1{
  182.         $this->chart->doZoom(
  183.                 $this->getTop()->calcPosPoint($x0)$this->getTop()->calcPosPoint($x1),
  184.                 $this->getBottom()->calcPosPoint($x0)$this->getBottom()->calcPosPoint($x1),
  185.                 $this->getLeft()->calcPosPoint($y1)$this->getLeft()->calcPosPoint($y0),
  186.                 $this->getRight()->calcPosPoint($y1)$this->getRight()->calcPosPoint($y0));
  187.     }
  188.  
  189.     protected function checkAxis($a{
  190.         return ($a == nullnew Axis(nullnull$this->chart$a;
  191.     }
  192.  
  193.     /**
  194.      * Accesses the Custom axes List.
  195.      *
  196.      * @return CustomAxes 
  197.      */
  198.     public function getCustom({
  199.         return $this->custom;
  200.     }
  201.  
  202.     public function setCustom($value{
  203.         $this->custom = $value;
  204.     }
  205.  
  206.     /**
  207.      * Calls adjustMaxMin method of all axes and custom axes
  208.      */
  209.     public function adjustMaxMin({
  210.         $this->left->adjustMaxMin();
  211.         $this->top->adjustMaxMin();
  212.         $this->right->adjustMaxMin();
  213.         $this->bottom->adjustMaxMin();
  214.         $this->depth->adjustMaxMin();
  215.         $this->depthTop->adjustMaxMin();
  216.  
  217.         for ($t 0$t sizeof($this->custom)$t++{
  218.             $this->custom->getAxis($t)->adjustMaxMin();
  219.         }
  220.     }
  221.  
  222.     public function internalCalcPositions({
  223.  
  224.         $this->left->internalCalcPositions();
  225.         $this->top->internalCalcPositions();
  226.         $this->right->internalCalcPositions();
  227.         $this->bottom->internalCalcPositions();
  228.         $this->depth->internalCalcPositions();
  229.         $this->depthTop->internalCalcPositions();
  230.  
  231.         for ($t 0$t sizeof($this->custom)$t++{
  232.             $this->custom->getAxis($t)->internalCalcPositions();
  233.         }
  234.     }
  235.  
  236.     /**
  237.      * Determines the Labels and formatting attributes of Left Chart side.<br>
  238.      * It also controls where Series points will be placed. <br>
  239.      * Every TChart class has five Axes: Left, Top, Right, Bottom and z depth.
  240.      *
  241.      * @return Axis 
  242.      */
  243.     public function getLeft({
  244.         return $this->checkAxis($this->left);
  245.     }
  246.  
  247.     public function setLeft($value{
  248.         $this->left $value;
  249.     }
  250.  
  251.     /**
  252.      * Determines the Labels and formatting attributes of Top Chart side.<br>
  253.      * It also controls where Series points will be placed.<br>
  254.      * Every TChart class has five Axes: Left, Top, Right, Bottom and z depth.
  255.      * The Top is pre-defined to be: <br>
  256.      * Horizontal = true<br>
  257.      * OtherSide = true<br>
  258.      *
  259.      * @return Axis 
  260.      * @see Axis
  261.      */
  262.     public function getTop({
  263.         return $this->checkAxis($this->top);
  264.     }
  265.  
  266.     public function setTop($value{
  267.         $this->top $value;
  268.     }
  269.  
  270.     /**
  271.      * Determines the Labels and formatting attributes of Right Chart side.<br>
  272.      * It also controls where Series points will be placed.<br>
  273.      * Every TChart class has five Axes: Left, Top, Right, Bottom and z depth.
  274.      *
  275.      * @return Axis 
  276.      * @see Axis
  277.      */
  278.     public function getRight({
  279.         return $this->checkAxis($this->right);
  280.     }
  281.  
  282.     public function setRight($value{
  283.         $this->right $value;
  284.     }
  285.  
  286.     /**
  287.      * Determines the Labels and formatting attributes of Bottom Chart side.<br>
  288.      * It also controls where Series points will be placed.<br>
  289.      * Every TChart class has five Axes: Left, Top, Right, Bottom and z depth.
  290.      *
  291.      * @return Axis 
  292.      * @see Axis
  293.      */
  294.     public function getBottom({
  295.         return $this->checkAxis($this->bottom);
  296.     }
  297.  
  298.     public function setBottom($value{
  299.         $this->bottom $value;
  300.     }
  301.  
  302.     /**
  303.      * Accesses characteristics of the Depth Axis, or z axis as it is also
  304.      * known.<br>
  305.      * Every TChart º has five Axes: Left, Top, Right, Bottom and z depth.
  306.      *
  307.      * @return Axis 
  308.      * @see Axis
  309.      */
  310.     public function getDepth({
  311.         if ($this->depth == null{
  312.            $this->depth = new DepthAxis(falsetrue$this->chart);
  313.         }
  314.         return $this->depth;
  315.     }
  316.  
  317.     public function setDepth($value{
  318.         $this->depth = $value;
  319.     }
  320.  
  321.     public function getDepthTop({
  322.         if ($this->depthTop == null{
  323.            $this->depthTop = new DepthAxis(falsefalse$this->chart);
  324.         }
  325.         return $this->depthTop;
  326.     }
  327.  
  328.     public function setDepthTop($value{
  329.         $this->depthTop = $value;
  330.     }
  331.  
  332.     /**
  333.      * Shows or hides the five Chart Axes at once.<br>
  334.      * Each Axis will be drawn depending also on their Visible property.<br>
  335.      * Default value: true
  336.      *
  337.      * @return boolean 
  338.      */
  339.     public function getVisible({
  340.         return $this->visible;
  341.     }
  342.  
  343.     /**
  344.      * Determines whether all five Chart Axes are visible or not.
  345.      *
  346.      * @param value boolean
  347.      */
  348.     public function setVisible($value{
  349.         $this->visible $this->setBooleanProperty($this->visible$value);
  350.     }
  351.  
  352.     public function setChart($value{
  353.         parent::setChart($value);
  354.  
  355.         $this->left->setChart($this->chart);
  356.         $this->top->setChart($this->chart);
  357.         $this->right->setChart($this->chart);
  358.         $this->bottom->setChart($this->chart);
  359.         $this->depth->setChart($this->chart);
  360.         $this->depthTop->setChart($this->chart);
  361.  
  362.         $this->custom->setChart($this->chart);
  363.     }
  364.  
  365.     public function draw($g{
  366.  
  367.         if ($g==null)
  368.             $g=$this->chart->getGraphics3D();
  369.  
  370.         $parent $this->chart->getParent();
  371.         if ($parent != null{
  372.             $parent->doBeforeDrawAxes();
  373.         }
  374.  
  375.         $old_name TChart::$controlName;
  376.         
  377.         if ($this->chart->isAxisVisible($this->left)) {
  378.             TChart::$controlName $old_name 'Axis_Left_';   
  379.             $this->left->draw(true);
  380.         }
  381.         if ($this->chart->isAxisVisible($this->right)) {
  382.             TChart::$controlName $old_name 'Axis_Right_';               
  383.             $this->right->draw(true);
  384.         }
  385.         if ($this->chart->isAxisVisible($this->top)) {
  386.             TChart::$controlName $old_name 'Axis_Top_';               
  387.             $this->top->draw(true);
  388.         }
  389.         if ($this->chart->isAxisVisible($this->bottom)) {
  390.             TChart::$controlName $old_name 'Axis_Bottom_';               
  391.             $this->bottom->draw(true);
  392.         }
  393.         if ($this->chart->isAxisVisible($this->depth)) {
  394.             TChart::$controlName $old_name 'Axis_Depth_';               
  395.             $this->depth->draw(true);
  396.         }
  397.         if ($this->chart->isAxisVisible($this->depthTop)) {
  398.             TChart::$controlName $old_name 'Axis_DepthTop_';               
  399.             $this->depthTop->draw(true);
  400.         }
  401.  
  402.         TChart::$controlName $old_name;
  403.         
  404.         for ($t 0$t sizeof($this->custom)$t++{
  405.             $a $this->custom->getAxis($t);
  406.             if ($a->getVisible()) {
  407.                 $a->draw(true);
  408.             }
  409.         }
  410.     }
  411. }
  412.  
  413. ?>

Documentation generated on Wed, 16 Jun 2010 12:02:49 +0200 by phpDocumentor 1.4.1