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

Source for file phpchartPlus.php

Documentation is available at phpchartPlus.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: phpchartplus2.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes the ConfigParser class
  13. */
  14. require_once("ConfigParser.php");
  15.  
  16. /**
  17. *Includes the DataParser class
  18. */
  19. require_once("DataParser.php");
  20.  
  21. /**
  22. *Includes the BarChart class
  23. */
  24. require_once("BarChart.php");
  25.  
  26. /**
  27. *Includes the AreaChart class
  28. */
  29. require_once("AreaChart.php");
  30.  
  31. /**
  32. *Includes the LineChart class
  33. */
  34. require_once("LineChart.php");
  35.  
  36. /**
  37. *Includes the PieChart class
  38. */
  39. require_once("PieChart.php");
  40.  
  41. /**
  42. *Includes the ColorAllocator class
  43. */
  44. require_once("ColorAllocator.php");
  45.  
  46. /**
  47. *Includes the Font class
  48. */
  49. require_once("Font.php");
  50.  
  51. class ImageSupport_Exception extends Exception {
  52. function ImageSupport_Exception($data) {
  53. Exception::__construct($data);
  54. }
  55. }
  56.  
  57. class FontSupport_Exception extends Exception {
  58.  
  59. function FontSupport_Exception($data) {
  60. Exception::__construct($data);
  61. }
  62. }
  63.  
  64. /**
  65. *Instanciates the appropriate Chart class
  66. *Instanciates the appropriate Chart class(BarChart,LineChart,AreaChart,PieChart) and associates it with instances of
  67. *ConfigParser,DataParser,Font and ColorAllocator classes
  68. */
  69. final class phpchartPlus {
  70. public $Chart_;
  71. public $ConfigParser_;
  72. public $DataParser_;
  73. private $Font_;
  74. private $ColorAllocator_;
  75. function __construct() {
  76.  
  77. $this->ConfigParser_=new ConfigParser();
  78. $this->DataParser_=new DataParser();
  79. $this->ColorAllocator_=new ColorAllocator();
  80. $this->Font_=new Font();
  81. }
  82.  
  83. /**
  84. *Instanciates the appropriate Chart class
  85. *@access public
  86. *@return void
  87. */
  88. public function get_Instance() {
  89. $this->get_php_im_support();
  90. $this->get_php_ft_support();
  91. switch($this->ConfigParser_->get_ChartType()) {
  92. case "Bar":
  93. $this->Chart_=new BarChart();
  94. break;
  95. case "Area":
  96. $this->Chart_=new AreaChart();
  97. break;
  98. case "Line":
  99. $this->Chart_=new LineChart();
  100. break;
  101. case "Pie":
  102. $this->Chart_=new PieChart();
  103. }
  104.  
  105. $this->Chart_->set_ConfigParser($this->ConfigParser_);
  106. $this->Chart_->set_DataParser($this->DataParser_);
  107.  
  108. $this->Chart_->set_ColorAllocator($this->ColorAllocator_);
  109. $this->Chart_->set_Font($this->Font_);
  110. }
  111.  
  112. /**
  113. *Verifies php's support for the selected image output type
  114. *@access private
  115. *@throws ImageSupport_Exception
  116. *@return void
  117. */
  118. private function get_php_im_support() {
  119.  
  120. switch($this->ConfigParser_->get_ImageOutputType()) {
  121. case "png":
  122. if (!function_exists("imagepng"))
  123. throw new ImageSupport_Exception("phpChartPlus:No php support for png images.Reconfigure GD with PNG support enabled");
  124. break;
  125. case "gif":
  126. if (!function_exists("imagegif"))
  127. throw new ImageSupport_Exception("phpChartPlus: No php support for gif images.Reconfigure GD with GIF support enabled");
  128. break;
  129. case "jpeg":
  130. if (!function_exists("imagejpeg"))
  131. throw new ImageSupport_Exception("phpchartPlus:No php support for jpeg images.Reconfigure GD with JPEG support enabled");
  132. }
  133. }
  134.  
  135. /**
  136. *Verifies php's support for FreeType2 Fonts
  137. *@access private
  138. *@throws FontSupport_Exception
  139. *@return void
  140. */
  141. private function get_php_ft_support() {
  142. if ($this->ConfigParser_->get_FontFileLocation()!=NULL)
  143. {
  144. if (!function_exists("imagefttext"))
  145. throw new FontSupport_Exception("phpchartPlus:No php support for FreeType fonts.Reconfigure with 'with-freetype-dir=' directive enabled");
  146. }
  147. }
  148.  
  149.  
  150. }
  151.  
  152. ?>

Documentation generated on Sun, 3 Oct 2004 14:59:24 +0300 by phpDocumentor 1.3.0RC3