TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file ChartFont.php

Documentation is available at ChartFont.php

  1. <?php
  2.  
  3. /**
  4.  * ChartFont class
  5.  *
  6.  * Description: Common Chart Font. Font methods used at several objects
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage drawing
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class ChartFont extends TeeBase
  17. {
  18.  
  19.    private $fontSize 8;
  20.    private $bold false;
  21.    private $bBrush;
  22.    private $font;// = new Font(DEFAULTFAMILY, Font.PLAIN, DEFAULTSIZE);
  23.    private $italic false;
  24.    private $name "";
  25.    private $shadow null;
  26.    private $size=8;
  27.    private $strikeout false;
  28.    private $underline false;
  29.    private $outline null;
  30.  
  31.    public static $DEFAULTSIZE 8;
  32.    public static $DEFAULTFAMILY "fonts/verdana.ttf";// Arial;;
  33. //   public static $DEFAULTFAMILY = "fonts/DejaVuSansCondensed.ttf";// Arial;;
  34.    public $fontCondensed;
  35.    public $fontCondensedBold;
  36.  
  37.  
  38.  
  39.    public function ChartFont($c null)
  40.    {
  41.       parent::__construct($c);
  42.      
  43.       $baseDir dirname(__FILE__"/../";
  44.  
  45.       // Free low-res fonts based on Bitstream Vera <http://dejavu.sourceforge.net/wiki/>
  46. //      $this->fontCondensed = $baseDir . "fonts/DejaVuSansCondensed.ttf";
  47.       $this->fontCondensed = $baseDir "fonts/verdanadensed.ttf";
  48.       $this->fontCondensedBold = $baseDir "fonts/DejaVuSansCondensed-Bold.ttf";
  49.  
  50.       self::$DEFAULTFAMILY $baseDir "fonts/verdana.ttf";// Arial;
  51. //      self::$DEFAULTFAMILY = $baseDir . "fonts/DejaVuSansCondensed.ttf";// Arial;
  52.       $this->name self::$DEFAULTFAMILY;
  53.       $this->size self::$DEFAULTSIZE;
  54.    }
  55.  
  56.    /**
  57.    * Defines a Font type for text.<br>
  58.    * Default value: Arial
  59.    *
  60.    * @return String 
  61.    */
  62.    public function getName()
  63.    {
  64.       return $this->name;
  65.    }
  66.  
  67.    /**
  68.    * Specifies a Font type for text.<br>
  69.    * Default value: Arial
  70.    *
  71.    * @param value String
  72.    */
  73.    public function setName($value)
  74.    {
  75.       $this->name $this->setStringProperty($this->name$value);
  76.    }
  77.  
  78.    private function changed()
  79.    {
  80.       if($this->chart != null)
  81.       {
  82.          $this->chart->doChangedFont($this);
  83.       }
  84.    }
  85.  
  86.    /**
  87.    * Use Invalidate when the entire canvas needs to be repainted.<br>
  88.    * When more than one region within the canvas needs repainting, Invalidate
  89.    * will cause the entire window to be repainted in a single pass, avoiding
  90.    * flicker caused by redundant repaints.<br>
  91.    * There is no performance penalty for calling Invalidate multiple times
  92.    * before the control is actually repainted.
  93.    */
  94.    public function invalidate()
  95.    {
  96.       parent::invalidate();
  97.  
  98.       if($this->font != null)
  99.       {
  100.          $this->font null;
  101.       }
  102.  
  103.       $this->changed();
  104.    }
  105.  
  106.    function hasOutline()
  107.    {
  108.       return($this->outline != null&& $this->outline->visible;
  109.    }
  110.  
  111.    /**
  112.    * The Font size (in points) for text.<br>
  113.    * When managing Font sizes of Drawing Canvas custom outputted text
  114.    * relative to Chart text (titles, labels, etc.), use Font.Height to size
  115.    * the Canvas text. <br>
  116.    * Default value: 8
  117.    *
  118.    * @return int 
  119.    */
  120.    public function getSize()
  121.    {
  122.       return $this->size;
  123.    }
  124.  
  125.    /**
  126.    * Sets Font sizing (in points) for text.<br>
  127.    * Default value: 8
  128.    *
  129.  
  130.    * @param value int
  131.    */
  132.    public function setSize($value)
  133.    {
  134.       $this->size $this->setIntegerProperty($this->size$value);
  135.    }
  136.  
  137.    /**
  138.    * Bold Font for text.<br>
  139.    * Default value: false
  140.    *
  141.    * @return boolean 
  142.    */
  143.    public function getBold()
  144.    {
  145.       return $this->bold;
  146.    }
  147.  
  148.    /**
  149.    * Sets Font bold for text.<br>
  150.    * Default value: false
  151.    *
  152.    * @param value boolean
  153.    */
  154.    public function setBold($value)
  155.    {
  156.       $this->bold $this->setBooleanProperty($this->bold$value);
  157.       // if True default bold font is used. If set to false default not bold
  158.       // font is used.
  159.       if ($value==true)
  160.         $this->name $this->fontCondensedBold;
  161.       else
  162.         $this->name $this->fontCondensed;
  163.    }
  164.  
  165.    public function reset()
  166.    {
  167.       $this->setColor(new Color(000));
  168.       $this->setBold(false);
  169.       $this->setItalic(false);
  170.       $this->setUnderline(false);
  171.       $this->setName(self::$DEFAULTFAMILY);
  172.       $this->setSize(self::$DEFAULTSIZE);
  173.    }
  174.  
  175.    /**
  176.    * Italic Font (true or false) for text.<br>
  177.    * Default value: false
  178.    *
  179.    * @return boolean 
  180.    */
  181.    public function getItalic()
  182.    {
  183.       return $this->italic;
  184.    }
  185.  
  186.    /**
  187.    * Sets Font italic (true or false) for text.<br>
  188.    * Default value: false
  189.    *
  190.    * @param value boolean
  191.    */
  192.    public function setItalic($value)
  193.    {
  194.       $this->italic $this->setBooleanProperty($this->italic$value);
  195.    }
  196.  
  197.    /**
  198.    * Underline Font for text.<br>
  199.    * Default value: false
  200.    *
  201.    * @return boolean 
  202.    */
  203.    public function getUnderline()
  204.    {
  205.       return $this->underline;
  206.    }
  207.  
  208.    /**
  209.    * Sets Font underline on/off.<br>
  210.    * Default value: false
  211.    *
  212.    * @param value boolean
  213.    */
  214.    public function setUnderline($value)
  215.    {
  216.       $this->underline $this->setBooleanProperty($this->underline$value);
  217.    }
  218.  
  219.    /**
  220.    * Font Strikeout on/off.<br>
  221.    * Default value: false
  222.    *
  223.    * @return boolean 
  224.    */
  225.    public function getStrikeout()
  226.    {
  227.       return $this->strikeout;
  228.    }
  229.  
  230.    /**
  231.    * Sets Font Strikeout on/off.<br>
  232.    * Default value: false
  233.    *
  234.    * @param value boolean
  235.    */
  236.    public function setStrikeout($value)
  237.    {
  238.       $this->strikeout $this->setBooleanProperty($this->strikeout$value);
  239.    }
  240.  
  241.    /**
  242.    * Defines a Font colour for text.
  243.    *
  244.    * @return Color 
  245.    */
  246.    public function getColor()
  247.    {
  248.       return $this->getBrush()->getColor();
  249.    }
  250.  
  251.    /**
  252.    * Defines a Font colour for text.
  253.    *
  254.    * @param value Color
  255.    */
  256.    public function setColor($value)
  257.    {
  258.       $this->getBrush()->setColor($value);
  259.    }
  260.  
  261.    /**
  262.    * Applies a gradient fill to the font.<br>
  263.    *
  264.    * @return Gradient 
  265.    */
  266.    public function getGradient()
  267.    {
  268.       return $this->getBrush()->getGradient();
  269.    }
  270.  
  271.    /**
  272.    * Accesses the shadow properties of the font.
  273.    *
  274.    * @return Shadow 
  275.    */
  276.    public function getShadow()
  277.    {
  278.       if($this->shadow == null)
  279.       {
  280.          $this->shadow new Shadow($this->chart1);
  281.       }
  282.       return $this->shadow;
  283.    }
  284.  
  285.    public function shouldDrawShadow()
  286.    {
  287.       return(($this->shadow != null&& $this->shadow->getVisible(&&
  288.       (($this->shadow->getWidth(!= 0|| ($this->shadow->getHeight(!= 0)));
  289.    }
  290.  
  291.    public function assign($f)
  292.    {
  293.       if ($f->bBrush == null{
  294.         $this->bBrush null;
  295.       else {
  296.         $this->getBrush()->assign($f->bBrush);
  297.       }
  298.  
  299.       if ($f->shadow == null{
  300.         $this->shadow null;
  301.       else {
  302.         $this->getShadow()->assign($f->shadow);
  303.       }
  304.  
  305.       if ($f->outline == null{
  306.         $this->outline null;
  307.       else {
  308.         $this->getOutline()->assign($f->outline);
  309.       }
  310.  
  311.       $this->bold $f->bold;
  312.       $this->strikeout $f->strikeout;
  313.       $this->underline $f->underline;
  314.       $this->italic $f->italic;
  315.  
  316.       $this->name $f->getName();
  317.       $this->size $f->size;
  318.       $this->font null;
  319.       $this->changed();
  320.    }
  321.  
  322.    /* todo    public function getDrawingFont() {
  323.    if ($this->font == null) {
  324.    $style=$this->Font.PLAIN;
  325.  
  326.    if (bold) {
  327.    style = Font.BOLD;
  328.    } else {
  329.    style = Font.PLAIN;
  330.    }
  331.  
  332.    if (italic) {
  333.    style |= Font.ITALIC;
  334.    }
  335.  
  336.    /** todo UNDERLINE AND STRIKEOUT DO NOT EXIST IN JAVA FONT */
  337.    //            if (underline) {
  338.    //                style |= Font.UNDERLINE;
  339.    //            }
  340.    //            if (strikeout) {
  341.    //                style |= Font.Strikeout;
  342.    //            }
  343.  
  344.    /** @todo CREATE FONT USING MAP OBJECT WITH TEXTATTRIBUTE (Strike, Underline, etc) */
  345.    //    }
  346.  
  347.    
  348.  
  349.    public function setChart($c)
  350.    {
  351.       parent::setChart($c);
  352.       if($this->shadow != null)
  353.       {
  354.          $this->shadow->setChart($this->chart);
  355.       }
  356.       if($this->bBrush != null)
  357.       {
  358.          $this->bBrush->setChart($this->chart);
  359.       }
  360.       if($this->outline != null)
  361.       {
  362.          $this->outline->setChart($this->chart);
  363.       }
  364.    }
  365.  
  366.    /**
  367.    * Sets the Brush characteristics of the font.
  368.    *
  369.    * @return ChartBrush 
  370.    */
  371.    public function getBrush()
  372.    {
  373.       if($this->bBrush == null)
  374.       {
  375.          $this->bBrush new ChartBrush($this->chartnew Color(000));
  376.       }
  377.       return $this->bBrush;
  378.    }
  379.  
  380.    public function getOutline()
  381.    {
  382.       if($this->outline == null)
  383.       {
  384.          $this->outline new ChartPen($this->chartnullfalse);
  385.       }
  386.       return $this->outline;
  387.    }
  388.  
  389.    public function getFontSize()
  390.    {
  391.       return $this->size;
  392.    }
  393. }
  394. ?>

Documentation generated on Wed, 16 Jun 2010 12:04:19 +0200 by phpDocumentor 1.4.1