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

Source for file LegendSymbol.php

Documentation is available at LegendSymbol.php

  1. <?php
  2.  
  3. /**
  4.   *
  5.   * <p>Title: LegendSymbol class</p>
  6.   *
  7.   * <p>Description: Legend item symbol characteristics</p>
  8.   *
  9.   * <p>Copyright (c) 2005-2010 by Steema Software SL. All Rights
  10.   * Reserved.</p>
  11.   *
  12.   * <p>Company: Steema Software SL</p>
  13.   *
  14.   */
  15.  
  16.   class LegendSymbol extends TeeBase {
  17.  
  18.     /**
  19.     * Determines if legend symbol should display without separation from other
  20.     * legend item symbols.
  21.     */
  22.  
  23.     /* todo review protected*/ public $continuous=false;
  24.  
  25.     /**
  26.     * Controls where to display the legend symbol related to symbol item.
  27.     */
  28.     /* todo review protected*/ public $position;
  29.  
  30.     /**
  31.     * Internal field pointing to parent legend class
  32.     */
  33.     public $legend;
  34.     private $defaultPen=true;
  35.     private $width 20;
  36.     private $widthUnits;
  37.     private $iPen;
  38.     private $squared=false;
  39.     private $visible=true;
  40.  
  41.  
  42.     // Interceptors
  43.     function __get$property {
  44.       $method ="get{$property}";
  45.       if method_exists$this$method ) ) {
  46.         return $this->$method();
  47.       }
  48.     }
  49.  
  50.     function __set $property,$value {
  51.       $method ="set{$property}";
  52.       if method_exists$this$method ) ) {
  53.         return $this->$method($value);
  54.       }
  55.     }
  56.  
  57.     /**
  58.     * The class constructor.
  59.     */
  60.     public function LegendSymbol($legend{
  61.  
  62.         $this->position = LegendSymbolPosition::$LEFT;
  63.         $this->widthUnits LegendSymbolSize::$PERCENT;
  64.  
  65.         parent::__construct($legend->chart);
  66.        
  67.         $this->readResolve();
  68.         $this->legend = $legend;
  69.     }
  70.  
  71.     protected function readResolve({
  72.         $this->defaultPen=true;
  73.         return $this;
  74.     }
  75.  
  76.         /**
  77.           * Defines the width of the color rectangles (symbols).<br>
  78.           * Default value: 20
  79.           *
  80.           * @return int 
  81.           */
  82.     public function getWidth({
  83.         return $this->width;
  84.     }
  85.  
  86.     public function setWidth($value{
  87.         $this->width $this->setIntegerProperty($this->width$value);
  88.     }
  89.  
  90.         /**
  91.           * The position of the Legend color rectangles. <br>
  92.           * It can have one of the following values: <br>
  93.           * Left      The color rectangles are placed left of the legend items <br>
  94.           * Right    The color rectangles are placed right of the legend items <br>
  95.           * Default value: Left
  96.           *
  97.           * @return LegendSymbolPosition 
  98.           */
  99.     public function getPosition({
  100.         return $this->position;
  101.     }
  102.  
  103.         /**
  104.           * Sets the position of the Legend color rectangles. <br>
  105.           * Default value: Left
  106.           *
  107.           * @param value LegendSymbolPosition
  108.           */
  109.     public function setPosition($value{
  110.         if ($this->position != $value{
  111.             $this->position = $value;
  112.             $this->invalidate();
  113.         }
  114.     }
  115.  
  116.         /**
  117.           * Defines the Width units for the width of Symbol.<br><br>
  118.           * - Percent is percentage of Legend box width <br>
  119.           * - Pixels is the width in standard pixels <br>
  120.           * Default value: Percent
  121.           *
  122.           * @return LegendSymbolSize 
  123.           */
  124.     public function getWidthUnits({
  125.         return $this->widthUnits;
  126.     }
  127.  
  128.         /**
  129.           * Sets the Width units for the width of Symbol.<br><br>
  130.           * Default value: Percent
  131.           *
  132.           * @param value LegendSymbolSize
  133.           */
  134.     public function setWidthUnits($value{
  135.         if ($this->widthUnits != $value{
  136.             $this->widthUnits $value;
  137.             $this->invalidate();
  138.         }
  139.     }
  140.  
  141.         /**
  142.           * Adjoins the different legend color rectangles when true.<br> The color
  143.           * rectangles of the different items are drawn attached to each other
  144.           * (no vertical spacing). When false, the color rectangles are drawn as
  145.           * seperate rectangles. <br>
  146.           * Default value: false
  147.           *
  148.           * @return boolean 
  149.           */
  150.     public function getContinuous({
  151.         return $this->continuous;
  152.     }
  153.  
  154.         /**
  155.           * Adjoins the different legend color rectangles when true.<br>
  156.           * Default value: false
  157.           *
  158.           * @param value boolean
  159.           */
  160.     public function setContinuous($value{
  161.         $this->continuous = $this->setBooleanProperty($this->continuous$value);
  162.     }
  163.  
  164.         /**
  165.           * Uses series pen properties to draw a border around the coloured box
  166.           * legend symbol, when true. When false, the Legend will use the legend
  167.           * symbol Pen property. <br>
  168.           * Default value: true
  169.           *
  170.           * @return boolean 
  171.           */
  172.     public function getDefaultPen({
  173.         return $this->defaultPen;
  174.     }
  175.  
  176.         /**
  177.           * Uses series pen properties to draw a border around the coloured box
  178.           * legend symbol, when true. When false, the Legend will use the legend
  179.           * symbol Pen property. <br>
  180.           * Default value: true
  181.           *
  182.           * @param value boolean
  183.           */
  184.     public function setDefaultPen($value{
  185.         $this->defaultPen $this->setBooleanProperty($this->defaultPen$value);
  186.     }
  187.  
  188.     /*todo review protected*/ public function calcWidth($value{
  189.         if ($this->visible{
  190.             if ($this->squared{
  191.                 return $this->legend->calcItemHeight(5;
  192.             else
  193.             if ($this->widthUnits == LegendSymbolSize::$PERCENT{
  194.                 return MathUtils::round($this->width $value 0.01);
  195.             else {
  196.                 return $this->width;
  197.             }
  198.         else {
  199.             return 0;
  200.         }
  201.     }
  202.  
  203.         /**
  204.           * pen used to draw a border around the color box legend symbols. <br>
  205.           * By default this pen is not used. Instead, the appropiate Series pen is
  206.           * used to draw the symbols borders.<br>
  207.           * To use this Pen, first set DefaultPen to false.
  208.           *
  209.           * @return ChartPen 
  210.           */
  211.     public function getPen({
  212.         if ($this->iPen == null{
  213.             $this->iPen new ChartPen($this->legend->chart);
  214.         }
  215.         return $this->iPen;
  216.     }
  217.  
  218.         /**
  219.           * Resizes the legend symbol to square shaped, when true.<br>
  220.           * When false, the legend symbol height is determined by the legend font
  221.           * size, and the symbol width is calculated using the Width and WidthUnits
  222.           * properties.<br>
  223.           * Default value: false
  224.           *
  225.           * @return boolean 
  226.           */
  227.     public function getSquared({
  228.         return $this->squared;
  229.     }
  230.  
  231.         /**
  232.           * Resizes the legend symbol to square shaped, when true.<br>
  233.           *
  234.           * @param value boolean
  235.           */
  236.     public function setSquared($value{
  237.         $this->squared $this->setBooleanProperty($this->squared$value);
  238.     }
  239.  
  240.         /**
  241.           * Shows or hides Legend symbols.<br>
  242.           * Default value: true
  243.           *
  244.           * @return boolean 
  245.           */
  246.     public function getVisible({
  247.         return $this->visible;
  248.     }
  249.  
  250.         /**
  251.           * Shows or hides Legend symbols.<br>
  252.           * Default value: true
  253.           *
  254.           * @param value boolean
  255.           */
  256.     public function setVisible($value{
  257.         $this->visible $this->setBooleanProperty($this->visible$value);
  258.     }
  259. }
  260.  
  261. ?>

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