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 / Font.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.0 KB  |  158 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 Text
  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: Font.php,v 1.8 2005/08/24 20:35:55 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  */
  30.  
  31. /**
  32.  * Include file Image/Graph/Common.php
  33.  */
  34. require_once 'Image/Graph/Common.php';
  35.  
  36. /**
  37.  * A font.
  38.  *
  39.  * @category   Images
  40.  * @package    Image_Graph
  41.  * @subpackage Text
  42.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  43.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  44.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  45.  * @version    Release: 0.7.2
  46.  * @link       http://pear.php.net/package/Image_Graph
  47.  * @abstract
  48.  */
  49. class Image_Graph_Font extends Image_Graph_Common
  50. {
  51.  
  52.     /**
  53.      * The name of the font
  54.      * @var string
  55.      * @access private
  56.      */
  57.     var $_name = false;
  58.  
  59.     /**
  60.      * The angle of the output
  61.      * @var int
  62.      * @access private
  63.      */
  64.     var $_angle = false;
  65.  
  66.     /**
  67.      * The size of the font
  68.      * @var int
  69.      * @access private
  70.      */
  71.     var $_size = 11;
  72.     
  73.     /**
  74.      * The color of the font
  75.      * @var Color
  76.      * @access private
  77.      */
  78.     var $_color = 'black';
  79.  
  80.     /**
  81.      * Image_Graph_Font [Constructor]
  82.      */
  83.     function Image_Graph_Font($name = false, $size = false)
  84.     {
  85.         parent::Image_Graph_Common();
  86.         if ($name !== false) {
  87.             $this->_name = $name;
  88.         }
  89.         if ($size !== false) {
  90.             $this->_size = $size;
  91.         }
  92.     }
  93.  
  94.     /**
  95.      * Set the color of the font
  96.      *
  97.      * @param mixed $color The color object of the Font
  98.      */
  99.     function setColor($color)
  100.     {
  101.         $this->_color = $color;
  102.     }
  103.  
  104.     /**
  105.      * Set the angle slope of the output font.
  106.      *
  107.      * 0 = normal, 90 = bottom and up, 180 = upside down, 270 = top and down
  108.      *
  109.      * @param int $angle The angle in degrees to slope the text
  110.      */
  111.     function setAngle($angle)
  112.     {
  113.         $this->_angle = $angle;
  114.     }
  115.  
  116.     /**
  117.      * Set the size of the font
  118.      *
  119.      * @param int $size The size in pixels of the font
  120.      */
  121.     function setSize($size)
  122.     {
  123.         $this->_size = $size;
  124.     }
  125.     
  126.     /**
  127.      * Get the font 'array'
  128.      *
  129.      * @return array The font 'summary' to pass to the canvas
  130.      * @access private
  131.      */
  132.     function _getFont($options = false)
  133.     {
  134.         if ($options === false) {
  135.             $options = array();
  136.         }
  137.         
  138.         if ($this->_name !== false) {
  139.             $options['name'] = $this->_name;
  140.         }
  141.         
  142.         if (!isset($options['color'])) {
  143.             $options['color'] = $this->_color;
  144.         }
  145.  
  146.         if (!isset($options['size'])) {
  147.             $options['size'] = $this->_size;
  148.         }
  149.  
  150.         if ((!isset($options['angle'])) && ($this->_angle !== false)) {
  151.             $options['angle'] = $this->_angle;
  152.         }
  153.         return $options;
  154.     }
  155.  
  156. }
  157.  
  158. ?>