1<?php 2 3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 5/** 6 * Class file containing a axis marker used for explicitly highlighting a point 7 * (line) on the graph, based on an value specified on an axis. 8 * 9 * PHP version 5 10 * 11 * LICENSE: This library is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published by 13 * the Free Software Foundation; either version 2.1 of the License, or (at your 14 * option) any later version. This library is distributed in the hope that it 15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 17 * General Public License for more details. You should have received a copy of 18 * the GNU Lesser General Public License along with this library; if not, write 19 * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 * 02111-1307 USA 21 * 22 * @category Images 23 * @package Image_Graph 24 * @subpackage Grid 25 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 26 * @author Stefan Neufeind <pear.neufeind@speedpartner.de> 27 * @copyright 2003-2009 The PHP Group 28 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 29 * @version SVN: $Id: Line.php 291170 2009-11-23 03:50:22Z neufeind $ 30 * @link http://pear.php.net/package/Image_Graph 31 */ 32 33/** 34 * Include file Image/Graph/Grid.php 35 */ 36require_once 'Image/Graph/Grid.php'; 37 38/** 39 * Display a grid 40 * 41 * {@link Image_Graph_Grid} 42 * 43 * @category Images 44 * @package Image_Graph 45 * @subpackage Grid 46 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 47 * @author Stefan Neufeind <pear.neufeind@speedpartner.de> 48 * @copyright 2003-2009 The PHP Group 49 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 50 * @version Release: 0.8.0 51 * @link http://pear.php.net/package/Image_Graph 52 */ 53class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid 54{ 55 56 /** 57 * The value 58 * @var double 59 * @access private 60 */ 61 var $_value = false; 62 63 /** 64 * Sets the value of the line marker (value on the axis) 65 * 66 * @param double $value the value 67 * 68 * @return void 69 */ 70 function setValue($value) 71 { 72 $this->_value = $value; 73 } 74 75 /** 76 * Output the grid 77 * 78 * @return bool Was the output 'good' (true) or 'bad' (false). 79 * @access private 80 */ 81 function _done() 82 { 83 if (parent::_done() === false) { 84 return false; 85 } 86 87 if (!$this->_primaryAxis) { 88 return false; 89 } 90 91 $this->_canvas->startGroup(get_class($this)); 92 93 $i = 0; 94 95 $this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value)); 96 97 $secondaryPoints = $this->_getSecondaryAxisPoints(); 98 99 reset($secondaryPoints); 100 list ($id, $previousSecondaryValue) = each($secondaryPoints); 101 while (list ($id, $secondaryValue) = each($secondaryPoints)) { 102 if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) { 103 $p1 = array ('X' => $this->_value, 'Y' => $secondaryValue); 104 $p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue); 105 } else { 106 $p1 = array ('X' => $secondaryValue, 'Y' => $this->_value); 107 $p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value); 108 } 109 110 $x1 = $this->_pointX($p1); 111 $y1 = $this->_pointY($p1); 112 $x2 = $this->_pointX($p2); 113 $y2 = $this->_pointY($p2); 114 115 $previousSecondaryValue = $secondaryValue; 116 117 $this->_getLineStyle(); 118 $this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2)); 119 } 120 121 $this->_canvas->endGroup(); 122 123 return true; 124 } 125 126} 127 128?>