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 / Pointing.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.3 KB  |  140 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: Pointing.php,v 1.8 2005/08/24 20:35:54 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.  * Data marker as a 'pointing marker'.
  38.  *
  39.  * Points to the data using another marker (as start and/or end)
  40.  *
  41.  * @category   Images
  42.  * @package    Image_Graph
  43.  * @subpackage Marker
  44.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  45.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  46.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  47.  * @version    Release: 0.7.2
  48.  * @link       http://pear.php.net/package/Image_Graph
  49.  */
  50. class Image_Graph_Marker_Pointing extends Image_Graph_Marker
  51. {
  52.  
  53.     /**
  54.      * The starting marker
  55.      * @var Marker
  56.      * @access private
  57.      */
  58.     var $_markerStart;
  59.  
  60.     /**
  61.      * The ending marker
  62.      * @var Marker
  63.      * @access private
  64.      */
  65.     var $_markerEnd;
  66.  
  67.     /**
  68.      * The X offset from the 'data'
  69.      * @var int
  70.      * @access private
  71.      */
  72.     var $_deltaX = -1;
  73.  
  74.     /**
  75.      * The Y offset from the 'data'
  76.      * @var int
  77.      * @access private
  78.      */
  79.     var $_deltaY = -1;
  80.  
  81.     /**
  82.      * Create an pointing marker, ie a pin on a board
  83.      *
  84.      * @param int $deltaX The the X offset from the real 'data' point
  85.      * @param int $deltaY The the Y offset from the real 'data' point
  86.      * @param Marker $markerEnd The ending marker that represents 'the head of
  87.      *   the pin'
  88.      */
  89.     function Image_Graph_Marker_Pointing($deltaX, $deltaY, & $markerEnd)
  90.     {
  91.         parent::Image_Graph_Marker();
  92.         $this->_deltaX = $deltaX;
  93.         $this->_deltaY = $deltaY;
  94.         $this->_markerStart = null;
  95.         $this->_markerEnd =& $markerEnd;
  96.     }
  97.  
  98.     /**
  99.      * Sets the starting marker, ie the tip of the pin on a board
  100.      *
  101.      * @param Marker $markerStart The starting marker that represents 'the tip
  102.      *   of the pin'
  103.      */
  104.     function setMarkerStart(& $markerStart)
  105.     {
  106.         $this->_markerStart =& $markerStart;
  107.         $this->_markerStart->_setParent($this);
  108.     }
  109.  
  110.     /**
  111.      * Draw the marker on the canvas
  112.      *
  113.      * @param int $x The X (horizontal) position (in pixels) of the marker on
  114.      *   the canvas
  115.      * @param int $y The Y (vertical) position (in pixels) of the marker on the
  116.      *   canvas
  117.      * @param array $values The values representing the data the marker 'points'
  118.      *   to
  119.      * @access private
  120.      */
  121.     function _drawMarker($x, $y, $values = false)
  122.     {
  123.         parent::_drawMarker($x, $y, $values);
  124.         if ($this->_markerStart) {
  125.             $this->_markerStart->_setParent($this);
  126.             $this->_markerStart->_drawMarker($x, $y, $values);
  127.         }
  128.         $this->_getLineStyle();
  129.         $this->_canvas->line(array('x0' => $x, 'y0' => $y, 'x1' => $x + $this->_deltaX, 'y1' => $y + $this->_deltaY));
  130.         $this->_markerEnd->_setParent($this);
  131.         $this->_markerEnd->_drawMarker(
  132.             $x + $this->_deltaX,
  133.             $y + $this->_deltaY,
  134.             $values
  135.         );
  136.     }
  137.  
  138. }
  139.  
  140. ?>