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

Source for file Dimension.php

Documentation is available at Dimension.php

  1. <?php
  2.  
  3.  /**
  4.  * Dimension class
  5.  *
  6.  * Description:
  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 Dimension {
  16.  
  17.     // Interceptors
  18.     function __get$property {
  19.       $method ="get{$property}";
  20.       if method_exists$this$method ) ) {
  21.         return $this->$method();
  22.       }
  23.     }
  24.  
  25.     function __set $property,$value {
  26.       $method ="set{$property}";
  27.       if method_exists$this$method ) ) {
  28.         return $this->$method($value);
  29.       }
  30.     }
  31.  
  32.     /**
  33.      * The width dimension; negative values can be used.
  34.      *
  35.      * @see #getSize
  36.      * @see #setSize
  37.      */
  38.     public $width;
  39.  
  40.     /**
  41.      * The height dimension; negative values can be used.
  42.      *
  43.      * @see #getSize
  44.      * @see #setSize
  45.      */
  46.     public $height;
  47.  
  48.     /**
  49.      * Constructs a <code>Dimension</code> and initializes
  50.      * it to the specified width and specified height.
  51.      *
  52.      * @param width the specified width
  53.      * @param height the specified height
  54.      */
  55.     public function Dimension($width=0,$height=0{
  56.         $this->width=$width;
  57.         $this->height=$height;
  58.     }
  59.  
  60.     /**
  61.      * Returns the width of this dimension in double precision.
  62.      * @return the width of this dimension in double precision
  63.      */
  64.     public function getWidth({
  65.         return $this->width;
  66.     }
  67.  
  68.     /**
  69.      * Returns the height of this dimension in double precision.
  70.      * @return the height of this dimension in double precision
  71.      */
  72.     public function getHeight({
  73.         return $this->height;
  74.     }
  75.  
  76.     /**
  77.      * Sets the size of this <code>Dimension</code> object to
  78.      * the specified width and height in double precision.
  79.      * Note that if <code>width</code> or <code>height</code>
  80.      * are larger than <code>Integer.MAX_VALUE</code>, they will
  81.      * be reset to <code>Integer.MAX_VALUE</code>.
  82.      *
  83.      * @param width  the new width for the <code>Dimension</code> object
  84.      * @param height the new height for the <code>Dimension</code> object
  85.      */
  86.     public function setSize($width$height{
  87.         $this->width = ceil($width);
  88.         $this->height = ceil($height);
  89.     }
  90.  
  91.     /**
  92.      * Gets the size of this <code>Dimension</code> object.
  93.      * This method is included for completeness, to parallel the
  94.      * <code>getSize</code> method defined by <code>Component</code>.
  95.      *
  96.      * @return   the size of this dimension, a new instance of
  97.      *            <code>Dimension</code> with the same width and height
  98.      */
  99.     public function getSize({
  100.         return new Dimension($this->width$this->height);
  101.     }
  102.  
  103.     /**
  104.      * Checks whether two dimension objects have equal values.
  105.      */
  106.     public function equals($obj{
  107.         if ($obj instanceof Dimension{
  108.             $d $obj;
  109.             return ($this->width == $d->width&& ($this->height == $d->height);
  110.         }
  111.         return false;
  112.     }
  113.  
  114.     /**
  115.      * Returns the hash code for this <code>Dimension</code>.
  116.      *
  117.      * @return    hash code for this <code>Dimension</code>
  118.      */
  119.     public function hashCode({
  120.         $sum $this->width + $this->height;
  121.         return $sum ($sum 1)/$this->width;
  122.     }
  123. }
  124. ?>

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