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

Source for file Chart.php

Documentation is available at Chart.php

  1. <?php
  2.  
  3. /**
  4.  * Chart class
  5.  *
  6.  * Description: Chart contents
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @link http://www.steema.com
  13.  */
  14.  
  15. class Chart extends TeeBase implements IBaseChart/*, Serializable/*,Cloneable*/ {
  16.  
  17.     // Private properties
  18.     private $autoRepaint=false;
  19.     private $export;
  20.     private $imports;
  21.     private $toolTip;
  22.     private $listeners;                // TeeEventListeners
  23.     private $savedScales;              // AllAxisSavedScales
  24.     private $numRedraws=0;
  25.     private $panel;
  26.     private $printer;
  27.     private $header$subHeader;
  28.     private $footer$subFooter;
  29.     private $walls;
  30.     private $tools;                    // ToolsCollection
  31.     private $animations;               // AnimationsCollection
  32.     private $panning;                  // Scroll
  33.  
  34.     // Protected properties
  35.     protected $parent;                 // IChart
  36.     protected $cancelMouse;
  37.     protected $IClicked;
  38.     protected $graphics3D;
  39.     protected $restoredAxisScales;
  40.     protected $printing;
  41.     protected $seriesWidth3D=0;
  42.     protected $legendPen=null;
  43.     protected $maxZOrder=0;
  44.     protected $aspect;
  45.     protected $axes;
  46.     protected $legend;
  47.     protected $page;
  48.     protected $series;                 // SeriesCollection
  49.     protected $chartBounds;
  50.     protected $zoom;                   // Zoom
  51.     protected $originalCursor;         // Cursor
  52.     protected $chartRect;
  53.  
  54.     // Public properties
  55.     public $clipWhenPrinting=true;     /* Apply clipping when printing */
  56.     public $clipWhenMetafiling=true;
  57.     public $seriesHeight3D=0;
  58.     public $left,$top,$right,$bottom;  // AxisSavedScales
  59.  
  60.     // Class definition
  61.  
  62.     // Interceptors
  63.     function __get$property {
  64.       $method ="get{$property}";
  65.       if method_exists$this$method ) ) {
  66.         return $this->$method();
  67.       }
  68.     }
  69.  
  70.     function __set $property,$value {
  71.       $method ="set{$property}";
  72.       if method_exists$this$method ) ) {
  73.         return $this->$method($value);
  74.       }
  75.     }
  76.  
  77.     /**
  78.     * The class constructor.
  79.     */
  80.     function Chart($parent=null$cursor=null{
  81.         $this->chartBounds=new Rectangle(0,0,0,0);
  82.         $this->chartRect=new Rectangle(0,0,0,0);
  83.  
  84.         parent::__construct(null);  // TeeBase
  85.  
  86.         TChart::$controlName =' Chart_';
  87.  
  88.         $this->initFields();
  89.         $this->readResolve();
  90.         $this->parent = $parent;        
  91.         $this->originalCursor = $cursor;
  92.  
  93.         // Apply Gradient temp..until Themes...
  94.         //$this->getPanel()->getGradient()->setVisible(true);
  95.     }
  96.  
  97.     private function initFields({
  98.         $this->setChart($this);
  99.         $this->series = new SeriesCollection($this);
  100.         $this->tools new ToolsCollection($this);
  101.         $this->animations new AnimationsCollection($this);
  102.         $this->aspect = new Aspect($this);
  103.         $this->panel new TeePanel($this);
  104.         $this->legend = new Legend($this);
  105.         $this->header new Header($this);
  106.         $this->header->defaultText "TeeChart";
  107.         $this->header->setText($this->header->defaultText);
  108.         $this->subHeader new Header($this);
  109.         $this->footer new Footer($this);
  110.         $this->subFooter new Footer($this);
  111.         $this->walls new Walls($this);
  112.         $this->axes = new Axes($this);
  113.         $this->page = new TeePage($this);
  114.  
  115.         $this->export new Exports($this);
  116.         $this->imports new Imports($this);
  117.         // TODO      $this->printer = new Printer($this);
  118.     }
  119.  
  120.     /**
  121.      * Main drawing procedure. Paints all Chart contents.
  122.      *
  123.      * @param IGraphics3D
  124.      */
  125.     private function internalDraw($g{
  126.         $this->seriesBeforeDraw();
  127.         $rect $this->chartRect;
  128.         $this->chartRect = $this->drawTitlesAndLegend($g$recttrue);
  129.         $this->setSeriesZOrder();
  130.         $rect $this->calcWallsRect($rect);
  131.         $this->chartRect = $rect;
  132.         $this->calcAxisRect();
  133.         $rect $this->chartRect;
  134.         $this->setSeriesZPositions();
  135.         $this->calcSeriesRect();
  136.         $g->projection($this->aspect->width3D$this->chartRect);
  137.         
  138.         TChart::$controlName 'Chart_';             
  139.         
  140.         if ($this->series->activeUseAxis(&& ($this->walls->getVisible())) {
  141.             TChart::$controlName .='Walls_';
  142.             $this->walls->paint($g,$rect);
  143.         }
  144.  
  145.         TChart::$controlName 'Chart_';                     
  146.         
  147.         if ($this->axes->getDrawBehind()) {
  148.             TChart::$controlName .='Axes_';            
  149.             $this->axes->draw($g);
  150.         }
  151.  
  152.         TChart::$controlName 'Chart_';             
  153.                 
  154.         //  Draw all Tools...
  155.         $tmpChartDrawEvent new ChartDrawEvent($thisChartDrawEvent::$PAINTING,
  156.                                               ChartDrawEvent::$SERIES);
  157.         $this->broadcastToolEvent($tmpChartDrawEvent);
  158.  
  159.         if ($this->parent != null{
  160.             $this->parent->doBeforeDrawSeries();
  161.         }
  162.  
  163.         $oldStrAlign $g->getTextAlign();
  164.  
  165.         TChart::$controlName 'Chart_';                     
  166.         
  167.         // Draw all Series...
  168.         if ($this->axes->getDepth()->getInverted()) {
  169.             for ($t sizeof($this->series1$t >= 0$t--{
  170.                 $s $this->series->getSeries($t);
  171.                 if ($s->getActive()) {
  172.                     TChart::$controlName .='Series' $t .'_';
  173.                     $s->drawSeries();
  174.                 }
  175.             }
  176.         else {
  177.             for ($t 0$t sizeof($this->series)$t++{
  178.                 $s $this->series->getSeries($t);
  179.                 if ($s->getActive()) {
  180.                     TChart::$controlName .='Series' $t .'_';
  181.                     $s->drawSeries();
  182.                 }
  183.             }
  184.  
  185.             $g->setTextAlign($oldStrAlign);
  186.         }
  187.  
  188.         /* TODO
  189.         if ($this->parent != null) {
  190.             $this->parent->doAfterDrawSeries();
  191.         }*/
  192.  
  193.         TChart::$controlName 'Chart_';                     
  194.                 
  195.         if (!$this->axes->getDrawBehind()) {
  196.             TChart::$controlName .='Axes_';
  197.             $this->axes->draw($g);
  198.         }
  199.  
  200.         TChart::$controlName 'Chart_';                     
  201.         
  202.         $rect $this->drawTitlesAndLegend($g$rectfalse);
  203.  
  204.         // Draw all tools
  205.         $tmpChartDrawEvent new ChartDrawEvent($thisChartDrawEvent::$PAINTED,
  206.                                               ChartDrawEvent::$CHART);
  207.         $this->broadcastToolEvent($tmpChartDrawEvent);
  208.  
  209.         // UTILS g.textOut(0, 0, 0, Integer.toString(numRedraws++));
  210.  
  211.         if (REV{
  212.             $g->doRev();
  213.         }
  214.     }                                                                                            
  215.  
  216.     private function readObject($in
  217.     {
  218.         $this->initFields();
  219.         $in->defaultReadObject();
  220.     }
  221.  
  222.     protected function readResolve({
  223.  
  224.         $this->aspect->setChart($this);
  225.         $this->panel->setChart($this);
  226.         $this->legend->setChart($this);
  227.         $this->header->setChart($this);
  228.         $this->subHeader->setChart($this);
  229.         $this->footer->setChart($this);
  230.         $this->subFooter->setChart($this);
  231.         $this->walls->setChart($this);
  232.         $this->axes->setChart($this);
  233.         $this->page->setChart($this);
  234.  
  235.         $this->export->setChart($this);
  236.         $this->imports->setChart($this);
  237.         // TODO       $this->printer->setChart($this);
  238.  
  239.         $this->series->setChart($this);
  240.         $this->tools->setChart($this);
  241.  
  242.         $this->restoredAxisScales = true;
  243.         $this->maxZOrder = 0;
  244.  
  245.         $parent $this->getParent();
  246.         if ($parent != null{
  247.             $parent->checkGraphics();
  248.         }
  249.  
  250.         return $this;
  251.     }
  252.  
  253.     public function recalcWidthHeight($r{
  254.         if ($r->$this->chartBounds->x{
  255.             $r->$this->chartBounds->x;
  256.         }
  257.         if ($r->$this->chartBounds->y{
  258.             $r->$this->chartBounds->y;
  259.         }
  260.         if ($r->getRight($this->chartBounds->x{
  261.             $r->width 1;
  262.         else
  263.         if ($r->getRight(== $this->chartBounds->x{
  264.             $r->width $this->chartBounds->width;
  265.         }
  266.         if ($r->getBottom($this->chartBounds->y{
  267.             $r->height 1;
  268.         else
  269.         if ($r->getBottom(== $this->chartBounds->y{
  270.             $r->height $this->chartBounds->height;
  271.         }
  272.  
  273.         $this->graphics3D->setXCenter(($r->$r->getRight()) 2);
  274.         $this->graphics3D->setYCenter(($r->$r->getBottom()) 2);
  275.  
  276.         return $r;
  277.     }
  278.  
  279.     public function cloner({
  280.         $c new Chart();
  281.  
  282.         $stream new ByteArrayOutputStream();
  283.         try {
  284.             $this->getExport()->getTemplate()->toStream($stream);
  285.         catch (Exception $ex
  286.             $ex->printStackTrace();
  287.         }
  288.  
  289.         $inputStream new ByteArrayInputStream($stream->toByteArray());
  290.  
  291.         try {
  292.             $c $c->getImport()->getTemplate()->fromStream($inputStream);
  293.         catch (Exception $ex{  
  294.             $ex->printStackTrace();
  295.         }
  296.         catch (Exception $ex{  
  297.             $ex->printStackTrace();
  298.         }
  299.  
  300.         return $c;
  301.     }
  302.  
  303.     /**
  304.      * @return Image 
  305.      */
  306.     public function image($width$height{
  307.         return $this->getExport()->getImage()->image($width$height);
  308.     }
  309.  
  310.     /**
  311.      * (Read only) Used to get the four sides of the Chart (Left, Top,
  312.      * Right and Bottom)
  313.      *
  314.      * @return Rectangle 
  315.      */
  316.     public function getChartBounds({
  317.         return $this->chartBounds;
  318.     }
  319.  
  320.     /**
  321.      * Sets the four sides of the Chart (Left, Top,
  322.      * Right and Bottom)
  323.      *
  324.      * @param value Rectangle
  325.      */
  326.     public function setChartBounds($value{
  327.         $this->chartBounds = $value;
  328.         $this->invalidate();
  329.     }
  330.  
  331.     /**
  332.      * The Chart width in pixels.
  333.      *
  334.      * @return int 
  335.      */
  336.     public function getWidth({
  337.         return $this->chartBounds->width;
  338.     }
  339.  
  340.     /**
  341.      * Sets the Chart width in pixels.
  342.      *
  343.      * @param value int
  344.      */
  345.     public function setWidth($value{
  346.         $this->chartBounds->width $value;
  347.         $this->invalidate();
  348.     }
  349.  
  350.     /**
  351.      * The Chart Height in pixels.
  352.      *
  353.      * @return int 
  354.      */
  355.     public function getHeight({
  356.         return $this->chartBounds->height;
  357.     }
  358.  
  359.     /**
  360.      * Sets the Chart Height in pixels.
  361.      *
  362.      * @param value int
  363.      */
  364.     public function setHeight($value{
  365.         $this->chartBounds->height $value;
  366.         $this->invalidate();
  367.     }
  368.  
  369.     public function getLeft({
  370.         return $this->chartBounds->getLeft();
  371.     }
  372.  
  373.     public function getRight({
  374.         return $this->chartBounds->getRight();
  375.     }
  376.  
  377.     public function getTop({
  378.         return $this->chartBounds->getTop();
  379.     }
  380.  
  381.     protected function getChartRectBottom({
  382.         return $this->chartRect->getBottom();
  383.     }
  384.  
  385.     protected function chartRectWidth({
  386.         return $this->chartRect->width;
  387.     }
  388.  
  389.     protected function chartRectHeight({
  390.         return $this->chartRect->height;
  391.     }
  392.  
  393.     // IBaseChart
  394.     public function doChangedBrush($value{
  395.         if ($this->graphics3D != null{
  396.             if ($value === $this->graphics3D->getBrush()) {
  397.                 $this->graphics3D->changed($this->graphics3D->getBrush());
  398.               }
  399.         }
  400.     }
  401.  
  402.     public function doChangedFont($value{
  403.         if ($this->graphics3D != null{
  404.             $this->graphics3D->changed($this->graphics3D->getFont());
  405.         }
  406.     }
  407.  
  408.     public function canDrawPanelBack({
  409.         return ((!$this->printing|| getPrinter().getPrintPanelBackground());
  410.     }
  411.  
  412.     /**
  413.      * Determines when Chart is being printed.
  414.      *
  415.      * @return boolean 
  416.      */
  417.     public function getPrinting({
  418.         return $this->printing;
  419.     }
  420.  
  421.     /**
  422.      * Determines when Chart is being printed.
  423.      *
  424.      * @param value boolean
  425.      */
  426.     public function setPrinting($value{
  427.         $this->printing = $value;
  428.     }
  429.  
  430.     public function setCancelMouse($value{
  431.         $this->cancelMouse = $value;
  432.     }
  433.  
  434.     // return Series
  435.     static public function changeSeriesType($series$newClass{
  436.         $type $newClass;
  437.         $tmpFunction $series->getFunction();
  438.     }
  439.  
  440.     /* TODO
  441.     static public function changeAllSeriesType($chart, $newClass) {
  442.         $tmp; // Series
  443.         
  444.         List $tmpList = new ArrayList(chart.getSeries());
  445.         Iterator it = tmpList.iterator();
  446.         while (it.hasNext()) {
  447.             Series s = (Series) it.next();
  448.             changeSeriesType(s, newClass);
  449.         }
  450.     }
  451.     */
  452.  
  453.     protected function removeAllComponents({
  454.         $this->series->clear();
  455.         $this->tools->clear();
  456.         $this->axes->getCustom()->clear();
  457.     }
  458.  
  459.     /**
  460.      * Returns array list of objects that implement the
  461.      * TeeEventListener interface.
  462.      *
  463.      * @return TeeEventListeners 
  464.      */
  465.     public function  getListeners({
  466.         if ($this->listeners == null{
  467.             $this->listeners new TeeEventListeners();
  468.         }
  469.         return $this->listeners;
  470.     }
  471.  
  472.     protected function removeListener($sender{
  473.         if ($this->listeners != null{
  474.             $this->listeners->remove($sender);
  475.         }
  476.     }
  477.  
  478.     // Return boolean
  479.     public function isValidDataSource($s$source{
  480.     /*  TODO        
  481.       $result = (($s != $source) && ($source instanceof Series) &&
  482.                           (s.isValidSourceOf((Series) source)));
  483.  
  484.         if (!result) {
  485.             result = DataSeriesSource::isValidSource(source);
  486.         }
  487.  
  488.         return $result;
  489.      */   
  490.     }
  491.  
  492.     // Parameter Axis
  493.     private function calcNumPages($a{
  494.         // By default, one single page.
  495.         $result 1;
  496.  
  497.         // Calc max number of points for all active series associated to "a" axis.
  498.         $tmp 0;
  499.         $firstTime true;
  500.  
  501.         for ($t 0$t $this->series->count()$t++{
  502.             $s $this->series->getSeries($t);
  503.             if ($s->getActive(&& $s->associatedToAxis($a)) {
  504.                 if ($firstTime || ($s->getCount($tmp)) {
  505.                     $tmp $s->getCount();
  506.                     $firstTime false;
  507.                 }
  508.             }
  509.  
  510.             // If there are points... divide into pages... }
  511.             if ($tmp 0{
  512.                 $result $tmp $this->page->getMaxPointsPerPage();
  513.  
  514.                 // Extra page for remaining points...
  515.                 if (($tmp $this->page->getMaxPointsPerPage()) 0{
  516.                     $result++;
  517.                 }
  518.             }
  519.  
  520.         }
  521.         return $result;
  522.     }
  523.  
  524.     // restore the "remembered" axis scales when unzooming
  525.     static private function restoreAxisScales($a=null$tmp=null{
  526.         if(($a==null&& ($tmp==null)) {
  527.                 if (!$this->restoredAxisScales{
  528.                     $this->restoreScales($this->savedScales);
  529.                     $this->restoredAxisScales = true;
  530.                 }
  531.         }
  532.         else
  533.         {
  534.                 $a->setAutomatic($tmp->auto);
  535.                 $a->setAutomaticMinimum($tmp->autoMin);
  536.                 $a->setAutomaticMaximum($tmp->autoMax);
  537.                 if (!$a->getAutomatic()) {
  538.                     $a->setMinMax($tmp->min$tmp->max);
  539.                 }
  540.         }
  541.     }
  542.  
  543.     public function getNumPages({
  544.         if (($this->page->getMaxPointsPerPage(0&& ($this->getSeries()->count(0)) {
  545.             if ($this->getSeries()->getSeries(0)->getYMandatory()) {
  546.                 return max($this->calcNumPages($this->axes->getTop()),
  547.                                 $this->calcNumPages($this->axes->getBottom()));
  548.             else {
  549.                 return max($this->calcNumPages($this->axes->getLeft()),
  550.                                 $this->calcNumPages($this->axes->getRight()));
  551.             }
  552.         else {
  553.             return 1;
  554.         }
  555.     }
  556.  
  557.     /**
  558.      * Displays a text box at the cursor.
  559.      *
  560.      * @return ToolTip 
  561.      */
  562.     public function getToolTip({
  563.         if ($this->toolTip == null{
  564.             $this->toolTip new ToolTip($this);
  565.         }
  566.         return $this->toolTip;
  567.     }
  568.  
  569.     /**
  570.      * Returns the Active series (visible) that corresponds to the
  571.      * ItemIndex position in the Legend.<br>
  572.      * When the Legend style is "Series", returns the series that corresponds
  573.      * to the Legend "ItemIndex" position. The "OnlyActive" parameter, when
  574.      * false takes into account all series, visibly active or not.
  575.      *
  576.      * @param itemIndex int
  577.      * @return Series that corresponds to the ItemIndex position in the Legend
  578.      */
  579.     public function activeSeriesLegend($itemIndex{
  580.         return $this->seriesLegend($itemIndextrue);
  581.     }
  582.  
  583.     /**
  584.      * Returns the Series.Title string.
  585.      *
  586.      * @param seriesIndex int
  587.      * @param onlyActive boolean
  588.      * @return String 
  589.      */
  590.     public function getSeriesTitleLegend($seriesIndex$onlyActive{
  591.         $tmpSeries null;
  592.  
  593.         if ($onlyActive{
  594.             $tmpSeries $this->activeSeriesLegend($seriesIndex);
  595.         else {
  596.             $tmpSeries $this->seriesLegend($seriesIndexfalse);
  597.         }
  598.  
  599.         return ($tmpSeries != null$tmpSeries->toString("";
  600.     }
  601.  
  602.     private function seriesBeforeDraw({
  603.         for ($t 0$t sizeof($this->series)$t++{
  604.             $s $this->series->getSeries($t);
  605.             if ($s->getActive()) {
  606.                 $s->doBeforeDrawChart();
  607.             }
  608.         }
  609.     }
  610.  
  611.     /**
  612.      * Accesses the Zoom characteristics of the Chart.
  613.      *
  614.      * @return Zoom 
  615.      */
  616.     public function getZoom({
  617.         if ($this->zoom == null{
  618.             $this->zoom = new Zoom($this);
  619.         }
  620.         return $this->zoom;
  621.     }
  622.  
  623.     public function setZoom($zoom{
  624.         $this->zoom = $zoom;
  625.     }
  626.  
  627.     /**
  628.      * Sets the scrolling direction or denies scrolling.
  629.      *
  630.      * @return Scroll 
  631.      */
  632.     public function getPanning({
  633.         if ($this->panning == null{
  634.             $this->panning new Scroll($this);
  635.         }
  636.         return $this->panning;
  637.     }
  638.  
  639.     public function setPanning($panning{
  640.         $this->panning $panning;
  641.     }
  642.  
  643.     private function calcSize3DWalls({
  644.         if ($this->aspect->getView3D()) {
  645.  
  646.             $tmp 0.001 $this->aspect->getChart3DPercent();
  647.  
  648.             if (!$this->aspect->getOrthogonal()) {
  649.                 $tmp *= 2;
  650.             }
  651.  
  652.             $this->seriesWidth3D = MathUtils::round($tmp $this->chartBounds->width);
  653.  
  654.             if ($this->aspect->getOrthogonal()) {
  655.                 $tmpSin sin($this->aspect->getOrthoAngle(*
  656.                                          MathUtils::getPiStep());
  657.                 $tmpCos cos($this->aspect->getOrthoAngle(*
  658.                                          MathUtils::getPiStep());
  659.                 $tmp $tmpSin $tmpCos;
  660.             else {
  661.                 $tmp 1;
  662.             }
  663.  
  664.             if ($tmp 1{
  665.                 $this->seriesWidth3D = MathUtils::round($this->seriesWidth3D / $tmp);
  666.             }
  667.  
  668.             $this->seriesHeight3D = MathUtils::round($this->seriesWidth3D * $tmp);
  669.  
  670.             $tmpNumSeries $this->aspect->getApplyZOrder(?
  671.                                max(1$this->maxZOrder + 11;
  672.  
  673.             $this->aspect->height3D $this->seriesHeight3D * $tmpNumSeries;
  674.             $this->aspect->width3D $this->seriesWidth3D * $tmpNumSeries;
  675.         else {
  676.             $this->seriesHeight3D = 0;
  677.             $this->seriesWidth3D = 0;
  678.             $this->aspect->height3D 0;
  679.             $this->aspect->width3D 0;
  680.         }
  681.     }
  682.  
  683.     public function getSeriesIndexOf($value{
  684.         return $this->series->indexOf($value);
  685.     }
  686.  
  687.     /**
  688.      * Collection of Series contained in this Chart.
  689.      *
  690.      * @return SeriesCollection 
  691.      */
  692.     public function getSeriesCollection({
  693.         return $this->series;
  694.     }
  695.  
  696.     /**
  697.     * Returns the Series at seriesIndex
  698.     *
  699.     * @param int $seriesIndex 
  700.     * @return Series 
  701.     */
  702.     public function getSeries($seriesIndex=-1{
  703.         if ($seriesIndex==-1{
  704.             return $this->series;
  705.         }
  706.         else
  707.         {
  708.             return $this->series->getSeries($seriesIndex);
  709.         }
  710.     }
  711.  
  712.     public function setSeriesCollection($value{
  713.         $this->series = $value;
  714.         $this->series->chart $this;
  715.     }
  716.  
  717.     private function checkTitle($t$e$c{
  718.         if ($this->parent != null{
  719.             $this->parent->checkTitle($t$e$c);
  720.         }
  721.     }
  722.     
  723.     // "remember" the axis scales when zooming, to restore if unzooming.
  724.     static private function saveAxisScales($a{
  725.         $result new AxisSavedScales();
  726.         $result->auto $a->getAutomatic();
  727.         $result->autoMin $a->getAutomaticMinimum();
  728.         $result->autoMax $a->getAutomaticMaximum();
  729.         $result->min $a->getMinimum();
  730.         $result->max $a->getMaximum();
  731.         return $result;
  732.     }
  733.     
  734.     private function saveScales({
  735.         $result new AllAxisSavedScales();
  736.         $result->top self::saveAxisScales($this->getAxes()->getTop());
  737.         $result->bottom self::saveAxisScales($this->getAxes()->getBottom());
  738.         $result->left self::saveAxisScales($this->getAxes()->getLeft());
  739.         $result->right self::saveAxisScales($this->getAxes()->getRight());
  740.         return $result;
  741.     }
  742.  
  743.     private function restoreScales($s{                
  744.         $this->restoreAxisScales($this->getAxes()->getTop()$s->top);
  745.         $this->restoreAxisScales($this->getAxes()->getBottom()$s->bottom);
  746.         $this->restoreAxisScales($this->getAxes()->getLeft()$s->left);
  747.         $this->restoreAxisScales($this->getAxes()->getRight()$s->right);
  748.     }
  749.     
  750.     public function doZoom($topx$topy$bottomx$bottomy$leftx$lefty$rightx$righty{
  751.         $this->doZoomPoints(new PointDouble($topx$topy),
  752.                new PointDouble($bottomx$bottomy),
  753.                new PointDouble($leftx$lefty),
  754.                new PointDouble($rightx$righty));
  755.     }
  756.  
  757.     public function doZoomPoints($top$bot$lef$rig{
  758.         if ($this->restoredAxisScales{
  759.             $this->savedScales $this->saveScales();
  760.             $this->restoredAxisScales = false;
  761.         }
  762.  
  763.         /* TODO not support for animation
  764.         if ($this->getZoom()->getAnimated()) {
  765.             $this->doZoomAnimated(top.x, top.y, bot.x, bot.y, lef.x, lef.y, rig.x,
  766.                            rig.y);
  767.             // animation...
  768.         }
  769.         */
  770.         
  771.         // final zoom
  772.         $this->getAxes()->getLeft()->setMinMax($lef->x$lef->y);
  773.         $this->getAxes()->getRight()->setMinMax($rig->x$rig->y);
  774.         $this->getAxes()->getTop()->setMinMax($top->x$top->y);
  775.         $this->getAxes()->getBottom()->setMinMax($bot->x$bot->y);
  776.         $this->getZoom()->setZoomed(true);
  777.  
  778.         if ($this->parent != null{
  779.             $this->parent->doZoomed($this);
  780.         }
  781.     }
  782.  
  783.     /**
  784.      * Obsolete.Please use tChart1.<!-- -->Zoom.<!-- -->Undo method.
  785.      */
  786.     public function undoZoom({
  787.         $this->zoom->undo();
  788.     }
  789.  
  790.     private function activeSeriesUseAxis({
  791.         for ($t 0$t sizeof($this->series)$t++{
  792.             $s $this->series->getSeries($t);
  793.             if ($s->getActive(&& $s->getUseAxis()) {
  794.                 return true;
  795.             }
  796.         }
  797.         return false;
  798.     }
  799.  
  800.     public function setBrushCanvas($aColor$aBrush$aBackColor{
  801. //      if ((!aBrush.Solid) && (AColor==aBackColor))
  802. //        if (aBackColor==Color.black) aColor=Color.WHITE; else aColor=Color.black;
  803.  
  804.         $this->graphics3D->setBrush($aBrush);
  805.         $this->graphics3D->getBrush()->setColor($aColor)////#1482 ColorEach
  806.     }
  807.  
  808.     /**
  809.      * Returns the number of active (visible) series.<br>
  810.      * CanClip returns if the Chart Drawing Canvas has the capability of
  811.      * "clipping" lines and polygons.<br>
  812.      * "Clipping" means the feature that allows hiding drawing outside the
  813.      * rectangle or polygon specifed by the developer.<br>
  814.      * CanClip returns false when the Chart is displayed in OpenGL 3D, or when
  815.      * the Chart is printed and the TeeClipWhenPrinting constant is true, or
  816.      * when the Chart is converted to a metafile image and the
  817.      * TeeClipWhenMetafiling constant is true. <br>
  818.      * By default all display drivers and printers support clipping. You can
  819.      * turn off the clipping constants in case the printer or display driver
  820.      * has a bug related to clipping. <br>
  821.      * See also: <br>
  822.      * ClipPoints, TeeClipWhenPrinting, TeeClipWhenMetafiling, ClipCanvas,
  823.      * UnClipCanvas, ClipRoundRectangle and ClipPolygon.
  824.      *
  825.      * @return boolean 
  826.      */
  827.     public function canClip({
  828.         return (!$this->graphics3D->getSupportsFullRotation()) &&
  829.                 (((!$this->printing&& (!$this->graphics3D->getMetafiling())) ||
  830.                  ($this->printing && $this->clipWhenPrinting||
  831.                  ($this->graphics3D->getMetafiling(&& $this->clipWhenMetafiling)
  832.                 );
  833.     }
  834.  
  835.     // Return Rectangle
  836.     private function calcWallsRect($r{
  837.         $this->calcSize3DWalls();
  838.  
  839.         // for orthogonal only :
  840.         if ($this->aspect->getView3D(&& $this->aspect->getOrthogonal()) {
  841.             $tmp 0;
  842.  
  843.             if ($this->activeSeriesUseAxis()) {
  844.                 $tmp $this->getWalls()->getBack()->getSize();
  845.             }
  846.  
  847.             $r->width -= abs($this->aspect->width3D$tmp;
  848.             $t abs($this->aspect->height3D$tmp;
  849.             $r->height -= $t;
  850.             $r->+= $t;
  851.  
  852.             if ($this->getWalls()->getRight()->getVisible()) {
  853.                 $r->width -= $this->getWalls()->getRight()->getSize(1;
  854.             }
  855.         }
  856.  
  857.         return $this->recalcWidthHeight($r);
  858.     }
  859.  
  860.     /**
  861.      * Returns if no series are active (visible) and associated to the
  862.      * Axis "a" parameter.
  863.      *
  864.      * @param Axis
  865.      * @return boolean 
  866.      */
  867.     private function noActiveSeries($a{
  868.         for ($t 0$t $this->series->count()$t++{
  869.             $s $this->series->getSeries($t);
  870.             if ($s->getActive(&& $s->associatedToAxis($a)) {
  871.                 return false;
  872.             }
  873.         }
  874.         return true;
  875.     }
  876.  
  877.     /**
  878.      * Returns the first Series that depends on the specified Axis.<br>
  879.      * If no Series depends on Axis, the null value is returned.
  880.      *
  881.      * @param axis Axis
  882.      * @return Series 
  883.      */
  884.     public function getAxisSeries($axis{
  885.         for ($t 0$t sizeof($this->series)$t++{
  886.             $s $this->getSeries($t);
  887.             if (($s->getActive(|| $this->noActiveSeries($axis)) &&
  888.                 $s->associatedToAxis($axis)) {
  889.                 return $s;
  890.             }
  891.         }
  892.  
  893.         return null;
  894.     }
  895.  
  896.     public function internalMinMax($aAxis$isMin$isX{
  897.         $firstTime true;
  898.         $tmp 0;
  899.         $tmpResult 0;
  900.  
  901.         if ($aAxis->isDepthAxis{
  902.             if ($aAxis->calcLabelStyle(== AxisLabelStyle::$VALUE{
  903.                 $tmpResult 0;
  904.                 $firstTime true;
  905.                 for ($t 0$t $this->series->count()$t++{
  906.                     $s $this->series->getSeries($t);
  907.                     if ($s->getActive()) {
  908.                         $tmp $isMin $s->getMinZValue($s->getMaxZValue();
  909.                         if ($firstTime || (isMin && (tmp tmpResult)) ||
  910.                             ((!$isMin&& ($tmp $tmpResult))) {
  911.                             $firstTime false;
  912.                             $tmpResult $tmp;
  913.                         }
  914.                     }
  915.                 }
  916.             else {
  917.                 $tmpResult $isMin ? -0.5 $this->maxZOrder + 0.5;
  918.             }
  919.         else {
  920.             $tmpResult 0;
  921.             $tmpSeries $this->getAxisSeries($aAxis);
  922.             $tmpPagingAxis ($tmpSeries != null?
  923.                                     $tmpSeries->getYMandatory(?
  924.                                     $isX :
  925.                                     !$isX $isX;
  926.  
  927.             if (($this->page->getMaxPointsPerPage(0&& $tmpPagingAxis{
  928.                 if (($tmpSeries != null&& ($tmpSeries->getCount(0)) {
  929.  
  930.                     $tmpList $isX $tmpSeries->getXValues(:
  931.                                         $tmpSeries->getYValues();
  932.  
  933.                     $tmpFirstPoint ($this->page->getCurrent(1*
  934.                                         $this->page->getMaxPointsPerPage();
  935.                     $tmpCount $tmpSeries->getCount();
  936.  
  937.                     if ($tmpCount <= $tmpFirstPoint{
  938.                         $tmpFirstPoint (max(0,($tmpCount /
  939.                                 $this->page->getMaxPointsPerPage()) 1*
  940.                                          $this->page->getMaxPointsPerPage());
  941.                     }
  942.  
  943.                     $tmpLastPoint $tmpFirstPoint +
  944.                                        $this->page->getMaxPointsPerPage(1;
  945.  
  946.                     if ($tmpCount <= $tmpLastPoint{
  947.                         $tmpLastPoint $tmpFirstPoint +
  948.                                        ($tmpCount %
  949.                                         $this->page->getMaxPointsPerPage()) 1;
  950.                     }
  951.  
  952.                     if ($isMin{
  953.                         $tmpResult $tmpList->value[$tmpFirstPoint];
  954.                     else {
  955.                         $tmpResult $tmpList->value[$tmpLastPoint];
  956.  
  957.                         if (!$this->page->getScaleLastPage()) {
  958.                             $tmpNumPoints $tmpLastPoint $tmpFirstPoint 1;
  959.  
  960.                             if ($tmpNumPoints $this->page->getMaxPointsPerPage()) {
  961.  
  962.                                 $tmp $tmpList->value[$tmpFirstPoint];
  963.                                 $tmpResult $tmp +
  964.                                             $this->page->getMaxPointsPerPage(*
  965.                                             ($tmpResult $tmp/
  966.                                             $tmpNumPoints;
  967.                             }
  968.                         }
  969.                     }
  970.                 }
  971.             else {
  972.                 $firstTime true;
  973.                 for ($t 0$t sizeof($this->series)$t++{
  974.                     $s $this->series->getSeries($t);
  975.  
  976.                     if (($s->getActive(|| $this->noActiveSeries($aAxis)) &&
  977.                         ($s->getCount(0)) {
  978.                         if (($isX &&
  979.                              (($s->getHorizontalAxis(== HorizontalAxis::$BOTH||
  980.                               ($s->getHorizAxis(=== $aAxis))) ||
  981.                             ((!$isX&&
  982.                              (($s->getVerticalAxis(== VerticalAxis::$BOTH||
  983.                               ($s->getVertAxis(=== $aAxis)))) {
  984.  
  985.                             if ($isMin{
  986.                                 $tmp $isX $s->getMinXValue(:
  987.                                       $s->getMinYValue();
  988.                             else {
  989.                                 $tmp $isX $s->getMaxXValue(:
  990.                                       $s->getMaxYValue();
  991.                             }
  992.  
  993.                             if ($firstTime || ($isMin && ($tmp $tmpResult)) ||
  994.                                 ((!$isMin&& ($tmp $tmpResult))) {
  995.                                 $tmpResult $tmp;
  996.                                 $firstTime false;
  997.                             }
  998.                         }
  999.                     }
  1000.                 }
  1001.             }
  1002.         }
  1003.         return $tmpResult;
  1004.     }
  1005.  
  1006.     /**
  1007.      * Returns the Maximum width in pixels of all Series Labels, whether
  1008.      * active or not.<br>
  1009.      * This applies only to Series which have Labels.
  1010.      *
  1011.      * @return int 
  1012.      */
  1013.  
  1014.     public function maxTextWidth({
  1015.         $tmpResult 0;
  1016.         for ($t 0$t sizeof($this->series)$t++{
  1017.             $s $this->series->getSeries($t);
  1018.             $labels=$s->getLabels();
  1019.             if (sizeof($labels0{
  1020.                 for ($tt 0$tt $s->getCount()$tt++{
  1021.                     $tmp=$this->multiLineTextWidth($labels[$tt]);
  1022.                     $tmpResult max($tmpResult,
  1023.                     $tmp->width);
  1024.                 }
  1025.             }
  1026.         }
  1027.         return $tmpResult;
  1028.     }
  1029.  
  1030.     /**
  1031.      * Returns the Maximum width of the Active Series Marks.<br>
  1032.      * Series Marks must be Visible. This can be used to adjust the Chart
  1033.      * Margins in order to accomodate the biggest Series Mark.
  1034.      *
  1035.      * @return int 
  1036.      */
  1037.     public function maxMarkWidth({
  1038.         $tmpResult 0;
  1039.         for ($t 0$t $this->series->count()$t++{
  1040.             $s $this->series->getSeries($t);
  1041.             if ($s->getActive()) {
  1042.                 $tmpResult max($tmpResult$s->maxMarkWidth());
  1043.             }
  1044.         }
  1045.         return $tmpResult;
  1046.     }
  1047.  
  1048.  
  1049.     private function calcString($result$st{
  1050.         $result->tmpResult max($result->tmpResult,
  1051.                             $this->getGraphics3D()->textWidth($st));
  1052.         $result->numLines++;
  1053.         return $result;
  1054.     }
  1055.  
  1056.     public function multiLineTextWidth($s{
  1057.         $result new MultiLine();
  1058.  
  1059.         // Note our use of ===.  Simply == would not work as expected
  1060.         // because the position of 'a' was the 0th (first) character.
  1061.         $i strpos($sLanguage::getString("LineSeparator"));
  1062.  
  1063.         if ($i === false{
  1064.             $result->count 1;
  1065.             $result->width $this->graphics3D->textWidth($s);
  1066.         else {
  1067.             $tmpResult 0;
  1068.             $r new CalcStringResults();
  1069.  
  1070.             while ($i !== false{
  1071.                 $r $this->calcString($r$s->substring(0$i 1));
  1072.                 $tmpResult $r->tmpResult;
  1073.  
  1074.                 $s $s->substring($i 1);
  1075.                 $i strpos($sLanguage::getString("LineSeparator"));
  1076.             }
  1077.  
  1078.             $result->count $r->numLines;
  1079.             $result->width $r->tmpResult;
  1080.  
  1081.             if (strlen($s!= 0{
  1082.                 $result->count++;
  1083.                 $result->width max($tmpResult$this->graphics3D->textWidth($s));
  1084.             }
  1085.         }
  1086.         return $result;
  1087.     }
  1088.  
  1089.     /**
  1090.      * Returns the Maximum Value of the Series X Values List.
  1091.      *
  1092.      * @param axis Axis
  1093.      * @return double 
  1094.      */
  1095.     public function getMaxXValue($axis{
  1096.         return $this->internalMinMax($axisfalsetrue);
  1097.     }
  1098.  
  1099.     /**
  1100.      * Returns the highest of all the current Series Y point values.
  1101.      *
  1102.      * @param axis Axis
  1103.      * @return double 
  1104.      */
  1105.     public function getMaxYValue($axis{
  1106.         return $this->internalMinMax($axisfalsefalse);
  1107.     }
  1108.  
  1109.     /**
  1110.      * Returns the Minimum Value of the Series X Values List.
  1111.      *
  1112.      * @param axis Axis
  1113.      * @return double 
  1114.      */
  1115.     public function getMinXValue($axis{
  1116.         return $this->internalMinMax($axistruetrue);
  1117.     }
  1118.  
  1119.     /**
  1120.      * Returns the Minimum Value of the Series Y Values List.
  1121.      *
  1122.      * @param axis Axis
  1123.      * @return double 
  1124.      */
  1125.     public function getMinYValue($axis{
  1126.         return $this->internalMinMax($axistruefalse);
  1127.     }
  1128.  
  1129.     /**
  1130.      * Returns whether the AColor parameter is used by any Series or not.
  1131.      *
  1132.      * @param color Color
  1133.      * @param checkBackground boolean When true, uses current Chart background
  1134.      * @return boolean 
  1135.      */
  1136.     public function isFreeSeriesColor($color$checkBackground{
  1137.         $isUsed ($checkBackground &&
  1138.                           (($color == $this->panel->getColor()) ||
  1139.                            ($color == $this->walls->getBack()->getColor())));
  1140.  
  1141.         for ($t 0$t $this->series->count()$t++{
  1142.             $s $this->series->getSeries($t);
  1143.             if (($s->getColor(== $color|| $isUsed{
  1144.                 return false;
  1145.             }
  1146.         }
  1147.  
  1148.         return !$isUsed;
  1149.     }
  1150.  
  1151.     /**
  1152.      * Returns a color from the default color palette not used by any Series.
  1153.      * <br>
  1154.      * The CheckBackGround parameter controls if the returned color should
  1155.      * or shouldn't be the Chart BackColor color. This function returns a
  1156.      * Color which is not used by any Series in the Chart.
  1157.      *
  1158.      * @param checkBackground boolean
  1159.      * @return Color 
  1160.      */
  1161.     public function freeSeriesColor($checkBackground{
  1162.         if ($this->getGraphics3D(== null{
  1163.             return new Color(255,255,255);
  1164.         else {
  1165.             $t 0;
  1166.             $g=$this->getGraphics3D();
  1167.  
  1168.             do {
  1169.                 $result $g->getDefaultColor($t);
  1170.                 if ($this->isFreeSeriesColor($result$checkBackground)) {
  1171.                     return $result;
  1172.                 else {
  1173.                     $t++;
  1174.                 }
  1175.             while ($t $g->getColorPaletteLength());
  1176.  
  1177.             return $g->getDefaultColor(0);
  1178.         }
  1179.     }
  1180.  
  1181.     /**
  1182.      * Default indexer.<br><br>
  1183.      *
  1184.      * Example:<pre><font face="Courier" size="4">
  1185.      * tChart1[0].Color=Color.Blue;
  1186.      *  is equivalent to
  1187.      * tChart1.Series[0].Color=Color.Blue;
  1188.      * </font></pre>
  1189.      *
  1190.      * @param index int
  1191.      * @return Series 
  1192.      */
  1193.     public function getItem($index{
  1194.         return $this->series->getSeries($index);
  1195.     }
  1196.  
  1197.     /**
  1198.      * Default indexer.<br>
  1199.      *
  1200.      * @param index int
  1201.      * @param value Series
  1202.      */
  1203.     public function setItem($index$value{
  1204.         $this->series->setSeries($index$value);
  1205.     }
  1206.  
  1207.     //  Steps to determine if an axis is Visible:
  1208.     // 1) The global Chart.AxisVisible property is True... and...
  1209.     // 2) The Axis Visible property is True... and...
  1210.     // 3) At least there is a Series Active and associated to the axis and
  1211.     //   the Series has the "UseAxis" property True.
  1212.     public function isAxisVisible($a{
  1213.  
  1214.         $result ($this->axes->getVisible(&& $a->getVisible());
  1215.  
  1216.         if ($result// if still visible...
  1217.             if ($a->isDepthAxis{
  1218.                 return $this->aspect->getView3D();
  1219.             else {
  1220.                 for ($t 0$t sizeof($this->series)$t++{
  1221.                     $s $this->series->getSeries($t);
  1222.                     if ($s->getActive()) {
  1223.                         if ($s->getUseAxis()) {
  1224.                             $result $s->associatedToAxis($a);
  1225.                             if ($result{
  1226.                                 return true;
  1227.                             }
  1228.                         else {
  1229.                             return false;
  1230.                         }
  1231.                     }
  1232.                 }
  1233.             }
  1234.         }
  1235.  
  1236.         return $result;
  1237.     }
  1238.  
  1239.     /**
  1240.      * Returns first active (visible) series.
  1241.      *
  1242.      * @return Series 
  1243.      */
  1244.     public function getFirstActiveSeries({
  1245.         for ($t 0$t $this->series->count()$t++{
  1246.             $s $this->series->getSeries($t);
  1247.             if ($s->getActive()) {
  1248.                 return $s;
  1249.             }
  1250.         }
  1251.         return null;
  1252.     }
  1253.  
  1254.     private function axisRect($a$r{
  1255.         if ($this->isAxisVisible($a)) {
  1256.             $oldR=$r;
  1257.             if($a != $a->getChart()->getAxes()->getDepthTop())
  1258.                 $a->calcRect($oldR,true);
  1259.             else
  1260.                 $a->calcRect($oldR,false);
  1261.             $r->intersect($oldR);
  1262.         }
  1263.         return $r;
  1264.     }
  1265.  
  1266.     private function calcAxisRect({
  1267.         $tmpR $this->chartRect;
  1268.         $this->axes->adjustMaxMin();
  1269.         $this->axes->internalCalcPositions();
  1270.  
  1271.         $oldR $tmpR;
  1272.  
  1273.         $tmpR $this->axisRect($this->axes->getLeft()$tmpR);
  1274.         $tmpR $this->axisRect($this->axes->getTop()$tmpR);
  1275.         $tmpR $this->axisRect($this->axes->getRight()$tmpR);
  1276.         $tmpR $this->axisRect($this->axes->getBottom()$tmpR);
  1277.         $tmpR $this->axisRect($this->axes->getDepth()$tmpR);
  1278.         $tmpR $this->axisRect($this->axes->getDepthTop()$tmpR);
  1279.  
  1280.         for ($t 0$t sizeof($this->axes->getCustom())$t++{
  1281.             $a $this->axes->getCustom()->getAxis($t);
  1282.             if ($this->isAxisVisible($a)) {
  1283.                 $oldR $tmpR;
  1284.                 $tmpR $a->calcRect($tmpRfalse)// <-- inflate only for first 4 axes
  1285.                 $tmpR->intersect($oldR);
  1286.             }
  1287.         }
  1288.  
  1289.         $tmpR $this->recalcWidthHeight($tmpR);
  1290.         $this->chartRect = $tmpR;
  1291.  
  1292.         $this->axes->internalCalcPositions()// recalc again
  1293.     }
  1294.  
  1295.     private function setSeriesZOrder({
  1296.         $this->maxZOrder = 0;
  1297.  
  1298.         $ok ($this->aspect->getApplyZOrder(&& $this->aspect->getView3D());
  1299.  
  1300.         if ($ok{
  1301.             $this->maxZOrder = -1;
  1302.             for ($t 0$t sizeof($this->series)$t++{
  1303.                 $s $this->series->getSeries($t);
  1304.                 if ($s->getActive()) {
  1305.                     $s->calcZOrder();
  1306.                 }
  1307.             }
  1308.         }
  1309.  
  1310.         // invert Z Orders
  1311.         if (!$this->axes->getDepth()->getInverted()) // 6.01
  1312.             for ($t 0$t sizeof($this->series)$t++{
  1313.                 $s $this->series->getSeries($t);
  1314.                 if ($s->getActive()) {
  1315.                     $s->iZOrder $ok $this->maxZOrder - $s->getZOrder(0;
  1316.                 }
  1317.             }
  1318.         }
  1319.  
  1320.     }
  1321.  
  1322.     /**
  1323.      * Returns the String to display at Legend for a given series and point
  1324.      * index.<br>
  1325.      * In other words it returns the string representation of a Series
  1326.      * Point value just as it would appear in Chart.Legend. The ValueIndex
  1327.      * parameter is the point index. Legend.TextStyle and all other
  1328.      * TChartLegend methods are used to create the resulting string.
  1329.      *
  1330.      * @param aSeries Series
  1331.      * @param valueIndex int
  1332.      * @return String 
  1333.      */
  1334.     public function formattedValueLegend($aSeries$valueIndex{
  1335.         return ($aSeries != null?
  1336.                 $this->legend->formattedValue($aSeries$valueIndex:
  1337.                 "";
  1338.     }
  1339.  
  1340.     private function setSeriesZPositions({
  1341.         for ($t 0$t sizeof($this->series)$t++{
  1342.             $s $this->series->getSeries($t);
  1343.             if ($s->getActive()) {
  1344.                 $s->setZPositions();
  1345.             }
  1346.         }
  1347.     }
  1348.  
  1349.     private function calcSeriesAxisRect($axis{
  1350.         $tmpLeft 0;
  1351.         $tmpTop 0;
  1352.         $tmpRight 0;
  1353.         $tmpBottom 0;
  1354.         $margins new Margins();
  1355.  
  1356.         for ($t 0$t sizeof($this->series)$t++{
  1357.  
  1358.             $tmpSeries $this->series->getSeries($t);
  1359.  
  1360.             if ($tmpSeries->getActive()) {
  1361.                 if ($tmpSeries->associatedToAxis($axis)) {
  1362.                     if ($axis->getHorizontal()) {
  1363.                         $tmpSeries->calcHorizMargins($margins);
  1364.                         if ($axis->getAutomaticMinimum()) {
  1365.                             $tmpLeft max($tmpLeft$margins->min);
  1366.                         }
  1367.                         if ($axis->getAutomaticMaximum()) {
  1368.                             $tmpRight max($tmpRight$margins->max);
  1369.                         }
  1370.                     else {
  1371.                         $tmpSeries->calcVerticalMargins($margins);
  1372.                         if ($axis->getAutomaticMaximum()) {
  1373.                             $tmpTop max($tmpTop$margins->min);
  1374.                         }
  1375.                         if ($axis->getAutomaticMinimum()) {
  1376.                             $tmpBottom max($tmpBottom$margins->max);
  1377.                         }
  1378.                     }
  1379.                 }
  1380.             }
  1381.         }
  1382.  
  1383.         // Apply offsets in pixels
  1384.         if ($axis->getHorizontal()) {
  1385.             $tmpLeft += $axis->getMinimumOffset();
  1386.             $tmpRight += $axis->getMaximumOffset();
  1387.         else {
  1388.             $tmpTop += $axis->getMaximumOffset();
  1389.             $tmpBottom += $axis->getMinimumOffset();
  1390.         }
  1391.  
  1392.         $axis->adjustMaxMinRect(Rectangle::fromLTRB($tmpLeft$tmpTop$tmpRight,
  1393.                                                      $tmpBottom));
  1394.     }
  1395.  
  1396.     private function calcSeriesRect({
  1397.         //std & custom axes
  1398.         for ($i 0$i $this->axes->getCount()$i++{
  1399.             $this->calcSeriesAxisRect($this->axes->getAxis($i));
  1400.         }
  1401.     }
  1402.  
  1403.     private function drawTitleFoot($g$rect$customOnly{
  1404.         $rect $this->header->doDraw($g$rect$customOnly);
  1405.         $rect $this->subHeader->doDraw($g$rect$customOnly);
  1406.         $rect $this->footer->doDraw($g$rect$customOnly);
  1407.         $rect $this->subFooter->doDraw($g$rect$customOnly);
  1408.  
  1409.         return $rect;
  1410.     }
  1411.  
  1412.     private function shouldDrawLegend({
  1413.         return $this->legend->getVisible(&&
  1414.                 ($this->legend->hasCheckBoxes(|| ($this->countActiveSeries(0));
  1415.     }
  1416.  
  1417.     public function doDrawLegend($g$tmp{
  1418.         if ($this->legend->getVisible()) {
  1419.             $this->legend->paint($g$tmp);
  1420.             if ($this->legend->getLastValue(>= $this->legend->getFirstValue()) {
  1421.                 $tmp $this->legend->resizeChartRect($tmp);
  1422.             }
  1423.         }
  1424.         return $tmp;
  1425.     }
  1426.  
  1427.     private function drawRightWallAfter({
  1428.        $p1 $this->graphics3D->calc3DPoint($this->chartRect->getRight(),
  1429.                                           $this->chartRect->y0);
  1430.        $p2 $this->graphics3D->calc3DPoint($this->chartRect->getRight(),
  1431.                                           $this->chartRect->getBottom(+
  1432.                                           $this->walls->calcWallSize($this->axes->getBottom()),
  1433.                                           $this->getAspect()->width3D +
  1434.                                           $this->walls->getBack()->getSize());
  1435.        return $p1-><= $p2->x;
  1436.     }
  1437.  
  1438.     private function drawTitlesAndLegend($g$tmp$beforeSeries{
  1439.        $rect $tmp;
  1440.  
  1441.        if ($beforeSeries{
  1442.             // draw titles and legend before series
  1443.             if ((!$this->legend->getCustomPosition()) && $this->shouldDrawLegend()) {
  1444.                 if ($this->legend->getVertical()) {
  1445.                     $tmp $this->doDrawLegend($g$tmp);
  1446.                     $tmp $this->drawTitleFoot($g$tmpfalse);
  1447.                 else {
  1448.                     $tmp $this->drawTitleFoot($g$tmpfalse);
  1449.                     $tmp $this->doDrawLegend($g$tmp);
  1450.                 }
  1451.             else {
  1452.                 $tmp $this->drawTitleFoot($g$tmpfalse);
  1453.             }
  1454.         else {
  1455.             // after series
  1456.             if ($this->legend->getCustomPosition(&& $this->shouldDrawLegend()) {
  1457.                 $tmp $this->doDrawLegend($g$tmp);
  1458.             }
  1459.  
  1460.             $tmp $this->drawTitleFoot($g$tmptrue);
  1461.         }
  1462.  
  1463.        if (!$beforeSeries{
  1464.             if ($this->activeSeriesUseAxis()) {
  1465.                 if ($this->getAspect()->getView3D(&& $this->walls->getView3D()) {
  1466.                     if ($this->walls->getRight()->getVisible(&& $this->drawRightWallAfter()) {
  1467.                         $this->walls->getRight()->paint($g$tmp);
  1468.                     }
  1469.                     if ($this->walls->getLeft()->getVisible(&&
  1470.                         ((!$this->getAspect()->getOrthogonal()) &&
  1471.                          ($this->getAspect()->getRotation(270))) {
  1472.                         $this->walls->getLeft()->paint($g$tmp);
  1473.                         $this->axes->getLeft()->hideBackGrid true;
  1474.                         $this->axes->getLeft()->draw($gfalse);
  1475.                         $this->axes->getLeft()->hideBackGrid false;
  1476.                     }
  1477.                 }
  1478.             }
  1479.         }
  1480.  
  1481.         return $tmp;
  1482.     }
  1483.  
  1484.     /**
  1485.      * Returns the number of active (visible) series.<br>
  1486.      * In other words it is a count of Series in Chart that have their Active
  1487.      * property set to true.
  1488.      *
  1489.      * @return int Number of Active (visible) Series.
  1490.      */
  1491.     public function countActiveSeries({
  1492.         $tmpResult 0;
  1493.         for ($t 0$t $this->series->count()$t++{
  1494.             $s $this->series->getSeries($t);
  1495.             if ($s->getActive()) {
  1496.                 $tmpResult++;
  1497.             }
  1498.         }
  1499.  
  1500.         return $tmpResult;
  1501.     }
  1502.  
  1503.     public function isAxisCustom($axis{
  1504.         return $this->axes->getCustom()->indexOf($axis!= -1;
  1505.     }
  1506.  
  1507.     /**
  1508.      * Returns the series that corresponds to the Legend "ItemIndex" position,
  1509.      * when the Legend style is "Series".<br>
  1510.      * The "OnlyActive" parameter, when false, takes into account all series,
  1511.      * visibly active or not.
  1512.      *
  1513.      * @param itemIndex int
  1514.      * @param onlyActive boolean
  1515.      * @return Series 
  1516.      */
  1517.     public function seriesLegend($itemIndex$onlyActive{
  1518.         $tmp 0;
  1519.         for ($t 0$t $this->series->count()$t++{
  1520.             $s $this->series->getSeries($t);
  1521.             if ($s->getShowInLegend(&& ((!$onlyActive|| $s->getActive())) {
  1522.                 if ($tmp == $itemIndex{
  1523.                     return $s;
  1524.                 else {
  1525.                     $tmp++;
  1526.                 }
  1527.             }
  1528.         }
  1529.         return null;
  1530.     }
  1531.  
  1532.     /**
  1533.      * Returns the text string corresponding to a Legend position.<br>
  1534.      * The Legend position depends on Legend.LegendStyle.<br>
  1535.      * If LegendStyle is lsSeries, then the text string will be the
  1536.      * SeriesOrValueIndexth Active Series Title.<br>
  1537.      * If LegendStyle is lsValues, then the text string will be the formatted
  1538.      * SeriesOrValueIndexth value of the first Active Series in the Chart.<br>
  1539.      * If LegendStyle is lsAuto and only one Active Series exists in the Chart,
  1540.      * then the LegendStyle is considered to be lsValues.<br>
  1541.      * If there's more than one Active Series then LegendStyle will be lsSeries.
  1542.      *
  1543.      * @param seriesOrValueIndex int
  1544.      * @return String 
  1545.      */
  1546.     public function formattedLegend($seriesOrValueIndex{
  1547.         $tmp $this->legend->formattedLegend($seriesOrValueIndex);
  1548.  
  1549.         /* TODO
  1550.         if ($this->parent != null) {
  1551.             $tmp = $this->parent->getLegendResolver()->getItemText(
  1552.                     $this->legend,
  1553.                     $this->legend->iLegendStyle,
  1554.                     $seriesOrValueIndex,
  1555.                     $tmp);
  1556.         }
  1557.         */
  1558.         
  1559.         return $tmp;
  1560.     }
  1561.  
  1562.     public function getMaxValuesCount({
  1563.         $result 0;
  1564.         $firstTime true;
  1565.  
  1566.         for ($t 0$t $this->series->count()$t++{
  1567.             $s $this->series->getSeries($t);
  1568.  
  1569.             if ($s->getActive(&& ($firstTime || ($s->getCount($result))) {
  1570.                 $result $s->getCount();
  1571.                 $firstTime false;
  1572.             }
  1573.         }
  1574.         return $result;
  1575.     }
  1576.  
  1577.     /**
  1578.      * Accesses all visible Background attributes..
  1579.      *
  1580.      * @return TeePanel 
  1581.      */
  1582.     public function getPanel({
  1583.         return $this->panel;
  1584.     }
  1585.  
  1586.     public function setPanel($value{
  1587.         $this->panel $value;
  1588.         $this->panel->setChart($this);
  1589.     }
  1590.  
  1591.     /**
  1592.      * Internal use.
  1593.      * Sets instance that implements the IChart interface.
  1594.      *
  1595.      * @param value IChart
  1596.      */
  1597.     public function setParent($value{
  1598.         $this->parent = $value;
  1599.     }
  1600.  
  1601.     // return IChart
  1602.     public function getParent({
  1603.         return $this->parent;
  1604.     }
  1605.  
  1606.     /**
  1607.      * Printing related attributes.
  1608.      *
  1609.      * @return Printer 
  1610.      */
  1611.     public function getPrinter({
  1612.         return $this->printer;
  1613.     }
  1614.  
  1615.     public function setPrinter($value{
  1616.         $this->printer $value;
  1617.         $this->printer->setChart($this);
  1618.     }
  1619.  
  1620.     /**
  1621.      * Accesses multiple page characteristics of the Chart.
  1622.      *
  1623.      * @return TeePage 
  1624.      */
  1625.     public function getPage({
  1626.         return $this->page;
  1627.     }
  1628.  
  1629.     public function setPage($value{
  1630.         $this->page = value;
  1631.         $this->page->setChart($this);
  1632.     }
  1633.  
  1634.     /**
  1635.      * Determines the Legend characteristics.<br>
  1636.      * Legend determines the text and drawing attributes of Chart's textual
  1637.      * representation of Series and Series values. <br>
  1638.      * The Legend class draws a rectangle and for each Series in a Chart (or
  1639.      * for each point in a Series) outputs a text representation of that
  1640.      * Series (or that point). You can use the Legend.LegendStyle and
  1641.      * Legend.TextStyle to control the text used to draw the legend. <br>
  1642.      * The Legend can be positioned at Left, Right, Top and Bottom chart sides
  1643.      * using Legend.Alignment. <br>
  1644.      * Use Legend.Visible to show / hide the Legend. <br>
  1645.      * Inverted makes Legend draw text starting from bottom.<br>
  1646.      * Frame, Font and Color allow you to change the Legend appearance.<br>
  1647.      * Legend.ColorWidth determines the percent width of each item's "colored"
  1648.      * mark. <br>
  1649.      * Legend.FirstValue controls which Series (or Series point) will be
  1650.      * used to draw first Legend item.
  1651.      *
  1652.      * @return Legend 
  1653.      */
  1654.     public function getLegend({
  1655.         return $this->legend;
  1656.     }
  1657.  
  1658.     public function setLegend($value{
  1659.         $this->legend = $value;
  1660.         $this->legend->setChart($this);
  1661.     }
  1662.  
  1663.  
  1664.     /**
  1665.      * Defines the Text and formatting attributes to be drawn at the top of
  1666.      * the Chart.<br>
  1667.      * Use Text to enter the desired Header lines, set Visible to true and
  1668.      * change Font, Frame and Brush. Use Alignment to control text output
  1669.      * position.
  1670.      *
  1671.      * @return Header 
  1672.      */
  1673.     public function getHeader({
  1674.         return $this->header;
  1675.     }
  1676.  
  1677.     public function setHeader($value{
  1678.         $this->header $value;
  1679.         $this->header->setChart($this);
  1680.     }
  1681.  
  1682.     /**
  1683.      * Obsolete.&nbsp;Please use Header instead.
  1684.      *
  1685.      * @return Header 
  1686.      */
  1687.     public function getTitle({
  1688.         return $this->header;
  1689.     }
  1690.  
  1691.     /**
  1692.      * Obsolete.&nbsp;Please use SubHeader instead.
  1693.      *
  1694.      * @return Header 
  1695.      */
  1696.     public function getSubTitle({
  1697.         return $this->subHeader;
  1698.     }
  1699.  
  1700.     /**
  1701.      * Defines the Text and formatting attributes to be drawn at the top of
  1702.      * the Chart, just below the Header text.<br>
  1703.      * Use Text to enter the desired SubHeader lines, set Visible to true and
  1704.      * change Font, Frame and Brush.<br>
  1705.      * Use Alignment to control text output position.
  1706.      *
  1707.      * @return Header 
  1708.      */
  1709.     public function getSubHeader({
  1710.         return $this->subHeader;
  1711.     }
  1712.  
  1713.     public function setSubHeader($value{
  1714.         $this->subHeader $value;
  1715.         $this->subHeader->setChart($this);
  1716.     }
  1717.  
  1718.     /**
  1719.      * Defines the Text and formatting attributes to be drawn at the bottom of
  1720.      * the Chart.<br>
  1721.      * Use Text to enter the desired Footer lines, set Visible to true and
  1722.      * change Font, Frame and Brush.<br>
  1723.      * Use Alignment to control text output position.
  1724.      *
  1725.      * @return Footer 
  1726.      */
  1727.     public function getFooter({
  1728.         return $this->footer;
  1729.     }
  1730.  
  1731.     public function setFooter($value{
  1732.         $this->footer $value;
  1733.         $this->footer->setChart($this);
  1734.     }
  1735.  
  1736.     /**
  1737.      * Defines the Text and formatting attributes to be drawn at the bottom of
  1738.      * the Chart, just above the Footer text.<br>
  1739.      * Use Text to enter the desired SubFooter lines, set Visible to true and
  1740.      * change Font, Frame and Brush.<br>
  1741.      * Use Alignment to control text output position.
  1742.      *
  1743.      * @return Footer 
  1744.      */
  1745.     public function getSubFooter({
  1746.         return $this->subFooter;
  1747.     }
  1748.  
  1749.     public function setSubFooter($value{
  1750.         $this->subFooter $value;
  1751.         $this->subFooter->setChart($this);
  1752.     }
  1753.  
  1754.     /**
  1755.      * 3D view parameters.
  1756.      *
  1757.      * @return Aspect 
  1758.      */
  1759.     public function getAspect({
  1760.         return $this->aspect;
  1761.     }
  1762.  
  1763.     public function setAspect($value{
  1764.         $this->aspect = $value;
  1765.         $this->aspect->setChart($this);
  1766.     }
  1767.  
  1768.     /**
  1769.      * Accesses TeeChart Draw attributes.
  1770.      *
  1771.      * @return IGraphics3D 
  1772.      */
  1773.     public function getGraphics3D({
  1774.         return $this->graphics3D;
  1775.     }
  1776.  
  1777.     public function setGraphics3D($value{
  1778.         if ($value != null{
  1779.             $this->graphics3D = $value;
  1780.             $this->invalidate();
  1781.         }
  1782.     }
  1783.  
  1784.     /**
  1785.      * Gets the index'th tool in getTools() collection
  1786.      *
  1787.      * @param index int
  1788.      * @return Tool 
  1789.      */
  1790.     public function getTool($index{
  1791.         return $this->tools->getTool($index);
  1792.     }
  1793.  
  1794.     /**
  1795.      * Collection of Tool components contained in this Chart.
  1796.      *
  1797.      * @return ToolsCollection 
  1798.      */
  1799.     public function getTools({
  1800.         return $this->tools;
  1801.     }
  1802.  
  1803.     public function setTools($value{
  1804.         $this->tools $value;
  1805.         $this->tools->chart $this;
  1806.     }
  1807.  
  1808.     /**
  1809.      * Gets the index'th animation in getAnimations() collection
  1810.      *
  1811.      * @param index int
  1812.      * @return Animation 
  1813.      */
  1814.     public function getAnimation($index{
  1815.         return $this->animations->getAnimation($index);
  1816.     }
  1817.         
  1818.     /**
  1819.      * Collection of Animation components contained in this Chart.
  1820.      *
  1821.      * @return AnimationsCollection 
  1822.      */
  1823.     public function getAnimations({
  1824.         return $this->animations;
  1825.     }
  1826.  
  1827.     public function setAnimations($value{
  1828.         $this->animations $value;
  1829.         $this->animations->chart $this;
  1830.     }
  1831.  
  1832.     
  1833.     /**
  1834.      * Accesses left, bottom and back wall characteristics of the Chart.
  1835.      *
  1836.      * @return Walls 
  1837.      */
  1838.     public function getWalls({
  1839.         return $this->walls;
  1840.     }
  1841.  
  1842.     public function setWalls($value{
  1843.         $this->walls $value;
  1844.         $this->walls->setChart($this);
  1845.     }
  1846.  
  1847.     /**
  1848.      * Accesses the five axes, Top, Left, Right, Bottom and z depthas well as
  1849.      * custom axis objects.
  1850.      *
  1851.      * @return Axes 
  1852.      */
  1853.     public function getAxes({
  1854.         return $this->axes;
  1855.     }
  1856.  
  1857.     public function setAxes($value{
  1858.         $this->axes = $value;
  1859.         $this->axes->setChart($this);
  1860.     }
  1861.  
  1862.     /**
  1863.      * Accesses Chart export attributes.
  1864.      *
  1865.      * @return Exports 
  1866.      */
  1867.     public function getExport({
  1868.         return $this->export;
  1869.     }
  1870.  
  1871.     public function setExport($value{
  1872.         $this->export $value;
  1873.         $this->export->setChart($this);
  1874.     }
  1875.  
  1876.     /**
  1877.      * Accesses Chart import attributes.
  1878.      *
  1879.      * @return Imports 
  1880.      */
  1881.     public function getImport({
  1882.         return $this->imports;
  1883.     }
  1884.  
  1885.     public function setImport($value{
  1886.         $this->imports $value;
  1887.         $this->imports->setChart($this);
  1888.     }
  1889.  
  1890.     public function getSeriesHeight3D({
  1891.         return $this->seriesHeight3D;
  1892.     }
  1893.  
  1894.     public function getSeriesWidth3D({
  1895.         return $this->seriesWidth3D;
  1896.     }
  1897.  
  1898.     public function getLegendPen({
  1899.         return $this->legendPen;
  1900.     }
  1901.  
  1902.     public function setLegendPen($value{
  1903.         $this->legendPen = $value;
  1904.     }
  1905.  
  1906.     public function moveSeriesTo($value$newIndex{
  1907.         $this->series->moveTo($value$newIndex);
  1908.     }
  1909.  
  1910.     /**
  1911.      * Removes a Series from the Chart series list, without disposing it.
  1912.      *
  1913.      * @param value Series
  1914.      */
  1915.     public function removeSeries($value{
  1916.         $this->series->remove($value);
  1917.     }
  1918.  
  1919.     public function addSeries($value{
  1920.         $result $this->series->indexOf($value);
  1921.         if ($result == -1{
  1922.             $this->series->add($value);
  1923.             $result $this->series->count(1;
  1924.         }
  1925.         return $result// int
  1926.     }
  1927.  
  1928.     public function getBottom({
  1929.         return $this->getChartBounds()->getBottom();
  1930.     }
  1931.  
  1932.     public function getMaxZOrder({
  1933.         return $this->maxZOrder;
  1934.     }
  1935.  
  1936.     public function setMaxZOrder($value{
  1937.         $this->maxZOrder = $value;
  1938.     }
  1939.  
  1940.     /**
  1941.      * Returns if the Chart should automatically repaint itself when a
  1942.      * property has been changed.
  1943.      *
  1944.      * @return boolean 
  1945.      */
  1946.     public function getAutoRepaint({
  1947.         return $this->autoRepaint;
  1948.     }
  1949.  
  1950.     /**
  1951.      * Sets if this Chart should automatically repaint after a property change.
  1952.      *
  1953.      * @param value boolean
  1954.      */
  1955.     public function setAutoRepaint($value{
  1956.         $this->autoRepaint $value;
  1957.         $this->doBaseInvalidate();
  1958.     }
  1959.  
  1960.     /**
  1961.      * Returns the rectangle that contains the four main Chart axes.
  1962.      *
  1963.      * @return Rectangle 
  1964.      */
  1965.     public function getChartRect({
  1966.         return $this->chartRect;
  1967.     }
  1968.  
  1969.     /**
  1970.      * Sets the rectangle to contain the four main Chart axes.
  1971.      *
  1972.      * @param value Rectangle
  1973.      */
  1974.     public function setChartRect($value{
  1975.         $this->chartRect = $value;
  1976.     }
  1977.  
  1978.     /**
  1979.      * Returns the number of Series associated to this Chart.
  1980.      *
  1981.      * @return int 
  1982.      */
  1983.     public function  getSeriesCount({
  1984.         return sizeof($this->series);
  1985.     }
  1986.  
  1987.     public function series({
  1988.         return $this->getSeries()->iterator();
  1989.     }
  1990.  
  1991.     public function tools({
  1992.         return $this->getTools()->iterator();
  1993.     }
  1994.  
  1995.     public function doBaseInvalidate({
  1996.         if (($this->graphics3D != null&& (!$this->graphics3D->getDirty()) &&
  1997.             $this->getAutoRepaint()) {
  1998.             $this->graphics3D->setDirty(true);
  1999.             $parent $this->getParent();
  2000.             if ($parent != null{
  2001.                 $parent->doInvalidate();
  2002.             }
  2003.         }
  2004.     }
  2005.  
  2006.     public function paint({
  2007.         $this->_paint($this->getGraphics3D()$this->chartBounds);
  2008.     }
  2009.  
  2010.     /**
  2011.      * Paints the Chart in your preferred Canvas and region.
  2012.      *
  2013.      * @param IGraphics3D
  2014.      * @param rect Rectangle
  2015.      */
  2016.     public function _paint($g$rect{
  2017.         TChart::$controlName 'Chart_';
  2018.                 
  2019.         $this->autoRepaint false;
  2020.  
  2021.         $oldG $this->graphics3D;
  2022.         $this->graphics3D = $g;
  2023.  
  2024.         // TODO  $this->parent->doBeforeDraw();
  2025.         $this->chartRect = $rect->copy();
  2026.         $this->chartBounds = $this->chartRect->copy();
  2027.         $g->initWindow($this->aspect$this->chartRect100);
  2028.         /* TODO
  2029.         if ((!getPrinter().isPrinting) ||
  2030.             ((getPrinter().isPrinting) &&
  2031.              (getPrinter().getPrintPanelBackground()))) {*/
  2032.                 $this->chartRect = $this->panel->draw($g$this->chartRect);
  2033.         //}
  2034.  
  2035.         $this->parent->doDrawImage($g);
  2036.         $this->internalDraw($g);
  2037.  
  2038.         /* TODO
  2039.         if (($this->zoom != null) && $this->zoom->getActive()) {
  2040.             $this->zoom->draw();
  2041.         }
  2042.  
  2043.         $g->resetState();
  2044.         $this->parent->doAfterDraw();
  2045.         $g->showImage();
  2046.         */
  2047.  
  2048.         $this->graphics3D = $oldG;
  2049.     }
  2050.  
  2051.  
  2052.     protected function broadcastToolEvent($ce{
  2053.         for ($t 0$t sizeof($this->tools)$t++{
  2054.             $s $this->tools->getTool($t);
  2055.             if ($s->getActive()) {
  2056.                 $s->chartEvent($ce);
  2057.             }
  2058.         }
  2059.     }
  2060. }
  2061.  
  2062. final class CalcStringResults {
  2063.         var $tmpResult;
  2064.         var $numLines;
  2065. }
  2066. ?>

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