linea21-externals
[ class tree: linea21-externals ] [ index: linea21-externals ] [ all elements ]

Source for file Text.class.php

Documentation is available at Text.class.php

  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.  * To handle text
  14.  *
  15.  * @package linea21.externals
  16.  * @subpackage artichow
  17.  */
  18. class awText {
  19.  
  20.     /**
  21.      * Your text
  22.      *
  23.      * @var string 
  24.      */
  25.     var $text;
  26.  
  27.     /**
  28.      * Text font
  29.      *
  30.      * @var Font 
  31.      */
  32.     var $font;
  33.  
  34.     /**
  35.      * Text angle
  36.      * Can be 0 or 90
  37.      *
  38.      * @var int 
  39.      */
  40.     var $angle;
  41.  
  42.     /**
  43.      * Text color
  44.      *
  45.      * @var Color 
  46.      */
  47.     var $color;
  48.  
  49.     /**
  50.      * Text background
  51.      *
  52.      * @var Color, Gradient
  53.      */
  54.     var $background;
  55.  
  56.     /**
  57.      * Padding
  58.      *
  59.      * @var array Array for left, right, top and bottom paddings
  60.      */
  61.     var $padding;
  62.  
  63.     /**
  64.      * Text border
  65.      *
  66.      * @var Border 
  67.      */
  68.     var $border;
  69.     
  70.     /**
  71.      * Build a new awtext
  72.      *
  73.      * @param string $text Your text
  74.      */
  75.      function awText($text$font NULL$color NULL$angle 0{
  76.     
  77.         if(is_null($font)) {
  78.             $font new awFont2;
  79.         }
  80.         
  81.         $this->setText($text);
  82.         $this->setFont($font);
  83.         
  84.         // Set default color to black
  85.         if($color === NULL{
  86.             $color new awColor(000);
  87.         }
  88.         
  89.         $this->setColor($color);
  90.         $this->setAngle($angle);
  91.         
  92.         $this->border = new awBorder;
  93.         $this->border->hide();
  94.     
  95.     }
  96.     
  97.     /**
  98.      * Get text
  99.      *
  100.      * @return string 
  101.      */
  102.      function getText({
  103.         return $this->text;
  104.     }
  105.     
  106.     /**
  107.      * Change text
  108.      *
  109.      * @param string $text New text
  110.      */
  111.      function setText($text{
  112.         $this->text = (string)$text;
  113.         $this->text str_replace("\r"""$text);
  114.     }
  115.  
  116.     /**
  117.      * Change text font
  118.      *
  119.      * @param Font 
  120.      */
  121.      function setFont(&$font{
  122.         $this->font $font;
  123.     }
  124.     
  125.     /**
  126.      * Get text font
  127.      *
  128.      * @return int 
  129.      */
  130.      function getFont({
  131.         return $this->font;
  132.     }
  133.  
  134.     /**
  135.      * Change text angle
  136.      *
  137.      * @param int 
  138.      */
  139.      function setAngle($angle{
  140.         $this->angle = (int)$angle;
  141.     }
  142.     
  143.     /**
  144.      * Get text angle
  145.      *
  146.      * @return int 
  147.      */
  148.      function getAngle({
  149.         return $this->angle;
  150.     }
  151.  
  152.     /**
  153.      * Change text color
  154.      *
  155.      * @param Color 
  156.      */
  157.      function setColor($color{
  158.         $this->color $color;
  159.     }
  160.     
  161.     /**
  162.      * Get text color
  163.      *
  164.      * @return Color 
  165.      */
  166.      function getColor({
  167.         return $this->color;
  168.     }
  169.     
  170.     /**
  171.      * Change text background
  172.      * 
  173.      * @param mixed $background 
  174.      */
  175.      function setBackground($background{
  176.         if(is_a($background'awColor')) {
  177.             $this->setBackgroundColor($background);
  178.         elseif(is_a($background'awGradient')) {
  179.             $this->setBackgroundGradient($background);
  180.         }
  181.     }
  182.     
  183.     /**
  184.      * Change text background color
  185.      *
  186.      * @param $color 
  187.      */
  188.      function setBackgroundColor($color{
  189.         $this->background $color;
  190.     }
  191.     
  192.     /**
  193.      * Change text background gradient
  194.      *
  195.      * @param $gradient 
  196.      */
  197.      function setBackgroundGradient($gradient{
  198.         $this->background $gradient;
  199.     }
  200.     
  201.     /**
  202.      * Get text background
  203.      *
  204.      * @return Color, Gradient
  205.      */
  206.      function getBackground({
  207.         return $this->background;
  208.     }
  209.  
  210.     /**
  211.      * Change padding
  212.      *
  213.      * @param int $left Left padding
  214.      * @param int $right Right padding
  215.      * @param int $top Top padding
  216.      * @param int $bottom Bottom padding
  217.      */
  218.      function setPadding($left$right$top$bottom{
  219.         $this->padding array((int)$left(int)$right(int)$top(int)$bottom);
  220.     }
  221.     
  222.     /**
  223.      * Get current padding
  224.      *
  225.      * @return array 
  226.      */
  227.      function getPadding({
  228.         return $this->padding;
  229.     }
  230.  
  231. }
  232.  
  233. registerClass('Text');
  234. ?>

Documentation generated on Fri, 16 Oct 2009 09:39:58 +0200 by phpDocumentor 1.4.1