[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/Graph/ -> Logo.php (source)

   1  <?php
   2  
   3  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   4  
   5  /**
   6   * Image_Graph - Main class for the graph creation.
   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 Logo
  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: Logo.php,v 1.9 2005/08/24 20:35:56 nosey Exp $
  28   * @link       http://pear.php.net/package/Image_Graph
  29   */
  30  
  31  /**
  32   * Include file Image/Graph/Element.php
  33   */
  34  require_once  'Image/Graph/Element.php';
  35  
  36  /**
  37   * Displays a logo on the canvas.
  38   *
  39   * By default the logo is displayed in the top-right corner of the canvas.
  40   * 
  41   * @category   Images
  42   * @package    Image_Graph
  43   * @subpackage Logo
  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_Logo extends Image_Graph_Element
  51  {
  52  
  53      /**
  54       * The file name
  55       * @var stirng
  56       * @access private
  57       */
  58      var $_filename;
  59  
  60      /**
  61       * The GD Image resource
  62       * @var resource
  63       * @access private
  64       */
  65      var $_image;
  66  
  67      /**
  68       * Alignment of the logo
  69       * @var int
  70       * @access private
  71       */
  72      var $_alignment;
  73  
  74      /**
  75       * Logo [Constructor]
  76       *
  77       * @param string $filename The filename and path of the image to use for logo
  78       */
  79      function Image_Graph_Logo($filename, $alignment = IMAGE_GRAPH_ALIGN_TOP_RIGHT)
  80      {
  81          parent::Image_Graph_Element();
  82          $this->_filename = $filename;
  83          $this->_alignment = $alignment;
  84      }
  85  
  86      /**
  87       * Sets the parent. The parent chain should ultimately be a GraPHP object
  88       *
  89       * @see Image_Graph
  90       * @param Image_Graph_Common $parent The parent
  91       * @access private
  92       */
  93      function _setParent(& $parent)
  94      {
  95          parent::_setParent($parent);
  96          $this->_setCoords(
  97              $this->_parent->_left,
  98              $this->_parent->_top,
  99              $this->_parent->_right,
 100              $this->_parent->_bottom
 101          );
 102      }
 103  
 104      /**
 105       * Output the logo
 106       *
 107       * @return bool Was the output 'good' (true) or 'bad' (false).
 108       * @access private
 109       */
 110      function _done()
 111      {
 112          if (parent::_done() === false) {
 113              return false;
 114          }
 115  
 116          $align = array();
 117  
 118          if ($this->_alignment & IMAGE_GRAPH_ALIGN_LEFT) {
 119              $x = $this->_parent->_left + 2;
 120              $align['horizontal'] = 'left';
 121          } elseif ($this->_alignment & IMAGE_GRAPH_ALIGN_RIGHT) {
 122              $x = $this->_parent->_right - 2;
 123              $align['horizontal'] = 'right';
 124          } else {
 125              $x = ($this->_parent->_left + $this->_parent->_right) / 2;
 126              $align['horizontal'] = 'center';
 127          }
 128  
 129          if ($this->_alignment & IMAGE_GRAPH_ALIGN_TOP) {
 130              $y = $this->_parent->_top + 2;
 131              $align['vertical'] = 'top';
 132          } elseif ($this->_alignment & IMAGE_GRAPH_ALIGN_BOTTOM) {
 133              $y = $this->_parent->_bottom - 2;
 134              $align['vertical'] = 'bottom';
 135          } else {
 136              $y = ($this->_parent->_top + $this->_parent->_bottom) / 2;
 137              $align['vertical'] = 'center';
 138          }
 139  
 140          $this->_canvas->image(
 141              array(
 142                  'x' => $x,
 143                  'y' => $y,
 144                  'filename' => $this->_filename,
 145                  'alignment' => $align
 146              )
 147          );
 148          return true;
 149      }
 150  
 151  }
 152  
 153  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7