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 / Marker / Array.php next >
Encoding:
PHP Script  |  2008-07-02  |  3.4 KB  |  105 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 Marker
  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: Array.php,v 1.6 2005/02/21 20:49:50 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  */
  30.  
  31. /**
  32.  * Include file Image/Graph/Marker.php
  33.  */
  34. require_once 'Image/Graph/Marker.php';
  35.  
  36. /**
  37.  * A sequential array of markers.
  38.  *
  39.  * This is used for displaying different markers for datapoints on a chart.
  40.  * This is done by adding multiple markers to a MarkerArrray structure.
  41.  * The marker array will then when requested return the 'next' marker in
  42.  * sequential order. It is possible to specify ID tags to each marker, which is
  43.  * used to make sure some data uses a specific marker.
  44.  *
  45.  * @category   Images
  46.  * @package    Image_Graph
  47.  * @subpackage Marker
  48.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  49.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  50.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  51.  * @version    Release: 0.7.2
  52.  * @link       http://pear.php.net/package/Image_Graph
  53.  */
  54. class Image_Graph_Marker_Array extends Image_Graph_Marker
  55. {
  56.  
  57.     /**
  58.      * The marker array
  59.      * @var array
  60.      * @access private
  61.      */
  62.     var $_markers = array ();
  63.  
  64.     /**
  65.      * Add a marker style to the array
  66.      *
  67.      * @param Marker $marker The marker to add
  68.      */
  69.     function add(& $marker)
  70.     {
  71.         if (is_a($marker, 'Image_Graph_Element')) {
  72.             parent::add($marker);
  73.         }
  74.         $this->_markers[] =& $marker;
  75.         reset($this->_markers);
  76.     }
  77.  
  78.     /**
  79.      * Draw the marker on the canvas
  80.      *
  81.      * @param int $x The X (horizontal) position (in pixels) of the marker on
  82.      *   the canvas
  83.      * @param int $y The Y (vertical) position (in pixels) of the marker on the
  84.      *   canvas
  85.      * @param array $values The values representing the data the marker 'points'
  86.      *   to
  87.      * @access private
  88.      */
  89.     function _drawMarker($x, $y, $values = false)
  90.     {
  91.         $ID = key($this->_markers);
  92.         if (!next($this->_markers)) {
  93.             reset($this->_markers);
  94.         }
  95.         $marker =& $this->_markers[$ID];
  96.  
  97.         if ($marker != null) {
  98.             $marker->_drawMarker($x, $y, $values);
  99.         }
  100.         parent::_drawMarker($x, $y, $values);
  101.     }
  102.  
  103. }
  104.  
  105. ?>