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

Source for file Series.php

Documentation is available at Series.php

  1. <?php
  2.  
  3. /**
  4.  * Series class
  5.  *
  6.  * Description: The base class for all TeeChart Series styles
  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 styles
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class Series extends TeeBase implements ISeries /*, Cloneable*/
  17. {
  18.    // Private properties
  19.    private $title="";
  20.    private $updating;
  21.    private $horizontalAxis;
  22.    private $verticalAxis;
  23.    private $customHorizAxis;
  24.    private $customVertAxis;
  25.    private $horizAxis;
  26.    private $vertAxis;
  27.    private $valuesList;
  28.    private $zOrder;
  29.    private $isMouseInside;
  30.    private $iLabelOrder;
  31.    private $depth;
  32.    private $showInLegend true;
  33.    private $function;
  34.    private $cursor;
  35.  
  36.    // Protected properties
  37.    protected $mandatory;
  38.    protected $notMandatory;
  39.    protected $vxValues;
  40.    protected $vyValues;
  41.    protected $sLabels;
  42.    protected $iColors;
  43.    protected $bColorEach;
  44.    protected $listenerList;
  45.    protected $customMarkText;
  46.    protected $bBrush;
  47.    protected $bActive=true;
  48.    protected $marks=null;
  49.    protected $startZ;
  50.    protected $middleZ;
  51.    protected $endZ;
  52.    protected $drawBetweenPoints=true;
  53.    protected $yMandatory=true;
  54.    protected $useSeriesColor=true;
  55.    protected $calcVisiblePoints=true;
  56.    protected $labelMember="";
  57.    protected $colorMember="";
  58.    protected $valueFormat;
  59.    protected $percentFormat;
  60.    protected $percentDecimal;
  61.    protected $firstVisible;
  62.    protected $lastVisible;
  63.    protected $iNumSampleValues;
  64.  
  65.    // Public properties
  66.    public $InternalUse;
  67.    public $iZOrder;
  68.    public $manualData = true;
  69.    public $allowSinglePoint = true;
  70.    /**
  71.    * Returns True when the Series needs axes to display points.
  72.    * For example, Pie Series returns False (it does not need axes).
  73.    */
  74.    public $useAxis = true;
  75.    /**
  76.    * Returns true if the series has ZValues.
  77.    */
  78.    public $hasZValues;
  79.    /**
  80.    * Constant field for internal use.
  81.    */
  82.    public static $AUTODEPTH = -1;
  83.    /**
  84.    * Constant field for internal use.
  85.    */
  86.    public static $AUTOZORDER = -1;
  87.  
  88.  
  89.    // Interceptors
  90.    function __get$property {
  91.      $method ="get{$property}";
  92.      if method_exists$this$method ) ) {
  93.        return $this->$method();
  94.      }
  95.    }
  96.  
  97.    function __set $property,$value {
  98.      $method ="set{$property}";
  99.      if method_exists$this$method ) ) {
  100.        return $this->$method($value);
  101.      }
  102.    }
  103.  
  104.    public function setMarkTextResolver($resolver)
  105.    {
  106.       if($resolver != null)
  107.       {
  108.          $this->customMarkText = $resolver;
  109.       }
  110.       else
  111.       {
  112.          $this->removeMarkTextResolver();
  113.       }
  114.    }
  115.  
  116.    public function removeMarkTextResolver()
  117.    {
  118. // TODO      $this->customMarkText = $this->MARKTEXT_RESOLVER;
  119.    }
  120.  
  121.    public function addSeriesPaintListener($l)
  122.    {
  123.       $this->listenerList->add($this->SeriesPaintListener->class $l);
  124.    }
  125.  
  126.    public function removeSeriesPaintListener($l)
  127.    {
  128.       $this->listenerList->remove($this->SeriesPaintListener->class $l);
  129.    }
  130.  
  131.    protected function fireSeriesPaint($e)
  132.    {
  133.       /* todo    $this->Object[] $this->listeners = $this->listenerList->getListenerList();
  134.       for ( $i = $this->listeners->length - 2; $i >= 0; $i -= 2) {
  135.       if ($this->listeners[$i] == $this->SeriesPaintListener->class) {
  136.       switch ($e->getDrawPart()) {
  137.       //SERIES
  138.       case 3: {
  139.       $tmpChartDrawEvent = new ChartDrawEvent();
  140.       if ($e->getID() == $tmpChartDrawEvent->PAINTING) {
  141.       (($this->SeriesPaintListener) $this->listeners[$i + 1])->seriesPainting($e);
  142.       } else if ($e->getID() == $tmpChartDrawEvent->PAINTED) {
  143.       (($this->SeriesPaintListener) $this->listeners[$i + 1])->seriesPainted($e);
  144.       }
  145.       break;
  146.       }
  147.       }
  148.       }
  149.       }  */
  150.    }
  151.  
  152.    public function addSeriesMouseListener($l)
  153.    {
  154.       // todo   $this->listenerList->add($this->SeriesMouseListener->class, $l);
  155.    }
  156.  
  157.    public function removeSeriesMouseListener($l)
  158.    {
  159.       // todo    $this->listenerList->remove($this->SeriesMouseListener->class, $l);
  160.    }
  161.  
  162.    protected function fireSeriesMouseEvent($se)
  163.    {
  164.       /* todo    $this->Object[] $this->listeners = $this->listenerList->getListenerList();
  165.       for ( $i = $this->listeners->length - 2; $i >= 0; $i -= 2) {
  166.       if ($this->listeners[$i] == $this->SeriesMouseListener->class) {
  167.       switch ($se->getID()) {
  168.       $tmpSeriesMouseEvent = new SeriesMouseEvent();
  169.       case $tmpSeriesMouseEvent->SERIES_CLICKED: {
  170.       (($this->SeriesMouseListener) $this->listeners[$i + 1])->seriesClicked($se);
  171.       break;
  172.       }
  173.       case $tmpSeriesMouseEvent->SERIES_ENTERED: {
  174.       (($this->SeriesMouseListener) $this->listeners[$i + 1])->seriesEntered($se);
  175.       break;
  176.       }
  177.       case $tmpSeriesMouseEvent->SERIES_EXITED: {
  178.       (($this->SeriesMouseListener) $this->listeners[$i + 1])->seriesExited($se);
  179.       break;
  180.       }
  181.       }
  182.       }
  183.       }
  184.       */
  185.    }
  186.  
  187.    protected function doClickPointer($valueIndex$x$y)
  188.    {
  189.       $tmpSeriesMouseEvent new SeriesMouseEvent();
  190.       $this->fireSeriesMouseEvent(new SeriesMouseEvent($this$tmpSeriesMouseEvent->SERIES_CLICKED$valueIndexnew TeePoint($x$y)));
  191.    }
  192.  
  193.    protected function hasListenersOf($listener)
  194.    {
  195.       /* todo    $this->Object[] $this->listeners = $this->listenerList->getListenerList();
  196.       for ( $i = $this->listeners->length - 2; $i >= 0; $i -= 2) {
  197.       if ($this->listeners[$i] == $listener) {
  198.       return true;
  199.       }
  200.       }             */
  201.       return false;
  202.    }
  203.  
  204.    public function getHorizAxis()
  205.    {
  206.       return $this->horizAxis;
  207.    }
  208.  
  209.    public function getVertAxis()
  210.    {
  211.       return $this->vertAxis;
  212.    }
  213.  
  214.    // Prevent instantiation
  215.    protected function Series($c null)
  216.    {
  217.       $this->zOrder self::$AUTOZORDER;
  218.       $this->percentFormat=Language::getString("DefPercentFormat");
  219.       $this->valueFormat=Language::getString("DefValueFormat");
  220.  
  221.       $this->bBrush = new ChartBrush(null new Color(0000true));
  222.  
  223.       $this->horizontalAxis HorizontalAxis::$BOTTOM;
  224.       $this->verticalAxis VerticalAxis::$LEFT;
  225.  
  226.       $this->depth self::$AUTODEPTH;
  227.      // TODO  $cursor= Cursors.DEFAULT;
  228.  
  229.       parent::__construct($c);
  230.  
  231.       $tmpColor new Color(0000true);
  232.       $this->setColor($tmpColor);
  233.  
  234.       $this->checkValuesList();
  235.  
  236.       $this->vxValues = new ValueList($this"ValuesX");// todo $this->Language->getString("ValuesX"));
  237.       $this->vxValues->setOrder(ValueListOrder::$ASCENDING);
  238.       $this->vyValues = new ValueList($this"ValuesY");// todo $this->Language->getString("ValuesY"));
  239.  
  240.       $this->readResolve();
  241.  
  242.       if($this->chart != null)
  243.       {
  244.          $this->bBrush->setChart($this->chart);
  245.          $this->chart->addSeries($this);
  246.          $this->added();
  247.       }
  248.    }
  249.  
  250.    public function getNotMandatory()
  251.    {
  252.       return $this->notMandatory;
  253.    }
  254.  
  255.    public function getMandatory()
  256.    {
  257.       return $this->mandatory;
  258.    }
  259.  
  260.    public function dispose()
  261.    {
  262.       if($this->function != null)
  263.       {
  264.          $this->function->setSeries(null);
  265.       }
  266.       $this->setDataSource(null);
  267.       $this->setChart(null);
  268.    }
  269.  
  270.    /**
  271.    * Creates a new series from the Class type of an existing series object.
  272.    *
  273.    * @param type Class
  274.    * @return Series 
  275.    * @throws InstantiationException
  276.    * @throws IllegalAccessException
  277.    */
  278.    public function newFromType($type)/* todo throws InstantiationException,
  279.    IllegalAccessException*/
  280.    {
  281.       return(new $type($this->chart));
  282.    }
  283.  
  284.    private function initMandatory()
  285.    {
  286.       $this->mandatory = $this->vyValues;
  287.       $this->notMandatory = $this->vxValues;
  288.    }
  289.  
  290.    private function checkValuesList()
  291.    {
  292.       if($this->valuesList == null)
  293.       {
  294.          $this->valuesList new ValuesLists();
  295.       }
  296.    }
  297.  
  298.    protected function readResolve()
  299.    {
  300.       $this->checkValuesList();
  301.  
  302.       // TODO        $this->listenerList = new EventListenerList();
  303.       // TODO        $this->customMarkText = $this->MARKTEXT_RESOLVER;
  304.  
  305.       $this->drawBetweenPoints = true;
  306.       $this->yMandatory = true;
  307.       $this->allowSinglePoint = true;
  308.  
  309.       $this->useAxis = true;
  310.  
  311.       $this->useSeriesColor = true;
  312.       $this->calcVisiblePoints = true;
  313.  
  314.       // TODO        $this->percentDecimal = new DecimalFormat($this->Language->getString("DefPercentFormat"));
  315.  
  316.       $this->initMandatory();
  317.       $this->recalcGetAxis();
  318.       return $this;
  319.    }
  320.  
  321.    /**
  322.    * Creates a new Series object and sets the Name, Chart, Sub-Style and
  323.    * Function methods.<br>
  324.    * This is an internal method, you should seldomly use it in your
  325.    * applications.
  326.    *
  327.    * @param chart IBaseChart
  328.    * @param type Class
  329.    * @param aFunction Class
  330.    * @param subIndex int
  331.    * @return Series 
  332.    * @throws InstantiationException
  333.    * @throws IllegalAccessException
  334.    */
  335.    public function createNewSeries($chart$type$aFunction$subIndex 0)/* tODO throws
  336.    InstantiationException, IllegalAccessException*/
  337.    {
  338.  
  339.       $result Series::newFromType($type);
  340.       $result->setChart($chart);
  341.  
  342.       if($aFunction != null)
  343.       {
  344.          $result->setFunction($aFunction->newInstance());
  345.       }
  346.  
  347.       if($subIndex != 0)
  348.       {
  349.          $result->setSubGallery($subIndex);
  350.       }
  351.  
  352.       return $result;
  353.    }
  354.  
  355.    protected function doBeforeDrawValues()
  356.    {
  357.       /* todo        $tmpChartDrawEvent = new ChartDrawEvent();
  358.       $this->fireSeriesPaint(new ChartDrawEvent($this, $tmpChartDrawEvent->PAINTING,
  359.       $tmpChartDrawEvent->SERIES));*/
  360.    }
  361.  
  362.    protected function doAfterDrawValues()
  363.    {
  364.       /* tODO        $tmpChartDrawEvent = new ChartDrawEvent();
  365.       $this->fireSeriesPaint(new ChartDrawEvent($this, $tmpChartDrawEvent->PAINTED,
  366.       $tmpChartDrawEvent->SERIES));*/
  367.    }
  368.  
  369.    public function calcZOrder()
  370.    {
  371.       if($this->zOrder == self::$AUTOZORDER)
  372.       {
  373.          if($this->chart->getAspect()->getView3D())
  374.          {
  375.             $this->chart->setMaxZOrder($this->chart->getMaxZOrder(1);
  376.             $this->iZOrder = $this->chart->getMaxZOrder();
  377.          }
  378.          else
  379.          {
  380.             $this->iZOrder = 0;
  381.          }
  382.       }
  383.       else
  384.       {
  385.          $this->chart->setMaxZOrder(max($this->chart->getMaxZOrder()$this->getZOrder()));
  386.       }
  387.    }
  388.  
  389.    /**
  390.    * Accesses the stored Color Array, if created, for the Series.<br>
  391.    * When attaching new series to any Chart, setting TChart Series.SerieColor
  392.    * to Color.EMPTY will make TeeChart assign a different color to each Series.
  393.    * <br>
  394.    * Some Series types allow Color.EMPTY in their Pen and Brushes properties,
  395.    * thus forcing the use of the actual point color instead of the Pen or
  396.    * Brush assigned color. <br>
  397.    * Default value: null
  398.    *
  399.    * <p>Example:
  400.    * <pre><font face="Courier" size="4">
  401.    * candleSeries.add( ...., Color.Yellow );
  402.    * candleSeries.getColors().setColor( 10, Color.Blue);
  403.    * </font></pre></p>
  404.    *
  405.    * @see Series#getColorEach
  406.    * @return ColorList 
  407.    */
  408.    public function getColors()
  409.    {
  410.       if($this->iColors == null)
  411.       {
  412.          $this->iColors = new ColorList(($this->getCount(0$this->getCount(:
  413.          $this->ValueList->defaultCapacity);
  414.       }
  415.       return $this->iColors;
  416.    }
  417.  
  418.    // For XMLEncoder only
  419.    /**
  420.    * Accesses the stored Color Array, if created, for the Series.<br>
  421.    * Default value: null
  422.    *
  423.    * @see #getColors
  424.    * @param value ColorList
  425.    */
  426.    public function setColors($value)
  427.    {
  428.       $this->iColors = $value;
  429.    }
  430.  
  431.    /**
  432.    * Point characteristics.
  433.    *
  434.    * @param index int
  435.    * @return SeriesXYPoint 
  436.    */
  437.    public function getPoint($index)
  438.    {
  439.       return new SeriesXYPoint($this$index);
  440.    }
  441.  
  442.    /**
  443.    * Values defining horizontal point positions.<br>
  444.    * By default, any Series has an XValues property. This is the IValueList
  445.    * where the  point values will be stored at runtime. Also by default,
  446.    * XValues is a Public method. Some derived Series publish it: Line series,
  447.    * Bar series, Points series, etc. Some others publish it with another,
  448.    * more friendly name: GanttSeries.StartValues, etc.  <br><br>
  449.    * <b>WARNING: </b><br>
  450.    * You <b>CAN NOT Delete, Clear or Add values DIRECTLY.</b> You need to
  451.    * call the Series equivalent methods to do this.
  452.    *
  453.    * @return ValueList 
  454.    */
  455.    public function getXValues()
  456.    {
  457.       return $this->vxValues;
  458.    }
  459.  
  460.    // For XMLEncoder only
  461.    public function setXValues($value)
  462.    {
  463.       $this->vxValues = $value;
  464.    }
  465.  
  466.    /**
  467.    * Values defining vertical point positions.<br><br>
  468.    * <b>WARNING: </b><br>
  469.    * You <b>CAN NOT Delete, Clear or Add values DIRECTLY.</b> You need to
  470.    * call the Series equivalent methods to do this.
  471.    *
  472.    * @return ValueList 
  473.    */
  474.    public function getYValues()
  475.    {
  476.       return $this->vyValues;
  477.    }
  478.  
  479.    // For XMLEncoder only
  480.    public function setYValues($value)
  481.    {
  482.       $this->vyValues = $value;
  483.    }
  484.  
  485.    /**
  486.    * Copies all properties from one Series component to another.<br>
  487.    * Only the common properties shared by both source and destination Series
  488.    * are copied. <br>
  489.    * The following code copies all properties from Series2 into Series1:
  490.    * <br><br>
  491.    * Series1.Assign( Series2 ) ;<br><br>
  492.    * Some Series types restore method values after assigning them. For
  493.    * example, Points series restores the Pointer.Visible method to true after
  494.    * being assigned to a Line series, which has Pointers invisible by default.
  495.    * <br>
  496.    * <b>Note:</b> Series events are not assigned.  Series DataSource and
  497.    * FunctionType properties are assigned.  Assign is used by
  498.    * CloneChartSeries and ChangeSeriesType methods for example.
  499.    *
  500.    * @param source Series
  501.    */
  502.    public function assign($source)
  503.    {
  504.       // AssignCommonProperties(source);
  505.       $this->title $source->title;
  506.       $this->bBrush->assign($source->bBrush);
  507.       $this->bColorEach = $source->bColorEach;
  508.       $this->showInLegend $source->showInLegend;
  509.       $this->valueFormat = $source->valueFormat;
  510.       $this->percentFormat = $source->percentFormat;
  511.       $this->percentDecimal = $source->percentDecimal;
  512.       $this->bActive = $source->bActive;
  513.  
  514.       if($this->datasource == null)
  515.       {
  516.          $this->assignValues($source);
  517.       }
  518.       $this->checkDataSource();
  519.    }
  520.  
  521.    public function getAllowSinglePoint()
  522.    {
  523.       return $this->allowSinglePoint;
  524.    }
  525.  
  526.    public function assignDispose($s$newSeries)
  527.    {
  528.  
  529.       $index $s->chart->getSeriesIndexOf($s);
  530.       $newSeries->assign($s);
  531.       $s->dispose();
  532.       $s $newSeries;
  533.       $s->chart->moveSeriesTo($s$index);
  534.       return $s;
  535.    }
  536.  
  537.    /**
  538.    * Replaces ASeries object with a new Series object of another class.
  539.    *
  540.    * @param Series
  541.    * @param newType Class
  542.    * @return Series 
  543.    * @throws InstantiationException
  544.    * @throws IllegalAccessException
  545.    */
  546.    public function changeType($s$newType)/* todo throws
  547.    InstantiationException, IllegalAccessException*/
  548.    {
  549.       if($s->get_class(!= $newType)
  550.       {
  551.          // Only if different classes
  552.          $newSeries $this->createNewSeries($s->chart$newTypenull);
  553.          if($newSeries != null)
  554.          {
  555.             $s Series::assignDispose($s$newSeries);
  556.          }
  557.       }
  558.       return $s;
  559.    }
  560.  
  561.    /**
  562.    * Returns the steema.teechart.styles.ValuesLists object of the series.<br>
  563.    * It permits access to the list of TeeChartValueLists of a Series. <br>
  564.    * Several standard Series types such as TLineSeries and  TBarSeries
  565.    * maintain 2 ValueLists, X and Y values. Other Series such as TCandleSeries
  566.    * maintain more lists, ie. DateValues, OpenValues, HighValues, LowValues
  567.    * and CloseValues.
  568.    *
  569.    * @see com.steema.teechart.styles.ValuesLists
  570.    * @return ValuesLists 
  571.    */
  572.    public function getValuesLists()
  573.    {
  574.       return $this->valuesList;
  575.    }
  576.  
  577.    public function valuesListAdd($value)
  578.    {
  579.       $this->checkValuesList();
  580.       $this->valuesList[$value;
  581.    }
  582.  
  583.    //Returns if a Series has "X" values (or Y values for non-vertical series like HorizBar)
  584.    public function hasNoMandatoryValues()
  585.    {
  586.  
  587.       if(/* $this->iUseNotMandatory && */($this->getCount(0))
  588.       {
  589.  
  590.          $tmp $this->getNotMandatory();
  591.  
  592.          if(($tmp->getFirst(== 0&& ($tmp->getLast(== $this->getCount(1))
  593.          {
  594.  
  595.             $tmpCount min(10000$this->getCount());
  596.  
  597.             for($t 0$t $tmpCount$t++)
  598.             {
  599.                if($tmp->getValue($t!= $t)
  600.                {
  601.                   return true;
  602.                }
  603.             }
  604.          }
  605.          else
  606.          {
  607.             return true;
  608.          }
  609.       }
  610.  
  611.       return false;
  612.    }
  613.  
  614.    /**
  615.    * Returns the URL of the associated bitmap icon for a given Series class.<br>
  616.    * This icon is used at ChartListBox and Series Editor dialog.
  617.    *
  618.    * @return URL 
  619.    */
  620.    public function getBitmapEditor()
  621.    {
  622.       $name $this->get_class();
  623.       $name "icons/" $name->substring($name->lastIndexOf('->'1"->gif";
  624.       return $this->Series->class ->getResource($name);
  625.    }
  626.  
  627.    /**
  628.    * Returns the value list that the AListName parameter has.
  629.    *
  630.    * @param aListName String
  631.    * @return ValueList 
  632.    */
  633.    public function getYValueList($aListName)
  634.    {
  635.       $aListName $aListName->toUpperCase();
  636.  
  637.       for($t 2$t sizeof($this->valuesList)$t++)
  638.       {
  639.          if($aListName->equals($this->valuesList->getValueList($t)->name->toUpperCase()))
  640.          {
  641.             return $this->valuesList->getValueList($t);
  642.          }
  643.       }
  644.  
  645.       return $this->vyValues;
  646.    }
  647.  
  648.    /**
  649.    * Specifies the custom horizontal axis for the series.<br>
  650.    * After adding a new horizontal Custom Axis to a Chart, use
  651.    * CustomHorizAxis to associate the Series to the Custom Axis. <br>
  652.    * Together with the axis PositionPercent and "stretching" methods, it's
  653.    * possible to have unlimited axes floating anywhere on the chart. <br>
  654.    * Scroll, zoom, and axis hit-detection also apply to custom-created axes.<br>
  655.    * Creating extra axes is only allowed at run-time, as a few lines of code
  656.    * are necessary.<br>
  657.    * Default value: null
  658.    *
  659.    * @return Axis 
  660.    */
  661.    public function getCustomHorizAxis()
  662.    {
  663.       return $this->customHorizAxis;
  664.    }
  665.  
  666.    /**
  667.    * Specifies the custom horizontal axis for the series.<br>
  668.    * Default value: null
  669.    *
  670.    * @param value Axis
  671.    */
  672.    public function setCustomHorizAxis($value)
  673.    {
  674.       $this->customHorizAxis $value;
  675.       $this->horizontalAxis ($value != nullHorizontalAxis::$CUSTOM :
  676.       HorizontalAxis::$BOTTOM;
  677.       $this->recalcGetAxis();
  678.       $this->repaint();
  679.    }
  680.  
  681.    /**
  682.    * Specifies the custom horizontal axis for the series.<br>
  683.    * Default value: null
  684.    *
  685.    * @param value int
  686.    */
  687.    public function setCustomHorizAxisValue($value)
  688.    {
  689.       if($this->getChart(!= null)
  690.       {
  691.          $tmp $this->getChart()->getAxes()->getCustom();
  692.          $this->setCustomHorizAxis($tmp->getAxis($value));
  693.       }
  694.    }
  695.  
  696.    /**
  697.    * Specifies the custom vertical axis for the series.<br>
  698.    * Default value: null
  699.    *
  700.    * @return Axis 
  701.    */
  702.    public function getCustomVertAxis()
  703.    {
  704.       return $this->customVertAxis;
  705.    }
  706.  
  707.    /**
  708.    * Specifies the custom vertical axis for the series.<br>
  709.    * Default value: null
  710.    *
  711.    * @param value int
  712.    */
  713.    public function setCustomVertAxisValue($value)
  714.    {
  715.       if($this->getChart(!= null)
  716.       {
  717.          $tmp $this->getChart()->getAxes()->getCustom();
  718.          $this->setCustomVertAxis($tmp->getAxis($value));
  719.       }
  720.    }
  721.  
  722.    /**
  723.    * Specifies the custom vertical axis for the series.<br>
  724.    * Default value: null
  725.    *
  726.    * @param value Axis
  727.    */
  728.    public function setCustomVertAxis($value)
  729.    {
  730.       $this->customVertAxis $value;
  731.       $this->verticalAxis ($value != nullVerticalAxis::$CUSTOM :
  732.       VerticalAxis::$LEFT;
  733.       $this->recalcGetAxis();
  734.       $this->repaint();
  735.    }
  736.  
  737.    /**
  738.    * Accesses a list of series point labels.
  739.    *
  740.    * @return StringList 
  741.    */
  742.    public function getLabels()
  743.    {
  744.       if($this->sLabels == null)
  745.       {
  746.          // todo review before the line below
  747.          //$this->sLabels = new StringList(($this->getCount() > 0) ? $this->getCount() :
  748.          //                         $this->ValueList->defaultCapacity);
  749.          $this->sLabels = Array();
  750.  
  751.       }
  752.       return $this->sLabels;
  753.    }
  754.  
  755.    /**
  756.    * Accesses a list of series point labels.
  757.    *
  758.    * @param value StringList
  759.    */
  760.    public function setLabels($value)
  761.    {
  762.       $this->sLabels = $value;
  763.    }
  764.  
  765.    /**
  766.    * The the Datasource Label Field.<br>
  767.    * Default value: ""
  768.    *
  769.    * @return String 
  770.    */
  771.    public function getLabelMember()
  772.    {
  773.       return $this->labelMember;
  774.    }
  775.  
  776.    /**
  777.    * Sets the Datasource Label Field.<br>
  778.    * Default value: ""
  779.    *
  780.    * @param value String
  781.    */
  782.    public function setLabelMember($value)
  783.    {
  784.       if(!$this->labelMember->equals($value))
  785.       {
  786.          $this->labelMember = $value;
  787.          $this->checkDataSource();
  788.       }
  789.    }
  790.  
  791.    /**
  792.    * The the Datasource Color Field.<br>
  793.    * Default value: ""
  794.    *
  795.    * @return String 
  796.    */
  797.    public function getColorMember()
  798.    {
  799.       return $this->colorMember;
  800.    }
  801.  
  802.    /**
  803.    * Sets the Datasource Color Field.<br>
  804.    * Default value: ""
  805.    *
  806.    * @param value String
  807.    */
  808.    public function setColorMember($value)
  809.    {
  810.       if(!$this->colorMember->equals($value))
  811.       {
  812.          $this->colorMember = $value;
  813.          $this->checkDataSource();
  814.       }
  815.    }
  816.  
  817.    /**
  818.    * Returns the number of pixels for horizontal margins
  819.    *
  820.    * @param margins Margins
  821.    */
  822.    public function calcHorizMargins($margins)
  823.    {
  824.       $margins->min 0;
  825.       $margins->max 0;// abstract
  826.    }
  827.  
  828.    /**
  829.    * Returns the number of pixels for vertical margins
  830.    *
  831.    * @param margins Margins
  832.    */
  833.    public function calcVerticalMargins($margins)
  834.    {
  835.       $margins->min 0;
  836.       $margins->max 0;// $this->abstract
  837.    }
  838.  
  839.    public function galleryChanged3D($is3D)
  840.    {
  841.       $this->chart->getAspect()->setView3D($is3D);
  842.    }
  843.  
  844.    /**
  845.    * Draws the Series "Legend" on the specified rectangle and Graphics.
  846.    *
  847.    * @param Graphics
  848.    * @param Rectangle
  849.    */
  850.    protected function paintLegend($g$r)
  851.    {
  852.       /** @todo VERIFY ! */
  853.  
  854.       $tmpChart null;
  855.  
  856.       if($this->chart == null)
  857.       {
  858.          //            tmpChart = new Chart();
  859.          //            tmpChart.setAutoRepaint(false);
  860.          //            setChart(tmpChart);
  861.       }
  862.       else
  863.       {
  864. //  TODO remove old     $this->chart->setAutoRepaint(false);
  865.       }
  866.  
  867.       //   try {
  868.       //Graphics3D g3d = new Graphics3D(chart);
  869.       //g3d.g = g;
  870.       //DrawLegend(g3d, -1, r);
  871.       //    } finally {
  872.       if($this->chart == $tmpChart)
  873.       {
  874.          $this->setChart(null);
  875.          //tmpChart.dispose();
  876.       }
  877.       else
  878.       {
  879. //  TODO remove old       $this->getChart()->setAutoRepaint(true);
  880.       }
  881.       //   }
  882.    }
  883.  
  884.    public function getUseAxis()
  885.    {
  886.       return $this->useAxis;
  887.    }
  888.  
  889.    public function associatedToAxis($a)
  890.    {
  891.       return $this->useAxis && (
  892.       ($a->getHorizontal(&&
  893.       (($this->horizAxis === $a||
  894.       ($this->horizontalAxis == HorizontalAxis::$BOTH))) ||
  895.       ((!$a->getHorizontal()) &&
  896.       (($this->vertAxis === $a||
  897.       ($this->verticalAxis == VerticalAxis::$BOTH)))
  898.       );
  899.    }
  900.  
  901.    /**
  902.    * Returns a new Series, copy of this original.<br>
  903.    * It returns the SeriesIndex of the new Series.
  904.    *
  905.    * @return Series 
  906.    * @throws InstantiationException
  907.    * @throws IllegalAccessException
  908.    */
  909.    public function cloneSeries()
  910.    {
  911.       return $this->cloneS();
  912.    }
  913.  
  914.    public function cloneS()
  915.    {
  916.       $tmp null;
  917.  
  918.       if($this->getFunction(!= null)
  919.       {
  920.          $tmp $this->getFunction()->get_class();
  921.       }
  922.  
  923.       try
  924.       {
  925.          $result $this->Series->createNewSeries($this->chart$this->get_class()$tmp);
  926.  
  927.          // result.Assign(this);
  928.          // add values to --> result
  929.          // if DataSource is not null, values are already added in Assign.
  930.          // if (result.DataSource==null)
  931.  
  932.          $result->assignValues($this);
  933.          return $result;
  934.  
  935.       }
  936.       catch(Exception $ex)
  937.       {
  938.          return null;
  939.       }
  940.    }
  941.  
  942.    /**
  943.    * Adds all Values from Source seriesto the current Series.
  944.    *
  945.    * @param source Series
  946.    */
  947.    public function assignValues($source)
  948.    {
  949.       $a new ArrayList();
  950.       $a->add($source);
  951.       $this->addValues($a);
  952.    }
  953.  
  954.    protected function addChartValue($source$valueIndex)
  955.    {
  956.       $tmpX $source->getXValues()->value[$valueIndex];
  957.       $tmpY $source->getYValues()->value[$valueIndex];
  958.  
  959.       // if we are adding values from (for example) an Horizontal Bar series...
  960.       if($this->yMandatory != $source->yMandatory)
  961.       {
  962.          $tmp $tmpX;
  963.          $tmpX $tmpY;
  964.          $tmpY $tmp;
  965.       }
  966.  
  967.       // pending: if ...FY.Order<>loNone then (inverted)
  968.  
  969.       $result $this->vxValues->addChartValue($tmpX);
  970.       $this->getYValues()->insertChartValue($result$tmpY);
  971.  
  972.       // rest of lists...
  973.       $listsCount sizeof($this->valuesList);
  974.       if($listsCount 2)
  975.       {
  976.          $tmp sizeof($source->valuesList1;
  977.          for($t 2$t $listsCount$t++)
  978.          {
  979.             $tmpY ($t <= $tmp?
  980.             $source->valuesList->getValueList($t)->value[$valueIndex0;
  981.             $this->valuesList->getValueList($t)->insertChartValue($result$tmpY);
  982.          }
  983.       }
  984.  
  985.       return $result;
  986.    }
  987.  
  988.    // Called when a new value is added to the series.
  989.    private function addedValue($source$valueIndex)
  990.    {
  991.       $tmpIndex $this->addChartValue($source$valueIndex);
  992.  
  993.       if($source->iColors != null)
  994.       {
  995.          $this->getColors()->setColor($tmpIndex,
  996.          $source->getColors()->getColor($valueIndex));
  997.       }
  998.  
  999.       if($source->sLabels != null)
  1000.       {
  1001.          $this->sLabels[$tmpIndex]=$source->sLabels[$valueIndex];
  1002.       }
  1003.  
  1004.       $this->notifyNewValue($this$tmpIndex);
  1005.    }
  1006.  
  1007.    // This method is called whenever the series points are added,
  1008.    // deleted, modified, etc.
  1009.    // DB : NOT sure to include it.
  1010.    private function notifyValue($valueIndex)
  1011.    {
  1012.       /*
  1013.       if (IUpdating==0)
  1014.       foreach (Series s in linkedSeries )
  1015.       switch (ValueEvent) {
  1016.       case veClear  : if (rOnClear in recalcOptions) clear();
  1017.       case veDelete : if (rOnDelete in recalcOptions )
  1018.       if (FunctionType==null) DeletedValue(this,valueIndex);
  1019.       case veAdd    : if (rOnInsert in recalcOptions)
  1020.       if (FunctionType==null) AddedValue(this,valueIndex);
  1021.       case veModify : if (rOnModify in recalcOptions) AddValues(this);
  1022.       case veRefresh: AddValues(this);
  1023.       }
  1024.       */
  1025.    }
  1026.  
  1027.    public function mouseEvent($e$c)
  1028.    {
  1029.       return $c;
  1030.    }
  1031.  
  1032.    // Triggers the OnAfterAdd event when a new point is added.
  1033.    // DB : Not sure to include it in NET.
  1034.    private function notifyNewValue($sender$valueIndex)
  1035.    {
  1036.       /*
  1037.       if (OnAfterAdd!=null) OnAfterAdd(sender,valueIndex);
  1038.       NotifyValue(veAdd,valueIndex);
  1039.       */
  1040.       if($this->bActive)
  1041.       {
  1042.          $this->repaint();
  1043.       }
  1044.    }
  1045.  
  1046.    // Allocates memory for the ALabel String parameter and inserts it
  1047.    // into the labels list.
  1048.    private function insertLabel($valueIndex$text)
  1049.    {
  1050.       if($text->length(!= 0)
  1051.       {
  1052.          $tmp $this->getLabels();
  1053.          $tmp[$valueIndex]=$text;
  1054.       }
  1055.    }
  1056.  
  1057.    private function addValuesFrom($source)
  1058.    {
  1059.       if($this->isValidSourceOf($source))
  1060.       {
  1061.          $this->beginUpdate();// $this->before $this->clear
  1062.          $this->clear();
  1063.  
  1064.          if($this->getFunction(== null)
  1065.          {// "Copy $this->Function", $this->copy $this->values->->->
  1066.  
  1067.             if($this->yMandatory != $source->yMandatory)
  1068.             {//  $Dec03 //#1274
  1069.                $this->getXValues()->setDateTime($source->getYValues()->getDateTime());
  1070.                $this->getYValues()->setDateTime($source->getXValues()->getDateTime());
  1071.             }
  1072.             else
  1073.             {
  1074.                $this->getXValues()->setDateTime($source->getXValues()->getDateTime());
  1075.                $this->getYValues()->setDateTime($source->getYValues()->getDateTime());
  1076.             }
  1077.  
  1078.             $sourceCount $source->getCount();
  1079.             for($t 0$t $sourceCount$t++)
  1080.             {
  1081.                $this->addedValue($source$t);
  1082.             }
  1083.  
  1084.          }
  1085.          else
  1086.          {
  1087.             $this->getXValues()->setDateTime($source->getXValues()->getDateTime());
  1088.             $this->getYValues()->setDateTime($source->getYValues()->getDateTime());
  1089.             $list Array();
  1090.             $list[]=$source;
  1091.             $this->getFunction()->addPoints($list);// $this->calculate $this->function
  1092.          }
  1093.  
  1094.          $this->endUpdate();// $this->propagate $this->changes->->->
  1095.       }
  1096.    }
  1097.  
  1098.    /**
  1099.    * Recalculates all dependent Series points again.<br>
  1100.    * Each Series has a DataSource method. When DataSource is a valid Series
  1101.    * or DataSet component, Series get all point values from the DataSource
  1102.    * and adds them as Series points. The RefreshSeries method forces the
  1103.    * Series to Clear and get all points again from the DataSource component.
  1104.    * The Refreshing process traverses the Series tree recursively.
  1105.    */
  1106.    public function refreshSeries()
  1107.    {
  1108.       if($this->chart != null)
  1109.       {
  1110.          for($t 0$t $this->chart->getSeriesCount()$t++)
  1111.          {
  1112.             $s $this->chart->getSeries($t);
  1113.             if($s->hasDataSource($this))
  1114.             {
  1115.                $s->checkDataSource();
  1116.             }
  1117.          }
  1118.       }
  1119.    }
  1120.  
  1121.    /**
  1122.    * Recalculates the function just one time, when finished adding points.
  1123.    */
  1124.    public function beginUpdate()
  1125.    {
  1126.       $this->updating++;
  1127.    }
  1128.  
  1129.    /**
  1130.    * Recalculates the function just one time, when finished adding points.
  1131.    */
  1132.    public function endUpdate()
  1133.    {
  1134.       $this->updating--;
  1135.       if($this->updating == 0)
  1136.       {
  1137.          $this->refreshSeries();
  1138.          $this->invalidate();
  1139.       }
  1140.    }
  1141.  
  1142.    // Clears and adds all points values from "source" ArrayList of Series.
  1143.    protected function addValues($source)
  1144.    {
  1145.       $s $source[0];
  1146.  
  1147.       if($this->isValidSourceOf($s))
  1148.       {
  1149.          $this->beginUpdate();// $this->before $this->Clear
  1150.          $this->clear();
  1151.  
  1152.          if($this->function == null)
  1153.          {
  1154.             // "Copy Function", copy values...
  1155.             if($this->yMandatory != $s->yMandatory)//  $Dec03 #1274
  1156.             {
  1157.                $this->vxValues->dateTime $s->vyValues->dateTime;
  1158.                $this->vyValues->dateTime $s->vxValues->dateTime;
  1159.             }
  1160.             else
  1161.             {
  1162.                $this->vxValues->dateTime $s->vxValues->dateTime;
  1163.                $this->vyValues->dateTime $s->vyValues->dateTime;
  1164.             }
  1165.  
  1166.             $this->addValuesFrom($s);
  1167.          }
  1168.          else
  1169.          {
  1170.             $this->vxValues->dateTime $s->vxValues->dateTime;
  1171.             $this->vyValues->dateTime $s->vyValues->dateTime;
  1172.             $this->function->addPoints($source);// $this->calculate $this->function
  1173.          }
  1174.  
  1175.          $this->endUpdate();
  1176.       }
  1177.    }
  1178.  
  1179.    public function setColorEach($value)
  1180.    {
  1181.       $this->bColorEach = $this->setBooleanProperty($this->bColorEach$value);
  1182.  
  1183.       if(!$this->bColorEach)
  1184.       {
  1185.          for($t 0$t $this->getCount()$t++)
  1186.          {
  1187.             if($this->isNull($t))
  1188.             {
  1189.                return;
  1190.             }
  1191.          }
  1192.          $this->iColors = null;
  1193.          $this->invalidate();
  1194.       }
  1195.    }
  1196.  
  1197.    public function dataSourceArray()
  1198.    {
  1199.       if($this->datasource instanceof ArrayList)
  1200.       {
  1201.          $this->$this->datasource;
  1202.          if($this->a->get(0)instanceof $Series)
  1203.          {
  1204.             $this->result new ArrayList();
  1205.             for($t 0$t $this->a->size()$t++)
  1206.             {
  1207.                $this->result->add($this->a->get($t));
  1208.             }
  1209.  
  1210.             return $this->result;
  1211.          }
  1212.       }
  1213.       /* ??? repeated from above, except above code returns a duplicated array
  1214.       else
  1215.       if (datasource instanceof ArrayList) {
  1216.       ArrayList a = (ArrayList) datasource;
  1217.       if (a.get(0) instanceof Series) {
  1218.       return a;
  1219.       }
  1220.       }
  1221.       */
  1222.       else
  1223.          if($this->datasource instanceof Series)
  1224.          {
  1225.             $result =Array();
  1226.             $result[]=$this->datasource;
  1227.             return $result;
  1228.          }/* TODOelse
  1229.       if ($this->datasource instanceof Series[]) {
  1230.       $tmp = $this->datasource;
  1231.       $result = new ArrayList();
  1232.       for ( $t = 0; $t < $tmp->length; $t++) {
  1233.       $result->add($tmp[$t]);
  1234.       }
  1235.       return $result;
  1236.       }        */
  1237.  
  1238.       return null;
  1239.    }
  1240.  
  1241.    public function hasDataSource($source)
  1242.    {
  1243.       if($this->datasource == null)
  1244.       {
  1245.          return false;
  1246.       }
  1247.       else
  1248.       {
  1249.          if($this->datasource === $source)
  1250.          {
  1251.             return true;
  1252.          }
  1253.  
  1254.          $a $this->dataSourceArray();
  1255.          if($a == null)
  1256.          {
  1257.             return false;
  1258.          }
  1259.          else
  1260.          {
  1261.             return in_array($source$a,true);
  1262.          }
  1263.       }
  1264.    }
  1265.  
  1266.    public function doDoubleClick($valueIndex$e)
  1267.    {
  1268.       $tmpSeriesMouseEvent new SeriesMouseEvent();
  1269.       $this->fireSeriesMouseEvent(new SeriesMouseEvent($this$tmpSeriesMouseEvent->SERIES_CLICKED$valueIndex$e));
  1270.    }
  1271.  
  1272.    public function doClick($valueIndex$e)
  1273.    {
  1274.       $tmpSeriesMouseEvent new SeriesMouseEvent();
  1275.       $this->fireSeriesMouseEvent(new SeriesMouseEvent($this$tmpSeriesMouseEvent->SERIES_CLICKED$valueIndex$e));
  1276.    }
  1277.  
  1278.    /**
  1279.    * Draws points with different preset Colors.<br>
  1280.    * If false, all points will be drawn using the Series Series.Color color
  1281.    * method.<br> If true, each Series point will be "colored" with its
  1282.    * corresponding point color. The point colors are stored in the
  1283.    * Series.PointColor array. If a point has an Color.Empty color value,
  1284.    * then a TeeChart determined, available color value will be used to draw
  1285.    * it.<br>
  1286.    * Default value: false
  1287.    *
  1288.    * @return boolean 
  1289.    */
  1290.    public function getColorEach()
  1291.    {
  1292.       return $this->bColorEach;
  1293.    }
  1294.  
  1295.    public function getCountLegendItems()
  1296.    {
  1297.       return $this->getCount();
  1298.    }
  1299.  
  1300.    /**
  1301.    * For internal use.
  1302.    *
  1303.    * @return int 
  1304.    */
  1305.    public function getNumGallerySeries()
  1306.    {
  1307.       return 2;
  1308.    }
  1309.  
  1310.    /**
  1311.    * Gets descriptive text.
  1312.    *
  1313.    * @return String 
  1314.    */
  1315.    public function getDescription()
  1316.    {
  1317.       return "";
  1318.    }
  1319.  
  1320.    private function calcMinMaxValue($a$b$c$d)
  1321.    {
  1322.       $axis $this->yMandatory ? $this->horizAxis $this->vertAxis;
  1323.       if($this->yMandatory)
  1324.       {
  1325.          return $axis->getInverted($axis->calcPosPoint($c:
  1326.          $axis->calcPosPoint($a);
  1327.       }
  1328.       else
  1329.       {
  1330.          return $axis->getInverted($axis->calcPosPoint($b:
  1331.          $axis->calcPosPoint($d);
  1332.       }
  1333.    }
  1334.  
  1335.    /**
  1336.    * Returns if this series is Visible.<br>
  1337.    *
  1338.    * @return boolean 
  1339.    */
  1340.    public function getVisible()
  1341.    {
  1342.       return $this->bActive;
  1343.    }
  1344.  
  1345.    /**
  1346.    * An alias to Active property.  <br>
  1347.    * Shows or Hides the component.
  1348.    *
  1349.    * @param value boolean
  1350.    */
  1351.    public function setVisible($value)
  1352.    {
  1353.       $this->setActive($value);
  1354.    }
  1355.  
  1356.    /**
  1357.    * Returns the corresponding X value of a Screen position between Axis
  1358.    * limits.<br>
  1359.    * The Screen position must be between Axis limits.
  1360.    *
  1361.    * @param screenPos int
  1362.    * @return double 
  1363.    */
  1364.    public function xScreenToValue($screenPos)
  1365.    {
  1366.       return $this->horizAxis->calcPosPoint($screenPos);
  1367.    }
  1368.  
  1369.    /**
  1370.    * Returns the corresponding Y value of a Screen position between Axis
  1371.    * limits.<br>
  1372.    * The resulting Value is based on the Series.GetVertAxis.
  1373.    *
  1374.    * @param screenPos int
  1375.    * @return double 
  1376.    */
  1377.    public function yScreenToValue($screenPos)
  1378.    {
  1379.       return $this->vertAxis->calcPosPoint($screenPos);
  1380.    }
  1381.  
  1382.    public function prepareForGallery($isEnabled)
  1383.    {
  1384.       $this->fillSampleValues(4);
  1385.       $this->getMarks()->setVisible(false);
  1386.       $this->getMarks()->getFont()->setSize(7);
  1387.       $this->getMarks()->setArrowLength(4);
  1388.       $this->getMarks()->setDrawEvery(2);
  1389.       $this->getMarks()->getCallout()->setLength(4);
  1390.  
  1391.       $this->setColorEach(false);
  1392.  
  1393.       if($isEnabled)
  1394.       {
  1395.          if($this->chart->getSeriesIndexOf($this== 0)
  1396.          {
  1397.             $tmpColor new Color();
  1398.             $this->setColor($tmpColor->RED);
  1399.          }
  1400.          else
  1401.          {
  1402.             $this->setColor($tmpColor->BLUE);
  1403.          }
  1404.       }
  1405.       else
  1406.       {
  1407.          $this->setColor($tmpColor->SILVER);
  1408.       }
  1409.    }
  1410.  
  1411.    protected function prepareLegendCanvas($g$valueIndex$backColor$aBrush)
  1412.    {
  1413.    }
  1414.  
  1415.    protected function drawLegendShape($g$valueIndex$rect)
  1416.    {
  1417.       $g->rectangle($rect);/* <-- $this->rectangle */
  1418.       if($g->getBrush()->getForegroundColor(== $this->chart->getLegend()->getColor())
  1419.       {
  1420.          /* <-- color conflict ! */
  1421.          $oldColor $g->getPen()->getColor();
  1422.          if($g->getBrush()->getForegroundColor(== new Color(0,0,0))
  1423.          {
  1424.             $g->getPen()->setColor(new Color(255,255,255));
  1425.          }
  1426.          $g->getBrush()->setVisible(false);
  1427.          $g->rectangle($rect);/* <--  $rectangle */
  1428.          $g->getPen()->setColor($oldColor);
  1429.       }                       
  1430.    }
  1431.  
  1432.    public function legendItemColor($index)
  1433.    {
  1434.       return $this->getValueColor($index);
  1435.    }
  1436.  
  1437.    public function drawLegend($g null $valueIndex$rect)
  1438.    {
  1439.       if($g == null)
  1440.          $g $this->chart->getGraphics3D();
  1441.  
  1442.       if(($valueIndex != - 1|| (!$this->getColorEach()))
  1443.       {
  1444.          // set pen
  1445.          $g->setPen($this->chart->getLegend()->getSymbol()->getPen());
  1446.  
  1447.          // set brush color
  1448.          $tmpColor ($valueIndex == - 1?
  1449.          $this->getColor($this->legendItemColor($valueIndex);
  1450.  
  1451.          $g->getBrush()->setColor($tmpColor);
  1452.  
  1453.          // if not empty brush...
  1454.          if (!$tmpColor->isEmpty()) {
  1455.              // set background color and style
  1456.              $tmpBack $this->chart->getLegend()->getColor();
  1457.              $tmpStyle new ChartBrush($this->chart);
  1458.              $tmpStyle->assign($this->bBrush);
  1459.              $this->prepareLegendCanvas($g$valueIndex$tmpBack$tmpStyle);
  1460.              // After calling PrepareLegendCanvas, set custom symbol pen, if any...
  1461.              if($this->chart->getLegendPen(!= null)
  1462.                 $g->setPen($this->chart->getLegendPen());
  1463.  
  1464.              // if back color is "default", use Legend back color
  1465.              if($tmpBack->isEmpty())
  1466.              {
  1467.                 $tmpBack $this->chart->getLegend()->getColor();
  1468.                 if($tmpBack->isEmpty())
  1469.                    $tmpBack $this->chart->getPanel()->getColor();
  1470.              }
  1471.  
  1472.              //force the use of TILED imagemode, so image always fits the legendshape boundary
  1473.              $tmpStyle->setImageMode(ImageMode::$TILE);
  1474.              
  1475.              $this->chart->setBrushCanvas($g->getBrush()->getColor()$tmpStyle$tmpBack);
  1476.  
  1477.              // draw shape
  1478.              $this->drawLegendShape($g$valueIndex$rect);
  1479.          }
  1480.       }
  1481.    }
  1482.  
  1483.    public function calcFirstLastVisibleIndex()
  1484.    {
  1485.  
  1486.       $this->firstVisible = -1;
  1487.       $this->lastVisible = -1;
  1488.  
  1489.       if($this->getCount(0)
  1490.       {
  1491.          $tmpLastIndex $this->getCount(1;
  1492.  
  1493.          if($this->calcVisiblePoints &&
  1494.          ($this->notMandatory->getOrder(!= ValueListOrder::$NONE))
  1495.          {
  1496.  
  1497.             /* NOTE:
  1498.             The code below does NOT use a "divide by 2" (bubble)
  1499.             algorithm because the tmpMin value might not have any
  1500.             correspondence with a Series point.
  1501.             When the Series point values are "floating" (not int)
  1502.             the "best" solution is to do a lineal all-traverse search.
  1503.             However, this code can still be optimized.
  1504.             It will be revisited for next coming releases.
  1505.  
  1506.             */
  1507.  
  1508.             $r $this->chart->getChartRect();
  1509.  
  1510.             $tmpMin $this->calcMinMaxValue($r->x$r->y$r->getRight(),
  1511.             $r->getBottom());
  1512.  
  1513.             $this->firstVisible = 0;
  1514.             while($this->notMandatory->value[$this->firstVisible$tmpMin)
  1515.             {
  1516.                $this->firstVisible++;
  1517.                if($this->firstVisible > $tmpLastIndex)
  1518.                {
  1519.                   $this->firstVisible = -1;
  1520.                   break;
  1521.                }
  1522.             }
  1523.  
  1524.             if($this->firstVisible >= 0)
  1525.             {
  1526.                $tmpMax $this->calcMinMaxValue($r->getRight()$r->getBottom(),
  1527.                $r->x,
  1528.                $r->y);
  1529.  
  1530.                if($this->notMandatory->getLast(<= $tmpMax)
  1531.                {
  1532.                   $this->lastVisible = $tmpLastIndex;
  1533.                }
  1534.                else
  1535.                {
  1536.                   $this->lastVisible = $this->firstVisible;
  1537.                   while($this->notMandatory->value[$this->lastVisible<
  1538.                   $tmpMax)
  1539.                   {
  1540.                      $this->lastVisible++;
  1541.                      if($this->lastVisible > $tmpLastIndex)
  1542.                      {
  1543.                         $this->lastVisible = $tmpLastIndex;
  1544.                         break;
  1545.                      }
  1546.                   }
  1547.  
  1548.                   if((!$this->drawBetweenPoints&&
  1549.                   ($this->notMandatory->value[$this->lastVisible$tmpMax))
  1550.                   {
  1551.                      $this->lastVisible--;
  1552.                   }
  1553.                }
  1554.             }
  1555.          }
  1556.          else
  1557.          {
  1558.             $this->firstVisible = 0;
  1559.             $this->lastVisible = $tmpLastIndex;
  1560.          }
  1561.       }
  1562.    }
  1563.  
  1564.    /**
  1565.    * Returns the length in pixels of the longest Mark text.
  1566.    *
  1567.    * @return int 
  1568.    */
  1569.    public function maxMarkWidth()
  1570.    {
  1571.       $tmpResult 0;
  1572.       $count $this->getCount();
  1573.       for($t 0$t $count$t++)
  1574.       {
  1575.          $tmpResult max($tmpResult$this->getMarks()->textWidth($t));
  1576.       }
  1577.       return $tmpResult;
  1578.    }
  1579.  
  1580.    /**
  1581.    * Returns corresponding Point value suitable for displaying at Series
  1582.    * Marks.
  1583.    *
  1584.    * @param valueIndex int
  1585.    * @return double 
  1586.    */
  1587.    public function getMarkValue($valueIndex)
  1588.    {
  1589.       return $this->mandatory->value[$valueIndex];
  1590.    }
  1591.  
  1592.    private function formatValue($value)
  1593.    {
  1594.       /* tODO  try {
  1595.       return new DecimalFormat($this->valueFormat)->format($value);
  1596.       } catch ( $e) {
  1597.       return new DecimalFormat($this->Language->getString("DefValueFormat"))->format($value);
  1598.       }    */
  1599.       // TODO temporary
  1600.       return $value;
  1601.    }
  1602.  
  1603.    private function labelOrValue($valueIndex)
  1604.    {
  1605.       $tmpResult ($this->sLabels == null"" :
  1606.       $this->sLabels[$valueIndex];
  1607.       if(strlen($tmpResult== 0)  {
  1608.          $tmpResult $this->formatValue($this->getMarkValue($valueIndex));
  1609.       }
  1610.       return $tmpResult;
  1611.    }
  1612.  
  1613.    private function getAXValue($valueIndex)
  1614.    {
  1615.       if(!($this->horizAxis == null))
  1616.       {
  1617.          if($this->vxValues->getDateTime())
  1618.          {
  1619.             try
  1620.             {
  1621.                if($this->horizAxis->getLabels()->getDateTimeFormat()->equals(""))
  1622.                {
  1623.                   /* tODO    $result = new DateTime($this->vxValues->value[$valueIndex])->
  1624.                   $this->toString(
  1625.                   $this->horizAxis->
  1626.                   $this->dateTimeDefaultFormat(
  1627.                   $this->horizAxis->getRange()));*/
  1628.                }
  1629.                else
  1630.                {
  1631.                   /* TODO    $result = new DateTime($this->vxValues->
  1632.                   $this->value[$valueIndex])->toString(
  1633.                   $this->horizAxis->getLabels()->
  1634.                   $this->getDateTimeFormat());*/
  1635.                }
  1636.             }
  1637.             catch(Exception $e)
  1638.             {
  1639.                /*todo   $result = (new DecimalFormat($this->Language->getString("DefValueFormat")))->format(
  1640.                $this->vxValues->value[$valueIndex]);*/
  1641.             }
  1642.  
  1643.             return $result;
  1644.  
  1645.          }
  1646.          else
  1647.          {
  1648.             return $this->formatValue($this->vxValues->value[$valueIndex]);
  1649.          }
  1650.  
  1651.       }
  1652.       else
  1653.       {
  1654.          return $this->horizAxis->getLabels()->labelValue(
  1655.          $this->vxValues->value[$valueIndex]);
  1656.       }
  1657.    }
  1658.  
  1659.    private function getAYValue($valueIndex)
  1660.    {
  1661.       return $this->formatValue($this->getMarkValue($valueIndex));
  1662.    }
  1663.  
  1664.    /**
  1665.    * Returns the String corresponding to the Series Mark text
  1666.    * for a given ValueIndex point.<br>
  1667.    * The Mark text depends on the Marks.Style method.<br>
  1668.    *
  1669.    * @param valueIndex int
  1670.    * @return String 
  1671.    */
  1672.    public function getMarkText($valueIndex)
  1673.    {
  1674.       $tmp $this->marks->getMultiLine(Language::getString("LineSeparator"" ";
  1675.  
  1676.       if($this->marks->getStyle(== MarksStyle::$VALUE)
  1677.       {
  1678.          $tmpResult $this->getAYValue($valueIndex);
  1679.       }
  1680.       else
  1681.          if($this->marks->getStyle(== MarksStyle::$PERCENT)
  1682.          {
  1683.             $tmpResult $this->marks->percentString(
  1684.             $valueIndexfalse);
  1685.          }
  1686.          else
  1687.             if($this->marks->getStyle(== MarksStyle::$LABEL)
  1688.             {
  1689.                $tmpResult $this->labelOrValue($valueIndex);
  1690.             }
  1691.             else
  1692.                if($this->marks->getStyle(== MarksStyle::$LABELPERCENT)
  1693.                {
  1694.                   $tmpResult $this->labelOrValue($valueIndex+
  1695.                   $tmp +
  1696.                   $this->marks->percentString($valueIndexfalse);
  1697.                }
  1698.                else
  1699.                   if($this->marks->getStyle(== MarksStyle::$LABELVALUE)
  1700.                   {
  1701.                      $tmpResult $this->labelOrValue($valueIndex+
  1702.                      $tmp $this->getAYValue($valueIndex);
  1703.                   }
  1704.                   else
  1705.                      if($this->marks->getStyle(== MarksStyle::$LEGEND)
  1706.                      {
  1707.                         $tmpResult $this->chart->formattedValueLegend($this,
  1708.                         $valueIndex);
  1709.                      }
  1710.                      else
  1711.                         if($this->marks->getStyle(== MarksStyle::$PERCENTTOTAL)
  1712.                         {
  1713.                            $tmpResult $this->marks->percentString($valueIndextrue);
  1714.                         }
  1715.                         else
  1716.                            if($this->marks->getStyle(== MarksStyle::$LABELPERCENTTOTAL)
  1717.                            {
  1718.                               $tmpResult $this->labelOrValue($valueIndex+
  1719.                               $tmp +
  1720.                               $this->marks->percentString($valueIndextrue);
  1721.                            }
  1722.                            else
  1723.                               if($this->marks->getStyle(== MarksStyle::$XVALUE)
  1724.                               {
  1725.                                  $tmpResult $this->getAXValue($valueIndex);
  1726.                               }
  1727.                               else
  1728.                                  if($this->marks->getStyle(== MarksStyle::$XY)
  1729.                                  {
  1730.                                     $tmpResult $this->getAXValue($valueIndex+
  1731.                                     $tmp $this->getAYValue($valueIndex);
  1732.                                  }
  1733.                                  else
  1734.                                  {
  1735.                                     $tmpResult "";
  1736.                                  }
  1737.  
  1738. // TODO       return $this->customMarkText->getMarkText($valueIndex, $tmpResult);
  1739.         return $tmpResult;
  1740.    }
  1741.  
  1742.    /**
  1743.    * Returns the String representation of a Index point used to draw the Mark.
  1744.    *
  1745.    * @param index int
  1746.    * @return String 
  1747.    */
  1748.    public function getValueMarkText($index)
  1749.    {
  1750.       return $this->getMarkText($index);
  1751.    }
  1752.  
  1753.    /**
  1754.    * Forces the Chart to Repaint.<br>
  1755.    * You don't normally call Repaint directly. It can be used within derived
  1756.    * TChartSeries components when changing their properties internally .
  1757.    */
  1758.    public function repaint()
  1759.    {
  1760.       $this->invalidate();
  1761.    }
  1762.  
  1763.    /**
  1764.    * Returns True when the tmpSeries parameter is of the same class.
  1765.    *
  1766.    * @param ISeries
  1767.    * @return boolean 
  1768.    */
  1769.    protected function sameClass($s)
  1770.    {
  1771.       return get_class($this== get_class($s);
  1772.    }
  1773.  
  1774.    /**
  1775.    * Sorts all points in the series using the Labels (texts) list.<br><br>
  1776.    * <b>Note:</b> non-mandatory values (X) are modified (they are not
  1777.    * preserved).
  1778.    *
  1779.    * @param order ValueListOrder
  1780.    */
  1781.    /* TODO   public function sortByLabels($order) {
  1782.    if ($order != ValueListOrder::$NONE) {
  1783.    $this->iLabelOrder = $order;
  1784.  
  1785.    $this->Utils->sort(
  1786.    0,
  1787.    $this->getCount() - 1,
  1788.    new Comparator() {
  1789.    public function compare($a, $b) {
  1790.    $result = $this->getLabels()->getString($a)->compareTo($this->getLabels()->
  1791.    $this->getString($b));
  1792.    return ($this->iLabelOrder == ValueListOrder::$DESCENDING) ? -$result :
  1793.    $result;
  1794.    }
  1795.    },
  1796.    $this->getValueIndexSwapper()
  1797.    );
  1798.  
  1799.    $this->iLabelOrder = ValueListOrder::$NONE;
  1800.    $this->notMandatory->fillSequence(); //    $values ( $them)
  1801.    $this->invalidate();
  1802.    }
  1803.    }
  1804.  
  1805.    public function sortByLabels() {
  1806.    $this->sortByLabels(ValueListOrder::$ASCENDING);
  1807.    }   */
  1808.  
  1809.    /**
  1810.    * For internal use.
  1811.    *
  1812.    * @return int 
  1813.    */
  1814.    public function getStartZ()
  1815.    {
  1816.       return $this->startZ;
  1817.    }
  1818.  
  1819.    public function setStartZ($value)
  1820.    {
  1821.       $this->startZ = $value;
  1822.    }
  1823.  
  1824.    /**
  1825.    * For internal use.
  1826.    *
  1827.    * @return int 
  1828.    */
  1829.    public function getMiddleZ()
  1830.    {
  1831.       return $this->middleZ;
  1832.    }
  1833.  
  1834.    public function setMarks($value)
  1835.    {
  1836.       $this->marks = $value;
  1837.    }
  1838.  
  1839.    public function setMiddleZ($value)
  1840.    {
  1841.       $this->middleZ = $value;
  1842.    }
  1843.  
  1844.    public function setZPositions()
  1845.    {
  1846.       $w $this->getChart()->getSeriesWidth3D();
  1847.       $this->setStartZ($this->iZOrder * $w);
  1848.  
  1849.       if($this->getDepth(== self::$AUTODEPTH)
  1850.       {
  1851.          $this->setEndZ($this->getStartZ($w);
  1852.       }
  1853.       else
  1854.       {
  1855.          $this->setEndZ($this->getStartZ($this->getDepth());
  1856.       }
  1857.  
  1858.       $this->setMiddleZ(($this->getStartZ($this->getEndZ()) 2);
  1859.  
  1860.       if($this->marks != null)
  1861.       {
  1862.          $this->marks->setZPosition($this->getMiddleZ());
  1863.       }
  1864.    }
  1865.  
  1866.    /**
  1867.    * For internal use.
  1868.    *
  1869.    * @return int 
  1870.    */
  1871.    public function getEndZ()
  1872.    {
  1873.       return $this->endZ;
  1874.    }
  1875.  
  1876.    public function setEndZ($value)
  1877.    {
  1878.       $this->endZ = $value;
  1879.    }
  1880.  
  1881.    /**
  1882.    * Determines the Format to display point values.<br>
  1883.    * It specifies the desired formatting string to be applied to Axis Labels.
  1884.    * It has effect when Axis associated Series have their XValues.DateTime
  1885.    * or YValues.DateTime is set to false. <br>
  1886.    * For DateTime Axis labels use AxisLabels.DateTimeFormat. <br>
  1887.    * ValueFormat is a standard formatting string specifier. <br>
  1888.    * Chart Axis uses it to draw the axis labels. <br>
  1889.    * Chart Series uses it to draw the Marks. <br>
  1890.    * Default value: Language::getString("DefValueFormat")
  1891.    *
  1892.    * @return String 
  1893.    */
  1894.    public function getValueFormat()
  1895.    {
  1896.       return $this->valueFormat;
  1897.    }
  1898.  
  1899.    /**
  1900.    * Determines the Format to display point values.<br>
  1901.    * Default value: Language::getString("DefValueFormat")
  1902.    *
  1903.    * @param value String
  1904.    */
  1905.    public function setValueFormat($value)
  1906.    {
  1907.       $this->valueFormat = $this->setStringProperty($this->valueFormat$value);
  1908.    }
  1909.  
  1910.    /**
  1911.    * The Format to display point values as percentage.<br>
  1912.    * PercentFormat is a standard string specifier. It is used to draw the
  1913.    * Series Marks Percent Style figures.<br>
  1914.    * Default value: Language::getString("DefPercentFormat")
  1915.    *
  1916.    * @see Series#getValueFormat
  1917.    * @return String 
  1918.    */
  1919.    public function getPercentFormat()
  1920.    {
  1921.       return $this->percentFormat;
  1922.    }
  1923.  
  1924.    /**
  1925.    * Sets the Format to display point values as percentage.<br>
  1926.    * Default value: Language::getString("DefPercentFormat")
  1927.    *
  1928.    * @param value String
  1929.    */
  1930.    public function setPercentFormat($value)
  1931.    {
  1932.       $this->percentFormat = $this->setStringProperty($this->percentFormat$value);
  1933.       $this->percentDecimal = new DecimalFormat($this->percentFormat);
  1934.    }
  1935.  
  1936.    /**
  1937.    * Horizontal axis associated to this Series.<br>
  1938.    * Default value: HorizontalAxis.Bottom
  1939.    *
  1940.    * @return HorizontalAxis 
  1941.    */
  1942.    public function getHorizontalAxis()
  1943.    {
  1944.       return $this->horizontalAxis;
  1945.    }
  1946.  
  1947.    /**
  1948.    * Stes the Horizontal axis associated to this Series.<br>
  1949.    * Default value: HorizontalAxis.Bottom
  1950.    *
  1951.    * @param value HorizontalAxis
  1952.    */
  1953.    public function setHorizontalAxis($value)
  1954.    {
  1955.       if($this->horizontalAxis != $value)
  1956.       {
  1957.          $this->horizontalAxis $value;
  1958.          if($this->horizontalAxis != HorizontalAxis::$CUSTOM)
  1959.          {
  1960.             $this->customHorizAxis null;
  1961.          }
  1962.          $this->recalcGetAxis();
  1963.          $this->invalidate();
  1964.       }
  1965.    }
  1966.  
  1967.    /**
  1968.    * Determines Vertical axis associated to this Series.<br>
  1969.    * Default value: VerticalAxis.Left
  1970.    *
  1971.    * @return VerticalAxis 
  1972.    */
  1973.    public function getVerticalAxis()
  1974.    {
  1975.       return $this->verticalAxis;
  1976.    }
  1977.  
  1978.    /**
  1979.    * Determines Vertical axis associated to this Series.<br>
  1980.    * Default value: VerticalAxis.Left
  1981.    *
  1982.    * @param value VerticalAxis
  1983.    */
  1984.    public function setVerticalAxis($value)
  1985.    {
  1986.       if($this->verticalAxis != $value)
  1987.       {
  1988.          $this->verticalAxis $value;
  1989.          if($this->verticalAxis != VerticalAxis::$CUSTOM)
  1990.          {
  1991.             $this->customVertAxis null;
  1992.          }
  1993.          $this->recalcGetAxis();
  1994.          $this->invalidate();
  1995.       }
  1996.    }
  1997.  
  1998.    /**
  1999.    * Returns "Value" parameter coordinate position in pixels.
  2000.    *
  2001.    * @param value double
  2002.    * @return int 
  2003.    */
  2004.    public function calcPosValue($value)
  2005.    {
  2006.       return $this->yMandatory ? $this->calcYPosValue($value$this->calcXPosValue($value);
  2007.    }
  2008.  
  2009.    /**
  2010.    * The pixel Screen Horizontal coordinate of the ValueIndex Series
  2011.    * value.<br>
  2012.    * This coordinate is calculated using the Series associated Horizontal
  2013.    * Axis.
  2014.    *
  2015.    * @param index int
  2016.    * @return int 
  2017.    */
  2018.    public function calcXPos($index)
  2019.    {
  2020.       return $this->calcXPosValue($this->vxValues->value[$index]);
  2021.    }
  2022.  
  2023.    /**
  2024.    * The pixel Screen Horizontal coordinate of the specified Value.
  2025.    * <br>
  2026.    * This coordinate is calculated using the Series associated Horizontal
  2027.    * Axis.
  2028.    *
  2029.    * @param value double
  2030.    * @return int 
  2031.    */
  2032.    public function calcXPosValue($value)
  2033.    {
  2034.       return $this->horizAxis->calcXPosValue($value);
  2035.    }
  2036.  
  2037.    /**
  2038.    * The pixel Screen Vertical coordinate of the ValueIndex Series
  2039.    * value.<br>
  2040.    * This coordinate is calculated using the Series associated Vertical Axis.
  2041.    *
  2042.    * @param index int
  2043.    * @return int 
  2044.    */
  2045.    public function calcYPos($index)
  2046.    {
  2047.       return $this->calcYPosValue($this->getYValues()->value[$index]);
  2048.    }
  2049.  
  2050.    /**
  2051.    * The pixel Screen Vertical coordinate of the specified Value.<br>
  2052.    * This coordinate is calculated using the Series associated Vertical Axis.
  2053.    *
  2054.    * @param value double
  2055.    * @return int 
  2056.    */
  2057.    public function calcYPosValue($value)
  2058.    {
  2059.       return $this->vertAxis->calcYPosValue($value);
  2060.    }
  2061.  
  2062.    public function getOriginValue($valueIndex)
  2063.    {
  2064.       return $this->getMarkValue($valueIndex);
  2065.    }
  2066.  
  2067.    /* Draws a point Mark using the APosition coordinates. */
  2068.    protected function drawMark($valueIndex$st$aPosition)
  2069.    {
  2070.       $this->getMarks()->internalDraw($valueIndex,
  2071.       $this->getValueColor($valueIndex)$st,
  2072.       $aPosition);
  2073.    }
  2074.  
  2075.    private function getDefaultColor($valueIndex)
  2076.    {
  2077.       if($this->bColorEach)
  2078.       {
  2079.          $c $this->getChart()->getGraphics3D()->getDefaultColor($valueIndex);
  2080.          return $c;
  2081.          // TODO remove above line            return $c->transparentColor($this->bBrush->getTransparency());
  2082.       }
  2083.       else
  2084.       {
  2085.          return $this->getColor();
  2086.       }
  2087.    }
  2088.  
  2089.    /**
  2090.    * The colour of the index point.
  2091.    *
  2092.    * @param valueIndex int
  2093.    * @return Color 
  2094.    */
  2095.    public function getValueColor($valueIndex)
  2096.    {
  2097.       if(($this->iColors != null&& (sizeof($this->iColors$valueIndex))
  2098.       {
  2099.          $result $this->iColors->getColor($valueIndex);
  2100.          return $result->isEmpty(?
  2101.          $this->getDefaultColor($valueIndex$result;
  2102.       }
  2103.       else
  2104.       {
  2105.          return $this->getDefaultColor($valueIndex);
  2106.       }
  2107.    }
  2108.  
  2109.    public function drawMarks()
  2110.    {
  2111.       $g $this->chart->getGraphics3D();
  2112.       $a $this->chart->getAspect();
  2113.  
  2114.       $shouldZoomFont ($a->getView3D(&&
  2115.       (!$g->getSupports3DText()) && $a->getZoomText(&&
  2116.       ($a->getZoom(!= 100));
  2117.  
  2118.       for($t $this->firstVisible$t <= $this->lastVisible$t++)
  2119.       {
  2120.          if(($t $this->marks->getDrawEvery()) == 0)
  2121.          {
  2122.             if(!$this->isNull($t))
  2123.             {
  2124.                $st $this->getMarkText($t);
  2125.  
  2126.                if(strlen($st!= 0)
  2127.                {
  2128.                   $tmpMark $this->getMarks()->markItem($t);
  2129.  
  2130.                   if($tmpMark->getVisible())
  2131.                   {
  2132.                      $g->setFont($tmpMark->getFont());
  2133.  
  2134.                      if($shouldZoomFont)
  2135.                      {
  2136.                         $f $g->getFont();
  2137.                         $f->setSize(max(1MathUtils::round(
  2138.                         01 *
  2139.                         $a->getZoom(*
  2140.                         $f->getSize())));
  2141.                      }
  2142.  
  2143.                      $tmpFontH $g->getFontHeight();
  2144.  
  2145.                      $tmp $this->chart->multiLineTextWidth($st);
  2146.                      $tmpW $tmp->width;
  2147.                      $tmpH $tmp->count $tmpFontH;
  2148.  
  2149.                      if($this->marks->shouldDrawSymbol())
  2150.                      {
  2151.                         $tmpW += $tmpFontH;// - 4;
  2152.                      }
  2153.  
  2154.                      $g->setPen($tmpMark->getPen());
  2155.                      if($tmpMark->getPen()->getVisible())
  2156.                      {
  2157.                         $tmpWidth MathUtils::round($tmpMark->getPen()->getWidth());
  2158.                         $tmpW += $tmpWidth;
  2159.                         $tmpH += $tmpWidth;
  2160.                      }
  2161.                      else
  2162.                      {
  2163.                         $tmpH++;
  2164.                      }
  2165.  
  2166.                      $aPos new SeriesMarksPosition();
  2167.                      $aPos->width $tmpW;
  2168.                      $aPos->height $tmpH;
  2169.                      $aPos->arrowTo->setX($this->calcXPos($t));
  2170.                      $aPos->arrowTo->setY($this->calcYPos($t));
  2171.                      $aPos->arrowFrom->setX($aPos->arrowTo->getX());
  2172.                      $aPos->arrowFrom->setY($aPos->arrowTo->getY());
  2173.                      $aPos->leftTop->setX($aPos->arrowTo->getX(($tmpW 2));
  2174.                      $aPos->leftTop->setY($aPos->arrowTo->getY($tmpH 1);
  2175.  
  2176.                      if($this->getMarks()->getSymbol(!= null)
  2177.                      {
  2178.                         $tmpR $this->getMarks()->getSymbol()->getShapeBounds();
  2179.                         $tmpR->$aPos->leftTop->getY(2;
  2180.                         $tmpR->$aPos->leftTop->getX(2;
  2181.                         $tmpR->width $tmpFontH;
  2182.                         $tmpR->height $tmpFontH;
  2183.                      }
  2184.  
  2185.                      $this->drawMark($t$st$aPos);
  2186.                   }
  2187.                }
  2188.             }
  2189.          }
  2190.       }
  2191.    }
  2192.  
  2193.    private function clipRegionCreate($activeRegion)
  2194.    {
  2195.       $tmpR $this->chart->getChartRect();
  2196.  
  2197.       if($this->chart->canClip())
  2198.       {
  2199.          // tmpR.height++; out mm 27ago07 causes incr series upon series
  2200.          $this->chart->getGraphics3D()->clipCube($tmpR0$this->chart->getAspect()->getWidth3D());
  2201.          $activeRegion true;
  2202.       }
  2203.  
  2204.       return $activeRegion;
  2205.    }
  2206.  
  2207.    // Remove the clipping region
  2208.    private function clipRegionDone($activeRegion)
  2209.    {
  2210.       if($activeRegion)
  2211.       {
  2212.          $this->chart->getGraphics3D()->unClip();
  2213.          $activeRegion false;
  2214.       }
  2215.  
  2216.       return $activeRegion;
  2217.    }
  2218.  
  2219.    // Draw the "Marks" of the Series
  2220.    private function drawMarksSeries($s$activeRegion)
  2221.    {
  2222.       if($s->getCount(0)
  2223.       {
  2224.          if(($s->marks != null&& ($s->getMarks()->getVisible()))
  2225.          {
  2226.             if($s->getMarks()->getClip())
  2227.             {
  2228.                $activeRegion $this->clipRegionCreate($activeRegion);
  2229.             }
  2230.             $s->drawMarks();
  2231.             if($s->getMarks()->getClip())
  2232.             {
  2233.                $activeRegion $this->clipRegionDone($activeRegion);
  2234.             }
  2235.          }
  2236.       }
  2237.       return $activeRegion;
  2238.    }
  2239.  
  2240.    // if the ASeries parameter has the same "Z" order than the current series, draw the point
  2241.    private function tryDrawSeries($s$valueIndex)
  2242.    {
  2243.       if($s->getActive(&& ($s->getZOrder(== $this->getZOrder()) &&
  2244.       ($valueIndex $s->getCount()))
  2245.       {
  2246.          $s->drawValue($valueIndex);
  2247.       }
  2248.    }
  2249.  
  2250.    protected function drawSeriesForward($valueIndex)
  2251.    {
  2252.       return true;// abstract
  2253.    }
  2254.  
  2255.    // Draw one single point (ValueIndex) for all Series
  2256.    private function drawAllSeriesValue($valueIndex)
  2257.    {
  2258.  
  2259.       $tmp1 $this->chart->getSeriesIndexOf($this);
  2260.       $tmp2 $this->chart->getSeriesCount(1;
  2261.  
  2262.       if($valueIndex $this->getCount())
  2263.       {
  2264.  
  2265.          if($this->drawSeriesForward($valueIndex))
  2266.          {
  2267.             for($t $tmp1$t <= $tmp2$t++)
  2268.             {
  2269.                $this->tryDrawSeries($this->chart->getSeries($t)$valueIndex);
  2270.             }
  2271.          }
  2272.          else
  2273.          {
  2274.             for($t $tmp2$t >= $tmp1$t--)
  2275.             {
  2276.                $this->tryDrawSeries($this->chart->getSeries($t)$valueIndex);
  2277.             }
  2278.          }
  2279.  
  2280.       }
  2281.       else
  2282.       {
  2283.          for($t $tmp1$t <= $tmp2$t++)
  2284.          {
  2285.             $this->tryDrawSeries($this->chart->getSeries($t)$valueIndex);
  2286.          }
  2287.       }
  2288.    }
  2289.  
  2290.    // Returns True if the series is the first one with the same ZOrder.
  2291.    // Some series allow sharing the same ZOrder (example: Stacked Bars).
  2292.    private function firstInZOrder()
  2293.    {
  2294.       if($this->getActive())
  2295.       {
  2296.          for($t 0$t $this->chart->getSeriesCount()$t++)
  2297.          {
  2298.             $s $this->chart->getSeries($t);
  2299.  
  2300.             if($s === $this)
  2301.             {
  2302.                break;
  2303.             }
  2304.             else
  2305.                if($s->getActive(&&
  2306.                ($s->getZOrder(== $this->getZOrder()))
  2307.                {
  2308.                   return false;
  2309.                }
  2310.          }
  2311.          return true;
  2312.       }
  2313.       else
  2314.       {
  2315.          return false;
  2316.       }
  2317.    }
  2318.  
  2319.    public function getHasZValues()
  2320.    {
  2321.       return $this->hasZValues;
  2322.    }
  2323.  
  2324.    /**
  2325.    * Returns true if there are more series that share the same Z order.<br>
  2326.    * For example Stacked Bars.
  2327.    *
  2328.    * @return boolean 
  2329.    */
  2330.    protected function moreSameZOrder()
  2331.    {
  2332.       if($this->chart->getAspect()->getApplyZOrder())
  2333.       {
  2334.          for($t 0$t $this->chart->getSeriesCount()$t++)
  2335.          {
  2336.             $s $this->chart->getSeries($t);
  2337.             if(!($s === $this))
  2338.             {
  2339.                if($s->getActive(&& (!$s->getHasZValues()) &&
  2340.                ($s->getZOrder(==
  2341.                $this->getZOrder()))
  2342.                {
  2343.                   return true;
  2344.                }
  2345.             }
  2346.          }
  2347.       }
  2348.       return false;
  2349.    }
  2350.  
  2351.    protected function draw()
  2352.    {
  2353.       if($this->drawValuesForward())
  2354.       {
  2355.          for($t $this->firstVisible$t <= $this->lastVisible$t++)
  2356.          {
  2357.             $this->drawValue($t);
  2358.          }
  2359.       }
  2360.       else
  2361.       {
  2362.          for($t $lastVisible$t >= $this->firstVisible$t--)
  2363.          {
  2364.             $this->drawValue($t);
  2365.          }
  2366.       }
  2367.    }
  2368.  
  2369.    public function doBeforeDrawChart(}// abstract
  2370.  
  2371.    /**
  2372.    * Draws the series to the Chart Canvas.
  2373.    *
  2374.    */
  2375.    public function drawSeries()
  2376.    {
  2377.  
  2378.       $activeRegion false;/* <--  IMPORTANT !!!! */
  2379.  
  2380.       if($this->chart->getAspect()->getView3D(&& $this->moreSameZOrder())
  2381.       {
  2382.  
  2383.          if($this->firstInZOrder())
  2384.          {
  2385.             $activeRegion false;
  2386.  
  2387.             $tmpFirst = -1;
  2388.             $tmpLast = -1;
  2389.  
  2390.             for($t $this->chart->getSeriesIndexOf($this)$t $this->chart->getSeriesCount()$t++)
  2391.             {
  2392.  
  2393.                $s $this->chart->getSeries($t);
  2394.  
  2395.                if($s->getActive(&& ($s->getZOrder(== $this->getZOrder()))
  2396.                {
  2397.                   $s->calcFirstLastVisibleIndex();
  2398.  
  2399.                   if($s->getFirstVisible(!= - 1)
  2400.                   {
  2401.                      $tmpFirst ($tmpFirst == - 1?
  2402.                      $s->getFirstVisible(:
  2403.                      max($tmpFirst,
  2404.                      $s->getFirstVisible());
  2405.                      $tmpLast ($tmpLast == - 1?
  2406.                      $s->getLastVisible(:
  2407.                      max($tmpLast$s->getLastVisible());
  2408.  
  2409.                      $s->doBeforeDrawValues();
  2410.  
  2411.                      if($this->chart->getAspect()->getClipPoints(&& (!$activeRegion))
  2412.                      {
  2413.                         $activeRegion $this->clipRegionCreate($activeRegion);
  2414.                      }
  2415.                   }
  2416.                }
  2417.             }
  2418.  
  2419.             // values
  2420.             if($tmpFirst != - 1)
  2421.             {
  2422.                if($this->drawValuesForward())
  2423.                {
  2424.                   for($t $tmpFirst$t <= $tmpLast$t++)
  2425.                   {
  2426.                      $this->drawAllSeriesValue($t);
  2427.                   }
  2428.                }
  2429.                else
  2430.                {
  2431.                   for($t $tmpLast$t >= $tmpFirst$t--)
  2432.                   {
  2433.                      $this->drawAllSeriesValue($t);
  2434.                   }
  2435.                }
  2436.             }
  2437.  
  2438.             // Finish Clipping Region
  2439.             $activeRegion $this->clipRegionDone($activeRegion);
  2440.  
  2441.             // Marks and doAfterDrawValues
  2442.             for($t 0$t $this->chart->getSeriesCount()$t++)
  2443.             {
  2444.                $s $this->chart->getSeries($t);
  2445.                if($s->getActive(&&
  2446.                ($s->getZOrder(== $this->getZOrder()) &&
  2447.                ($s->getFirstVisible(!= - 1))
  2448.                {
  2449.                   $activeRegion $this->drawMarksSeries($s$activeRegion);
  2450.                   $this->doAfterDrawValues();
  2451.                }
  2452.             }
  2453.          }
  2454.       }
  2455.       else
  2456.       {
  2457.          $this->calcFirstLastVisibleIndex();
  2458.  
  2459.          if($this->firstVisible != - 1)
  2460.          {
  2461.             $this->doBeforeDrawValues();
  2462.             if($this->useAxis && $this->chart->getAspect()->getClipPoints())
  2463.             {
  2464.                $activeRegion $this->clipRegionCreate($activeRegion);
  2465.             }
  2466.  
  2467.             $this->draw();
  2468.  
  2469.             $activeRegion $this->clipRegionDone($activeRegion);
  2470.             $activeRegion $this->drawMarksSeries($this$activeRegion);
  2471.  
  2472.             $this->doAfterDrawValues();
  2473.          }
  2474.       }
  2475.    }
  2476.  
  2477.    /**
  2478.    * Obsolete.&nbsp;Use the Series.Color method instead.
  2479.    *
  2480.    * @see Series#getColor
  2481.    * @param value Color
  2482.    */
  2483.    protected function setSeriesColor($value)
  2484.    {
  2485.       $this->setColor($value);
  2486.    }
  2487.  
  2488.    protected function canAddRandomPoints()
  2489.    {
  2490.       return true;
  2491.    }
  2492.  
  2493.    private $datasource;
  2494.  
  2495.    /**
  2496.    * Object to load data from.<br>
  2497.    * Default value: null
  2498.    *
  2499.    * @return Object 
  2500.    */
  2501.    public function getDataSource()
  2502.    {
  2503.       return $this->datasource;
  2504.    }
  2505.  
  2506.    /**
  2507.    * Object to load data from.<br>
  2508.    * Default value: null
  2509.    *
  2510.    * @param value Object
  2511.    */
  2512.    public function setDataSource($value)
  2513.    {
  2514.       if($this->datasource != $value)
  2515.       {
  2516.  
  2517.          // To protect when disposing the Data.SeriesSource component.
  2518.          if($this->datasource instanceof SeriesSource{
  2519.             $this->datasource->setSeries(null);
  2520.          }
  2521.  
  2522.          $this->datasource $value;
  2523.          if($this->datasource instanceof SeriesSource{
  2524.             $this->datasource->setSeries($this);
  2525.          }
  2526.  
  2527.          //if (! (datasource is Series)) Function=null; //CI Dec 03
  2528.          if(!($this->datasource instanceof Series&&
  2529.          // TODO                !($this->datasource instanceof Series[]) &&
  2530.          !(is_Array($this->datasource)))
  2531.          {
  2532.             $this->setFunction(null);
  2533.          }
  2534.  
  2535.          $this->checkDataSource();
  2536.       }
  2537.    }
  2538.  
  2539.    /**
  2540.    * Adds the collection of objects that implement the IList interface.
  2541.    *
  2542.    * @param list ArrayList
  2543.    */
  2544.    /* TODO    public function add($list) {
  2545.    for ( $t = 0; $t < sizeof($list); $t++) {
  2546.    $this->add($list->get($t));
  2547.    TODO review before            $this->add(($list->get($t))->doubleValue());
  2548.    }
  2549.    }  */
  2550.  
  2551.    public function getValueListNum($index)
  2552.    {
  2553.       return $this->valuesList->getValueList($index);
  2554.    }
  2555.  
  2556.    public function getValueList($name)
  2557.    {
  2558.       for($t 0$t sizeof($this->valuesList)$t++)
  2559.       {
  2560.          if($this->valuesList->getValueList($t)->name->equals($name))
  2561.          {
  2562.             return $this->valuesList->getValueList($t);
  2563.          }
  2564.       }
  2565.       return null;
  2566.    }
  2567.  
  2568.    protected function getFields($otherList)
  2569.    {
  2570.       $fieldCount 0;
  2571.  
  2572.       for($t 0$t sizeof($this->valuesList)$t++)
  2573.       {
  2574.          $v $this->valuesList->getValueList($t);
  2575.          if($v->getDataMember()->length(!= 0)
  2576.          {
  2577.             $fieldCount++;
  2578.             if($this->mandatory != $v)
  2579.             {
  2580.                $otherList $v;
  2581.             }
  2582.          }
  2583.       }
  2584.       return $fieldCount;
  2585.    }
  2586.  
  2587.    // Prevents a circular relationship between series and
  2588.    // series DataSource. Raises an exception if "dest" is already "this".
  2589.    public function checkOtherSeries($dest)/* todo throws ChartException*/
  2590.    {
  2591.       if($dest == $this)
  2592.       {
  2593.          new ChartException(Language::getString("CircularSeries"));
  2594.       }
  2595.       else
  2596.       {
  2597.          $a $dest->dataSourceArray();
  2598.          if($a != null)
  2599.          {
  2600.             for($t 0$t $a->size()$t++)
  2601.             {
  2602.                // TODO  ($a->get($t))->checkOtherSeries($this);
  2603.             }
  2604.          }
  2605.       }
  2606.    }
  2607.  
  2608.    private function fillFromDataSource()
  2609.    {
  2610.       if($this->datasource instanceof Series)
  2611.       {
  2612.          $this->addValuesFrom($this->datasource);
  2613.       }
  2614.       else
  2615.          if(is_Array($this->datasource))
  2616.          {
  2617.               $a $this->datasource;
  2618.               if(sizeof($a0)
  2619.               {
  2620.                  $o $a[0];
  2621.                  if(!($o instanceof Series))
  2622.                  {  // Array of Values
  2623.                     $this->addValues($a);
  2624.                  }
  2625.                  else
  2626.                  // Array of Series
  2627.                     $tmp $this->datasource;
  2628.                     $a Array();
  2629.                     for $t 0$t sizeof($tmp)$t++{
  2630.                       $a[$t]=$tmp[$t];
  2631.                       $this->addValues($a);
  2632.                     }
  2633.                  }
  2634.               }
  2635.               /*
  2636.             } else if ($this->datasource instanceof SeriesSource) {
  2637.             $this->datasource->refreshData();
  2638.             } else {
  2639.             if (!$this->DataSeriesSource->tryRefreshData($this)) {
  2640.  
  2641.             /** @todo THROWING HERE MAKES EXPLOSION
  2642.             //  throw new TeeChartException(
  2643.             //          "Cannot bind to non-supported datasource: " +
  2644.             //          datasource.toString());
  2645.             }             */
  2646.          }
  2647.    }
  2648.  
  2649.    /**
  2650.    * Refreshes all Series point values, either from database Tables
  2651.    * or Series points.<br>
  2652.    *
  2653.    * You can call this method regularly if you want new or modified data to
  2654.    * appear in realtime in the Series. The parent Chart will be repainted to
  2655.    * reflect any changes.
  2656.    */
  2657.    public function checkDataSource()
  2658.    {
  2659.       if($this->datasource != null)
  2660.       {
  2661.          $this->fillFromDataSource();
  2662.       }
  2663.       else
  2664.          if($this->function != null)
  2665.          {
  2666.             if($this->function->noSourceRequired)
  2667.             {// $this->For "Custom" $this->function
  2668.                $this->beginUpdate();
  2669.                $this->clear();
  2670.                $this->function->addPoints(null);
  2671.                $this->endUpdate();
  2672.             }
  2673.          }
  2674.          else
  2675.             if(!$this->manualData)
  2676.             {
  2677.                if($this->canAddRandomPoints())
  2678.                {
  2679.                   $this->fillSampleValues();
  2680.                }
  2681.             }
  2682.          //else
  2683.          //clear();
  2684.       }
  2685.  
  2686.       protected function recalcGetAxis()
  2687.       {
  2688.          if($this->chart != null)
  2689.          {
  2690.             $this->horizAxis $this->chart->getAxes()->getBottom();
  2691.  
  2692.             if($this->horizontalAxis == HorizontalAxis::$TOP)
  2693.             {
  2694.                $this->horizAxis $this->chart->getAxes()->getTop();
  2695.             }
  2696.             else
  2697.                if($this->horizontalAxis == HorizontalAxis::$CUSTOM)
  2698.                {
  2699.                   if($this->customHorizAxis != null)
  2700.                   {
  2701.                      $this->horizAxis $this->customHorizAxis;
  2702.                   }
  2703.                }
  2704.  
  2705.             $this->vertAxis $this->chart->getAxes()->getLeft();
  2706.  
  2707.             if($this->verticalAxis == VerticalAxis::$RIGHT)
  2708.             {
  2709.                $this->vertAxis $this->chart->getAxes()->getRight();
  2710.             }
  2711.             else
  2712.                if($this->verticalAxis == VerticalAxis::$CUSTOM)
  2713.                {
  2714.                   if($this->customVertAxis != null)
  2715.                   {
  2716.                      $this->vertAxis $this->customVertAxis;
  2717.                   }
  2718.                }
  2719.          }
  2720.          else
  2721.          {
  2722.             $this->horizAxis null;
  2723.             $this->vertAxis null;
  2724.          }
  2725.       }
  2726.  
  2727.       protected function added()
  2728.       {
  2729.          /* TODO review - if is not commented freeseriescolor makes a repaint which affects to the
  2730.          series->horizaxis to be null and vertaxistoo, temporary color assigned manually
  2731.          */
  2732.          $this->recalcGetAxis();
  2733.          if($this->getColor()->isEmpty())
  2734.          {
  2735.             $this->setColor($this->chart->freeSeriesColor(true));
  2736.          }
  2737.  
  2738.          $this->checkDataSource();
  2739.       }
  2740.  
  2741.       /**
  2742.       * Obsolete.&nbsp;Use the Series.Color method instead.
  2743.       * @see steema.teechart.styles.Series.Color
  2744.       *
  2745.       * @return Color 
  2746.       */
  2747.       protected function getSeriesColor()
  2748.       {
  2749.          return $this->getColor();
  2750.       }
  2751.  
  2752.       /**
  2753.       * Default color for all points.<br>
  2754.       * The TChart Series SeriesColor method is the default color in which the
  2755.       * Series points will be drawn. It could be any valid color. If you add
  2756.       * points with Color.EMPTY color, then they will be drawn with the
  2757.       * SeriesColor color. This method is the default Color associated to the
  2758.       * Series. When you place a new Series component in a Chart, TeeChart will
  2759.       * assign a free color to this method (a Color that no other Series in the
  2760.       * same Chart uses). Some Series have the ColorEach boolean property.
  2761.       * Setting this to true will force the Series to paint each point with a
  2762.       * different color, thus without using its SeriesColor.<br>
  2763.       * SeriesColor is also used to paint the small rectangle in Chart Legend.
  2764.       * <br>Default value: Color.Empty
  2765.       *
  2766.       * @see Series#getColorEach
  2767.       * @return Color 
  2768.       */
  2769.       public function getColor()
  2770.       {
  2771.          return $this->bBrush->getColor();
  2772.       }
  2773.  
  2774.       /**
  2775.       * Default color for all points.<br>
  2776.       * Default value: Color.Empty
  2777.       *
  2778.       * @see #getColorEach
  2779.       * @param value Color
  2780.       */
  2781.       public function setColor($value)
  2782.       {
  2783.          $this->bBrush->setColor($value);
  2784.          if($this->chart != null)
  2785.          {
  2786.             $tmpSeriesEventStyle new SeriesEventStyle();
  2787.             // TODO       $this->chart->broadcastEvent($this, $tmpSeriesEventStyle->CHANGECOLOR);
  2788.          }
  2789.       }
  2790.  
  2791.       /**
  2792.       * Shows or hides this series.<br>
  2793.       * It can be changed both at design time or runtime. When hiding, all point
  2794.       * values are preserved, so there's no need to refill the values again
  2795.       * when showing them. The Series relatives Chart Axis are rescaled in order
  2796.       * to accomodate changes.
  2797.       *
  2798.       * @return boolean 
  2799.       */
  2800.       public function getActive()
  2801.       {
  2802.          return $this->bActive;
  2803.       }
  2804.  
  2805.       /**
  2806.       * Shows or hides this series.<br>
  2807.       * It can be changed both at design time or runtime. When hiding, all point
  2808.       * values are preserved, so there's no need to refill the values again
  2809.       * when showing them. The Series relatives Chart Axis are rescaled in order
  2810.       * to accomodate changes.
  2811.       *
  2812.       * @param value boolean
  2813.       */
  2814.       public function setActive($value)
  2815.       {
  2816.          $this->bActive = $this->setBooleanProperty($this->bActive$value);
  2817.          if($this->chart != null)
  2818.          {
  2819.             $tmpSeriesEventStyle new SeriesEventStyle();
  2820.             // TODO     $this->chart->broadcastEvent($this, $tmpSeriesEventStyle->CHANGEACTIVE);
  2821.          }
  2822.       }
  2823.  
  2824.       /**
  2825.       * Exchanges one point with another. Also the point color and point label.
  2826.       *
  2827.       * @param int index of first point to exchange.
  2828.       * @param int index of second point to exchange.
  2829.       */
  2830.       protected function swapValueIndex($a$b)
  2831.       {
  2832.          for($t 0$t sizeof($this->valuesList)$t++)
  2833.          {
  2834.             $v $this->valuesList->getValueList($t);
  2835.             $v->exchange($a$b);
  2836.          }
  2837.  
  2838.          if($this->iColors != null)
  2839.          {
  2840.             $this->iColors->exchange($a$b);
  2841.          }
  2842.          if($this->sLabels != null)
  2843.          {
  2844.               /* $this->sLabels->exchange($a, $b); */
  2845.               // Exchange Array
  2846.               $c=$this->sLabels[$a];
  2847.               $this->sLabels[$a]=$this->sLabels[$b];
  2848.               $this->sLabelx[$b]=$c;
  2849.          }
  2850.       }
  2851.  
  2852.       public function getValueIndexSwapper()
  2853.       {
  2854.          /* todo        return new Swapper() {
  2855.          public function swap($a, $b) {
  2856.          $this->swapValueIndex($a, $b);
  2857.          }
  2858.          };*/
  2859.       }
  2860.  
  2861.       /**
  2862.       * Series description to show in Legend and dialogs.<br>
  2863.       * Every Series has a Title method of type String. It is used in
  2864.       * TChart.Legend to draw the series descriptions. If Title is empty,
  2865.       * then the Series class Name will be used to draw the legend. Setting
  2866.       * Title both at design time and runtime will force the Chart to repaint.
  2867.       * <br>Default value: ""
  2868.       *
  2869.       * @return String 
  2870.       */
  2871.       public function getTitle()
  2872.       {
  2873.          return $this->title;
  2874.       }
  2875.  
  2876.       /**
  2877.       * Series description to show in Legend and dialogs.<br>
  2878.       * Default value: ""
  2879.       *
  2880.       * @param value String
  2881.       */
  2882.       public function setTitle($value)
  2883.       {
  2884.          $this->title $this->setStringProperty($this->title$value);
  2885.          if($this->chart != null)
  2886.          {
  2887. /* todo            $tmpSeriesEventStyle = new SeriesEventStyle();
  2888.             $this->chart->broadcastEvent($this, $tmpSeriesEventStyle->CHANGETITLE);
  2889. */
  2890.          }
  2891.       }
  2892.  
  2893.       public function onDisposing(}
  2894.  
  2895.       public function setChart($value)
  2896.       {
  2897.  
  2898.          if($this->chart != $value)
  2899.          {
  2900.             if($this->chart != null)
  2901.             {
  2902.                $this->chart->removeSeries($this);
  2903.             }
  2904.  
  2905.             parent::setChart($value);
  2906.  
  2907.             $this->bBrush->setChart($this->chart);
  2908.  
  2909.             if($this->chart != null)
  2910.             {
  2911.                $this->chart->addSeries($this);
  2912.                $this->added();
  2913.             }
  2914.  
  2915.             if($this->marks != null)
  2916.             {
  2917.                $this->marks->iSeries $this;
  2918.                $this->marks->setChart($this->chart);
  2919.                $this->marks->getCallout()->setChart($this->chart);
  2920.             }
  2921.  
  2922.             if($this->function != null)
  2923.             {
  2924.                $this->function->setChart($this->chart);
  2925.             }
  2926.  
  2927.             if($this->chart != null)
  2928.             {
  2929.                $this->chart->invalidate();
  2930.             }
  2931.  
  2932.             for($t 0$t sizeof($this->valuesList)$t++)
  2933.             {
  2934.                $this->valuesList->getValueList($t)->series $this;
  2935.                $this->valuesList->getValueList($t)->setChart($this->chart);
  2936.             }
  2937.          }
  2938.       }
  2939.  
  2940.       protected function setHorizontal()
  2941.       {
  2942.          $this->mandatory = $this->vxValues;
  2943.          $this->notMandatory = $this->vyValues;
  2944.          $this->yMandatory = false;
  2945.       }
  2946.  
  2947.       /**
  2948.       * Adds new point with specified DateTime x and Double y values.
  2949.       *
  2950.       * @see ValueList
  2951.       * @param DateTime
  2952.       * @param double
  2953.       * @return int index of added point
  2954.       */
  2955.  
  2956.       // TODO add datatime
  2957.       /*    public function add($x, $y) {
  2958.       $this->vxValues->dateTime = true;
  2959.       return $this->add($x->toDouble(), $y);
  2960.       }
  2961.  
  2962.       *//**
  2963.       * @see ValueList
  2964.       *
  2965.       * @param DateTime
  2966.       * @param DateTime
  2967.       * @return int index of added point
  2968.       */
  2969.       /* todo public function add($x, $y) {
  2970.       $this->vxValues->dateTime = true;
  2971.       $this->vyValues->dateTime = true;
  2972.       return $this->add($x->toDouble(), $y->toDouble());
  2973.       }       */
  2974.  
  2975.       /**
  2976.       * Adds new point with specified DateTime x, Double y values and Color.
  2977.       * @see ValueList
  2978.       *
  2979.       * @param DateTime
  2980.       * @param double
  2981.       * @param Color
  2982.       * @return int index of added point
  2983.       */
  2984.       /* TODO public function add($x, $y, $c) {
  2985.       $this->vxValues->dateTime = true;
  2986.       return $this->add($x->toDouble(), $y, $c);
  2987.       }
  2988.       */
  2989.       /**
  2990.       * Adds new point with specified DateTime x, Double y values and Text.
  2991.       * @see ValueList
  2992.       *
  2993.       * @param DateTime
  2994.       * @param double
  2995.       * @param text String
  2996.       * @return int index of added point
  2997.       */
  2998.       /* TODO    public function add($x, $y, $text) {
  2999.       $this->vxValues->dateTime = true;
  3000.       return $this->add($x->toDouble(), $y, $text);
  3001.       }
  3002.       */
  3003.  
  3004.       /**
  3005.       * Obsolete.&nbsp;Please use add(x,y,Color.<!-- -->Transparent)
  3006.       * method instead.
  3007.       *
  3008.       * @param double
  3009.       * @param double
  3010.       * @return int 
  3011.       */
  3012.       public function addNullXY($x$y)
  3013.       {
  3014.          $tmpColor new Color(000127);// TRANSPARENT
  3015.          return $this->add($x$y$tmpColor);
  3016.       }
  3017.  
  3018.       /**
  3019.       * Obsolete.&nbsp;Please use add() method without parameters instead.
  3020.       *
  3021.       * @return int 
  3022.       */
  3023.       public function addNull()
  3024.       {
  3025.          return $this->add();
  3026.       }
  3027.  
  3028.       /**
  3029.       * Adds a new point with specified value.
  3030.       *
  3031.       * @param value int
  3032.       * @return int 
  3033.       */
  3034.       public function add($value "null")
  3035.       {
  3036.          if($value == "null"{
  3037.             $tmpColor new Color(0,0,0,127);// TRANSPARENT
  3038.             return $this->addYColor(0$tmpColor);
  3039.          }
  3040.          else {
  3041.             if($this->yMandatory{
  3042.                return $this->addXY($this->getCount()$value);
  3043.             }
  3044.             else {
  3045.                return $this->addXY($value$this->getCount());
  3046.             }
  3047.          }
  3048.       }
  3049.  
  3050.       /**
  3051.       * Adds a new point with specified value.
  3052.       *
  3053.       * @param value double
  3054.       * @return int 
  3055.       */
  3056.       /* TODO public function add($value) {
  3057.       if ($this->yMandatory) {
  3058.       return $this->add($this->getCount(), $value);
  3059.       } else {
  3060.       return $this->add($value, $this->getCount());
  3061.       }
  3062.       }       */
  3063.  
  3064.       /**
  3065.       * Adds a new point with specified value.
  3066.       *
  3067.       * @param value float
  3068.       * @return int 
  3069.       */
  3070.       /* TODO    public function add($value) {
  3071.       return $this->add(($this->double) $value);
  3072.       }
  3073.       */
  3074.       /**
  3075.       * Adds a new point with specified value and text.
  3076.       *
  3077.       * @param value double
  3078.       * @param text String
  3079.       * @return int 
  3080.       */
  3081.       public function addYText($value$text)
  3082.       {
  3083.          if($this->yMandatory{
  3084.             return $this->addXYText($this->getCount()$value$text);
  3085.          }
  3086.          else {
  3087.             return $this->addXYText($value$this->getCount()$text);
  3088.          }
  3089.       }
  3090.  
  3091.       /**
  3092.       * Adds a new point with specified x and y values.
  3093.       *
  3094.       * @param double
  3095.       * @param double
  3096.       * @return int 
  3097.       */
  3098.       public function addXY($x$y)
  3099.       {
  3100.          $tmp $this->vxValues->addChartValue($x);
  3101.          $this->vyValues->insertChartValue($tmp$y);
  3102.  
  3103.          $listsCount sizeof($this->valuesList);
  3104.          if($listsCount 2)
  3105.          {
  3106.             for($t 2$t $listsCount$t++{
  3107.                $v $this->valuesList->getValueList($t);
  3108.                $v->insertChartValue($tmp$v->tempValue);
  3109.             }
  3110.          }
  3111.  
  3112.          if($this->updating == 0{
  3113.             $this->invalidate();
  3114.          }
  3115.  
  3116.          return $tmp;
  3117.       }
  3118.  
  3119.       /**
  3120.       * Adds the pair of floating point x- and y-pixel coordinates
  3121.       *
  3122.       * @param Double
  3123.       * @return int 
  3124.       */
  3125.       /*todo    public function add($p) {
  3126.       return $this->add($p->x, $p->y);
  3127.       } */
  3128.  
  3129.       /**
  3130.       * Adds a new point with specified x,y values and text.
  3131.       *
  3132.       * @param double
  3133.       * @param double
  3134.       * @param text String
  3135.       * @return int 
  3136.       */
  3137.       public function addXYText($x$y$text)
  3138.       {
  3139.          $tmpColor new Color(0000true);// EMPTY
  3140.          return $this->addXYTextColor($x$y$text$tmpColor);
  3141.       }
  3142.  
  3143.       /**
  3144.       * Adds a new point with specified x,y values, text and color.
  3145.       *
  3146.       * @param double
  3147.       * @param double
  3148.       * @param text String
  3149.       * @param color Color
  3150.       * @return int 
  3151.       */
  3152.       public function addXYTextColor($x$y$text=""$color=null)
  3153.       {
  3154.          $tmp $this->addXY($x$y);
  3155.  
  3156.          if ($color!=null{
  3157.            if(!($color->isEmpty())) {
  3158.               $this->getColors()->setColor($tmp$color);
  3159.            }
  3160.          }
  3161.  
  3162.          if(($text != null))
  3163.          {
  3164.             if($this->getXValues()->getOrder(== ValueListOrder::$NONE)
  3165.             {
  3166.                $this->sLabels[sizeof($this->sLabels)]=$text;
  3167.             }
  3168.             else if(strlen($text!= 0)
  3169.             {
  3170.                $this->sLabels[$tmp$text;
  3171.             }
  3172.          }
  3173.          return $tmp;
  3174.       }
  3175.  
  3176.       /**
  3177.       * Adds a new Datetime point to a Series, label and color.
  3178.       *
  3179.       * @param aDate DateTime datetime value
  3180.       * @param double
  3181.       * @param text String point text
  3182.       * @param color Color
  3183.       * @return int index of added point
  3184.       */
  3185.       /* TODO    public function add($aDate, $y, $text, $color) {
  3186.       $this->vxValues->dateTime = true;
  3187.       return $this->add($aDate->toDouble(), $y, $text, $color);
  3188.       }  */
  3189.  
  3190.       /**
  3191.       * Adds a new point with specified x and y values and color.
  3192.       *
  3193.       * @param double
  3194.       * @param double
  3195.       * @param color Color
  3196.       * @return int 
  3197.       */
  3198.       public function addXYColor($x$y$color)
  3199.       {
  3200.          return $this->addXYTextColor($x$y""$color);
  3201.       }
  3202.  
  3203.       /**
  3204.       * Adds a new point with specified value, text and color.
  3205.       *
  3206.       * @param value double
  3207.       * @param text String
  3208.       * @param color Color
  3209.       * @return int 
  3210.       */
  3211.       public function addYTextColor($value$text$color)
  3212.       {
  3213.          if($this->yMandatory)
  3214.          {
  3215.             return $this->addXYTextColor($this->getCount()$value$text$color);
  3216.          }
  3217.          else
  3218.          {
  3219.             return $this->addXYTextColor($value$this->getCount()$text$color);
  3220.          }
  3221.       }
  3222.  
  3223.       /**
  3224.       * Adds a new point with specified value and color.
  3225.       *
  3226.       * @param value double
  3227.       * @param color Color
  3228.       * @return int 
  3229.       */
  3230.       public function addYColor($value$color)
  3231.       {
  3232.          if($this->yMandatory)
  3233.          {
  3234.             return $this->addXYColor($this->getCount()$value$color);
  3235.          }
  3236.          else
  3237.          {
  3238.             return $this->addXYColor($value$this->getCount()$color);
  3239.          }
  3240.       }
  3241.  
  3242.       /**
  3243.       * Adds a new null point with specified text.
  3244.       *
  3245.       * @param text String
  3246.       * @return int 
  3247.       */
  3248.       public function addText($text)
  3249.       {
  3250.          $tmpColor new Color(000127);// Transparent
  3251.          return $this->addYTextColor(0$text$tmpColor);
  3252.       }
  3253.  
  3254.       /**
  3255.       * Adds all points in source Series.
  3256.       *
  3257.       * @param source Series
  3258.       */
  3259.       //[Description("Adds all points in source Series.")]
  3260.       /* tODO    public function add($source) {
  3261.       $this->addValuesFrom($source);
  3262.       }  */
  3263.  
  3264.       protected function convertArray($a$numPoints)
  3265.       {
  3266.          /*double[]*/$tmpArray null;
  3267.  
  3268.          //        if (a instanceof DateTime[]) {
  3269.          //            tmpArray = new double[numPoints];
  3270.          //            int max = a.size();
  3271.          //            for (int i = 0; i <= max; i++) {
  3272.          //                tmpArray[i] = (DateTime) a.get(i);
  3273.          //            }
  3274.          //        } else if ((a instanceof int[]) || (a instanceof float[]) ||
  3275.          //                   (a instanceof Decimal[])) {
  3276.          //            tmpArray = new double[numPoints];
  3277.          //            a.CopyTo(tmpArray, 0);
  3278.          //        } else if (a instanceof double[]) {
  3279.          //            tmpArray = (double[]) a;
  3280.          //        }
  3281.  
  3282.          return $this->tmpArray;
  3283.       }
  3284.  
  3285.       /**
  3286.       * Adds the X and Y arrays.
  3287.       *
  3288.       * @param xValues ArrayList
  3289.       * @param yValues ArrayList
  3290.       */
  3291.       /* TODO    public function add($xValues, $yValues) {
  3292.       $numPoints = $yValues->size();
  3293.       $this->getXValues()->count = $numPoints;
  3294.       $this->getXValues()->value = $this->convertArray($xValues, $numPoints);
  3295.       $this->getYValues()->count = $numPoints;
  3296.       $this->getYValues()->value = $this->convertArray($yValues, $numPoints);
  3297.       $this->getXValues()->statsOk = false;
  3298.       $this->getYValues()->statsOk = false;
  3299.       $this->invalidate();
  3300.       }
  3301.       */
  3302.       /**
  3303.       * Adds the array of double values.
  3304.       *
  3305.       * @param values double[]
  3306.       */
  3307.       public function addArray($values)
  3308.       {
  3309.          for($t 0$t sizeof($values)$t++)
  3310.             $this->add($values[$t]);
  3311.       }
  3312.  
  3313.       /**
  3314.       * Adds the array of float values.
  3315.       *
  3316.       * @param values float[]
  3317.       */
  3318.       /*    public function add($values) {
  3319.       for ( $t = 0; $t < $values->length; $t++) {
  3320.       $this->add($values[$t]);
  3321.       }
  3322.       }
  3323.       */
  3324.       /**
  3325.       * Adds the array of integer values.
  3326.       *
  3327.       * @param values int[]
  3328.       */
  3329.       /* TODO    public function add($values) {
  3330.       for ( $t = 0; $t < $values->length; $t++) {
  3331.       $this->add($values[$t]);
  3332.       }
  3333.       }
  3334.       */
  3335.       public function checkMouse($c$x$y)
  3336.       {
  3337.          $r new MouseClicked($cfalse);
  3338.  
  3339.          $tmpCursors new Cursors();
  3340.          if(($this->getCursor(!= $tmpCursors->DEFAULT||
  3341.          ($this->hasListenersOf($this->SeriesMouseListener->class)))
  3342.          {
  3343.             if($this->clicked($x$y!= - 1)
  3344.             {
  3345.                if($this->getCursor(!= $tmpCursors->DEFAULT)
  3346.                {
  3347.                   $r->cursor $this->getCursor();
  3348.                }
  3349.  
  3350.                if(!$this->isMouseInside)
  3351.                {
  3352.                   $this->isMouseInside true;
  3353.                   $tmpSeriesMouseEvent new SeriesMouseEvent();
  3354.                   $this->fireSeriesMouseEvent(new SeriesMouseEvent($this,
  3355.                         $tmpSeriesMouseEvent->SERIES_ENTERED1,
  3356.                         new TeePoint($x$y)));
  3357.                }
  3358.  
  3359.                $r->clicked true;
  3360.             }
  3361.             else
  3362.             {
  3363.                if($this->isMouseInside)
  3364.                {
  3365.                   $this->isMouseInside false;
  3366.                   $this->fireSeriesMouseEvent(new $tmpSeriesMouseEvent(this ,
  3367.                         $tmpSeriesMouseEvent->SERIES_EXITED1,
  3368.                         new TeePoint($x$y)));
  3369.                }
  3370.             }
  3371.          }
  3372.          return $r;
  3373.       }
  3374.  
  3375.       /**
  3376.       * Reorders points according to Order property of X,Y,etc value lists.<br>
  3377.       * Refreshes sort order of Series points if Order type of XValues or
  3378.       * YValues is not loNone.
  3379.       */
  3380.       public function checkOrder()
  3381.       {
  3382.          if ($this->mandatory->getOrder(!= ValueListOrder::$NONE)
  3383.          {
  3384.             $this->mandatory->sort();
  3385.  
  3386.             // if NotMandatory list has a ValueSource, do not call FillSequence
  3387.             if($this->notMandatory->valueSource->length(== 0)
  3388.             {
  3389.                $this->notMandatory->fillSequence();
  3390.             }
  3391.             $this->repaint();
  3392.          }
  3393.       }
  3394.  
  3395.       /**
  3396.       * Removes all points, texts and Colors from the Series.<br>
  3397.       * Dependent Series are notified. If no new points are appended to the
  3398.       * Series, nothing will be painted.
  3399.       */
  3400.       public function clear()
  3401.       {
  3402.          $this->clearLists();
  3403.          if($this->updating == 0)
  3404.          {
  3405.             $this->invalidate();
  3406.          }
  3407.       }
  3408.  
  3409.       protected function clearLists()
  3410.       {
  3411.          // Values
  3412.          for($t 0$t sizeof($this->valuesList)$t++)
  3413.          {
  3414.             $this->valuesList->getValueList($t)->clear();
  3415.          }
  3416.          if($this->sLabels != null)
  3417.          {
  3418.             $this->sLabelsArray();
  3419.          }
  3420.          if($this->iColors != null)
  3421.          {
  3422.             unset($this->iColors);// Clears the array
  3423.          }
  3424.          if($this->marks != null)
  3425.          {
  3426.             $this->marks->clear();
  3427.          }
  3428.       }
  3429.  
  3430.       public function clicked($p)
  3431.       {
  3432.          return $this->clicked($p->x$p->y);
  3433.       }// $this->abstract
  3434.  
  3435.       /**
  3436.       * Returns the ValueIndex of the "clicked" point in the Series.<br>
  3437.       * Clicked means the X and Y coordinates are in the point screen region
  3438.       * bounds. If no point is "touched", Clicked returns -1
  3439.       *
  3440.       * @param int
  3441.       * @param int
  3442.       * @return int 
  3443.       */
  3444.       /* tODO    public function clicked($x, $y) {
  3445.       return -1;
  3446.       } // $this->abstract
  3447.       */
  3448.       /**
  3449.       * Returns the number of points in the Series.
  3450.       *
  3451.       * @return int 
  3452.       */
  3453.       public function getCount()
  3454.       {
  3455.          return $this->mandatory->count;
  3456.       }
  3457.  
  3458.       /**
  3459.       * Removes the index th point.<br>
  3460.       * X values remain unchanged.<br>
  3461.       * The Chart will be automatically redrawn. <br>
  3462.       * Dependent Series will be recalculated.
  3463.       *
  3464.       * @param index int
  3465.       */
  3466.       public function delete($index)
  3467.       {
  3468.          $this->vxValues->removeAt($index);
  3469.          $this->vyValues->removeAt($index);
  3470.          if(($this->sLabels != null&&
  3471.          (sizeof($this->sLabels$index))
  3472.          {
  3473.             $this->sLabels->remove($index);
  3474.          }
  3475.          if(($this->iColors != null&&
  3476.          ($this->iColors->size($index))
  3477.          {
  3478.             $this->iColors->remove($index);
  3479.          }
  3480.          if($this->marks != null)
  3481.          {
  3482.             if($this->marks->getPositions()->size($index)
  3483.             {
  3484.                $this->marks->getPositions()->remove($index);
  3485.             }
  3486.             if($this->marks->getItems()->size($index)
  3487.             {
  3488.                $this->marks->getItems()->remove($index);
  3489.             }
  3490.          }
  3491.          if($this->updating == 0)
  3492.          {
  3493.             $this->invalidate();
  3494.          }
  3495.       }
  3496.  
  3497.       /**
  3498.       * Removes count number of points starting at index.<br>
  3499.       * When RemoveGap parameter is true, it calls ValueList FillSequence.<br>
  3500.       * The Chart will be automatically redrawn. <br>
  3501.       * Dependent Series will be recalculated.
  3502.       *
  3503.       * @param index int
  3504.       * @param count int
  3505.       * @param removeGap boolean
  3506.       */
  3507.       /* TODO    public function delete($index, $count, $removeGap) {
  3508.       $this->vxValues->removeRange($index, $count);
  3509.       $this->vyValues->removeRange($index, $count);
  3510.       if (($this->sLabels != null) &&
  3511.       ($this->sLabels->size() > $index + $count - 1)) {
  3512.       $this->sLabels->removeRange($index, $count);
  3513.       }
  3514.       if (($this->iColors != null) &&
  3515.       ($this->iColors->getCount() > $index + $count - 1)) {
  3516.       $this->iColors->removeRange($index, $count);
  3517.       }
  3518.       if (($this->marks != null) &&
  3519.       ($this->marks->getPositions()->size() >
  3520.       $index + $count - 1)) {
  3521.       $this->marks->getPositions()->removeRange($index, $count);
  3522.       }
  3523.       if ($removeGap) {
  3524.       $this->notMandatory->fillSequence();
  3525.       }
  3526.       if ($this->updating == 0) {
  3527.       $this->invalidate();
  3528.       }
  3529.       }
  3530.  
  3531.       public function delete($index, $count) {
  3532.       $this->delete($index, $count, false);
  3533.       }
  3534.       */
  3535.       protected function randomBounds($numValues)
  3536.       {
  3537.          $minX=0.0;
  3538.          $maxX=0.0;
  3539.  
  3540.          $result new SeriesRandom();
  3541.  
  3542.          $result->MinY 0;
  3543.          $maxY 1000;
  3544.  
  3545.          if(($this->chart != null&&
  3546.          ($this->chart->getMaxValuesCount(0))
  3547.          {
  3548.             $result->MinY $this->chart->getMinYValue($this->vertAxis);
  3549.             $maxY $this->chart->getMaxYValue($this->vertAxis);
  3550.  
  3551.             if($maxY == $result->MinY)
  3552.             {
  3553.                if($maxY == 0)
  3554.                {
  3555.                   $maxY 1000;
  3556.                }
  3557.                else
  3558.                {
  3559.                   $maxY 2.0 $result->MinY;
  3560.                }
  3561.             }
  3562.  
  3563.             $minX $this->chart->getMinXValue($this->horizAxis);
  3564.             $maxX $this->chart->getMaxXValue($this->horizAxis);
  3565.  
  3566.             if($maxX == $minX)
  3567.             {
  3568.                if($maxX == 0)
  3569.                {
  3570.                   $maxX $numValues;
  3571.                }
  3572.                else
  3573.                {
  3574.                   $maxX 2.0 $minX;
  3575.                }
  3576.             }
  3577.  
  3578.             if(!$this->yMandatory)
  3579.             {
  3580.                $tmp $minX;
  3581.                $minX $result->MinY;
  3582.                $result->MinY $tmp;
  3583.  
  3584.                $tmp $maxX;
  3585.                $maxX $maxY;
  3586.                $maxY $tmp;
  3587.             }
  3588.          }
  3589.          else
  3590.          {
  3591.             if($this->vxValues->getDateTime())
  3592.             {
  3593.                $minX gettimeofday(true)// get Now as double
  3594.                $maxX $minX $numValues 1;
  3595.             }
  3596.             else
  3597.             {
  3598.                $minX 0;
  3599.                $maxX $numValues 1;
  3600.             }
  3601.          }
  3602.  
  3603.          $NEGATIVE_INFINITY =intval('-1000000000000');
  3604.  
  3605.          if (bccomp($NEGATIVE_INFINITY$result->MinY== 0{
  3606.             $result->MinY 0;
  3607.          }
  3608.  
  3609.          if (bccomp($NEGATIVE_INFINITY$minX== 0{
  3610.             $minX 0;
  3611.          }
  3612.  
  3613.          if (bccomp($NEGATIVE_INFINITY$maxY== 0{
  3614.             $maxY 0;
  3615.          }
  3616.  
  3617.          if (bccomp($NEGATIVE_INFINITY$maxX== 0{
  3618.             $maxX 0;
  3619.          }
  3620.  
  3621.          $result->StepX $maxX $minX;
  3622.          if($numValues 1)
  3623.          {
  3624.             $result->StepX /= ($numValues 1);
  3625.          }
  3626.          $result->DifY $maxY $result->MinY;
  3627.  
  3628.          $MAX_VALUE intval('1000000000000');
  3629.  
  3630.          if($result->DifY $MAX_VALUE)
  3631.          {
  3632.             $result->DifY $MAX_VALUE;
  3633.          }
  3634.          else
  3635.             if($result->DifY < - $MAX_VALUE)
  3636.             {
  3637.                $result->DifY = -$MAX_VALUE;
  3638.             }
  3639.  
  3640.          $result->tmpY $result->MinY +
  3641.          $result->DifY $result->Random();
  3642.          $result->tmpX $minX;
  3643.  
  3644.          return $result;
  3645.       }
  3646.  
  3647.       public function getNumSampleValues()
  3648.       {
  3649.          return $this->numSampleValues();
  3650.       }
  3651.  
  3652.       protected function numSampleValues()
  3653.       {
  3654.          return 25;
  3655.       }
  3656.  
  3657.       protected function addSampleValues($numValues)
  3658.       {
  3659. //  TODO remove old        $this->chart->setAutoRepaint(false);
  3660.  
  3661.          $s $this->randomBounds($numValues);
  3662.          $tmpH MathUtils::round($s->DifY 25);
  3663.  
  3664.          for($t 1$t <= $numValues$t++)
  3665.          {
  3666.         //    $s->tmpY = abs($s->tmpY + $tmpH * $s->Random() - ($tmpH / 2));  //TODO review
  3667.             $s->tmpY $s->Random();
  3668.  
  3669.             if($this->yMandatory)
  3670.             {
  3671.                $this->addXY($s->tmpX$s->tmpY);
  3672.             }
  3673.             else
  3674.             {
  3675.                $this->addXY($s->tmpY$s->tmpX);
  3676.             }
  3677.  
  3678.             $s->tmpX += $s->StepX;
  3679.          }
  3680.  
  3681. //  TODO remove old       $this->chart->setAutoRepaint(true);
  3682.       }
  3683.  
  3684.       /**
  3685.       * Adds the specified NumValues random points.
  3686.       *
  3687.       * @param numValues int the number of sample values to add.
  3688.       */
  3689.       public function fillSampleValues($numValues = -1)
  3690.       {
  3691.          if($numValues == - 1)
  3692.             $numValues $this->getNumSampleValues();
  3693.  
  3694.          if($numValues == 0)
  3695.          {
  3696.             $numValues $this->iNumSampleValues;
  3697.             if($numValues <= 0)
  3698.             {
  3699.                $numValues $this->getNumSampleValues();
  3700.             }
  3701.          }
  3702.  
  3703.          $this->clear();
  3704.  
  3705.          $this->beginUpdate();
  3706.          $this->addSampleValues($numValues);
  3707.          $this->checkOrder();
  3708.          $this->endUpdate();
  3709.  
  3710.          $this->manualData = false;
  3711.       }
  3712.  
  3713.       /**
  3714.       * Returns true if the index th point in the Series is "null" or "empty".
  3715.       * <br>
  3716.       * A point is considered "null" when the color of that point is
  3717.       * "Transparent".
  3718.       *
  3719.       * @param index int the point index.
  3720.       * @return boolean true if the point color is Color.Transparent
  3721.       */
  3722.       public function isNull($index)
  3723.       {
  3724.          return($this->iColors != null&&
  3725.          ($this->iColors->getCount($index&& $this->iColors->getColor($index)->isNull();
  3726.       }
  3727.  
  3728.       /**
  3729.       * Validates Series datasource.<br>
  3730.       * The isValidSourceOf function returns false if the Value parameter is the
  3731.       * same as Self. <br>
  3732.       * It's used to validate the DataSource property both at design and
  3733.       * run-time.
  3734.       *
  3735.       * @param value Series the series to validate.
  3736.       * @return boolean true if value can be a Series data source.
  3737.       */
  3738.       public function isValidSourceOf($value)
  3739.       {
  3740.          return $this !== $value;
  3741.       }
  3742.  
  3743.       protected function isValidSeriesSource($value)
  3744.       {
  3745.          return true;
  3746.       }
  3747.  
  3748.       /**
  3749.       * Function object to calculate values.<br>
  3750.       * Default value: null
  3751.       *
  3752.       * @return Function 
  3753.       */
  3754.       public function getFunction()
  3755.       {
  3756.          return $this->function;
  3757.       }
  3758.  
  3759.       public function setFunction($value)
  3760.       {
  3761.          $b $this->function === $value;
  3762.  
  3763.          if($b==false)
  3764.          {
  3765.             // if (function!=null) function.Dispose();
  3766.  
  3767.             $this->function $value;
  3768.             if($this->function != null)
  3769.             {
  3770.                $this->function->setSeries($this);
  3771.             }
  3772.             $this->checkDataSource();
  3773.          }
  3774.       }
  3775.  
  3776.       /**
  3777.       * The Depth of the series points or interconnecting lines.<br>
  3778.       * Default value: -1
  3779.       *
  3780.       * @return int 
  3781.       */
  3782.       public function getDepth()
  3783.       {
  3784.          return $this->depth;
  3785.       }
  3786.  
  3787.       /**
  3788.       * Sets the Depth of the series points or interconnecting lines.<br>
  3789.       * Default value: -1
  3790.       *
  3791.       * @param value int
  3792.       */
  3793.       public function setDepth($value)
  3794.       {
  3795.          $this->depth $this->setIntegerProperty($this->depth$value);
  3796.       }
  3797.  
  3798.       /**
  3799.       * Determines where on the depth axis the Series is drawn.<br><br>
  3800.       * Read-only and run time. <br><br>
  3801.       * It's valid only when TChart.Aspect.View3D is true and when there's more
  3802.       * than one Series in the same chart. <br>
  3803.       * You can't alter the ZOrder property directly. If you want a different
  3804.       * order, you need to use tChart.SeriesList instead.<br>
  3805.       * The ZOrder property is calculated for each Series just before the
  3806.       * Chart is drawn. <br>
  3807.       * TChart.ApplyZOrder controls if Series will be assigned a different
  3808.       * Z position or not. When False, all Series are drawn at same Z plane.<br>
  3809.       * TChart.MaxZOrder returns the highest of all Series ZOrder values. <br>
  3810.       * Default value: AutoZOrder
  3811.       *
  3812.       * @return int 
  3813.       */
  3814.       public function getZOrder()
  3815.       {
  3816.          return($this->zOrder == self::$AUTOZORDER$this->iZOrder :
  3817.          $this->zOrder;
  3818.       }
  3819.  
  3820.       /**
  3821.       * Determines where on the depth axis the Series is drawn.<br><br>
  3822.       * Default value: AutoZOrder
  3823.       *
  3824.       * @param value int
  3825.       */
  3826.       public function setZOrder($value)
  3827.       {
  3828.          $this->zOrder $this->setIntegerProperty($this->zOrder$value);
  3829.          $this->iZOrder = ($this->zOrder == self::$AUTOZORDER:
  3830.          $this->zOrder;
  3831.       }
  3832.  
  3833.       /**
  3834.       * Displays this Series Title in Legend.<br>
  3835.       * It is only meaningful when LegendStyle is Series or LastValues. <br>
  3836.       * Default value: true
  3837.       *
  3838.       * @return boolean 
  3839.       */
  3840.       public function getShowInLegend()
  3841.       {
  3842.          return $this->showInLegend;
  3843.       }
  3844.  
  3845.       /**
  3846.       * Displays this Series Title in Legend.<br>
  3847.       * Default value: true
  3848.       *
  3849.       * @param value boolean
  3850.       */
  3851.       public function setShowInLegend($value)
  3852.       {
  3853.          $this->showInLegend $this->setBooleanProperty($this->showInLegend$value);
  3854.       }
  3855.  
  3856.       /**
  3857.       * Returns the index of the Series' first visible point.
  3858.       *
  3859.       * @return int 
  3860.       */
  3861.       public function getFirstVisible()
  3862.       {
  3863.          return $this->firstVisible;
  3864.       }
  3865.  
  3866.       /**
  3867.       * Returns the index of the Series' last visible point.
  3868.       *
  3869.       * @return int 
  3870.       */
  3871.       public function getLastVisible()
  3872.       {
  3873.          return $this->lastVisible;
  3874.       }
  3875.  
  3876.       /**
  3877.       * Cursor displayed when mouse is over a series point.<br>
  3878.       * Each Series determines the intersection of points with mouse coordinates
  3879.       * each time the mouse moves. There are many different Cursors available.
  3880.       * The Series ZOrder determines the order in which Series will be examined
  3881.       * to calculate the clicked Series point. <br>
  3882.       * Default value: default
  3883.       *
  3884.       * @return Cursor 
  3885.       */
  3886.       public function getCursor()
  3887.       {
  3888.          return $this->cursor;
  3889.       }
  3890.  
  3891.       /**
  3892.       * Cursor displayed when mouse is over a series point.<br>
  3893.       * Default value: default
  3894.       *
  3895.       * @param value Cursor
  3896.       */
  3897.       public function setCursor($value)
  3898.       {
  3899.          $this->cursor $value;
  3900.       }
  3901.  
  3902.       /**
  3903.       * Defines how to draw a mark near to each Series point.<br>
  3904.       * A mark consist of a colored rectangle with a text string on it and a
  3905.       * line that indicates which points corresponds to which mark. <br>
  3906.       * Each different Series type draws it's marks differently. <br>
  3907.       *
  3908.       * @return SeriesMarks 
  3909.       */
  3910.       public function getMarks()
  3911.       {
  3912.          if($this->marks == null)
  3913.          {
  3914.             $this->marks = new SeriesMarks($this)// delayed creation
  3915.             $this->marks->setZPosition($this->middleZ);
  3916.          }
  3917.          return $this->marks;
  3918.       }
  3919.  
  3920.       /**
  3921.       * Returns whether Series draws its points in ascending/descending order.
  3922.       * <br>Some Series need to draw their points in descending order (starting
  3923.       * from the last point to the first) depending on certain situations.
  3924.       * For example, when the horizontal axis Inverted property is True. <br>
  3925.       *
  3926.       * @return boolean true if values in this series are displayed forward,
  3927.       *  from 0 to Count-1.
  3928.       */
  3929.       public function drawValuesForward()
  3930.       {
  3931.          $result true;
  3932.          if($this->mandatory === $this->vyValues)
  3933.          {
  3934.             $result !$this->horizAxis->getInverted();
  3935.             if(($this->chart->getAspect()->getView3D()) &&
  3936.             (!$this->chart->getAspect()->getOrthogonal()) &&
  3937.             ($this->chart->getAspect()->getRotation(270))
  3938.             {
  3939.                $result !$result;
  3940.             }
  3941.             return $result;
  3942.          }
  3943.          else
  3944.          {
  3945.             return !$this->vertAxis->getInverted();
  3946.          }
  3947.       }
  3948.  
  3949.       /**
  3950.       * Called internally. Draws the "ValueIndex" point of the Series.
  3951.       *
  3952.       * @param index int
  3953.       */
  3954.       public function drawValue($index}// abstract
  3955.  
  3956.       public function legendToValueIndex($legendIndex)
  3957.       {
  3958.          return $legendIndex;
  3959.       }
  3960.  
  3961.       /**
  3962.       * Sets the specified series point to a null (transparent) point.<br>
  3963.       *
  3964.       * <p>Example:
  3965.       * <pre><font face="Courier" size="4">
  3966.       * lineSeries1.setNull( 123 ); // -- make null (empty) point index 123
  3967.       * lineSeries1.setIgnoreNulls( false ); // -- allow null points
  3968.       * lineSeries1.setStairs( true ); // -- set "stairs" mode
  3969.       * </font></pre></p>
  3970.       *
  3971.       * @param valueIndex int
  3972.       */
  3973.       public function setNull($valueIndex)
  3974.       {
  3975.          $tmpColor new Color(000127);// Transparent
  3976.          $this->getColors()->setColor($valueIndex$tmpColor);
  3977.       }
  3978.  
  3979.       public function createSubGallery($addSubChart)
  3980.       {
  3981.          $addSubChart->createSubChart(Language::getString("Normal"));
  3982.       }
  3983.  
  3984.       /**
  3985.       * Creates and prepares the index'th Series style to show at sub-gallery
  3986.       * dialog.
  3987.       *
  3988.       * @param index int
  3989.       */
  3990.       public function setSubGallery($index}// abstract
  3991.  
  3992.       protected function setValueList($l,
  3993.       $value)
  3994.       {
  3995.          $l->assign($value);
  3996.          $this->repaint();
  3997.       }
  3998.  
  3999.       /**
  4000.       * Returns the size in pixels corresponding to value parameter in
  4001.       * horizontal axis scales.<br>
  4002.       * This coordinate is calculated using the Series associated Horizontal
  4003.       * Axis.
  4004.       *
  4005.       * @param value double
  4006.       * @return int 
  4007.       */
  4008.       public function calcXSizeValue($value)
  4009.       {
  4010.          return $this->horizAxis->calcSizeValue($value);
  4011.       }
  4012.  
  4013.       /**
  4014.       * Returns the size in pixels corresponding to value parameter in vertical
  4015.       * axis scales.<br>
  4016.       * This coordinate is calculated using the Series associated Vertical Axis.
  4017.       *
  4018.       * @param value double
  4019.       * @return int 
  4020.       */
  4021.       public function calcYSizeValue($value)
  4022.       {
  4023.          return $this->vertAxis->calcSizeValue($value);
  4024.       }
  4025.  
  4026.       private function calcXValue($valueIndex)
  4027.       {
  4028.          if($this->horizAxis != null)
  4029.          {
  4030.             return $this->horizAxis->getLabels()->labelValue(
  4031.             $this->vxValues->value[$valueIndex]);
  4032.          }
  4033.          else
  4034.          {
  4035.             return $this->formatValue($this->vxValues->value[$valueIndex]);
  4036.          }
  4037.       }
  4038.  
  4039.       /**
  4040.       * Overridden ToString() method.
  4041.       *
  4042.       * @see Series#getTitle
  4043.       * @return String the Series Series.Title method.
  4044.       */
  4045.       public function toString()
  4046.       {
  4047.          $tmpResult $this->title;
  4048.          if(strlen($tmpResult== 0)
  4049.          {
  4050.  
  4051.             if(strlen($tmpResult== 0)
  4052.             {
  4053.                if($this->chart != null)
  4054.                {
  4055.  
  4056.                   $tmpResult "Series" " " $this->chart->getSeriesIndexOf($this);
  4057.  
  4058.                   /* tODO temp lines added
  4059.                   $tmpResult = $this->Language->getString("Series") + " " +
  4060.                   $this->Integer->toString($this->chart->getSeriesIndexOf($this));
  4061.                   */
  4062.                }
  4063.                else
  4064.                {
  4065. //                  $tmpResult = parent::toString();
  4066.                }
  4067.             }
  4068.          }
  4069.          return (string)$tmpResult;
  4070.       }
  4071.  
  4072.       /**
  4073.       * Obsolete.&nbsp;Please use ToString() method instead.
  4074.       *
  4075.       * @return String 
  4076.       */
  4077.       public function titleOrName()
  4078.       {
  4079.          return $this->toString();
  4080.       }
  4081.  
  4082.       private function valueToStr($tmpValue)
  4083.       {
  4084.          if($this->mandatory->getDateTime())
  4085.          {
  4086.             if($tmpValue 1)
  4087.             {
  4088.                return date('H:i:s',$tmpValue);
  4089.             }
  4090.             else
  4091.             {
  4092.                return date('Y-m-d',$tmpValue);
  4093.             }
  4094.          }
  4095.          else
  4096.          {
  4097.             return $this->formatValue($tmpValue);
  4098.          }
  4099.       }
  4100.  
  4101.       private function calcPercentSt($value)
  4102.       {
  4103.          return $this->percentDecimal->format(($this->mandatory->getTotalABS(== 0100 :
  4104.          $value $this->mandatory->getTotalABS());
  4105.       }
  4106.  
  4107.       /* Returns the formatted String corresponding to the LegendIndex
  4108.       point. The String is used to show at the Legend.
  4109.       Uses the LegendTextStyle property to ) the appropiate formatting.*/
  4110.       /**
  4111.       * Returns the formatted String corresponding to the LegendIndex point.
  4112.       *
  4113.       *
  4114.       * @param legendIndex int
  4115.       * @param legendTextStyle LegendTextStyle
  4116.       * @return String 
  4117.       */
  4118.       public function getLegendString($legendIndex$legendTextStyle)
  4119.       {
  4120.          $valueIndex $this->legendToValueIndex($legendIndex);
  4121.          // TODO remove bef-..- if $this->sLabels==null
  4122.          $tmpResult (sizeof($this->sLabels<= $valueIndex"" :
  4123.          $this->sLabels[$valueIndex];
  4124.  
  4125.          if($legendTextStyle != LegendTextStyle::$PLAIN)
  4126.          {
  4127.             $tmpValue $this->getMarkValue($valueIndex);
  4128.             if($legendTextStyle == LegendTextStyle::$LEFTVALUE)
  4129.             {
  4130.                if(strlen($tmpResult!= 0)
  4131.                {
  4132.                   $tmpResult " " $tmpResult;
  4133.                   // TODO remove above line before  :
  4134.                   // $tmpResult = $this->Language->getString("ColumnSeparator") + $tmpResult;
  4135.                }
  4136.                return $this->valueToStr($tmpValue$tmpResult;
  4137.             }
  4138.             else
  4139.                // TODO change code bellow
  4140.                if($legendTextStyle == LegendTextStyle::$RIGHTVALUE)
  4141.                {
  4142.                   if($tmpResult->length(!= 0)
  4143.                   {
  4144.                      $tmpResult $tmpResult " ";  // TODO $this->Language->getString("ColumnSeparator");
  4145.                   }
  4146.                   return $this->valueToStr($tmpResult$tmpValue;
  4147.                }
  4148.                else
  4149.                   if($legendTextStyle == LegendTextStyle::$LEFTPERCENT)
  4150.                   {
  4151.                      if($tmpResult->length(!= 0)
  4152.                      {
  4153.                        // TODO below used temp " " ....$this->Language->getString("ColumnSeparator")*/
  4154.                         $tmpResult " " $tmpResult;
  4155.                      }
  4156.                      return $this->calcPercentSt($tmpValue$tmpResult;
  4157.                   }
  4158.                   else
  4159.                      if($legendTextStyle == LegendTextStyle::$RIGHTPERCENT)
  4160.                      {
  4161.                         if($tmpResult->length(!= 0)
  4162.                         {
  4163.                            // TODO below used temp " " ....$this->Language->getString("ColumnSeparator")*/
  4164.                            $tmpResult $tmpResult " ";
  4165.                         }
  4166.                         return $tmpResult $this->calcPercentSt($tmpValue);
  4167.                      }
  4168.                      else
  4169.                         if($legendTextStyle == LegendTextStyle::$XVALUE)
  4170.                         {
  4171.                            return $this->calcXValue($valueIndex);
  4172.                         }
  4173.                         else
  4174.                            if($legendTextStyle == LegendTextStyle::$VALUE)
  4175.                            {
  4176.                               return $this->valueToStr($tmpValue);
  4177.                            }
  4178.                            else
  4179.                               if($legendTextStyle == LegendTextStyle::$PERCENT)
  4180.                               {
  4181.                                  return $this->calcPercentSt($tmpValue);
  4182.                               }
  4183.                               else
  4184.                                  if($legendTextStyle == LegendTextStyle::$XANDVALUE)
  4185.                                  {
  4186.                                     // TODO change " " for $this->Language->getString("ColumnSeparator")
  4187.                                     return $this->calcXValue($valueIndex" " $this->valueToStr($tmpValue);
  4188.                                  }
  4189.                                  else
  4190.                                     if($legendTextStyle == LegendTextStyle::$XANDPERCENT)
  4191.                                     {
  4192.                                        // TODO change " " for $this->Language->getString("ColumnSeparator")
  4193.                                        return $this->calcXValue($valueIndex" " $this->calcPercentSt($tmpValue);
  4194.                                     }
  4195.          }
  4196.          return $tmpResult;
  4197.       }
  4198.  
  4199.       /**
  4200.       * The Maximum Value of the Series X Values List.
  4201.       *
  4202.       * @return double 
  4203.       */
  4204.       public function getMaxXValue()
  4205.       {
  4206.          return $this->vxValues->getMaximum();
  4207.       }
  4208.  
  4209.       /**
  4210.       * The Maximum Value of the Series Y Values List.
  4211.       *
  4212.       * @return double 
  4213.       */
  4214.       public function getMaxYValue()
  4215.       {
  4216.          return $this->vyValues->getMaximum();
  4217.       }
  4218.  
  4219.       /**
  4220.       * The Minimum Value of the Series X Values List.
  4221.       *
  4222.       * @return double 
  4223.       */
  4224.       public function getMinXValue()
  4225.       {
  4226.          return $this->vxValues->getMinimum();
  4227.       }
  4228.  
  4229.       /**
  4230.       * The Minimum Value of the Series Y Values List.
  4231.       *
  4232.       * @return double 
  4233.       */
  4234.       public function getMinYValue()
  4235.       {
  4236.          return $this->vyValues->getMinimum();
  4237.       }
  4238.  
  4239.       /**
  4240.       * The Maximum Z Value. For non-3D series, this is the Z order.
  4241.       *
  4242.       * @return double 
  4243.       */
  4244.       public function getMaxZValue()
  4245.       {
  4246.          return $this->getZOrder();
  4247.       }
  4248.  
  4249.       /**
  4250.       * The Minimum Z Value. For non-3D series, this is the Z order.
  4251.       *
  4252.       * @return double 
  4253.       */
  4254.       public function getMinZValue()
  4255.       {
  4256.          return $this->getZOrder();
  4257.       }
  4258.  
  4259.       /**
  4260.       * Returns whether or not this Series has Y values as mandatory.
  4261.       *
  4262.       * @return boolean 
  4263.       */
  4264.       public function getYMandatory()
  4265.       {
  4266.          return $this->yMandatory;
  4267.       }
  4268.    }
  4269.  
  4270.       /* TODO    public interface MarkTextResolver {
  4271.       String getMarkText(int valueIndex, String markText);
  4272.       };
  4273.  
  4274.       private transient $MARKTEXT_RESOLVER = $new $MarkTextResolver() ${
  4275.       public function getMarkText($valueIndex, $markText) {
  4276.       return $markText;
  4277.       }
  4278.       };
  4279.       */
  4280. ?>

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