[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/Graph/Plotarea/ -> Radar.php (source)

   1  <?php
   2  
   3  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   4  
   5  /**
   6   * Image_Graph - PEAR PHP OO Graph Rendering Utility.
   7   *
   8   * PHP versions 4 and 5
   9   *
  10   * LICENSE: This library is free software; you can redistribute it and/or modify
  11   * it under the terms of the GNU Lesser General Public License as published by
  12   * the Free Software Foundation; either version 2.1 of the License, or (at your
  13   * option) any later version. This library is distributed in the hope that it
  14   * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  16   * General Public License for more details. You should have received a copy of
  17   * the GNU Lesser General Public License along with this library; if not, write
  18   * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19   * 02111-1307 USA
  20   *
  21   * @category   Images
  22   * @package    Image_Graph
  23   * @subpackage Plotarea
  24   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  25   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  26   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  27   * @version    CVS: $Id: Radar.php,v 1.8 2006/02/28 22:48:07 nosey Exp $
  28   * @link       http://pear.php.net/package/Image_Graph
  29   */
  30  
  31  /**
  32   * Include file Image/Graph/Plotarea.php
  33   */
  34  require_once  'Image/Graph/Plotarea.php';
  35  
  36  /**
  37   * Plot area used for radar plots.
  38   *
  39   * @category   Images
  40   * @package    Image_Graph
  41   * @subpackage Plotarea
  42   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  43   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  44   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  45   * @version    Release: 0.7.2
  46   * @link       http://pear.php.net/package/Image_Graph
  47   */
  48  class Image_Graph_Plotarea_Radar extends Image_Graph_Plotarea
  49  {
  50  
  51      /**
  52       * Create the plotarea, implicitely creates 2 normal axis
  53       */
  54      function Image_Graph_Plotarea_Radar()
  55      {
  56          parent::Image_Graph_Element();
  57          $this->_padding = array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10);
  58          $this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
  59          $this->_axisX->_setParent($this);
  60          $this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);
  61          $this->_axisY->_setParent($this);
  62          $this->_axisY->_setMinimum(0);
  63      }
  64  
  65      /**
  66       * Get the width of the 'real' plotarea
  67       *
  68       * @return int The width of the 'real' plotarea, ie not including space occupied by padding and axis
  69       * @access private
  70       */
  71      function _plotWidth()
  72      {
  73          return (min($this->height(), $this->width())) * 0.80;
  74      }
  75  
  76      /**
  77       * Get the height of the 'real' plotarea
  78       *
  79       * @return int The height of the 'real' plotarea, ie not including space occupied by padding and axis
  80       * @access private
  81       */
  82      function _plotHeight()
  83      {
  84          return (min($this->height(), $this->width())) * 0.80;
  85      }
  86  
  87      /**
  88       * Left boundary of the background fill area
  89       *
  90       * @return int Leftmost position on the canvas
  91       * @access private
  92       */
  93      function _fillLeft()
  94      {
  95          return (int) (($this->_left + $this->_right - $this->_plotWidth()) / 2);
  96      }
  97  
  98      /**
  99       * Top boundary of the background fill area
 100       *
 101       * @return int Topmost position on the canvas
 102       * @access private
 103       */
 104      function _fillTop()
 105      {
 106          return (int) (($this->_top + $this->_bottom - $this->_plotHeight()) / 2);
 107      }
 108  
 109      /**
 110       * Right boundary of the background fill area
 111       *
 112       * @return int Rightmost position on the canvas
 113       * @access private
 114       */
 115      function _fillRight()
 116      {
 117          return (int) (($this->_left + $this->_right + $this->_plotWidth()) / 2);
 118      }
 119  
 120      /**
 121       * Bottom boundary of the background fill area
 122       *
 123       * @return int Bottommost position on the canvas
 124       * @access private
 125       */
 126      function _fillBottom()
 127      {
 128          return (int) (($this->_top + $this->_bottom + $this->_plotHeight()) / 2);
 129      }
 130  
 131      /**
 132       * Get the X pixel position represented by a value
 133       *
 134       * @param double $value The value to get the pixel-point for
 135       * @return double The pixel position along the axis
 136       * @access private
 137       */
 138      function _pointX($value)
 139      {
 140          if (is_array($value)) {
 141              if ($value['Y'] == '#min#') {
 142                  $radius = 0;
 143              } elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
 144                  $radius = 1;
 145              } else {
 146                  $radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
 147                      ($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
 148              }
 149              $x = ($this->_left + $this->_right) / 2 -
 150                  $radius * ($this->_plotWidth() / 2) *
 151                  cos(deg2rad($this->_axisX->_point($value['X'])));
 152          }
 153          return max($this->_plotLeft, min($this->_plotRight, $x));
 154      }
 155  
 156      /**
 157       * Get the Y pixel position represented by a value
 158       *
 159       * @param double $value The value to get the pixel-point for
 160       * @return double The pixel position along the axis
 161       * @access private
 162       */
 163      function _pointY($value)
 164      {
 165          if (is_array($value)) {
 166              if ($value['Y'] == '#min#') {
 167                  $radius = 0;
 168              } elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
 169                  $radius = 1;
 170              } else {
 171                  $radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
 172                      ($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
 173              }
 174  
 175              $y = ($this->_top + $this->_bottom) / 2 -
 176                  $radius * ($this->_plotHeight() / 2) *
 177                  sin(deg2rad($this->_axisX->_point($value['X'])));
 178          }
 179          return max($this->_plotTop, min($this->_plotBottom, $y));
 180      }
 181  
 182      /**
 183       * Update coordinates
 184       *
 185       * @access private
 186       */
 187      function _updateCoords()
 188      {
 189          if (is_array($this->_elements)) {
 190              $keys = array_keys($this->_elements);
 191              foreach ($keys as $key) {
 192                  $element =& $this->_elements[$key];
 193                  if (is_a($element, 'Image_Graph_Plot')) {
 194                      $this->_setExtrema($element);
 195                  }
 196              }
 197              unset($keys);
 198          }
 199  
 200          $this->_calcEdges();
 201  
 202          $centerX = (int) (($this->_left + $this->_right) / 2);
 203          $centerY = (int) (($this->_top + $this->_bottom) / 2);
 204          $radius = min($this->_plotHeight(), $this->_plotWidth()) / 2;
 205  
 206          if (is_object($this->_axisX)) {
 207              $this->_axisX->_setCoords(
 208                  $centerX - $radius,
 209                  $centerY - $radius,
 210                  $centerX + $radius,
 211                  $centerY + $radius
 212              );
 213          }
 214  
 215          if (is_object($this->_axisY)) {
 216              $this->_axisY->_setCoords(
 217                  $centerX,
 218                  $centerY,
 219                  $centerX - $radius,
 220                  $centerY - $radius
 221              );
 222          }
 223  
 224          $this->_plotLeft = $this->_fillLeft();
 225          $this->_plotTop = $this->_fillTop();
 226          $this->_plotRight = $this->_fillRight();
 227          $this->_plotBottom = $this->_fillBottom();
 228  
 229          Image_Graph_Element::_updateCoords();
 230          
 231          if (is_object($this->_axisX)) {
 232              $this->_axisX->_updateCoords();
 233          }
 234  
 235          if (is_object($this->_axisY)) {
 236              $this->_axisY->_updateCoords();
 237          }
 238          
 239      }
 240  
 241  }
 242  
 243  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7