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

Source for file Exports.php

Documentation is available at Exports.php

  1. <?php
  2.  
  3.  /**
  4.  * Exports class
  5.  *
  6.  * Description:
  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 exports
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16.  class Exports extends TeeBase {
  17.  
  18.     private $image;
  19.     private $template;
  20.     private $data;
  21.  
  22.  
  23.     // Interceptors
  24.     function __get$property {
  25.       $method ="get{$property}";
  26.       if method_exists$this$method ) ) {
  27.         return $this->$method();
  28.       }
  29.     }
  30.  
  31.     function __set $property,$value {
  32.       $method ="set{$property}";
  33.       if method_exists$this$method ) ) {
  34.         return $this->$method($value);
  35.       }
  36.     }
  37.  
  38.     public function Exports($c{
  39.         parent::__construct($c);
  40.     }
  41.  
  42.     /**
  43.     * Gets a class instance with methods to export chart Series data.
  44.     *
  45.     * @return DataExport 
  46.     */
  47.     public function getData({
  48.         if ($this->data == null{
  49.             $this->data new DataExport($this->chart);
  50.         }
  51.  
  52.         return $this->data;
  53.     }
  54.  
  55.     /**
  56.     * Gets a class instance with methods to create images from chart.
  57.     *
  58.     * @return ImageExport 
  59.     */
  60.     public function getImage({
  61.         if ($this->image == null{
  62.             $this->image new ImageExport($this->chart);
  63.         }
  64.  
  65.         return $this->image;
  66.     }
  67.  
  68.     /**
  69.     * Gets a class instance with methods to store the chart to a file or
  70.     * stream using Java standard serialization and XMLEncoder mechanisms.
  71.     *
  72.     * <p>Example:
  73.     * <pre><font face="Courier" size="4">
  74.     *  myChart.getExport().getTemplate().toXML(tmpName);
  75.     *          showSavedFile(tmpName);
  76.     * </font></pre></p>
  77.     *
  78.     * @return TemplateExport 
  79.     */
  80.     public function getTemplate({
  81.         if ($this->template == null{
  82.             $this->template new TemplateExport($this->getChart());
  83.         }
  84.  
  85.         return $this->template;
  86.     }
  87.  
  88. }
  89.  
  90.  
  91.  /**
  92.  * DataExport class
  93.  *
  94.  * Description:
  95.  *
  96.  * @author
  97.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  98.  * @version 1.0
  99.  * @package TeeChartPHP
  100.  * @subpackage exports
  101.  * @link http://www.steema.com
  102.  */
  103.  
  104.      class DataExport {
  105.  
  106.         private $xmlFormat;
  107.         private $txtFormat;
  108.         private $htmlFormat;
  109.         private $excelFormat;
  110.         private $chart;
  111.  
  112.         public function DataExport($c=null{
  113.             $this->chart=$c;
  114.         }
  115.  
  116.         /**
  117.         * Export Chart to XML data format
  118.         *
  119.         * @return XMLFormat 
  120.         */
  121.         public function getXML({
  122.             if ($this->xmlFormat == null{
  123.                 $this->xmlFormat new XMLFormat($this->chart);
  124.             }
  125.             return $this->xmlFormat;
  126.         }
  127.  
  128.         /**
  129.         * Export Chart as text
  130.         *
  131.         * <p>Example:
  132.         * <pre><font face="Courier" size="4">
  133.         * myChart.getExport().getData().getText().save(tmpName);
  134.         * </font></pre></p>
  135.  
  136.         * @return TextFormat 
  137.         */
  138.         public function getText({
  139.             if ($this->txtFormat == null{
  140.                 $this->txtFormat new TextFormat($this->chart);
  141.             }
  142.             return $this->txtFormat;
  143.         }
  144.  
  145.         /**
  146.         * Export Chart as HTML table
  147.         *
  148.         * @return HTMLFormat 
  149.         */
  150.         public function getHTML({
  151.             if ($this->htmlFormat == null{
  152.                 $this->htmlFormat new HTMLFormat($this->chart);
  153.             }
  154.             return $this->htmlFormat;
  155.         }
  156.  
  157.         /**
  158.         * Export Chart as Excel spreadsheet
  159.         *
  160.         * @return ExcelFormat 
  161.         */
  162.         public function getExcel({
  163.             if ($this->excelFormat == null{
  164.                 $this->excelFormat new ExcelFormat($this->chart);
  165.             }
  166.             return $this->excelFormat;
  167.         }
  168.  
  169.      }
  170.  
  171.  
  172.      class ColorPersistenceDelegate /*extends DefaultPersistenceDelegate*/ {
  173.  
  174.         public function ColorPersistenceDelegate($constructorPropertyNames{
  175.             //parent::DefaultPersistenceDelegate($constructorPropertyNames);
  176.         }
  177.  
  178.         protected function mutatesTo($oldInstance$newInstance{
  179.             return $oldInstance->equals($newInstance);
  180.         }
  181.     }
  182.  
  183.  
  184.     class TemplateExport {
  185.  
  186.         private $chart;   
  187.         
  188.         public function TemplateExport($c=null{
  189.             $this->chart=$c;
  190.         }
  191.                 
  192.         /**
  193.         * Writes a TChart oboject with all of its settings by cycling to a file using serialization mechanism.
  194.         *
  195.         * @param fileName String
  196.         */
  197.         public function toFile($fileName{
  198.  
  199.           $f=fopen($fileName,'w');
  200.           if($f==false)
  201.           {
  202.                 die("Unable to create file");
  203.           }
  204.           else
  205.           {
  206.             if (file_exists($fileName)) {             
  207.                $str SerializeManager::instance()->serializeObject($this->chart);
  208.                fwrite($f$str);
  209.                fclose($f);               
  210.             }
  211.             else
  212.             {
  213.                $str SerializeManager::instance()->serializeObject($this->chart);
  214.                fwrite($f$str);
  215.                fclose($f);               
  216.             }
  217.           }            
  218.         }
  219.          
  220.         private function getProperties($value{
  221.             try {
  222.                 return $this->Introspector->getBeanInfo($value)->
  223.                         $this->getPropertyDescriptors();
  224.             catch Excepction $ex{
  225.             }
  226.  
  227.             return null;
  228.         }
  229.  
  230.         /**
  231.         * Returns all properties in "value" Object that are different from their
  232.         * default values, in XML text format.
  233.         *
  234.         * @param value Object
  235.         * @return String 
  236.         */
  237.         public function getXML($value=null{
  238.             if ($value==null{
  239.                $value $this->getChart();
  240.             }
  241.  
  242.             $stream new ByteArrayOutputStream();
  243.             $this->toXML($value$stream);
  244.             return new String($stream->toByteArray());
  245.         }
  246.  
  247.         /**
  248.         * Stores all chart properties to a file in XML format using Java
  249.         * XMLEncoder class.
  250.         *
  251.         * @param file File
  252.         * @throws FileNotFoundException
  253.         */
  254.         public function toXML($file/* TODO throws FileNotFoundException*/ {
  255.             $this->toXML($file->getPath());
  256.         }
  257.  
  258.                 /**
  259.                   * Stores all chart properties to a file in XML format using Java
  260.                   * XMLEncoder class.
  261.                   *
  262.                   * @param fileName String
  263.                   * @throws FileNotFoundException
  264.                   */
  265.         /*public function toXML($fileName)  TODO  throws FileNotFoundException {
  266.             $this->toXML(new BufferedOutputStream(
  267.                     new FileOutputStream($fileName)));
  268.         }
  269.  
  270.                 /**
  271.                   * Stores all chart properties to stream, in XML text format using
  272.                   * Java XMLEncoder class.
  273.                   *
  274.                   * @param stream OutputStream
  275.  
  276.         public function toXML($stream) {
  277.             $this->toXML($this->getChart(), $stream);
  278.         }
  279.         */
  280.         /* TODO
  281.         private function prepareTransients() {
  282.             $this->PropertyDescriptor[] $this->propertyDescriptors = $this->getProperties($this->Chart->class);
  283.  
  284.             for ( $i = 0; $i < $this->propertyDescriptors->length; ++$i) {
  285.                  $pd = $this->propertyDescriptors[$i];
  286.                 if ($pd->getName()->equals("graphics3D")) {
  287.                     $tmpBoolean = new Boolean();
  288.                     $pd->setValue("/*transient*//*", $tmpBoolean->TRUE);
  289.                 }
  290.             }
  291.  
  292.             $this->PropertyDescriptor[] $this->propertyDescriptors2 = $this->getProperties($this->TeeBase->class);
  293.  
  294.             for ( $i = 0; $i < $propertyDescriptors2->length; ++$i) {
  295.                  $pd = $propertyDescriptors2[$i];
  296.                 if ($pd->getName()->equals("chart")) {
  297.                     $pd->setValue("/*transient", $tmpBoolean->TRUE);
  298.                 }
  299.             }
  300.  
  301.             $this->PropertyDescriptor[] $this->propertyDescriptors3 = $this->getProperties($this->Series->class);
  302.  
  303.             for ( $i = 0; $i < $propertyDescriptors3->length; ++$i) {
  304.                  $pd = $propertyDescriptors3[$i];
  305.                 if (($pd->getName()->equals("endZ")) ||
  306.                     ($this->pd->getName()->equals("middleZ")) ||
  307.                     ($this->pd->getName()->equals("startZ"))) {
  308.                     $pd->setValue("/*transient", $tmpBoolean->TRUE);
  309.                 }
  310.             }
  311.         } */
  312.  
  313.                 /**
  314.                   * Stores value object properties to stream, in XML text format using
  315.                   * Java XMLEncoder class.
  316.                   *
  317.                   * @param value Object
  318.                   * @param stream OutputStream
  319.                   */
  320. /* TODO        public function toXML($value, $stream) {
  321.  
  322.             $xe = new XMLEncoder($stream);
  323.  
  324.             $xe->setExceptionListener(new ExceptionListener() {
  325.                 public function exceptionThrown($exception) {
  326.                     $exception->printStackTrace();
  327.                 }
  328.             });
  329.  
  330.             $this->prepareTransients();
  331.  
  332.              $colorDel = new ColorPersistenceDelegate(
  333.                     new String[] {"Red", "Green", "Blue", "Alpha"});
  334.             $this->xe->setPersistenceDelegate($this->Color->class, $colorDel);
  335.  
  336.             $this->xe->writeObject($this->value);
  337.             $this->xe->close();
  338.         }
  339. */
  340.  
  341.                 /**
  342.                   * Writes all non-transient chart fields to a stream using Java standard
  343.                   * serialization mechanism.
  344.                   *
  345.                   * @param stream OutputStream
  346.                   * @throws IOException
  347.                   */
  348. /*        public function toStream($stream) todo throws IOException {
  349.              $out = new ObjectOutputStream($stream);
  350.             $this->prepareTransients();
  351.             $out->writeObject($this->chart);
  352.             $out->close();
  353.         }*/
  354.     }
  355.  
  356. ?>

Documentation generated on Wed, 16 Jun 2010 12:05:15 +0200 by phpDocumentor 1.4.1