Source for file Label.class.php
Documentation is available at Label.class.php 
 * This work is hereby released into the Public Domain.  
 * To view a copy of the public domain dedication,  
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to  
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.  
require_once dirname(__FILE__ ). "/../Graph.class.php";  
 * @package linea21.externals  
class awLabel implements awPositionable {  
     * Move position from this vector  
    protected $hAlign =  awLabel::CENTER;  
    protected $vAlign =  awLabel::MIDDLE;  
     * @param string $label First label  
    public function __construct($label =  NULL, $font =  NULL, $color =  NULL, $angle =  0) {  
            $this->set(array($label));  
     * Get an element of the label from its key  
     * @param int $key Element key  
    public function get($key) {  
     * Set one or several labels  
     * @param array $labels Array of string or a string  
    public function set($labels) {  
            $this->texts =  array((string) $labels);  
     * Count number of texts in the label  
    public function count() {  
     * Set a callback function for labels  
     * @param string $function   
        $this->function =  is_null($function) ?  $function : (string) $function;  
     * Return the callback function for labels  
     * @param string $format New format (printf style: %.2f for example)  
        eval ('function '. $function. '($value) { 
            return sprintf("'. addcslashes($format, '"'). '", $value);  
     * @param awFont $font New font  
     * @param awColor $color Font color (can be NULL)  
    public function setFont(awFont $font, $color =  NULL) {  
     * @param int $angle New angle  
        $this->angle = (int) $angle;  
    public function setColor(awColor $color) {  
     * @param mixed $background   
        $this->background =  $background;  
     * Change text background color  
        $this->background =  $color;  
     * Change text background gradient  
        $this->background =  $gradient;  
     * @param int $left Left padding  
     * @param int $right Right padding  
     * @param int $top Top padding  
     * @param int $bottom Bottom padding  
    public function setPadding($left, $right, $top, $bottom) {  
        $this->padding =  array((int) $left, (int) $right, (int) $top, (int) $bottom);  
    public function hide($hide =  TRUE) {  
        $this->hide = (bool) $hide;  
    public function show($show =  TRUE) {  
        $this->hide = (bool) !$show;  
     * @param int $key The key to hide  
     * @param int $value The value to hide  
     * @param int $x Add this interval to X coord  
     * @param int $y Add this interval to Y coord  
    public function move($x, $y) {  
        $this->move =  $this->move->move($x, $y);  
     * @param int $h Horizontal alignment  
     * @param int $v Vertical alignment  
    public function setAlign($h =  NULL, $v =  NULL) {  
     * Get a text from the labele  
     * @param mixed $key Key in the array text  
            $value =  $this->texts[$key];  
            $text->setFont($this->font);  
            $text->setAngle($this->angle);  
            $text->setColor($this->color);  
            if($this->background instanceof  awColor) {  
                $text->setBackgroundColor($this->background);  
            } else if($this->background instanceof  awGradient) {  
                $text->setBackgroundGradient($this->background);  
            $text->border =  $this->border;  
            if($this->padding !==  NULL) {  
     * Get max width of all texts  
     * @param awDriver $driver A driver  
        return $this->getMax($driver, 'getTextWidth');  
     * Get max height of all texts  
     * @param awDriver $driver A driver  
        return $this->getMax($driver, 'getTextHeight');  
     * @param awDriver $driver   
     * @param awPoint $p Label center  
     * @param int $key Text position in the array of texts (default to zero)  
    public function draw(awDriver $driver, awPoint $p, $key =  0) {  
            list ($left, $right, $top, $bottom) =  $text->getPadding(); 
//            $font = $text->getFont();  
            $width =  $driver->getTextWidth($text);  
            $height =  $driver->getTextHeight($text);  
                    $x -=  ($width -  $left +  $right) /  2;  
                    $y -=  ($height +  $bottom);  
                    $y -=  ($height -  $top +  $bottom) /  2;  
            $driver->string($text, $this->move->move($x, $y));  
    protected function getMax(awDriver $driver, $function) {  
        foreach($this->texts as $key =>  $text) {  
            $font =  $text->getFont();  
                $max =  $font->{$function}($text);  
                $max =  max($max, $font->{$function}($text));  
 
 
        
       |