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

Source for file FlexFormat.php

Documentation is available at FlexFormat.php

  1. <?php
  2.  
  3.  /**
  4.  * FlexFormat class
  5.  *
  6.  * Description: Chart data export to Flex
  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 FlexFormat extends ImageExportFormat {
  17.  
  18.     private $embeddedImages;
  19.     private $imagePath;
  20.          
  21.     // Interceptors
  22.     function __get$property {
  23.       $method ="get{$property}";
  24.       if method_exists$this$method ) ) {
  25.         return $this->$method();
  26.       }
  27.     }
  28.  
  29.     function __set $property,$value {
  30.       $method ="set{$property}";
  31.       if method_exists$this$method ) ) {
  32.         return $this->$method($value);
  33.       }
  34.     }
  35.  
  36.     public function FlexFormat($c{
  37.         parent::ImageExportFormat($c);
  38.  
  39.         $this->fileExtension="mxml";
  40.         $this->embeddedImagess true;
  41.         $this->imagePath "";        
  42.     }
  43.     
  44.     public function getEmbeddedImages()
  45.     {
  46.       return $this->embeddedImages
  47.     }
  48.     
  49.     public function setEmbeddedImages($value
  50.     {
  51.       $this->embeddedImages $value
  52.     }
  53.  
  54.     public function getImagePath()
  55.     {
  56.       return $this->imagePath;
  57.     }
  58.     
  59.     public function setImagePath($value)
  60.     {
  61.       $this->imagePath $value
  62.     }
  63.        
  64.     public function Save($fileName$makeAll=false$deleteTemp=false$makeHTML=false)
  65.     {
  66.       if (!$makeAll)
  67.       {
  68.         $this->imagePath dirname($fileName);
  69.         $this->saveFlex($fileName);        
  70.       }
  71.       else
  72.       {
  73.         $dir dirname($fileName);
  74.         $tmpFile $fileName;
  75.  
  76.         if (strpos("/"$fileName!= -1)
  77.         {
  78.           if (realpath($dir!= false)
  79.           {
  80.             //dir = fileName.Substring(0, fileName.LastIndexOf('\\'));
  81.             //fileName = fileName.Substring(fileName.LastIndexOf('\\')+1);
  82.           }
  83.         }
  84.         
  85.         FlexOptions::CompileDeleteShow($this->chart$this->getWidth()$this->getHeight()$dir$fileName$deleteTemptruefalse);
  86.         if ($makeHTML)
  87.           FlexOptions::GenerateHTML($this->chart$this->getWidth()$this->getHeight()$dir$fileName);
  88.       }
  89.     }
  90.  
  91.    public function SaveFlex($fileName)
  92.     {
  93.         // Create the mxml file        
  94.         $fhandle=fopen($fileName,'w');
  95.         if($fhandle==false)
  96.         {
  97.               die("Unable to create file");
  98.         }
  99.         else
  100.         {        
  101.           rewind($fhandle);        
  102.           $oldGraphics $this->getChart()->getGraphics3D();
  103.           $g new Graphics3DFlex($fhandle$this->chart);
  104.         
  105.           $g->setImagePath($this->ImagePath);
  106.           $g->setEmbeddedImages($this->EmbeddedImages);
  107.           $this->chart->setGraphics3D($g);
  108.                       
  109.           $this->chart->_paint($gnew Rectangle(00,  $this->getWidth()$this->getHeight()));
  110.           
  111.           // To add end of mxml file
  112.           $g->ShowImage($g);
  113.  
  114.           $this->chart->setGraphics3D($oldGraphics);
  115.         
  116.           // Close the mxml file
  117.           fflush($fhandle);
  118.           ftruncate($fhandleftell($fhandle));          
  119.           fclose($fhandle);                         
  120.         }
  121.     }
  122.  
  123.     /// <summary>
  124.     /// Save a Chart as a Flex image
  125.     /// </summary>
  126.     /// <param name="c">Chart to save</param>
  127.     /// <param name="fileName">filename as string</param>
  128.     static public function SaveToFile($c$fileName)
  129.     {
  130.       $s new FlexFormat($c);
  131.       $s->Save(fileName);
  132.     }
  133. }                             
  134. ?>

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