[ Index ]
 

Code source de Cr@wltr@ck 2.2.1

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

title

Body

[fermer]

/graphs/artichow/php5/inc/ -> Border.class.php (source)

   1  <?php
   2  /*
   3   * This work is hereby released into the Public Domain.
   4   * To view a copy of the public domain dedication,
   5   * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
   6   * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
   7   *
   8   */
   9   
  10  require_once dirname(__FILE__)."/../Graph.class.php";
  11   
  12  /**
  13   * Draw border
  14   *
  15   * @package Artichow
  16   */
  17  class awBorder {
  18  
  19      /**
  20       * Border color
  21       *
  22       * @var Color
  23       */
  24      protected $color;
  25  
  26      /**
  27       * Hide border ?
  28       *
  29       * @var bool
  30       */
  31      protected $hide = FALSE;
  32  
  33      /**
  34       * Border line style
  35       *
  36       * @var int
  37       */
  38      protected $style;
  39      
  40      /**
  41       * Build the border
  42       *
  43       * @param awColor $color Border color
  44       * @param int $style Border style
  45       */
  46  	public function __construct($color = NULL, $style = awLine::SOLID) {
  47      
  48          $this->setStyle($style);
  49          
  50          if($color instanceof awColor) {
  51              $this->setColor($color);
  52          } else {
  53              $this->setColor(new awBlack);
  54          }
  55          
  56      }
  57      
  58      /**
  59       * Change border color
  60       * This method automatically shows the border if it is hidden
  61       *
  62       * @param awColor $color
  63       */
  64  	public function setColor(awColor $color) {
  65          $this->color = $color;
  66          $this->show();
  67      }
  68      
  69      /**
  70       * Change border style
  71       *
  72       * @param int $style
  73       */
  74  	public function setStyle($style) {
  75          $this->style = (int)$style;
  76      }
  77      
  78      /**
  79       * Hide border ?
  80       *
  81       * @param bool $hide
  82       */
  83  	public function hide($hide = TRUE) {
  84          $this->hide = (bool)$hide;
  85      }
  86      
  87      /**
  88       * Show border ?
  89       *
  90       * @param bool $show
  91       */
  92  	public function show($show = TRUE) {
  93          $this->hide = (bool)!$show;
  94      }
  95      
  96      /**
  97       * Is the border visible ?
  98       *
  99       * @return bool
 100       */
 101  	public function visible() {
 102          return !$this->hide;
 103      }
 104      
 105      /**
 106       * Draw border as a rectangle
 107       *
 108       * @param awDrawer $drawer
 109       * @param awPoint $p1 Top-left corner
 110       * @param awPoint $p2 Bottom-right corner
 111       */
 112  	public function rectangle(awDrawer $drawer, awPoint $p1, awPoint $p2) {
 113      
 114          // Border is hidden
 115          if($this->hide) {
 116              return;
 117          }
 118      
 119          $line = new awLine;
 120          $line->setStyle($this->style);
 121          $line->setLocation($p1, $p2);
 122          
 123          $drawer->rectangle($this->color, $line);
 124          
 125      }
 126      
 127      /**
 128       * Draw border as an ellipse
 129       *
 130       * @param awDrawer $drawer
 131       * @param awPoint $center Ellipse center
 132       * @param int $width Ellipse width
 133       * @param int $height Ellipse height
 134       */
 135  	public function ellipse(awDrawer $drawer, awPoint $center, $width, $height) {
 136      
 137          // Border is hidden
 138          if($this->hide) {
 139              return;
 140          }
 141          
 142          switch($this->style) {
 143          
 144              case awLine::SOLID :
 145                  $drawer->ellipse($this->color, $center, $width, $height);
 146                  break;
 147              
 148              default :
 149                  awImage::drawError("Class Border: Dashed and dotted borders and not yet implemented on ellipses.");
 150                  break;
 151          
 152          }
 153          
 154          
 155      }
 156  
 157  }
 158  
 159  registerClass('Border');
 160  ?>


Généré le : Thu Sep 6 14:14:11 2007 par Balluche grâce à PHPXref 0.7