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

Source for file TeeShape.php

Documentation is available at TeeShape.php

  1. <?php
  2.  
  3. /**
  4.  * Shape class
  5.  *
  6.  * Description: Base class for Chart Shape elements
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @link http://www.steema.com
  13.  */
  14.  
  15. class TeeShape extends TeeBase {
  16.  
  17.     protected $defaultVisible=true;
  18.     protected $visible=true;
  19.     protected $bTransparent=false;
  20.     protected $pPen=null;
  21.     protected $bBevel=null;
  22.     protected $shadow=null;
  23.     protected $bImageBevel=null;
  24.     protected $bBrush=null;
  25.     protected $shapeBounds=null;
  26.     protected $bBorderRound=0;
  27.     protected $shapeBorders=null;
  28.  
  29.     // Interceptors
  30.     function __get$property {
  31.       $method ="get{$property}";
  32.       if method_exists$this$method ) ) {
  33.         return $this->$method();
  34.       }
  35.     }
  36.  
  37.     function __set $property,$value {
  38.       $method ="set{$property}";
  39.       if method_exists$this$method ) ) {
  40.         return $this->$method($value);
  41.       }
  42.     }
  43.  
  44.     /**
  45.     * The class constructor.
  46.     */
  47.     public function __construct($c=null{
  48.         $this->shapeBounds = new Rectangle(0,0,0,0);
  49.  
  50.         parent::__construct($c);
  51.         
  52.         $this->defaultVisible=true;
  53.         $this->shapeBorders=new ShapeBorders($c);
  54.     }
  55.  
  56.     /**
  57.      * Defines the Shape Borders.
  58.      *
  59.      * @return shapeBorders 
  60.      */
  61.     public function getShapeBorders({
  62.         return $this->shapeBorders;
  63.     }
  64.  
  65.     /**
  66.      * Defines the boundaries of the Shape.
  67.      *
  68.      * @return Rectangle 
  69.      */
  70.     public function getShapeBounds({
  71.         return $this->shapeBounds;
  72.     }
  73.  
  74.     /**
  75.      * Defines the boundaries of the Shape.
  76.      *
  77.      * @param value Rectangle
  78.      */
  79.     public function setShapeBounds($value{
  80.         $this->getShapeBounds()->setX($value->getX());
  81.         $this->getShapeBounds()->setY($value->getY());
  82.         $this->getShapeBounds()->setWidth($value->getWidth());
  83.         $this->getShapeBounds()->setHeight($value->getHeight());
  84.     }
  85.  
  86.     /**
  87.      * Obsolete.&ndsp;Please use Bevel.<!-- -->Inner.
  88.      *
  89.      *
  90.      * @return BevelStyle 
  91.      */
  92.     public function getBevelInner({
  93.         return $this->getBevel()->getInner();
  94.     }
  95.  
  96.     /**
  97.      * Defines the inner bevel type of the TChart Panel border.<br>
  98.      * Available types:<br>
  99.      *                  None<br>
  100.      *                  Lowered<br>
  101.      *                  Raised<br>
  102.      *
  103.      *
  104.      * @param value BevelStyle
  105.      */
  106.     public function setBevelInner($value{
  107.         $this->getBevel()->setInner($value);
  108.     }
  109.  
  110.     /**
  111.      * Obsolete.&nbsp;Please use Bevel.<!-- -->Width
  112.      *
  113.      * @return int 
  114.      */
  115.     public function getBevelWidth({
  116.         return $this->getBevel()->getWidth();
  117.     }
  118.  
  119.     /**
  120.      * Obsolete.&nbsp;Please use Bevel.<!-- -->Width
  121.      *
  122.      * @param value int
  123.      */
  124.     public function setBevelWidth($value{
  125.         $this->getBevel()->setWidth($value);
  126.     }
  127.  
  128.     /**
  129.      * Obsolete.&nbsp;Please use Bevel.<!-- -->Outer
  130.      *
  131.      *
  132.      * @return BevelStyle 
  133.      */
  134.     public function getBevelOuter({
  135.         return $this->getBevel()->getOuter();
  136.     }
  137.  
  138.     /**
  139.      * Defines the outer bevel type of the TChart Panel border.<br>
  140.      * Available types:<br>
  141.      *                  None<br>
  142.      *                  Lowered<br>
  143.      *                  Raised<br>
  144.      *
  145.      *
  146.      * @param value BevelStyle
  147.      */
  148.     public function setBevelOuter($value{
  149.         $this->getBevel()->setOuter($value);
  150.     }
  151.  
  152.     /**
  153.      * Chart associated with this object.
  154.      *
  155.      * @param IBaseChart
  156.      */
  157.     public function setChart($c{
  158.         parent::setChart($c);
  159.  
  160.         if ($this->pPen != null{
  161.             $this->pPen->setChart($this->chart);
  162.         }
  163.         if ($this->shadow != null{
  164.             $this->shadow->setChart($this->chart);
  165.         }
  166.         if ($this->bBrush != null{
  167.             $this->bBrush->setChart($this->chart);
  168.         }
  169.         if ($this->bBevel != null{
  170.             $this->bBevel->setChart($this->chart);
  171.         }
  172.     }
  173.  
  174.     /**
  175.      * Sets the bevel characteristics of the Shape.
  176.      *
  177.      * @return ImageBevel 
  178.      */
  179.     public function getImageBevel({
  180.         if ($this->bImageBevel==null)
  181.             $this->bImageBevel=new ImageBevel($this->chart);
  182.         return $this->bImageBevel;
  183.     }
  184.  
  185.     /**
  186.      * Sets the bevel characteristics of the Shape.
  187.      *
  188.      * @return TeeBevel 
  189.      */
  190.     public function getBevel({
  191.         if ($this->bBevel == null{
  192.             $this->bBevel = new TeeBevel($this->chart);
  193.         }
  194.  
  195.         return $this->bBevel;
  196.     }
  197.  
  198.     /**
  199.      * Internal use - serialization
  200.      */
  201.     public function setBevel($value{
  202.         $this->bBevel = $value;
  203.     }
  204.  
  205.     /**
  206.      * Defines the shape's Shadow characteristics.
  207.      *
  208.      * @return Shadow 
  209.      */
  210.     public function getShadow({
  211.         if ($this->shadow == null{
  212.             $this->shadow = new Shadow($this->chart);
  213.         }
  214.         return $this->shadow;
  215.     }
  216.  
  217.     /**
  218.      * Defines the kind of brush used to fill shape background.
  219.      *
  220.      * @return ChartBrush 
  221.      */
  222.     public function getBrush({
  223.         if ($this->bBrush == null{
  224.             $this->bBrush = new ChartBrush($this->chart,new Color(255,255,255)true);
  225.         }
  226.         return $this->bBrush;
  227.     }
  228.  
  229.     /**
  230.      * Internal use - serialization
  231.      */
  232.     public function setBrush($value{
  233.         $this->bBrush = $value;
  234.     }
  235.  
  236.     /**
  237.      * Rounds the Borders of the Chart Shapes.
  238.      *
  239.      * @return int 
  240.      */
  241.     public function getBorderRound({
  242.         return $this->bBorderRound;
  243.     }
  244.  
  245.     /**
  246.      * Rounds the Borders of the Chart Shapes.
  247.      *
  248.      * @param value int
  249.      */
  250.     public function setBorderRound($value{
  251.         $this->bBorderRound = $this->setIntegerProperty($this->bBorderRound$value);
  252.         // Assign value to independent shape borders
  253.         $this->getShapeBorders()->getTopLeft()->setBorderRound($value);
  254.         $this->getShapeBorders()->getBottomLeft()->setBorderRound($value);
  255.         $this->getShapeBorders()->getTopRight()->setBorderRound($value);
  256.         $this->getShapeBorders()->getBottomRight()->setBorderRound($value);
  257.     }
  258.  
  259.     /**
  260.      * Rendered Image for Shape background.<br>
  261.      * Default value: null
  262.      *
  263.      * @return Image 
  264.      */
  265.     public function getImage({
  266.         return $this->getBrush()->getImage();
  267.     }
  268.  
  269.     public function setDefaultVisible($value{
  270.         $this->defaultVisible = $value;
  271.         $this->visible = $value;
  272.     }
  273.  
  274.     /**
  275.      * Sets Rendered Image for Shape background.<br>
  276.      * Default value: null
  277.      *
  278.      * @param value Image
  279.      */
  280.     public function setImage($value{
  281.         $this->getBrush()->setImage($value);
  282.     }
  283.  
  284.     /**
  285.      * ImageMode for rendered Shape background Image.<br>
  286.      * Default value: ImageMode::$Stretch
  287.      *
  288.      * @return ImageMode 
  289.      */
  290.     public function getImageMode({
  291.         return $this->getBrush()->getImageMode();
  292.     }
  293.  
  294.     /**
  295.      * Sets the ImageMode for rendered Shape background Image.<br>
  296.      * Default value: ImageMode.Stretch
  297.      *
  298.      * @param value ImageMode
  299.      */
  300.     public function setImageMode($value{
  301.         $this->getBrush()->setImageMode($value);
  302.     }
  303.  
  304.     //CDI TTrack //#1480 -- added new property ... have to set Shape.Color to Color.Transparent for it to work
  305.     /** Sets the shape image to transparent.
  306.      *
  307.      * @return boolean 
  308.      */
  309.     public function getImageTransparent({
  310.         return $this->getBrush()->getImageTransparent();
  311.     }
  312.  
  313.     public function setImageTransparent($value{
  314.         $this->getBrush()->setImageTransparent($value);
  315.     }
  316.  
  317.     /**
  318.      * Defines the shape Color.
  319.      *
  320.      * @return Color 
  321.      */
  322.     public function getColor({
  323.         return $this->getBrush()->getColor();
  324.     }
  325.  
  326.     public function setColor($value{
  327.         $this->_setColor($value);
  328.     }
  329.  
  330.     /**
  331.      * Defines the shape Color.
  332.      *
  333.      * @param value Color
  334.      */
  335.     public function _setColor($value{
  336.         $this->getBrush()->setColor($value);
  337.     }
  338.  
  339.     /**
  340.      * Calls the  Gradient characteristics for the shape.
  341.      *
  342.      * @return Gradient 
  343.      */
  344.     public function getGradient({
  345.         return $this->getBrush()->getGradient();
  346.     }
  347.  
  348.     /**
  349.      * Shows or hides the Shape.
  350.      *
  351.      * @return boolean 
  352.      */
  353.     public function getVisible({
  354.         return $this->visible;
  355.     }
  356.  
  357.     /**
  358.      * Shows or hides the Shape.
  359.      *
  360.      * @param value boolean
  361.      */
  362.     public function setVisible($value{
  363.         $this->visible = $this->setBooleanProperty($this->visible$value);
  364.     }
  365.  
  366.     /**
  367.      * Enables/disables transparency of shape.<br>
  368.      * See transparency, which sets percentage transparency when
  369.      * Transparent is true.
  370.      *
  371.      * @see Shape#getTransparency
  372.      * @return boolean 
  373.      */
  374.     public function getTransparent({
  375.         return $this->bTransparent;
  376.     }
  377.  
  378.     /**
  379.      * Enables/disables transparency of shape.<br>
  380.      *
  381.      * @param value boolean
  382.      */
  383.     public function setTransparent($value{
  384.         $this->bTransparent = $this->setBooleanProperty($this->bTransparent$value);
  385.     }
  386.  
  387.     /**
  388.      * Specifies the pen used to draw the shape.
  389.      *
  390.      * @return ChartPen 
  391.      */
  392.     public function getPen({
  393.         if ($this->pPen == null{
  394.             $this->pPen = new ChartPen($this->chartnew Color(0,0,0));
  395.         }
  396.         return $this->pPen;
  397.     }
  398.  
  399.     /**
  400.      * Internal use - serialization
  401.      */
  402.     public function setPen($value{
  403.         $this->pPen = $value;
  404.     }
  405.  
  406.     /**
  407.      * Shape rectangle left co-ordinate.
  408.      *
  409.      * @return int 
  410.      */
  411.     public function getLeft({
  412.         return $this->shapeBounds->x;
  413.     }
  414.  
  415.     /**
  416.      * Shape rectangle left co-ordinate.
  417.      *
  418.      */
  419.     public function setLeft($value{
  420.         $this->shapeBounds->x$value//$this->setIntegerProperty($this->shapeBounds->x, $value);
  421.         $this->invalidate();
  422.     }
  423.  
  424.     /**
  425.      * Shape rectangle top co-ordinate.
  426.      *
  427.      * @return int 
  428.      */
  429.     public function getTop({
  430.         return $this->shapeBounds->y;
  431.     }
  432.  
  433.     /**
  434.      * Shape rectangle top co-ordinate.
  435.      *
  436.      * @param value int
  437.      */
  438.     public function setTop($value{
  439.         $this->shapeBounds->y=$value;
  440.         $this->invalidate();
  441.     }
  442.  
  443.     /**
  444.      * Shape rectangle right co-ordinate.
  445.      *
  446.      * @return int 
  447.      */
  448.     public function getRight({
  449.         return $this->shapeBounds->getRight();
  450.     }
  451.  
  452.     /**
  453.      * Shape rectangle right co-ordinate.
  454.      *
  455.      * @param value int
  456.      */
  457.     public function setRight($value{
  458.         if ($this->shapeBounds->getRight(!= $value{
  459.             $this->shapeBounds->setRight($value);
  460.             $this->invalidate();
  461.         }
  462.     }
  463.  
  464.     /**
  465.      * Shape rectangle bottom co-ordinate.
  466.      *
  467.      * @return int 
  468.      */
  469.     public function getBottom({
  470.         return $this->shapeBounds->getBottom();
  471.     }
  472.  
  473.     /**
  474.      * Shape rectangle bottom co-ordinate.
  475.      *
  476.      * @param value int
  477.      */
  478.     public function setBottom($value{
  479.         if ($this->shapeBounds->getBottom(!= $value{
  480.             $this->shapeBounds->setBottom($value);
  481.             $this->invalidate();
  482.         }
  483.     }
  484.  
  485.     /* The Height of the shape. */
  486.     public function getHeight()
  487.     {
  488.         return $this->shapeBounds->height;
  489.     }
  490.  
  491.     public function setHeight($value)
  492.     {
  493.         $this->getShapeBounds()->setHeight($value);
  494.     }
  495.  
  496.     /* The Width of the shape. */
  497.     public function getWidth()
  498.     {
  499.         return $this->shapeBounds->width;
  500.     }
  501.  
  502.     public function setWidth($value)
  503.     {
  504.         $this->shapeBounds->width $value;
  505.     }
  506.  
  507.     /**
  508.      * Assign all properties from a shape to another.
  509.      *
  510.      * @param Shape
  511.      */
  512.     public function assign($shape{
  513.         if ($shape != null{
  514.             if ($shape->bBevel != null{
  515.                 $this->bBevel->assign($shape->bBevel);
  516.             }
  517.             if ($shape->bBrush != null{
  518.                 $this->bBrush->assign($shape->bBrush);
  519.             }
  520.  
  521.             $this->setShapeBounds($shape->shapeBounds);
  522.  
  523.             if ($shape->pPen != null{
  524.                 $this->pPen->assign($shape->pPen$shape->pPen->getColor());
  525.             }
  526.             if ($shape->shadow != null{
  527.                 $this->shadow->assign($shape->shadow);
  528.             }
  529.  
  530.             $this->setVisible($shape->getVisible());
  531.             $this->setTransparent($shape->getTransparent());
  532.         }
  533.     }
  534.  
  535.     public function paint($gd$rect{
  536.  
  537.         if (!$this->bTransparent{
  538.             $gd->setBrush($this->getBrush());
  539.             $gd->setPen($this->getPen());
  540.  
  541.             //CDI BorderRound
  542.             if (($this->getShapeBorders()->getTopLeft()->getBorderRound(0||
  543.                  ($this->getShapeBorders()->getBottomLeft()->getBorderRound(0)||
  544.                  ($this->getShapeBorders()->getTopRight()->getBorderRound(0||
  545.                  ($this->getShapeBorders()->getBottomRight()->getBorderRound(0))
  546.             {
  547.                 //$gd->createImage();
  548.                 //$gd->roundRectangle($rect->x, $rect->y, $rect->getRight(),
  549.                   //  $rect->getBottom(), $this->bBorderRound);
  550.  
  551.                 $gd->drawRoundedBorders($this->getShapeBorders(),null,null);
  552.             else {                
  553.                 $gd->rectangle($rect);
  554.                 
  555.                 if ($this->getBrush()->getGradient()->getVisible()==true{
  556.             
  557.                  $colA array($this->getBrush()->getGradient()->getStartColor()->getRed(),
  558.                    $this->getBrush()->getGradient()->getStartColor()->getGreen(),
  559.                    $this->getBrush()->getGradient()->getStartColor()->getBlue());   
  560.                  $colB array($this->getBrush()->getGradient()->getEndColor()->getRed(),
  561.                    $this->getBrush()->getGradient()->getEndColor()->getGreen(),
  562.                    $this->getBrush()->getGradient()->getEndColor()->getBlue());
  563.                        
  564.                  $penWidth=$this->getPen()->getWidth();
  565.                  Gradient::imagecolorgradient(
  566.                    $this->getChart()->getGraphics3D()->img,
  567.                    $rect->getX()+$penWidth$rect->getY()+$penWidth
  568.                    $rect->getRight()-$penWidth$rect->getHeight()-$penWidth,
  569.                     $colA,$colB
  570.                  );            
  571.                 }                           
  572.             }
  573.  
  574.             if (($this->shadow != null&& $this->shadow->getVisible()) {
  575.                 $this->shadow->draw($gd$rect);
  576.             }
  577.  
  578.             if ($this->bBevel != null{
  579.                 $this->bBevel->draw($gd$rect);
  580.             }                       
  581.         }
  582.     }
  583.  
  584.     /**
  585.      * The Transparency level from 0 to 100% of shape.<br>
  586.      * Transparency is a value between 0 and 100 which sets the transparency
  587.      * percentage with respect to foreground versus background.<br>
  588.      * Default value: 0
  589.      *
  590.      * @return int 
  591.      */
  592.     public function getTransparency({
  593.         return $this->getBrush()->getTransparency();
  594.     }
  595.  
  596.     /**
  597.      * Sets Transparency level from 0 to 100% of shape.<br>
  598.      * Default value: 0
  599.      *
  600.      * @param value int
  601.      */
  602.     public function setTransparency($value{
  603.         $this->getBrush()->setTransparency($value);
  604.     }
  605. }
  606.  
  607. ?>

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