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

Source for file CanvasFlex.php

Documentation is available at CanvasFlex.php

  1. <?php
  2.  
  3.   class Graphics3DFlex extends GraphicsGD 
  4.   {
  5.  
  6.     # private members
  7.     private $iAddedInitApp;
  8.     private $iApplication;
  9.     private $iScript;
  10.     private $iIdent;
  11.     private $iTransp;
  12.     private $iImageID;
  13.     private $iSmallDots;
  14.     private $iPath=Array();
  15.     private $iItems=Array();
  16.     private $embeddedImages;
  17.     private $imagePath;
  18.     private $fStream;
  19.     private $tipString;       
  20.  
  21.    
  22.     public function Graphics3DFlex($fhandle,$c)
  23.     {
  24.       parent::GraphicsGD($c$c->getWidth()$c->getHeight());
  25.            
  26.       $this->iCanvasType "Flex"
  27.       $this->fStream=$fhandle;
  28.       $this->supportsID = true;
  29.       $this->embeddedImages true;
  30.       $this->iPath Array();
  31.       $this->iItems Array();
  32.       $this->iImageID 0;
  33.     }
  34.     
  35.     private function ImageSource($graphic)
  36.     {
  37.       if ($this->EmbeddedImages)
  38.       {
  39.         return '@Embed("' $this->ImageFileName($graphic'")';
  40.       }
  41.       else
  42.       {
  43.         return $this->ImageFileName($graphic);
  44.       }
  45.     }
  46.  
  47.     private function GraphicsExtension($format)
  48.     {                             
  49.       if ($format == ImageExport::getEMF())
  50.       {
  51.         return "emf";
  52.       }
  53.       else if ($format == ImageExport::getGIF())
  54.       {
  55.         return "gif";
  56.       }
  57.       else if ($format == ImageExport::getJPEG())
  58.       {
  59.         return "jpg";
  60.       }
  61.       else if ($format == ImageExport::getTIFF())
  62.       {
  63.         return "tif";
  64.       }
  65.       else
  66.       {
  67.         return "png";
  68.       }
  69.     }
  70.  
  71.     private function CalcResult($tmp)
  72.     {
  73.       $tmpExt $this->GraphicsExtension($tmp->RawFormat);
  74.  
  75.       $result "TeeChart_Flex_Temp_" $this->iImageID "." $tmpExt;
  76.       ++$this->iImageID;
  77.  
  78.       $tmp->Save($this->ImagePath "/" $result);
  79.  
  80.       return $result;
  81.     }
  82.  
  83.     private function ImageFileName($graphic)
  84.     {
  85.       if ($graphic->RawFormat == ImageExport::getPNG()) //.Bmp)
  86.       {
  87.         $format new JPEGFormat($this->Chart);
  88.         /*MemoryStream ms = new MemoryStream();
  89.         Bitmap bmp = new Bitmap(graphic);
  90.         format.Save(ms, bmp, bmp.Width, bmp.Height);
  91.         bmp = new Bitmap(ms);*/
  92.         return $this->CalcResult($bmp);
  93.       }
  94.       else
  95.       {
  96.         return $this->CalcResult($graphic);
  97.       }
  98.     }
  99.  
  100.     private function FlexSize($R)
  101.     {
  102.       return $this->FlexSizeWH($R->Width$R->Height);
  103.     }
  104.  
  105.     private function FlexSizeWH($w$h)
  106.     {
  107.       return 'width="' MathUtils::round($w'" height="' MathUtils::round($h'"';
  108.     }
  109.  
  110.     private function ParseSeriesID($ID)
  111.     {
  112.       $result false;
  113.  
  114.       if (strpos($ID,"Series"!= false)
  115.       {
  116.         $ID str_replace('""',"",$ID);
  117.         
  118.         $elements Split('_',$ID);
  119.         
  120.         // TODO  must work for all Series... now just work for 0 index
  121.         // $seriesIndex = str_replace("Series", "", $elements[1]) - 1;
  122.         $seriesIndex 0;
  123.         
  124.         for ($tt=0$tt sizeof($elements)++$tt
  125.         {
  126.            if (strstr($elements[$tt]'SeriesPointer')!= false
  127.            {
  128.               $srsPtrIndx $tt;
  129.               break
  130.            }   
  131.         }
  132.         
  133.         if (sizeof($elements4
  134.           $valueIndex=(int)$elements[4];
  135.         else
  136.           $valueIndex=(int)0;
  137. //        $srsPtrIndx = array_search('id=\"SeriesPointer', $elements); //  strpos($elements, "SeriesPointer");
  138. //        $valueIndex = (int)($elements[2]);        
  139.   //      if ($srsPtrIndx > (sizeof($elements) - 3 ))  // - 2   before
  140.     //    {
  141.       //    $valueIndex += $elements[$srsPtrIndx + 1];
  142.         //}
  143.  
  144.         for ($i 0$i sizeof($this->getChart()->getTools())$i++)
  145.         {
  146.           if ($this->Chart->Tools[$i]->Active && $this->chart->getTool($iinstanceof MarksTip)
  147.           {
  148.             $marksTip $this->chart->getTool($i);
  149.                         if ($marksTip->series == $this->chart->getSeries($seriesIndex|| $marksTip->series == null)
  150.             {
  151.               $series $this->chart->getSeries($seriesIndex);
  152.               $result true;
  153.  
  154.               $tmpStyle $series->getMarks()->getStyle();
  155.               $tmpOld $this->chart->getAutoRepaint();
  156.               $this->chart->autoRepaint false;
  157.               $series->getMarks()->style $marksTip->getStyle();
  158.  
  159.               $this->tipString $series->getValueMarkText($valueIndex);
  160.                                                
  161.               $series->getMarks()->style $tmpStyle;
  162.               $this->chart->autoRepaint $tmpOld;
  163.             }
  164.           }
  165.         }
  166.       }
  167.  
  168.       return $result;
  169.     }
  170.  
  171.     private function AddAnimation($ID)
  172.     {
  173.       $result "";
  174.       $this->tipString "";
  175.       $ineffect "";
  176.       $outeffect "";
  177.  
  178.       if ($this->isMarksTip)      
  179.         if ($this->ParseSeriesID($ID))
  180.         {
  181.           $result ' toolTip="' $this->tipString '"';        
  182.         }
  183.         
  184.         
  185.       if (sizeof($this->chart->animations0)      
  186.         for ($i 0$i sizeof($this->chart->animations)$i++)
  187.         {
  188.           $animation $this->chart->animations[$i];
  189.           switch ($animation->trigger)
  190.           {
  191.             case AnimationTrigger::$MouseClick:
  192.               $ineffect "mouseDownEffect";
  193.               $outeffect "mouseUpEffect";
  194.               break;
  195.             case AnimationTrigger::$MouseOver:
  196.               $ineffect "rollOverEffect";
  197.               $outeffect "rollOutEffect";
  198.               break;
  199.           }
  200.  
  201.           if ($animation instanceof Expand{
  202.             
  203.             $strTarget '';
  204.             
  205.             switch ($animation->target)
  206.             {
  207.                     case 0:
  208.                         $strTarget ='None';
  209.                         break;
  210.                     case 1:
  211.                         $strTarget ='Legend';
  212.                         break;
  213.                     case 2:
  214.                         $strTarget ='Axis';
  215.                         break;
  216.                     case 3:
  217.                         $strTarget ='Series';
  218.                         break;
  219.                     case 4:
  220.                         $strTarget ='Header';
  221.                         break;
  222.                     case 5:
  223.                         $strTarget ='Foot';
  224.                         break;
  225.                     case 6
  226.                         $strTarget ='ChartRect';
  227.                         break;
  228.                     case 7:
  229.                         $strTarget ='SeriesMarks';
  230.                         break;
  231.                     case 8:
  232.                         $strTarget ='SeriesPointer';
  233.                         break;
  234.                     case 9:
  235.                         $strTarget ='SubHeader';
  236.                         break;
  237.                     case 10:
  238.                         $strTarget ='SubFoot';
  239.                         break;
  240.                     case 11:
  241.                         $strTarget ='AxisTitle';
  242.                         break;
  243.                     default:
  244.                         break;
  245.             }
  246.                               
  247.             if (strpos($ID,$strTarget!= false)        
  248.             {
  249.                 if (strpos($ID,'Chart_Series'!= false)        
  250.                     $result .= ' ' $ineffect ' ="{teeexpand}" ' $outeffect ' ="{teeunexpand}"';
  251.             }
  252.           }
  253.         }
  254.         
  255.       return $result;
  256.     }
  257.  
  258.     private function AddTag($ATag$AText)
  259.     {
  260.       $ID $this->TheID();
  261.       $this->AddToStream($this->iIdent '<' $ATag $ID ' ' $AText $this->AddAnimation($ID'/>');
  262.     }
  263.  
  264.     private function CalcAlpha($penOnly)
  265.     {
  266.       if ($penOnly)
  267.       {
  268.         return $this->Pen->Transparency;
  269.       }
  270.       else
  271.       {
  272.         if ($this->Brush->Visible)
  273.         {
  274.           return $this->Brush->Transparency;
  275.         }
  276.         else if ($this->Pen->Visible)
  277.         {
  278.           return $this->Pen->Transparency;
  279.         }
  280.         else
  281.         {
  282.           return 0;
  283.         }
  284.       }
  285.     }                                   
  286.  
  287.     private function TheID()
  288.     {
  289.       $result "";
  290.       $tmpID $this->CurrentID();
  291.  
  292.       $tmp 0;
  293.       
  294.       $this->isMarksTip false;         
  295.  
  296.       if (strstr($tmpID'SeriesPointer_'!=false
  297.         if (strstr($tmpID'Chart_Series'!=false)
  298.         {
  299.           $series_index substr($tmpID,12,1);
  300.           
  301.           for ($t 0$t sizeof($this->chart->getTools())$t++{
  302.             $s $this->chart->getTool($t);
  303.             if ($s->getActive()) {
  304.                 if ($s instanceof MarksTip{
  305.                    //if ($s->getSeries() ==)
  306.                    $this->isMarksTip true
  307.                    //$tmpID = "";
  308.                 }                 
  309.             }                                              
  310.           }  
  311.       }
  312.       
  313.               
  314.     /*  if (strpos($tmpID,"MarksTip_") != false)
  315.       {
  316.         $this->isMarksTip = true;
  317.         $tmpID = str_replace("MarksTip_", "",$tmpID);
  318.       }
  319.       else
  320.       {
  321.         $this->isMarksTip = false;
  322.       }
  323.    */
  324.       $result $tmpID;
  325.      
  326.       while( (in_array$result$this->iItems )) != FALSE )
  327.       {
  328.         ++$tmp;
  329.         $result $tmpID "_" $tmp;
  330.       }
  331.             
  332.       $this->iItems[]=$result;
  333.  
  334.       return ' id="' $result '"';
  335.     }
  336.     
  337.     private function CurrentID()
  338.     {
  339.       $tmpStr="";
  340.       if (sizeof($this->iPath== 0)
  341.       {
  342.         if ($this->Chart->Parent != null)
  343.         {
  344.            // TODO 
  345.            // If we wanto display the name of the component which references to the
  346.            // mxml file lines we have to add a Control property into the TChart class
  347.            // for example and set and assign each class name to it at the time it's 
  348.            // instanced.
  349.           //$tmpStr .= get_class($this->getChart()->getParent()) . "_";   
  350.           $tmpStr .= TChart::$controlName "_";
  351.         }
  352.         else
  353.         {
  354.           $tmpStr .= "Chart";
  355.         }
  356.       }
  357.       else
  358.       {
  359.         $tmpStr->Append($this->iPath[0]);
  360.       }
  361.  
  362.       for ($i 1$i sizeof($this->iPath)$i++)
  363.       {
  364.         $tmpStr .= "_" $this->iPath[$i];
  365.       }
  366.  
  367.       return $tmpStr;
  368.     }
  369.  
  370.     private function PenWidth()
  371.     {
  372.       if ($this->Pen->Width == 1)
  373.       {
  374.         return "";
  375.       }
  376.       else
  377.       {
  378.         return ' strokeWidth="' $this->Pen->Width '"';
  379.       }
  380.     }
  381.  
  382.     private function BrushColor()
  383.     {
  384.       if ($this->Brush->Visible)
  385.       {
  386.         if ($this->Brush->Gradient->Visible)
  387.         {
  388.           return $this->FlexGradient($this->Brush->Gradient);
  389.         }
  390.         else
  391.         {
  392.           return " brushColor=" $this->FlexColor($this->Brush->Color); ;
  393.         }
  394.       }
  395.       else
  396.       {
  397.         return ' brushColor=""';
  398.       }
  399.     }
  400.  
  401.     private function GradientDirection($direction)
  402.     {
  403.       $result "";
  404.  
  405.       switch ($direction)
  406.       {
  407.         case "BackwardDiagonal":
  408.           $result "TopBottom";
  409.           break;
  410.         case "ForwardDiagonal":
  411.           $result "LeftRight";
  412.           break;
  413.         case "Horizontal":
  414.           $result "RightLeft";
  415.           break;
  416.         case "Vertical":
  417.           $result "BottomTop";
  418.           break;
  419.       }
  420.  
  421.       return $result;
  422.     }
  423.  
  424.     private function FlexGradient($gradient)
  425.     {
  426.       $tmpType "Linear";
  427.  
  428.       return ' gradientType="' $tmpType '" ' .
  429.           'gradientDir="' $this->GradientDirection($gradient->Direction'" ' .
  430.           "startColor=" $this->FlexColor($gradient->StartColor" " .
  431.           "endColor=" $this->FlexColor($gradient->EndColor" ";
  432.     }
  433.  
  434.     private function PenColor()
  435.     {
  436.       if ($this->getPen()->getVisible())
  437.       {
  438.         return ' strokeColor=' $this->FlexColor($this->getPen()->getColor())
  439.       }
  440.       else
  441.       {
  442.         return ' strokeColor=""';
  443.       }
  444.     }
  445.  
  446.     private function ColorInternal($color)
  447.     {
  448.       switch ($color)
  449.       {
  450.         case Color::Black():
  451.           $result "black";
  452.           break;
  453.         case Color::Blue():
  454.           $result "blue";
  455.           break;
  456.         case Color::Fuchsia():
  457.           $result "fuchsia";
  458.           break;
  459.         case Color::Gray():
  460.           $result "gray";
  461.           break;
  462.         case Color::Green():
  463.           $result "green";
  464.           break;
  465.         case Color::Lime():
  466.           $result "lime";
  467.           break;
  468.         case Color::Maroon():
  469.           $result "maroon";
  470.           break;
  471.         case Color::Navy():
  472.           $result "navy";
  473.           break;
  474.         case Color::Olive():
  475.           $result "olive";
  476.           break;
  477.         case Color::Purple():
  478.           $result "purple";
  479.           break;
  480.         case Color::Red():
  481.           $result "red";
  482.           break;
  483.         case Color::Silver():
  484.           $result "silver";
  485.           break;
  486.         case Color::Teal():
  487.           $result "teal";
  488.           break;
  489.         case Color::White():
  490.           $result "white";
  491.           break;
  492.         case Color::Yellow():
  493.           $result "yellow";
  494.           break;
  495.         default:
  496.           $result "0x" self::rgbhex($color->getRed()$color->getGreen()$color->getBlue());
  497.           break;
  498.       }
  499.  
  500.       return $result;
  501.     }
  502.  
  503.     // Converts RGB color to Hex
  504.     static function rgbhex($red,$green,$blue{
  505.       $red dechex($red);
  506.       $green dechex($green);
  507.       $blue dechex($blue);
  508.  
  509.       return strtoupper($red.$green.$blue);
  510.     }
  511.     
  512.  
  513.     private function FlexColor($aColor)
  514.     {
  515.       return '"' $this->ColorInternal($aColor'"';
  516.     }
  517.  
  518.     private function FlexAlpha($transparency)
  519.     {
  520.       if ($transparency == 0)
  521.       {
  522.         return "";
  523.       }
  524.       else
  525.       {
  526.         return ' alpha="' $this->FloatToStr(1.0 ($transparency 100.0)) '"';
  527.       }
  528.     }
  529.  
  530.     private function FlexPoints($Points)
  531.     {
  532.       //tmpStr.Length = 0;
  533.       $tmpStr->Append('points="[');
  534.  
  535.       if (sizeof($Points0)
  536.       {
  537.         $tmpStr->Append($this->$Points[0]);
  538.  
  539.         for ($i 1$i sizeof($Points)$i++)
  540.         {
  541.           $tmpStr->Append("," $this->$Points[$i]);
  542.         }
  543.       }
  544.  
  545.       $tmpStr->Append(']"');
  546.       return $tmpStr;
  547.     }
  548.  
  549.     private function FontStyle($AFont)
  550.     {
  551.       if ($AFont->Italic)
  552.       {
  553.         return ' fontStyle="italic" ';
  554.       }
  555.       else
  556.       {
  557.         return "";
  558.       }
  559.     }
  560.  
  561.     private function FontWeight($AFont)
  562.     {
  563.       if ($AFont->Bold)
  564.       {
  565.         return ' fontWeight="bold" ';
  566.       }
  567.       else
  568.       {
  569.         return "";
  570.       }
  571.     }
  572.  
  573.     private function TextDecoration($AFont)
  574.     {
  575.       if ($AFont->Underline)
  576.       {
  577.         return ' textDecoration="underline" ';
  578.       }
  579.       else
  580.       {
  581.         return "";
  582.       }
  583.     }
  584.  
  585.     private function FlexFont($AFont)
  586.     {
  587.       return $this->FontStyle($AFont.
  588.           $this->FontWeight($AFont.
  589.           ' fontSize="' . (int)($AFont->Size/* * 1.2*/'" ' .
  590.           $this->TextDecoration($AFont.
  591.           ' fontFamily="Verdana" ' .
  592.           ' color=' $this->FlexColor($AFont->Color" ";
  593.  
  594.           //          ' fontFamily="' . $AFont->Name . '" ' .          
  595.     }
  596.  
  597.  
  598.     #region protected and internal members
  599.     private $IPath=Array();
  600.  
  601. /*
  602. #if BLOCK
  603.     protected internal override TVisualBlock BeginEntity(string Entity, TVisualBlock Visual)
  604.     {
  605.       TVisualBlock Result = Visual;
  606.       this.iPath.Add(Entity);
  607.       this.iIdent = this.iIdent + " ";
  608.       return Result;
  609.     }
  610. #elif SILVERLIGHT || WPF
  611.     protected internal override UIElement BeginEntity(string Entity, UIElement Visual)
  612.     {
  613.       UIElement Result = Visual;
  614.       this.iPath.Add(Entity);
  615.       this.iIdent = this.iIdent + " ";
  616.       return Result;
  617.     }
  618. #else
  619.     protected internal override object BeginEntity(string Entity, object Visual)
  620.     {
  621.       this.iPath.Add(Entity);
  622.       this.iIdent = this.iIdent + " ";
  623.       return Visual;
  624.     }
  625. #endif
  626.  
  627.  
  628.     protected internal override function EndEntity()
  629.     {
  630.       this.iPath.RemoveAt(this.iPath.Count - 1);
  631.       this.iIdent = this.iIdent.Remove(0, 1);
  632.     }
  633.      */
  634.     private function AddAnimationTypes()
  635.     {
  636.       //Animation animation;
  637.       if (sizeof($this->chart->getAnimations()) 0)
  638.       {
  639.         for ($i 0$i sizeof($this->chart->getAnimations())$i++)
  640.         {
  641.           $animation $this->chart->getAnimation($i);
  642.           if ($animation instanceof Expand)
  643.           {
  644.             $expand $animation;
  645.             $this->AddToStream('    <mx:Parallel id="teeexpand">');
  646.             $this->AddToStream('        <mx:children>');
  647.             $this->AddToStream('            <mx:Move duration="' $expand->getSpeed(
  648.                     '" suspendBackgroundProcessing="true"    xBy="-' 
  649.                     ($expand->getSizeBy(2'" yBy="-' ($expand->getSizeBy(2
  650.                     '"/>');
  651.             $this->AddToStream('            <mx:Resize duration="' $expand->getSpeed(
  652.                      '" suspendBackgroundProcessing="true" widthBy="' 
  653.                      $expand->getSizeBy('" heightBy="' 
  654.                      $expand->getSizeBy('"/>');
  655.             $this->AddToStream('        </mx:children>');
  656.             $this->AddToStream('    </mx:Parallel>');
  657.             $this->AddToStream('    <mx:Parallel id="teeunexpand">');
  658.             $this->AddToStream('        <mx:children>');
  659.             $this->AddToStream('            <mx:Resize duration="' $expand->getSpeed(
  660.                     '" suspendBackgroundProcessing="true" widthBy="-' 
  661.                     $expand->getSizeBy('" heightBy="-' 
  662.                     $expand->getSizeBy('"/>');
  663.             $this->AddToStream('            <mx:Move duration="' $expand->getSpeed(
  664.                     '" suspendBackgroundProcessing="true" xBy="' 
  665.                     ($expand->getSizeBy(2'" yBy="' ($expand->getSizeBy(2
  666.                     '"/>');
  667.             $this->AddToStream('        </mx:children>');
  668.             $this->AddToStream('    </mx:Parallel>');
  669.           }
  670.         }
  671.       }
  672.     }
  673.  
  674.     
  675.     /// <summary>
  676.     /// Adds canvas instruction to stream.
  677.     /// </summary>
  678.     /// <param name="text">Instructions to be added to stream.</param>
  679.     protected function AddToStream($text)
  680.     {
  681.         $linetext $text "\r\n";
  682.  
  683.         fwrite($this->fStream,$linetext);
  684.         fflush($this->fStream);
  685.     }
  686.         
  687.     private $isMarksTip;
  688.  
  689.     private function AddMarksTip()
  690.     {
  691.       $hasMarksTip false;
  692.       if (sizeof($this->chart->getTools()) 0)
  693.       {
  694.         for ($i 0$i sizeof($this->chart->getTools())$i++)
  695.         {
  696.           if ($this->chart->getTool($i)->active && $this->chart->getTool($iinstanceof MarksTip)
  697.           {
  698.             $hasMarksTip true;
  699.             break;
  700.           }
  701.         }
  702.       }
  703.  
  704.       if ($hasMarksTip)
  705.       {
  706.         $this->AddToStream('    <mx:Script>');
  707.         $this->AddToStream('        <![CDATA[');
  708.         $this->AddToStream('        import mx.managers.ToolTipManager;');
  709.         $this->AddToStream('        import com.steema.graphics.HtmlToolTip;');
  710.         $this->AddToStream('        ToolTipManager.toolTipClass = HtmlToolTip;');
  711.         $this->AddToStream('       ]]>');
  712.  
  713.         //iScript = 
  714.  
  715.         $this->AddToStream('    </mx:Script>');
  716.  
  717.         $this->AddToStream('    <mx:Style>');
  718.         $this->AddToStream('      HtmlToolTip {');
  719.         $this->AddToStream('        fontFamily: "Verdana";');
  720.         $this->AddToStream('        fontSize: 12;');
  721.         $this->AddToStream('        fontStyle: "normal";');
  722.         $this->AddToStream('        color: #000000;');
  723.         $this->AddToStream('        backgroundColor: #FFFFFF;');
  724.         $this->AddToStream('      }');
  725.         $this->AddToStream('    </mx:Style>');
  726.       }
  727.     }
  728.  
  729.     public /*protected */ function InitWindow($a$r$MaxDepth)
  730.     {
  731.       parent::initWindow($a,$r,$MaxDepth);
  732.  
  733.       $this->iAddedInitApp false;
  734.  
  735.       $this->AddToStream('<?xml version="1.0"?>');
  736.       $this->AddToStream('<!-- Generated by TeeChart for .NET -->');
  737.       $this->AddToStream('<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"');
  738.       $this->AddToStream('                xmlns:tee="com.steema.graphics.*"');
  739.       $this->AddToStream('                ' $this->FlexSize($r));
  740.       $this->AddToStream('                paddingTop="0"');
  741.       $this->AddToStream('                paddingBottom="0"');
  742.       $this->AddToStream('                paddingRight="0"');
  743.       $this->AddToStream('                paddingLeft="0"');
  744.       $this->AddToStream('>');
  745.  
  746.       //iApplication = swFromStream.
  747.  
  748.       $this->AddMarksTip();
  749.       $this->AddAnimationTypes();
  750.  
  751.       $this->AddToStream('    <mx:Canvas ' $this->FlexSize($r' horizontalScrollPolicy = "off" verticalScrollPolicy = "off">');
  752.     }
  753.  
  754.     // TODO search original net file for pointtostr
  755.     protected function PointToStr($X$Y)
  756.     {
  757.       return 'x="' . (int)$X '" y="' . (int)$Y '"';
  758.     }
  759.  
  760.     public function ShowImage($g)
  761.     {
  762.       $this->AddToStream('    </mx:Canvas>');
  763.       $this->AddToStream('</mx:Application>');
  764.     }
  765.  
  766.     protected function TransparentEllipse($x1$y1$x2$y2)
  767.     {
  768.       //throw new Exception("The method or operation is not implemented.");
  769.     }
  770.  
  771.     public function textOut($x$y$z$text$align=-1
  772.     {
  773.         
  774.         $font=$this->getFont();
  775.         $fontFileName $font->getName();
  776.  
  777.         $fontSize $font->getFontSize();
  778.         $lineSpacing 1;
  779.  
  780.         $textWidth =  $this->textWidth($text)//  $lrx - $llx;
  781.         $textHeight $this->textHeight($text)//  $fontSize; // $lry - $ury;
  782.         $angle 0;
  783.                 
  784.         if ($align==-1{
  785.            $align $this->getTextAlign();
  786.         }
  787.                                   
  788.         if (in_array(StringAlignment::$HORIZONTAL_CENTER_ALIGN$align)) {
  789.             $x -= ($textWidth 2);
  790.         }
  791.         else
  792.         if (in_array (StringAlignment::$HORIZONTAL_RIGHT_ALIGN$align)) {
  793.             $x -= $textWidth;
  794.         }
  795.  
  796. /*        if (in_array (StringAlignment::$VERTICAL_CENTER_ALIGN, $align)) {
  797.             $y += $textHeight - 3;
  798.         }
  799. */
  800.         /*if (in_array (StringAlignment::$VERTICAL_TOP_ALIGN, $align)) {
  801.             $py += $textHeight;
  802.         }*/
  803.         /*else
  804.         if (in_array (StringAlignment::$VERTICAL_BOTTOM_ALIGN, $align)) {
  805.             $y += $textHeight + 3;
  806.         } */
  807.                 
  808.       if (in_array (StringAlignment::$FAR$align)) 
  809.       {
  810.         $x -= MathUtils::round($this->TextWidth($text));
  811.       
  812.       else 
  813.       if (in_array (StringAlignment::$CENTER$align)) 
  814.       {
  815.         //$x += MathUtils::round($this->TextWidth($text) / 2.0);
  816.         $y -= MathUtils::round($this->TextHeight($text2.0);        
  817.       }
  818.       
  819.       $this->AddTag("mx:Label"'text="' $text '" ' $this->PointToStr($x$y.
  820.        $this->FlexFont($this->Font' textAlign="left"');
  821.     }
  822.  
  823.     private function RXY($r)
  824.     {
  825.       return 'rx="' '8' '" ry="' '8' '"';
  826.     }
  827.  
  828.     public function rectangle($r)
  829.     {        
  830.       if ($this->getBrush()->getImage(!= null)
  831.       {
  832.         // TODO $this->Draw($r, $b->Image, $b->ImageTransparent);
  833.       }
  834.       else
  835.       {          
  836.         if ($this->getChart()->getPanel()->getBorderRound(0)
  837.         {
  838.           $this->AddTag("tee:RoundRect"$this->PointToStr($r->X$r->Y" " $this->FlexSize($r" " $this->RXY($r.
  839.             $this->FlexAlpha($this->CalcAlpha(false)) $this->PenColor($this->BrushColor($this->PenWidth());
  840.         }
  841.         else
  842.         {
  843.           $this->AddTag("tee:Rectangle"$this->PointToStr($r->X$r->Y" " .
  844.              $this->FlexSize($r$this->FlexAlpha($this->CalcAlpha(false)) $this->PenColor($this->BrushColor($this->PenWidth());
  845.         }
  846.       }
  847.     }
  848.   
  849.     public function getEmbeddedImages({
  850.          return $this->embeddedImages
  851.     }
  852.     
  853.     public function setEmbeddedImages($value{
  854.           $this->embeddedImages $value
  855.     }
  856.     
  857.     public function getImagePath({
  858.         return $this->imagePath
  859.     }
  860.     
  861.     public function setImagePath($value{
  862.         $this->imagePath $value
  863.     }
  864.  
  865.     public function Arc($x1$y1$x2$y2$startAngle$sweepAngle)
  866.     {
  867.       if ($this->Pen->Visible)
  868.       {
  869.         $this->AddTag("tee:Arc",
  870.           'x0="' $x1 '" y0="' $y1 '" ' .
  871.           'x1="' $x2 '" y1="' $y2 '" ' .
  872.           'startAngle="' $this->FloatToStr($startAngle.
  873.           '" endAngle="' $this->FloatToStr($startAngle $sweepAngle'" ' .
  874.           $this->FlexAlpha($this->CalcAlpha(true)) .
  875.           $this->PenColor(.
  876.           $this->PenWidth());
  877.       }
  878.     }
  879.     
  880.     public function _Arc($x1$y1$x2$y2$x3$y3$x4$y4)
  881.     {
  882.       //double start, sweep;
  883.  
  884.       if ($this->Pen->Visible)
  885.       {
  886.         $this->CalcArcAngles($x1$y1$x2$y2$x3$y3$x4$y4/*out*/ $start/*out*/ $sweep);
  887.         $this->Arc((int)$x1(int)$y1(int)$x2(int)$y2(float)$start(float)$sweep);
  888.       }
  889.     }
  890.  
  891.     public function FillRegion($brush$region)
  892.     {
  893.       //throw new Exception("The method or operation is not implemented.");
  894.     }
  895.  
  896.     public function ellipse($x1$y1$x2$y2$z=0$angle=0
  897.     {
  898.       if($z>0{
  899.         $p1 $this->calc3DPos($x1$y1$z);
  900.         $p2 $this->calc3DPos($x2$y2$z);
  901.         $this->ellipsePoints($p1,$p2);
  902.        //  todo here draw directly the ellipse with p1 and p2 $this->ellipsePoints($p1, $p2);
  903.       }
  904.       else
  905.       {
  906.         if ($angle>0{
  907.         //  todo remove Point[] p = new Point[NUMCIRCLEPOINTS]; //       : Array[0..NumCirclePoints-1] of TPoint;
  908.           $p Array();
  909.  
  910.           $points Array();
  911.           for ($t 0$t 3$t++{
  912.               $points[$tnew TeePoint();
  913.           }
  914.  
  915.           $xCenter ($x2 $x10.5;
  916.           $yCenter ($y2 $y10.5;
  917.           $xRadius ($x2 $x10.5;
  918.           $yRadius ($y2 $y10.5;
  919.  
  920.           $angle *= M_PI 180.0;
  921.           $tmpPiStep M_PI (self::$NUMCIRCLEPOINTS 1);
  922.  
  923.           // initial rotation (rotation matrix elements)
  924.           $tmpSinAngle sin($angle);
  925.           $tmpCosAngle cos($angle);
  926.  
  927.           for ($t 0$t self::$NUMCIRCLEPOINTS$t++{
  928.             $tmpSin sin($t $tmpPiStep);
  929.             $tmpCos cos($t $tmpPiStep);
  930.             $tmpX $xRadius $tmpSin;
  931.             $tmpY $yRadius $tmpCos;
  932.  
  933.             $p[$tnew TeePoint(
  934.                     MathUtils::round($xCenter +
  935.                                           ($tmpX $tmpCosAngle +
  936.                                            $tmpY $tmpSinAngle)),
  937.                     MathUtils::round($yCenter +
  938.                                           -$tmpX $tmpSinAngle +
  939.                                            $tmpY $tmpCosAngle))
  940.                    );
  941.           }
  942.  
  943.           if ($this->getBrush()->getVisible()) {
  944.             $old $this->getPen()->getVisible();
  945.             $this->getPen()->setVisible(false);
  946.  
  947.             $xc MathUtils::round($xCenter);
  948.             $yc MathUtils::round($yCenter);
  949.  
  950.             for ($t 1$t self::$NUMCIRCLEPOINTS$t++{
  951.                 // has to be in loop because the Polygon
  952.                 // transforms the positions from 3d to 2d in each pass
  953.                 $points[0]->setX($xc);
  954.                 $points[0]->setY($yc);
  955.                 $points[1$p[$t 1];
  956.                 $points[2$p[$t];
  957.                 $this->polygon($z$points);
  958.             }
  959.             // close it up with polygon from last to first
  960.             $points[0]->setX($xc);
  961.             $points[0]->setY($yc);
  962.             $points[1$p[self::$NUMCIRCLEPOINTS 1];
  963.             $points[2$p[0];
  964.             $this->polygon($z$points);
  965.             
  966.             $this->getPen()->setVisible($old);
  967.           }
  968.           if ($this->getPen()->getVisible()) {
  969.             $this->polyLine($z$p);
  970.           }
  971.         }
  972.         else
  973.         {
  974.          // updates x,y,width,height to be used in imagefilledellipse correctly
  975.           
  976.           //$x1=$x1+(($x2-$x1) / 2);
  977.           //$y1=$y1+(($y2-$y1) / 2);
  978.           $tmpWidth=((int)$x2-(int)$x1)//*2;
  979.           $tmpHeight=((int)$y2-(int)$y1)//*2;          
  980.           
  981.           /*$x1=(int)$x1+(((int)$x2-(int)$x1));
  982.           $y1=(int)$y1+(((int)$y2-(int)$y1));
  983.           $tmpWidth=((int)$x2-(int)$x1);
  984.           $tmpHeight=((int)$y2-(int)$y1);
  985.            */
  986.           if ($this->brush->getVisible()) {             
  987.             $this->AddTag("tee:Ellipse"$this->PointToStr((int)$x1(int)$y1" " $this->FlexSizeWH((int)$tmpWidth(int)$tmpHeight.
  988.             $this->FlexAlpha($this->CalcAlpha(false)) $this->BrushColor($this->PenColor($this->PenWidth());
  989.           }
  990.  
  991.         }
  992.       }
  993.     }
  994.  
  995.     public function EraseBackground($left$top$right$bottom)
  996.     {
  997.       //throw new Exception("The method or operation is not implemented.");
  998.     }
  999.  
  1000.     public function Draw($x$y$image)
  1001.     {
  1002.       if ($image != null)
  1003.       {
  1004.         $this->AddTag('mx:Image'$this->PointToStr($x$y' source="' $this->ImageSource($image'"');
  1005.       }
  1006.     }
  1007.  
  1008.     public function _Draw($destRect$srcRect$image$transparent)
  1009.     {
  1010.       if ($image != null)
  1011.       {
  1012.         $this->AddTag('mx:Image'$this->PointToStr($destRect->X$destRect->Y' ' .
  1013.           ' scaleX="' $this->FloatToStr($destRect->Width $image->Width'" ' .
  1014.           ' scaleY="' $this->FloatToStr($destRect->Height $image->Height'" ' .
  1015.           ' source="' $this->ImageSource($image'"');
  1016.       }
  1017.     }
  1018.  
  1019. /*
  1020.     public override function Polygon(params PointDouble[] $p)
  1021.     {
  1022.       $this->AddTag("tee:Polygon", $this->FlexPoints($p) . " " .
  1023.        $this->FlexAlpha($this->CalcAlpha(false)) . $this->BrushColor() . $this->PenColor() . 
  1024.        $this->PenWidth());
  1025.     }
  1026. */
  1027.     public function Polygon(/*params* Point[]*/ $p)
  1028.     {
  1029.        $this->AddTag("tee:Polygon"$this->FlexPoints($p" " .
  1030.        $this->FlexAlpha($this->CalcAlpha(false)) $this->BrushColor($this->PenColor(.
  1031.        $this->PenWidth());
  1032.     }
  1033.  
  1034.     public function ClipEllipse($r)
  1035.     {
  1036.       //throw new Exception("The method or operation is not implemented.");
  1037.     }
  1038.  
  1039.     public function ClipPolygon(/*params Point[]*/ $p)
  1040.     {                                         
  1041.       //throw new Exception("The method or operation is not implemented.");
  1042.     }
  1043.  
  1044.     public function ClipRectangle($r)
  1045.     {
  1046.       //throw new Exception("The method or operation is not implemented.");
  1047.     }
  1048.  
  1049.     public function SetClipRegion($region)
  1050.     {
  1051.       //throw new Exception("The method or operation is not implemented.");
  1052.     }
  1053.  
  1054.     public function DrawPath($pen$path)
  1055.     {
  1056.       //throw new Exception("The method or operation is not implemented.");
  1057.     }
  1058.  
  1059.     
  1060.     public function GradientFill($left$top$right$bottom$startColor$endColor$direction)
  1061.     {
  1062.       //throw new Exception("The method or operation is not implemented.");
  1063.     }
  1064.     
  1065.  
  1066.     public function Pixel($x$y$z$color)
  1067.     {
  1068.       //throw new Exception("The method or operation is not implemented.");
  1069.     }
  1070.  
  1071.     public function polyLine($z$p)        
  1072.     {
  1073.       $this->AddTag("tee:Polyline"$this->FlexPoints($p' ' .
  1074.              $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth());
  1075.     }
  1076.  
  1077.     public function RotateLabel($x$y$text$rotDegree)
  1078.     {
  1079.       $this->DoText($x$y$text$rotDegree$this->Font->Color);
  1080.     }
  1081.  
  1082.     public function UnClip()
  1083.     {
  1084.       //throw new Exception("The method or operation is not implemented.");
  1085.     }
  1086.  
  1087.     public function ClearClipRegions()
  1088.     {
  1089.       //throw new Exception("The method or operation is not implemented.");
  1090.     }
  1091.  
  1092.     private function Pos0($x=null$y=null)
  1093.     {
  1094.         if (($x==null&& ($y==null)) {
  1095.                         
  1096.             if ($this->moveToX==null
  1097.                 $this->moveToX=0;
  1098.  
  1099.             if ($this->moveToY==null
  1100.                 $this->moveToY=0;
  1101.                 
  1102.           $result'x0="' round($this->moveToX'" y0="' round($this->moveToY'"';
  1103.         }
  1104.         else
  1105.         {
  1106.             if ($x==null
  1107.                 $x=0;
  1108.  
  1109.             if ($y==null
  1110.                 $y=0;
  1111.                             
  1112.           $result'x0="' round($x'" y0="' round($y'"';                        
  1113.         }
  1114.         return $result;
  1115.     }
  1116.  
  1117.     private function Pos1($x$y)
  1118.     {
  1119.       return 'x1="' MathUtils::round($x'" y1="' MathUtils::round($y'"';
  1120.     }
  1121.  
  1122.     private function DashLenGap()
  1123.     {
  1124.       $len 4;
  1125.       $gap 4;
  1126.  
  1127.       switch ($this->Pen->Style)
  1128.       {
  1129.         case 2:  // Dash:
  1130.           break;
  1131.         case 3:  // DashDot:
  1132.           $len 4$gap 2;
  1133.           break;
  1134.         case 4:  // DashDotDot:
  1135.           $len 4$gap 3;
  1136.           break;
  1137.         case 1:  // Dot:
  1138.           $len 2$gap 2;
  1139.           break;
  1140.       }
  1141.  
  1142.       return ' len="' $len '" gap="' $gap '"';
  1143.     }
  1144.  
  1145.     public function LineTo($x$y)
  1146.     {
  1147.       if ($this->Pen->Style == DashStyle::$SOLID)
  1148.       {
  1149.         $this->AddTag("tee:Line"$this->Pos0(" " $this->Pos1($x$y
  1150.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1151.           $this->PenWidth());
  1152.       }
  1153.       else
  1154.       {
  1155.         $this->AddTag("tee:DashLine"$this->Pos0(" " $this->Pos1($x$y.
  1156.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1157.           $this->DashLenGap());
  1158.       }
  1159.  
  1160.     }
  1161.     
  1162.     /**
  1163.     * Draws a straight line
  1164.     *
  1165.     * @access       public
  1166.     * @param        integer         line start (X)
  1167.     * @param        integer         line start (Y)
  1168.     * @param        integer         line end (X)
  1169.     * @param        integer         line end (Y)
  1170.     * @param        Color           line color
  1171.     * @param        integer         line width
  1172.     */
  1173.  
  1174.     function line($x1$y1$x2$y2$color=null$width = -1)
  1175.     {
  1176.         if ($color==null)
  1177.         {
  1178.           //$color = $this->PenColor();
  1179.         }
  1180.         
  1181.         // Assign the pen width for the image
  1182.         /* Set thickness. */
  1183.         if ($width==-1{
  1184.           //$width = $this->pen->getWidth();
  1185.         }
  1186.         
  1187.         if ($this->Pen->Style == DashStyle::$SOLID)
  1188.         {
  1189.           $this->AddTag("tee:Line"$this->Pos0($x1,$y1" " $this->Pos1($x2$y2
  1190.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1191.           $this->PenWidth());
  1192.         }
  1193.         else
  1194.         {
  1195.           $this->AddTag("tee:DashLine"$this->Pos0($x1$y1" " $this->Pos1($x2$y2.
  1196.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1197.           $this->DashLenGap());
  1198.         }      
  1199.     }
  1200.  
  1201.     /**
  1202.     * Draws a Line between point p0 and point p1 using specific pen.
  1203.     *
  1204.     * @param pen ChartPen id the pen used
  1205.     * @param p0 Point is origin xy
  1206.     * @param p1 Point is destination xy
  1207.     */
  1208.     public function ___line($pen$p0$p1{
  1209.  
  1210.         $oldPen $this->getPen();
  1211.         $this->setPen($pen);
  1212.  
  1213.         if ($this->Pen->Style == DashStyle::$SOLID)
  1214.         {
  1215.           $this->AddTag("tee:Line"$this->Pos0($p0->getX(),$p0->getY()) " " $this->Pos1($p1->getX()$p1->getY()) 
  1216.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1217.           $this->PenWidth());
  1218.         }
  1219.         else
  1220.         {
  1221.           $this->AddTag("tee:DashLine"$this->Pos0($p0->getX(),$p0->getY()) " " $this->Pos1($p1->getX()$p1->getY()) .
  1222.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1223.           $this->DashLenGap());
  1224.         }   
  1225.                 
  1226.         $this->setPen($oldPen);
  1227.     }
  1228.  
  1229.     /**
  1230.     * Draws a Line from (X,Y,Z0) to (X,Y,Z1).
  1231.     *
  1232.     * @param int
  1233.     * @param int
  1234.     * @param z0 int
  1235.     * @param z1 int
  1236.     */
  1237.     public function zLine($x$y$z0$z1{
  1238.         $c1 imagecolorallocate($this->img$this->pen->getColor()->red,
  1239.             $this->pen->getColor()->green,
  1240.             $this->pen->getColor()->blue);
  1241.  
  1242.         $p1=$this->calc3DPos($x$y$z0);
  1243.         $p2=$this->calc3DPos($x$y$z1);
  1244.  
  1245.       if ($this->Pen->Style == DashStyle::$SOLID)
  1246.       {                                        
  1247.         $this->AddTag("tee:Line"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) 
  1248.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1249.           $this->PenWidth());
  1250.       }
  1251.       else
  1252.       {
  1253.         $this->AddTag("tee:DashLine"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) .
  1254.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1255.           $this->DashLenGap());
  1256.       }         
  1257.     }
  1258.                 
  1259.     /**
  1260.      * Draws a Horizontal at z depth position.
  1261.      *
  1262.      * @param left int
  1263.      * @param right int
  1264.      * @param int
  1265.      * @param int
  1266.      */
  1267.     public function horizontalLine($left$right$y$z=0{
  1268.         $p1=$this->calc3DPos($left$y$z);
  1269.         $p2=$this->calc3DPos($right$y$z);
  1270.         
  1271.       if ($this->Pen->Style == DashStyle::$SOLID)
  1272.       {                                        
  1273.         $this->AddTag("tee:Line"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) 
  1274.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1275.           $this->PenWidth());
  1276.       }
  1277.       else
  1278.       {
  1279.         $this->AddTag("tee:DashLine"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) .
  1280.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1281.           $this->DashLenGap());
  1282.       }              
  1283.     }    
  1284.     
  1285.     /**
  1286.      * Draws a Vertical Line from (X,Top) to (X,Bottom) at z depth position.
  1287.      *
  1288.      * @param int
  1289.      * @param top int
  1290.      * @param bottom int
  1291.      * @param int
  1292.      */
  1293.     public function verticalLine($x$top$bottom$z=0{
  1294.         $p1=$this->calc3DPos($x$top$z);
  1295.         $p2=$this->calc3DPos($x$bottom$z);
  1296.  
  1297.       if ($this->Pen->Style == DashStyle::$SOLID)
  1298.       {
  1299.                                         
  1300.         $this->AddTag("tee:Line"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) 
  1301.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor(.
  1302.           $this->PenWidth());
  1303.       }
  1304.       else
  1305.       {
  1306.         $this->AddTag("tee:DashLine"$this->Pos0($p1->getX(),$p1->getY()) " " $this->Pos1($p2->getX()$p2->getY()) .
  1307.           $this->FlexAlpha($this->CalcAlpha(true)) $this->PenColor($this->PenWidth(
  1308.           $this->DashLenGap());
  1309.       }      
  1310.     }    
  1311.  
  1312.     public function DrawBeziers(/*params Point[]*/ $p)
  1313.     {
  1314.       //throw new Exception("The method or operation is not implemented.");
  1315.     }
  1316.  
  1317.     public function PrepareDrawImage()
  1318.     {
  1319.       //throw new Exception("The method or operation is not implemented.");
  1320.     }
  1321.  
  1322.     public function AddLink($x$y$Text$URL$Hint)
  1323.     {
  1324.       $this->AddTag('mx:LinkButton''label="' $Text '" ' $this->PointToStr($x$y.
  1325.         ' toolTip="' $Hint '" ' .
  1326.         $this->FlexFont($this->Font.
  1327.         'click="navigateToURL(new URLRequest("' $URL "'), '" $Hint '")"');
  1328.     }
  1329.  
  1330.     public function AddToolTip($Entity$ToolTip)
  1331.     {
  1332.       if (!$iAddedInitApp)
  1333.       {
  1334.         //TODO
  1335.       }
  1336.     }
  1337.  
  1338. }
  1339. ?>

Documentation generated on Wed, 16 Jun 2010 12:03:51 +0200 by phpDocumentor 1.4.1