upload
[pear] / Image / Graph / Marker / Plus.php
1 <?php\r
2 \r
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */\r
4 \r
5 /**\r
6  * Image_Graph - PEAR PHP OO Graph Rendering Utility.\r
7  *\r
8  * PHP versions 4 and 5\r
9  *\r
10  * LICENSE: This library is free software; you can redistribute it and/or modify\r
11  * it under the terms of the GNU Lesser General Public License as published by\r
12  * the Free Software Foundation; either version 2.1 of the License, or (at your\r
13  * option) any later version. This library is distributed in the hope that it\r
14  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty\r
15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser\r
16  * General Public License for more details. You should have received a copy of\r
17  * the GNU Lesser General Public License along with this library; if not, write\r
18  * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\r
19  * 02111-1307 USA\r
20  *\r
21  * @category   Images\r
22  * @package    Image_Graph\r
23  * @subpackage Marker\r
24  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>\r
25  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen\r
26  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1\r
27  * @version    CVS: $Id: Plus.php,v 1.7 2005/08/03 21:21:54 nosey Exp $\r
28  * @link       http://pear.php.net/package/Image_Graph\r
29  */\r
30 \r
31 /**\r
32  * Include file Image/Graph/Marker.php\r
33  */\r
34 require_once 'Image/Graph/Marker.php';\r
35 \r
36 /**\r
37  * Data marker as a plus.\r
38  *\r
39  * @category   Images\r
40  * @package    Image_Graph\r
41  * @subpackage Marker\r
42  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>\r
43  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen\r
44  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1\r
45  * @version    Release: 0.7.2\r
46  * @link       http://pear.php.net/package/Image_Graph\r
47  */\r
48 class Image_Graph_Marker_Plus extends Image_Graph_Marker\r
49 {\r
50         \r
51         /**\r
52          * The thickness of the plus in pixels (thickness is actually double this)\r
53          * @var int\r
54          * @access private\r
55          */\r
56         var $_thickness = 2;\r
57         \r
58     /**\r
59      * Draw the marker on the canvas\r
60      *\r
61      * @param int $x The X (horizontal) position (in pixels) of the marker on\r
62      *   the canvas\r
63      * @param int $y The Y (vertical) position (in pixels) of the marker on the\r
64      *   canvas\r
65      * @param array $values The values representing the data the marker 'points'\r
66      *   to\r
67      * @access private\r
68      */\r
69     function _drawMarker($x, $y, $values = false)\r
70     {\r
71         if ($this->_thickness > 0) {\r
72                 $this->_getLineStyle();\r
73                 $this->_getFillStyle();\r
74                 $this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y - $this->_thickness));\r
75                 $this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y - $this->_thickness));\r
76                 $this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y - $this->_size));\r
77                 $this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y - $this->_size));\r
78                 $this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y - $this->_thickness));\r
79                 $this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y - $this->_thickness));\r
80                 $this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y + $this->_thickness));\r
81                 $this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y + $this->_thickness));\r
82                 $this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y + $this->_size));\r
83                 $this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y + $this->_size));\r
84                 $this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y + $this->_thickness));\r
85                 $this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y + $this->_thickness));\r
86                 $this->_canvas->polygon(array('connect' => true));\r
87         } else {\r
88                 $this->_getLineStyle();\r
89                 $this->_canvas->line(array('x0' => $x - $this->_size, 'y0' => $y, 'x1' => $x + $this->_size, 'y1' => $y));\r
90                 $this->_getLineStyle();\r
91                 $this->_canvas->line(array('x0' => $x, 'y0' => $y - $this->_size, 'x1' => $x, 'y1' => $y + $this->_size));\r
92         }\r
93         parent::_drawMarker($x, $y, $values);\r
94     }\r
95 \r
96 }\r
97 \r
98 ?>