home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Image / Graph / Grid / Polar.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  3.5 KB  |  111 lines

  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 Grid
  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: Polar.php,v 1.10 2005/08/24 20:36:04 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  * @since      File available since Release 0.3.0dev2
  30.  */
  31.  
  32. /**
  33.  * Include file Image/Graph/Grid.php
  34.  */
  35. require_once 'Image/Graph/Grid.php';
  36.  
  37. /**
  38.  * Display a line grid on the plotarea.
  39.  *
  40.  * {@link Image_Graph_Grid}
  41.  *
  42.  * @category   Images
  43.  * @package    Image_Graph
  44.  * @subpackage Grid
  45.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  46.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  47.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  48.  * @version    Release: 0.7.2
  49.  * @link       http://pear.php.net/package/Image_Graph
  50.  * @since      Class available since Release 0.3.0dev2
  51.  */
  52. class Image_Graph_Grid_Polar extends Image_Graph_Grid
  53. {
  54.  
  55.     /**
  56.      * GridLines [Constructor]
  57.      */
  58.     function Image_Graph_Grid_Polar()
  59.     {
  60.         parent::Image_Graph_Grid();
  61.         $this->_lineStyle = 'lightgrey';
  62.     }
  63.  
  64.     /**
  65.      * Output the grid
  66.      *
  67.      * @return bool Was the output 'good' (true) or 'bad' (false).
  68.      * @access private
  69.      */
  70.     function _done()
  71.     {
  72.         if (parent::_done() === false) {
  73.             return false;
  74.         }
  75.  
  76.         if (!$this->_primaryAxis) {
  77.             return false;
  78.         }
  79.  
  80.         $this->_canvas->startGroup(get_class($this));
  81.         
  82.         $value = false;
  83.  
  84.         $p0 = array ('X' => '#min#', 'Y' => '#min#');
  85.         if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y) {
  86.             $p1 = array ('X' => '#min#', 'Y' => '#max#');
  87.             $r0 = abs($this->_pointY($p1) - $this->_pointY($p0));
  88.         } else {
  89.             $p1 = array ('X' => '#max#', 'Y' => '#min#');
  90.             $r0 = abs($this->_pointX($p1) - $this->_pointX($p0));
  91.         }
  92.  
  93.         $cx = $this->_pointX($p0);
  94.         $cy = $this->_pointY($p0);
  95.  
  96.         $span = $this->_primaryAxis->_axisSpan;
  97.  
  98.         while (($value = $this->_primaryAxis->_getNextLabel($value)) !== false) {
  99.             $r = $r0 * ($value - $this->_primaryAxis->_getMinimum()) / $span;
  100.  
  101.             $this->_getLineStyle();
  102.             $this->_canvas->ellipse(array('x' => $cx, 'y' => $cy, 'rx' => $r, 'ry' => $r));
  103.         }
  104.         
  105.         $this->_canvas->endGroup();
  106.         
  107.         return true;
  108.     }
  109.  
  110. }
  111. ?>