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

Source for file ShapeSeries.php

Documentation is available at ShapeSeries.php

  1. <?php
  2.  
  3. /**
  4.   *
  5.   * <p>Title: ShapeSeries class</p>
  6.   *
  7.   * <p>Description: Shape Series.</p>
  8.   *
  9.   * <p>Copyright (c) 2005-2010 by Steema Software SL. All Rights Reserved.</p>
  10.   *
  11.   * <p>Company: Steema Software SL</p>
  12.   *
  13.   */
  14.  
  15.   class ShapeSeries extends Series {
  16.  
  17.     private $shape;
  18.     private $style;
  19.     private $xyStyle;
  20.     private $textVertAlign;
  21.     private $textHorizAlign;
  22.  
  23.     // Interceptors
  24.     function __get$property {
  25.       $method ="get{$property}";
  26.       if method_exists$this$method ) ) {
  27.         return $this->$method();
  28.       }
  29.     }
  30.  
  31.     function __set $property,$value {
  32.       $method ="set{$property}";
  33.       if method_exists$this$method ) ) {
  34.         return $this->$method($value);
  35.       }
  36.     }
  37.  
  38.     public function ShapeSeries($c=null{
  39.  
  40.         $this->style ShapeStyle::$CIRCLE;
  41.         $this->xyStyle ShapeXYStyle::$AXIS;
  42.         $this->textVertAlign ShapeTextVertAlign::$CENTER;
  43.         $this->textHorizAlign ShapeTextHorizAlign::$CENTER;
  44.  
  45.         $this->shape new TextShape($c);
  46.  
  47.         parent::Series($c);
  48.  
  49.         $this->getBrush()->setColor(new Color(255,255,255));
  50.         $this->setSeriesColor($this->getBrush()->getColor());
  51.  
  52.         $this->addDefaultPoints();
  53.     }
  54.  
  55.     public function setChart($c{
  56.  
  57.         parent::setChart($c);
  58.  
  59.         if ($this->shape != null{
  60.             $this->shape->setChart($c);
  61.         }
  62.     }
  63.  
  64.     private function addDefaultPoints({
  65.         if (parent::getChart(!= null{
  66.             $this->addXY(00);
  67.             $this->addXY(100100);
  68.         }
  69.     }
  70.  
  71.     protected function drawLegendShape($g$valueIndex$rect{
  72.         $this->drawShape($gfalse$rect);
  73.     }
  74.  
  75.     private function drawText($r{
  76.  
  77.         $tmpPosX 0;
  78.         $tmpH 0;
  79.         $tmpPosY 0;
  80.         $tmpWidth 0;
  81.  
  82.         $g $this->chart->getGraphics3D();
  83.         if (sizeof($this->getText()) 0{
  84.             $g->setFont($this->getFormat()->getFont());
  85.             $tmpH MathUtils::round($g->textHeight($this->getFont()"H"));
  86.  
  87.             $tmpMid $r->center();
  88.  
  89.             if ($this->textVertAlign == ShapeTextVertAlign::$TOP{
  90.                 $tmpPosY $r->getTop();
  91.             else
  92.             if ($this->textVertAlign == ShapeTextVertAlign::$CENTER{
  93.                 $tmpPosY $tmpMid->getY(MathUtils::round($tmpH sizeof($this->getText()) 2.0);
  94.             else {
  95.                 $tmpPosY $r->getBottom(($tmpH strlen($this->getText()));
  96.             }
  97.  
  98.             for $t 0$t sizeof($this->getText())$t++{
  99.                 $tmpWidth $g->textWidth($this->getText($t));
  100.  
  101.                 if ($this->textHorizAlign == ShapeTextHorizAlign::$CENTER{
  102.                     $tmpPosX $tmpMid->getX(($tmpWidth 2);
  103.                 else
  104.                 if ($this->textHorizAlign == ShapeTextHorizAlign::$LEFT{
  105.                     $tmpPosX $r->getLeft($this->getPen()->getWidth($shapeHorizMargin;
  106.                 else {
  107.                     $tmpPosX $r->getRight($this->getPen()->getWidth($tmpWidth -
  108.                               $shapeHorizMargin;
  109.                 }
  110.  
  111.                 if ($this->getXYStyle(== ShapeXYStyle::$PIXELS{
  112.                     $g->textOut($tmpPosX$tmpPosY0$this->getText($t));
  113.                 else {
  114.                     $g->textOut($tmpPosX$tmpPosY$this->getStartZ()$this->getText($t));
  115.                 }
  116.  
  117.                 $tmpPosY += $tmpH;
  118.             }
  119.         }
  120.     }
  121.  
  122.     /**
  123.       * Displays customized Strings inside Shapes.<br>
  124.       * You can use the Font and Aligment properties to control Text display.<br>
  125.       * <b>Note:</b> You may need to change Shape Font size to a different
  126.       * value when creating metafiles or when zooming Charts.
  127.       *
  128.       * @return String[] 
  129.       */
  130.     public function getText($index=-1{
  131.       if ($index != -1{
  132.         $tmpx array();   // TODO remove this line ?
  133.         $tmpx $this->shape->getLines();
  134.  
  135.         return $tmpx[$index];
  136.       }
  137.       else
  138.       {
  139.         // TODO review if enter..
  140.         if ($this->shape->getLines(== null{
  141.             $tmpStr "";
  142.             $this->shape->setLines($tmpStr);
  143.         }
  144.         return $this->shape->getLines();
  145.       }
  146.     }
  147.  
  148.         /**
  149.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  150.           * The values should be expressed in Axis coordinates. <br>
  151.           * You can convert from Screen pixel coordinates to values and vice-versa
  152.           * using several TChart and Series methods like XScreenToValue and
  153.           * YScreenToValue.
  154.           *
  155.           * @return double 
  156.           */
  157.     public function getX0({
  158.         return $this->vxValues->value[0];
  159.     }
  160.  
  161.         /**
  162.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  163.           *
  164.           * @param value double
  165.           */
  166.     public function setX0($value{
  167.         $this->vxValues->value[0$value;
  168.         $this->invalidate();
  169.     }
  170.  
  171.         /**
  172.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  173.           * The values should be expressed in Axis coordinates. <br>
  174.           * You can convert from Screen pixel coordinates to values and vice-versa
  175.           * using several TChart and Series methods like XScreenToValue and
  176.           * YScreenToValue.
  177.           *
  178.           * @return double 
  179.           */
  180.     public function getX1({
  181.         return $this->vxValues->value[1];
  182.     }
  183.  
  184.         /**
  185.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  186.           *
  187.           * @param value double
  188.           */
  189.     public function setX1($value{
  190.         $this->vxValues->value[1$value;
  191.         $this->invalidate();
  192.     }
  193.  
  194.         /**
  195.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  196.           * The values should be expressed in Axis coordinates. <br>
  197.           * You can convert from Screen pixel coordinates to values and vice-versa
  198.           * using several TChart and Series methods like XScreenToValue and
  199.           * YScreenToValue.
  200.           *
  201.           * @return double 
  202.           */
  203.     public function getY0({
  204.         return $this->vyValues->value[0];
  205.     }
  206.  
  207.         /**
  208.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  209.           *
  210.           * @param value double
  211.           */
  212.     public function setY0($value{
  213.         $this->vyValues->value[0$value;
  214.         $this->invalidate();
  215.     }
  216.  
  217.         /**
  218.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  219.           * The values should be expressed in Axis coordinates. <br>
  220.           * You can convert from Screen pixel coordinates to values and vice-versa
  221.           * using several TChart and Series methods like XScreenToValue and
  222.           * YScreenToValue.
  223.           *
  224.           * @return double 
  225.           */
  226.     public function getY1({
  227.         return $this->vyValues->value[1];
  228.     }
  229.  
  230.         /**
  231.           * Coordinate used to define the englobing ShapeSeries rectangle.<br>
  232.           *
  233.           * @param value double
  234.           */
  235.     public function setY1($value{
  236.         $this->vyValues->value[1$value;
  237.         $this->invalidate();
  238.     }
  239.  
  240.         /**
  241.           * Defines how a TChartShape component appears on a Chart.<br>
  242.           * Default value: Circle
  243.           *
  244.           *
  245.           * @return ShapeStyle 
  246.           */
  247.     public function getStyle({
  248.         return $this->style;
  249.     }
  250.  
  251.         /**
  252.           * Defines how a TChartShape component appears on a Chart.<br>
  253.           * Default value: Circle
  254.           *
  255.           *
  256.           * @param value ShapeStyle
  257.           */
  258.     public function setStyle($value{
  259.         $this->style $value;
  260.         $this->chart->invalidate();
  261.     }
  262.  
  263.     public function getFormat({
  264.         return $this->shape;
  265.     }
  266.  
  267.         /**
  268.           * Sets the vertical alignment of Text within a TChartShape Series shape.
  269.           * <br>
  270.           * It can be Top, Center, Bottom.
  271.           *
  272.           * @return ShapeTextVertAlign 
  273.           */
  274.     public function getVertAlignment({
  275.         return $this->textVertAlign;
  276.     }
  277.  
  278.         /**
  279.           * Sets the vertical alignment of Text within a TChartShape Series shape.
  280.           * <br>
  281.           *
  282.           * @param value ShapeTextVertAlign
  283.           */
  284.     public function setVertAlignment($value{
  285.         if ($this->textVertAlign != $value{
  286.             $this->textVertAlign $value;
  287.         }
  288.         $this->repaint();
  289.     }
  290.  
  291.         /**
  292.           * Horizontally aligns the text.<br>
  293.           * There are three options; Centre, Left or Right.
  294.           *
  295.           * @return ShapeTextHorizAlign 
  296.           */
  297.     public function getHorizAlignment({
  298.         return $this->textHorizAlign;
  299.     }
  300.  
  301.         /**
  302.           * Horizontally aligns the text.<br>
  303.           *
  304.           * @param value ShapeTextHorizAlign
  305.           */
  306.     public function setHorizAlignment($value{
  307.         if ($this->textHorizAlign != $value{
  308.             $this->textHorizAlign $value;
  309.         }
  310.         $this->repaint();
  311.     }
  312.  
  313.     private function getShapeRectangle({
  314.  
  315.         if ($this->xyStyle==ShapeXYStyle::$PIXELS{
  316.             $x0 = (int) ($this->getX0());
  317.             $y0 = (int) ($this->getY0());
  318.             $x1 = (int) ($this->getX1());
  319.             $y1 = (int) ($this->getY1());
  320.         }
  321.         else
  322.         if ($this->xyStyle==ShapeXYStyle::$AXIS{
  323.             $x0 $this->calcXPos(0);
  324.             $y0 $this->calcYPos(0);
  325.             $x1 $this->calcXPos(1);
  326.             $y1 $this->calcYPos(1);
  327.         }
  328.         else
  329.             {
  330.             $x0 $this->calcXPos(0);
  331.             $y0 $this->calcYPos(0);
  332.             $x1 $x0 + (int) ($this->getX1());
  333.             $y1 $y0 + (int) ($this->getY1());
  334.         }
  335.  
  336.         return Rectangle::fromLTRB($x0$y0$x1$y1);
  337.     }
  338.  
  339.     private function getAdjustedRectangle({
  340.         $r $this->getShapeRectangle();
  341.         if ($r->== $r->getBottom()) {
  342.             $r->height 1;
  343.         else
  344.         if ($r->$r->getBottom()) {
  345.              $tmp $r->height;
  346.             $r->$r->getBottom();
  347.             $r->height -$tmp);
  348.         }
  349.  
  350.         if ($r->== $r->getRight()) {
  351.             $r->width 1;
  352.         else
  353.         if ($r->$r->getRight()) {
  354.              $tmp $r->width;
  355.             $r->$r->getRight();
  356.             $r->width -$tmp);
  357.         }
  358.  
  359.         return $r;
  360.     }
  361.  
  362.     private function drawDiagonalCross2D($g$r{
  363.         $g->line($r->x$r->y$r->getRight(1$r->getBottom(1);
  364.         $g->line($r->x$r->getBottom()$r->getRight(1$r->1);
  365.     }
  366.  
  367.     private function drawDiagonalCross3D($g$r{
  368.         $g->line($r->x$r->y$r->getRight()$r->getBottom()$this->getMiddleZ());
  369.         $g->line($r->x$r->getBottom()$r->getRight()$r->y$this->getMiddleZ());
  370.     }
  371.  
  372.     private function drawCross3D($g$r{
  373.         $tmpMid $r->center();
  374.         $g->verticalLine($tmpMid->x$r->y$r->getBottom()$this->getMiddleZ());
  375.         $g->horizontalLine($r->x$r->getRight()$tmpMid->y$this->getMiddleZ());
  376.     }
  377.  
  378.     private function drawCross2D($g$r{
  379.         $tmpMid $r->center();
  380.         $g->verticalLine($tmpMid->x$r->y$r->getBottom(1);
  381.         $g->horizontalLine($r->x$r->getRight(1$tmpMid->y);
  382.     }
  383.  
  384.     private function doGradient($is3D$r{
  385.  
  386.         $g=$this->chart->getGraphics3D();
  387.         if ((!$this->getTransparent()) && $this->getGradient()->getVisible()) {
  388.              $tmpR $is3D $g->calcRect3D($r$this->getMiddleZ()) $r;
  389.             if ($this->style == ShapeStyle::$CIRCLE{
  390.                 $g->clipEllipse($tmpR);
  391.             }
  392.  
  393.             $this->getGradient()->draw($this->chart->getGraphics3D()$tmpR);
  394.  
  395.             if ($this->style == ShapeStyle::$CIRCLE{
  396.                 $g->unClip();
  397.             }
  398.             $g->getBrush()->setVisible(false);
  399.         }
  400.     }
  401.  
  402.     private function _drawShape($is3D$r{
  403.         $this->drawShape($this->chart->getGraphics3D()$is3D$r);
  404.     }
  405.  
  406.     private function drawShape($g$is3D$r{
  407.         $g->setPen($this->getPen());
  408.  
  409.         if ($this->getTransparent()) {
  410.             $g->getBrush()->setVisible(false);
  411.         else {
  412.             $g->setBrush($this->getBrush());
  413.             $g->getBrush()->setColor($this->getColor());
  414.         }
  415.  
  416.         //            if ( Brush.Color.isEmpty())
  417.         //                g.getBrush().getVisible()=false;
  418.  
  419.         // TODO assign visible brush to false if transparent is true
  420.  
  421.  
  422.         $tmpMid $r->center();
  423.  
  424.         if ($is3D{
  425.             if ($this->style==ShapeStyle::$RECTANGLE{
  426.                 $this->doGradient($is3D$r);
  427.                 $g->rectangle($r$this->getMiddleZ());
  428.             }
  429.             else
  430.             if ($this->style==ShapeStyle::$CIRCLE{
  431.                 $this->doGradient($is3D$r);
  432.                 $g->ellipseRectZ($r$this->getMiddleZ());
  433.             }
  434.             else
  435.             if ($this->style==ShapeStyle::$VERTLINE{
  436.                 $g->verticalLine($tmpMid->getX()$r->getY()$r->getBottom()$this->getMiddleZ());
  437.             }
  438.             else
  439.             if ($this->style==ShapeStyle::$HORIZLINE{
  440.                 $g->horizontalLine($r->getX()$r->getRight()$tmpMid->getY()$this->getMiddleZ());
  441.             }
  442.             else
  443.             if ($this->style==ShapeStyle::$TRIANGLE{
  444.                 $g->triangle(new TeePoint($r->getX()$r->getBottom()),
  445.                            new TeePoint($tmpMid->getX()$r->getY()),
  446.                            new TeePoint($r->getRight()$r->getBottom())$this->getMiddleZ());
  447.             }
  448.             else
  449.             if ($this->style==ShapeStyle::$INVERTTRIANGLE{
  450.                 $g->triangle(new TeePoint($r->getX()$r->getY()),
  451.                            new TeePoint($tmpMid->getX()$r->getBottom()),
  452.                            new TeePoint($r->getRight()$r->getY())$this->getMiddleZ());
  453.             }
  454.             else
  455.             if ($this->style==ShapeStyle::$LINE{
  456.                 $g->line($r->getX()$r->getY()$r->getRight()$r->getBottom()$this->getMiddleZ());
  457.             }
  458.             else
  459.             if ($this->style==ShapeStyle::$DIAMOND{
  460.                 $g->plane(new TeePoint($r->getX()$tmpMid->getY()),
  461.                         new TeePoint($tmpMid->getX()$r->getY()),
  462.                         new TeePoint($r->getRight()$tmpMid->getY()),
  463.                         new TeePoint($tmpMid->getX()$r->getBottom())$this->getMiddleZ());
  464.             }
  465.             else
  466.             if ($this->style==ShapeStyle::$CUBE{
  467.                 $g->cube($r$this->getStartZ()$this->getEndZ()!$this->getTransparent());
  468.             }
  469.             else
  470.             if ($this->style==ShapeStyle::$CROSS{
  471.                 $this->drawCross3D($g,$r);
  472.             }
  473.             else
  474.             if ($this->style==ShapeStyle::$DIAGCROSS{
  475.                 $this->drawDiagonalCross3D($g,$r);
  476.             }
  477.             else
  478.             if ($this->style==ShapeStyle::$STAR{
  479.                 $this->drawCross3D($g,$r);
  480.                 $this->drawDiagonalCross3D($g,$r);
  481.             }
  482.             else
  483.             if ($this->style==ShapeStyle::$PYRAMID{
  484.                 $g->pyramid(true$r$this->getStartZ()$this->getEndZ()!$this->getTransparent());
  485.             }
  486.             else
  487.             if ($this->style==ShapeStyle::$INVERTPYRAMID{
  488.                 $g->pyramid(true$r->getX()$r->getBottom()$r->getRight()$r->getY()$this->getStartZ(),
  489.                           $this->getEndZ(),
  490.                           !$this->getTransparent());
  491.             }
  492.         else {
  493.             if ($this->style==ShapeStyle::$RECTANGLE{
  494.                 if ($this->getFormat()->getShapeStyle(==
  495.                     TextShapeStyle::$ROUNDRECTANGLE{
  496.                      $roundSize 12;
  497.                      $tmpR new Rectangle($r->getLeft()$r->getTop(),
  498.                             $r->width $roundSize,
  499.                             $r->height $roundSize);
  500.                     $g->roundRectangle($tmpR$roundSize$roundSize);
  501.                 else {
  502.                     $this->doGradient($is3D$r);
  503.  
  504.                     $g->rectangle($r);
  505.                 }
  506.             }
  507.             else
  508.             if ($this->style==ShapeStyle::$CIRCLE{
  509.                 $this->doGradient($is3D$r);
  510.                 $g->ellipseRect($r);
  511.             }
  512.             else
  513.             if ($this->style==ShapeStyle::$VERTLINE{
  514.                 $g->verticalLine($tmpMid->getX()$r->getY()$r->getBottom());
  515.             }
  516.             else
  517.             if ($this->style==ShapeStyle::$HORIZLINE{
  518.                 $g->horizontalLine($r->getX()$r->getRight(1$tmpMid->getY());
  519.             }
  520.             else
  521.             if (($this->style==ShapeStyle::$TRIANGLE|
  522.                 ($this->style==ShapeStyle::$PYRAMID)) {
  523.                 // Point[] array
  524.                 $tmp Array(new TeePoint($r->getX()$r->getBottom()),
  525.                               new TeePoint($tmpMid->getX()$r->getY()),
  526.                               new TeePoint($r->getRight()$r->getBottom()));
  527.                 $g->polygon($tmp);
  528.             }
  529.             else
  530.             if (($this->style==ShapeStyle::$INVERTTRIANGLE|
  531.                 ($this->style==ShapeStyle::$INVERTPYRAMID)) {
  532.                 // Point[] array
  533.                 $tmp Array(new TeePoint($r->getX()$r->getY()),
  534.                               new TeePoint($tmpMid->getX()$r->getBottom()),
  535.                               new TeePoint($r->getRight()$r->getY()));
  536.                 $g->polygon($tmp);
  537.             }
  538.             else
  539.             if ($this->style==ShapeStyle::$LINE{
  540.                 $g->line($r->getX()$r->getY()$r->getRight()$r->getBottom());
  541.             }
  542.             else
  543.             if ($this->style==ShapeStyle::$DIAMOND{
  544.                 // Point[] array
  545.                 $tmp Array(new TeePoint($r->getX()$tmpMid->getY()),
  546.                               new TeePoint($tmpMid->getX()$r->getY()),
  547.                               new TeePoint($r->getRight()$tmpMid->getY()),
  548.                               new TeePoint($tmpMid->getX()$r->getBottom()));
  549.                 $g->polygon($tmp);
  550.             }
  551.             else
  552.             if ($this->style==ShapeStyle::$CUBE{
  553.                 $g->rectangle($r);
  554.             }
  555.             else
  556.             if ($this->style==ShapeStyle::$CROSS{
  557.                 $this->drawCross2D($g,$r);
  558.             }
  559.             else
  560.             if ($this->style==ShapeStyle::$DIAGCROSS{
  561.                 $this->drawDiagonalCross2D($g,$r);
  562.             }
  563.             else
  564.             if ($this->style==ShapeStyle::$STAR{
  565.                 $this->drawCross2D($g,$r);
  566.                 $this->drawDiagonalCross2D($g,$r);
  567.             }
  568.         }
  569.     }
  570.  
  571.         /**
  572.           * Called internally. Draws the "ValueIndex" point of the Series.
  573.           *
  574.           * @param valueIndex int
  575.           */
  576.     public function drawValue($valueIndex{
  577.         if (($this->getCount(== 2&& ($valueIndex == 0)) {
  578.             $r $this->getAdjustedRectangle();
  579.             if ($r->intersects($this->chart->getChartRect())) {
  580.                  $tmp ($this->xyStyle == ShapeXYStyle::$PIXELSfalse :
  581.                               $this->chart->getAspect()->getView3D();
  582.  
  583.                 $this->_drawShape($tmp,
  584.                     ($this->style == ShapeStyle::$LINE$this->getShapeRectangle($r);
  585.  
  586.                 $this->drawText($r);
  587.             }
  588.         }
  589.     }
  590.  
  591.     protected function addSampleValues($numValues{
  592.          $r $this->randomBounds(1);
  593.         if ($r->StepX == 0{
  594.             $this->addDefaultPoints();
  595.         else {
  596.             $this->add($r->tmpX ($r->StepX 8.0)$r->tmpY 2);
  597.             $this->add($r->tmpX $r->StepX ($r->StepX 8.0),
  598.                 $r->tmpY MathUtils::round($r->DifY $r->Random()));
  599.         }
  600.     }
  601.  
  602.         /**
  603.           * Returns the ValueIndex of the "clicked" point in the Series.
  604.           *
  605.           * @param int
  606.           * @param int
  607.           * @return int 
  608.           */
  609.     public function clicked($x$y{
  610.  
  611.          $p;
  612.  
  613.         if (($this->chart != null)) {
  614.             $p $this->chart->getGraphics3D()->calculate2DPosition($x$y$this->getStartZ());
  615.         else {
  616.             $p new TeePoint($x$y);
  617.         }
  618.  
  619.          $r $this->getShapeRectangle();
  620.          $tmpMid $r->center();
  621.  
  622.          $tmp;
  623.  
  624.         if ($this->style==ShapeStyle::$VERTLINE){
  625.             $tmp GraphicsGD::pointInLineTolerance($p$tmpMid->x$r->y$tmpMid->x,
  626.                                                   $r->getBottom()3);
  627.         else if ($this->style==ShapeStyle::$HORIZLINE{
  628.             $tmp GraphicsGD::pointInLineTolerance($p$r->x$tmpMid->y$r->getRight(),
  629.                                                   $tmpMid->y3);
  630.         else if ($this->style==ShapeStyle::$LINE{
  631.             $tmp GraphicsGD::pointInLineTolerance($p$r->x$r->y$r->getRight(),
  632.                                                   $r->getBottom()3);
  633.         else if ($this->style==ShapeStyle::$DIAMOND{
  634.             // Point[] array
  635.             $points=Array (new TeePoint($tmpMid->x$r->y),
  636.                                             new TeePoint($r->getRight()$tmpMid->y),
  637.                                             new TeePoint($tmpMid->x$r->getBottom()),
  638.                                             new TeePoint($r->x$tmpMid->y));
  639.  
  640.             $tmp GraphicsGD::pointInPolygon($p$points);
  641.         else if (($this->style==ShapeStyle::$TRIANGLE($this->style==ShapeStyle::$PYRAMID)) {
  642.             $tmp GraphicsGD::pointInTriangle($p$r->x$r->getRight()$r->getBottom()$r->y);
  643.         else if (($this->style==ShapeStyle::$INVERTTRIANGLE($this->style==ShapeStyle::$INVERTPYRAMID)) {
  644.             $tmp GraphicsGD::pointInTriangle($p$r->x$r->getRight()$r->y$r->getBottom());
  645.         else if ($this->style==ShapeStyle::$CIRCLE{
  646.             $tmp GraphicsGD::pointInEllipse($p$r);
  647.         else {
  648.             $tmp $r->contains($x$y);
  649.         }
  650.         return $tmp : -1;
  651.     }
  652.  
  653.         /**
  654.           * Determines the font attributes used to output ShapeSeries.<br>
  655.           * No auto font sizing is performed, so you must specify the desired font
  656.           * size to avoid shape text from overlapping the Shape boundaries.
  657.           *
  658.           * @return ChartFont 
  659.           */
  660.     public function getFont({
  661.         return $this->shape->getFont();
  662.     }
  663.  
  664.         /**
  665.           * Defines the brush used to fill shape background.<br>
  666.           * <p>Example:
  667.           * <pre><font face="Courier" size="4">
  668.           * //shape1
  669.           * shape[0] = new TeeShape(myChart.getChart());
  670.           * tmpShape = shape[0];
  671.           * tmpShape.getMarks().setVisible(false);
  672.           * tmpShape.setColor(Color.WHITE);
  673.           * tmpShape.getBrush().setColor(Color.WHITE);
  674.           * tmpShape.getBrush().setImageMode(ImageMode::$TILE);
  675.           * tmpShape.getBrush().loadImage(ChartSamplePanel.class.getResource(URL_IMAGE1));
  676.           *
  677.           * tmpShape.setStyle(ShapeStyle::$CIRCLE);
  678.           * tmpShape.getPen().setColor(Color.RED);
  679.           * tmpShape.getPen().setWidth(2);
  680.           * tmpShape.setX1(50);
  681.           * tmpShape.setY1(50);
  682.           * </font></pre></p>
  683.           *
  684.           * @return ChartBrush 
  685.           */
  686.     public function getBrush({
  687.         return $this->shape->getBrush();
  688.     }
  689.  
  690.         /**
  691.           * Defines pen to draw Series Shape.
  692.           *
  693.           * @return ChartPen 
  694.           */
  695.     public function getPen({
  696.         return $this->shape->getPen();
  697.     }
  698.  
  699.         /**
  700.           * Gets Gradient fill characteristics for the ShapeSeries Shape.
  701.           *
  702.           * @return Gradient 
  703.           */
  704.     public function getGradient({
  705.         return $this->shape->getGradient();
  706.     }
  707.  
  708.     public function setText($value{
  709.         $this->shape->setLines($value);
  710.     }
  711.  
  712.         /**
  713.           * Allows Shape Brush attributes to fill the interior of the Shape.<br>
  714.           * When false, Shapes do not redraw their background, so charting contents
  715.           * behind Shape Series is seen inside the Shape. <br>
  716.           * Default value: false
  717.           *
  718.           * @return boolean 
  719.           */
  720.     public function getTransparent({
  721.         return $this->shape->getTransparent();
  722.     }
  723.  
  724.         /**
  725.           * Allows Shape Brush attributes to fill the interior of the Shape.<br>
  726.           * Default value: false
  727.           *
  728.           * @param value boolean
  729.           */
  730.     public function setTransparent($value{
  731.         $this->shape->setTransparent($value);
  732.     }
  733.  
  734.     public function prepareForGallery($isEnabled{
  735.         parent::prepareForGallery($isEnabled);
  736.  
  737.         $tmpColor new Color(255,255,255)// White
  738.         $this->getFont()->setColor($tmpColor);
  739.         $this->getFont()->setSize(12);
  740.         // String[1] array
  741.         $tmpArray Array();
  742.         $this->shape->setLines($tmpArray);
  743.         if ($this->chart->getSeriesIndexOf($this== 1{
  744.             $this->style ShapeStyle::$CIRCLE;
  745.             $this->getBrush()->setColor($isEnabled $tmpColor->BLUE $tmpColor->SILVER);
  746.             // String[] array
  747.             $tmpArray(Language::getString("ShapeGallery1"));
  748.             $this->setText($tmp);
  749.         else {
  750.             $this->style ShapeStyle::$TRIANGLE;
  751.             $this->getBrush()->setColor($isEnabled $tmpColor->RED $tmpColor->SILVER);
  752.             // String[] array
  753.             $tmpArray(Language::getString("ShapeGallery2"));
  754.             $this->setText($tmp);
  755.         }
  756.     }
  757.  
  758.     public function calcZOrder({
  759.         if ($this->getUseAxis()) {
  760.             parent::calcZOrder();
  761.         }
  762.     }
  763.  
  764.     protected function moreSameZOrder({
  765.         return false;
  766.     }
  767.  
  768.         /**
  769.           * Can be set to:- Axis, AxisOrigin or Pixels.
  770.           *
  771.           *
  772.           * @return ShapeXYStyle 
  773.           */
  774.     public function getXYStyle({
  775.         return $this->xyStyle;
  776.     }
  777.  
  778.         /**
  779.           * Can be set to:- Axis, AxisOrigin or Pixels.
  780.           *
  781.           *
  782.           * @param value ShapeXYStyle
  783.           */
  784.     public function setXYStyle($value{
  785.         if ($this->xyStyle != $value{
  786.             $this->xyStyle $value;
  787.             $this->repaint();
  788.         }
  789.     }
  790.  
  791.         /**
  792.           * Returns false if the Value parameter is the same as Self.
  793.           *
  794.           * @param Series
  795.           * @return boolean 
  796.           */
  797.     public function isValidSourceOf($s{
  798.         return $s instanceof Shape;
  799.     }
  800.  
  801.     public function createSubGallery($addSubChart{
  802.         parent::createSubGallery($addSubChart);
  803.  
  804.         $addSubChart->createSubChart(Language::getString("Rectangle"));
  805.         $addSubChart->createSubChart(Language::getString("VertLine"));
  806.         $addSubChart->createSubChart(Language::getString("HorizLine"));
  807.         $addSubChart->createSubChart(Language::getString("Ellipse"));
  808.         $addSubChart->createSubChart(Language::getString("DownTri"));
  809.         $addSubChart->createSubChart(Language::getString("Line"));
  810.         $addSubChart->createSubChart(Language::getString("Diamond"));
  811.         $addSubChart->createSubChart(Language::getString("Cube"));
  812.         $addSubChart->createSubChart(Language::getString("Cross"));
  813.         $addSubChart->createSubChart(Language::getString("DiagCross"));
  814.         $addSubChart->createSubChart(Language::getString("Star"));
  815.         $addSubChart->createSubChart(Language::getString("Pyramid"));
  816.         $addSubChart->createSubChart(Language::getString("InvPyramid"));
  817.         $addSubChart->createSubChart(Language::getString("Hollow"));
  818.     }
  819.  
  820.     public function setSubGallery($index{
  821.         switch ($index{
  822.         case 1:
  823.             $this->setStyle(ShapeStyle::$RECTANGLE);
  824.             break;
  825.         case 2:
  826.             $this->setStyle(ShapeStyle::$VERTLINE);
  827.             break;
  828.         case 3:
  829.             $this->setStyle(ShapeStyle::$HORIZLINE);
  830.             break;
  831.         case 4:
  832.             $this->setStyle(ShapeStyle::$CIRCLE);
  833.             break;
  834.         case 5:
  835.             $this->setStyle(ShapeStyle::$INVERTTRIANGLE);
  836.             break;
  837.         case 6:
  838.             $this->setStyle(ShapeStyle::$LINE);
  839.             break;
  840.         case 7:
  841.             $this->setStyle(ShapeStyle::$DIAMOND);
  842.             break;
  843.         case 8:
  844.             $this->setStyle(ShapeStyle::$CUBE);
  845.             break;
  846.         case 9:
  847.             $this->setStyle(ShapeStyle::$CROSS);
  848.             break;
  849.         case 10:
  850.             $this->setStyle(ShapeStyle::$DIAGCROSS);
  851.             break;
  852.         case 11:
  853.             $this->setStyle(ShapeStyle::$STAR);
  854.             break;
  855.         case 12:
  856.             $this->setStyle(ShapeStyle::$PYRAMID);
  857.             break;
  858.         case 13:
  859.             $this->setStyle(ShapeStyle::$INVERTPYRAMID);
  860.             break;
  861.         case 14:
  862.             $this->setTransparent(!$this->getTransparent());
  863.             break;
  864.         default:
  865.             parent::setSubGallery($index);
  866.         }
  867.     }
  868.  
  869.         /**
  870.           * Gets descriptive text.
  871.           *
  872.           * @return String 
  873.           */
  874.     public function getDescription({
  875.         return Language::getString("GalleryShape");
  876.     }
  877. }
  878. ?>

Documentation generated on Wed, 16 Jun 2010 12:08:15 +0200 by phpDocumentor 1.4.1