upload
[pear] / Image / Graph / Figure / Rectangle.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 Figure\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: Rectangle.php,v 1.9 2005/08/24 20:36:01 nosey Exp $\r
28  * @link       http://pear.php.net/package/Image_Graph\r
29  */\r
30 \r
31 /**\r
32  * Include file Image/Graph/Element.php\r
33  */\r
34 require_once 'Image/Graph/Element.php';\r
35 \r
36 /**\r
37  * Rectangle to draw on the canvas\r
38  *\r
39  * @category   Images\r
40  * @package    Image_Graph\r
41  * @subpackage Figure\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_Figure_Rectangle extends Image_Graph_Element\r
49 {\r
50 \r
51     /**\r
52      * Rectangle [Construcor]\r
53      *\r
54      * @param int $x The leftmost pixel of the box on the canvas\r
55      * @param int $y The topmost pixel of the box on the canvas\r
56      * @param int $width The width in pixels of the box on the canvas\r
57      * @param int $height The height in pixels of the box on the canvas\r
58      */\r
59     function Image_Graph_Figure_Rectangle($x, $y, $width, $height)\r
60     {\r
61         parent::Image_Graph_Element();\r
62         $this->_setCoords($x, $y, $x + $width, $y + $height);\r
63     }\r
64 \r
65     /**\r
66      * Output the box\r
67      *\r
68      * @return bool Was the output 'good' (true) or 'bad' (false).\r
69      * @access private\r
70      */\r
71     function _done()\r
72     {\r
73         if (parent::_done() === false) {\r
74             return false;\r
75         }\r
76 \r
77         $this->_canvas->startGroup(get_class($this));\r
78         \r
79         $this->_getFillStyle();\r
80         $this->_getLineStyle();\r
81         $this->_canvas->rectangle(\r
82                 array(\r
83                 'x0' => $this->_left,\r
84                 'y0' => $this->_top,\r
85                 'x1' => $this->_right,\r
86                 'y1' => $this->_bottom\r
87             )\r
88         );\r
89         \r
90         $this->_canvas->endGroup();\r
91         \r
92         return true;\r
93     }\r
94 \r
95 }\r
96 ?>