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

Source for file Shadow.php

Documentation is available at Shadow.php

  1. <?php
  2.  
  3. /**
  4.  * Shadow class
  5.  *
  6.  * Description: Properties to draw a shadow
  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 Shadow extends TeeBase {
  16.  
  17.     private $height 3;
  18.     private $width 3;
  19.  
  20.     protected $bBrush;
  21.     protected $bVisible=false;
  22.     protected $defaultVisible=false;
  23.     protected $defaultSize;
  24.     protected $defaultColor;
  25.  
  26.     // Interceptors
  27.     function __get$property {
  28.       $method ="get{$property}";
  29.       if method_exists$this$method ) ) {
  30.         return $this->$method();
  31.       }
  32.     }
  33.  
  34.     function __set $property,$value {
  35.       $method ="set{$property}";
  36.       if method_exists$this$method ) ) {
  37.         return $this->$method($value);
  38.       }
  39.     }
  40.  
  41.     /**
  42.      * Shadow constructor, defines initial size and color
  43.      *
  44.      * @param IBaseChart
  45.      * @param size int
  46.      * @param color Color
  47.      */
  48.     public function Shadow($c$size=-1$color=null{
  49.         parent::__construct($c);
  50.                
  51.         if($size != -1)  {
  52.                 $this->defaultSize = $size;
  53.                 $this->width $size;
  54.                 $this->height $size;
  55.         else {
  56.                 $this->defaultSize=3;
  57.         }
  58.  
  59.         if($color != null)  {
  60.                 $this->setColor($color);
  61.                 $this->defaultColor = $color;
  62.         else {
  63.                 $this->bBrush = new ChartBrush($cnew Color(120,120,120))// DARK_GRAY
  64.         }
  65.     }
  66.  
  67.     /**
  68.      * Assigns characteristics of Shadow '$value'.<br>
  69.      * Copies all properties from Source Shadow to Self.
  70.      *
  71.      * @param value Shadow
  72.      */
  73.     public function assign($value{
  74.         $this->height $value->height;
  75.         $this->width $value->width;
  76.         $this->bVisible = $value->bVisible;
  77.         $this->bBrush->assign($value->bBrush);
  78.     }
  79.  
  80.     /**
  81.      * Defines the shadow Color. Gets or sets Color used to fill shadow.
  82.      *
  83.      * @return Color 
  84.      */
  85.     public function getColor({
  86.         return $this->bBrush->getColor();
  87.     }
  88.  
  89.     /**
  90.      * Defines the shadow Color. Gets or sets Color used to fill shadow.
  91.      *
  92.      * @param value Color
  93.      */
  94.     public function setColor($value{
  95.         $this->bBrush->setColor($value);
  96.     }
  97.  
  98.     public function setDefaultSize($value{
  99.         $this->defaultSize = $value;
  100.         $this->height $value;
  101.         $this->width $value;
  102.     }
  103.  
  104.     public function setDefaultVisible($value{
  105.         $this->defaultVisible = $value;
  106.         $this->bVisible = $value;
  107.     }
  108.  
  109.     protected function shouldSerializeHeight({
  110.         return $this->height != $this->defaultSize;
  111.     }
  112.  
  113.     /**
  114.      * The Transparency level from 0 to 100% of shadow.<br>
  115.      * Transparency is a $value between 0 and 100 which sets the transparency
  116.      * percentage with respect to foreground versus background for the shadow.
  117.      *
  118.      * @return int 
  119.      */
  120.     public function getTransparency({
  121.         return $this->bBrush->getTransparency();
  122.     }
  123.  
  124.     /**
  125.      * Sets Transparency level from 0 to 100% of shadow.<br>
  126.      *
  127.      * @param $value int
  128.      */
  129.     public function setTransparency($value{
  130.         $this->bBrush->setTransparency($value);
  131.     }
  132.  
  133.     /**
  134.      * The vertical displacement of the shadow in pixels.
  135.      *
  136.      * @return int 
  137.      */
  138.     public function getHeight({
  139.         return $this->height;
  140.     }
  141.  
  142.     /**
  143.      * Sets the vertical displacement of the shadow in pixels.
  144.      *
  145.      * <p>Example:
  146.      * <pre><font face="Courier" size="4">
  147.      * pieSeries = new com.steema.teechart.styles.Pie(myChart.getChart());
  148.      * pieSeries.getMarks().setVisible(true);
  149.      * pieSeries.getShadow().setVisible(true);
  150.      * pieSeries.getShadow().setWidth(30);
  151.      * pieSeries.getShadow().setHeight(50);
  152.      * pieSeries.getShadow().setColor(Color.SILVER);
  153.      * pieSeries.fillSampleValues(9);
  154.      *
  155.      * @param value int
  156.      */
  157.     public function setHeight($value{
  158.         $this->height $this->setIntegerProperty($this->height$value);
  159.     }
  160.  
  161.     /**
  162.      * Obsolete.&nbsp;Please use Width property.
  163.      *
  164.      * @return int 
  165.      */
  166.     public function getHorizSize({
  167.         return $this->width;
  168.     }
  169.  
  170.     /**
  171.      * Obsolete.&nbsp;Please use Width property.
  172.      *
  173.      * @param $value int
  174.      */
  175.     public function setHorizSize($value{
  176.         $this->width $value;
  177.     }
  178.  
  179.     /**
  180.      * Obsolete.&nbsp;Please use Height property.
  181.      *
  182.      * @return int 
  183.      */
  184.     public function getVertSize({
  185.         return $this->height;
  186.     }
  187.  
  188.     /**
  189.      * Obsolete.&nbsp;Please use Height property.
  190.      *
  191.      * @param $value int
  192.      */
  193.     public function setVertSize($value{
  194.         $this->height $value;
  195.     }
  196.  
  197.     protected function shouldSerializeWidth({
  198.         return $this->width != $this->defaultSize;
  199.     }
  200.  
  201.     /**
  202.      * The horizontal shadow size in pixels.
  203.      *
  204.      * @return int 
  205.      */
  206.     public function getWidth({
  207.         return $this->width;
  208.     }
  209.  
  210.     /**
  211.      * Sets the horizontal shadow size in pixels.
  212.      *
  213.      * <p>Example:
  214.      * <pre><font face="Courier" size="4">
  215.      * pieSeries = new com.steema.teechart.styles.Pie(myChart.getChart());
  216.      * pieSeries.getMarks().setVisible(true);
  217.      * pieSeries.getShadow().setVisible(true);
  218.      * pieSeries.getShadow().setWidth(30);
  219.      * pieSeries.getShadow().setHeight(50);
  220.      * pieSeries.getShadow().setColor(Color.SILVER);
  221.      * pieSeries.fillSampleValues(9);
  222.      *
  223.      * @param value int
  224.      */
  225.     public function setWidth($value{
  226.         $this->width $this->setIntegerProperty($this->width$value);
  227.     }
  228.  
  229.     /**
  230.      * Defines the Brush characteristics to fill the shadow.
  231.      *
  232.      * @return ChartBrush 
  233.      */
  234.     public function getBrush({
  235.         return $this->bBrush;
  236.     }
  237.  
  238.     /**
  239.      * Size in pixels of shadow.<br>
  240.      * Returns the biggest of the HorizSize and VertSize properties.
  241.      * When setting Size, it will set both HorizSize and VertSize to the
  242.      * same $value.
  243.      *
  244.      * @return Dimension 
  245.      */
  246.     public function getSize({
  247.         return new Dimension($this->width$this->height);
  248.     }
  249.  
  250.     /**
  251.      * Sets both horizontal and vertical shadow size to same $value.
  252.      *
  253.      * @param $value int
  254.      */
  255.     public function setSize($value{
  256.       $this->width=$value;
  257.       $this->height=$value;
  258.       $this->invalidate();
  259.     }
  260.  
  261.     /**
  262.      * Size in pixels of shadow.<br>
  263.      *
  264.      * @param $value Dimension
  265.      */
  266. /*    public function setSize($value) {
  267.         $this->width = $value->width;
  268.         $this->height = $value->height;
  269.         $this->invalidate();
  270.     }
  271. */
  272.     protected function shouldSerializeVisible({
  273.         return $this->bVisible != $this->defaultVisible;
  274.     }
  275.  
  276.     /**
  277.      * Determines whether the shadow will appear on screen.
  278.      *
  279.      * @return boolean 
  280.      */
  281.     public function getVisible({
  282.         return $this->bVisible;
  283.     }
  284.  
  285.     /**
  286.      * Determines whether the shadow will appear on screen.
  287.      *
  288.      * @param $value boolean
  289.      */
  290.     public function setVisible($value{
  291.         $this->bVisible = $this->setBooleanProperty($this->bVisible$value);
  292.     }
  293.  
  294.     /**
  295.      * Draws a shadow around the Rect rectangle parameter, using the ACanvas
  296.      * canvas.<br>
  297.      * Uses the Height, Width and Transparency properties to draw the shadow.
  298.      *
  299.      * @param IGraphics3D
  300.      * @param rect Rectangle
  301.      */
  302.     public function _draw($g$rect{
  303.         $this->draw($g$rect00);
  304.     }
  305.  
  306.     /**
  307.      * Draws a shadow around the Rect rectangle parameter.<br>
  308.      * Uses the Height, Width and Transparency properties to draw the shadow.
  309.      *
  310.      * @param IGraphics3D
  311.      * @param rect Rectangle
  312.      * @param angle int
  313.      * @param aZ int
  314.      */
  315.     public function draw($g$rect$angle=0$aZ=0{
  316.  
  317.           //TChart::$controlName .='Shadow';           
  318.           if (($this->height != 0|| ($this->width != 0)) {
  319.             $g->getPen()->setVisible(false);
  320.             $g->setBrush($this->getBrush());
  321.  
  322.             $bottom new Rectangle($rect->getLeft($this->width$rect->getBottom()($rect->getRight()-$rect->getLeft()) $this->height);
  323.             $right new Rectangle($rect->getRight()$rect->getTop($this->height$this->width($rect->getBottom()-$rect->getTop()) $this->height);
  324.  
  325.             if $angle>{
  326.                     $g->polygon($aZ,$g->rotateRectangle($bottom,$angle));
  327.                     $g->polygon($aZ,$g->rotateRectangle($right,$angle));
  328.             else {
  329.                     $g->rectangle($bottom);
  330.                     $g->rectangle($right);
  331.             }
  332.  
  333. /*          Pep Changed to fix when legend have transparency
  334.             Rectangle tmp = new Rectangle(rect);
  335.             tmp.translate(width, height);
  336.  
  337.             if (angle > 0) {
  338.                 g.polygon(aZ, g.rotateRectangle(tmp, angle));
  339.             } else {
  340.                 g.rectangle(tmp);
  341.             }*/
  342.           }
  343.     }
  344.  
  345.     public function setChart($c{
  346.         parent::setChart($c);
  347.  
  348.         if ($this->bBrush != null{
  349.             $this->bBrush->setChart($this->chart);
  350.         }
  351.     }
  352. }
  353. ?>

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