Development

Changeset 9195 for plugins/dwJpgraphPlugin

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
05/22/08 23:47:29 (4 months ago)
Author:
dwhittle
Message:

dwJpgraphPlugin: sync jpgraph libs + updated package.xml (closes #3570)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/dwJpgraphPlugin/lib/jpgraph/README

    r6910 r9195  
    44This package contains JpGraph, an Object Oriented PHP5 Graph Plotting library. 
    55 
    6 The library is Copyright (C) 2000-2007 Aditus Consulting and 
     6The library is Copyright (C) 2001-2006 Aditus Consulting and 
    77released under dual license QPL 1.0 for open source and educational 
    88use and JpGraph Professional License for commercial use.  
     
    7373* PHP 5.1.0 or higher  
    7474* GD 2.28 or higher 
    75 Note: Earlier versions might work but are unsupported. 
     75Note: Earlier versions might work but is unsupported. 
    7676 
    7777Recommended: 
     
    107107   for most users. (See also Note 3. below) 
    108108    
    109 4. Read (really!) the FAQ on http://www.aditus.nu/jpgraph/jpgraphfaq.php. 
     1094. Read (really!) the FAQ on http://www.aditus.nu/jpgraph/jpg_faq.php. 
    110110 
    111111 
     
    150150 
    151151 
     152Bug reports and suggestions 
     153--------------------------- 
     154Should be reported in the issue tracker at 
     155 
     156http://www.aditus.nu/bugtraq 
     157 
     158 
     159Change history: 
     160------------------------------------------------------------------------ 
     161Date        Ver        Comment 
     162------------------------------------------------------------------------ 
     1632005-12-04  2.0        First public 2.0 release 
     1642005-11-30  2.0rc2     Release candidate 
     1652005-05-13  2.0beta    Beta version of 2.0 serie for PHP5 
     166------------------------------------------------------------------------- 
     167 
    152168<EOF> 
  • plugins/dwJpgraphPlugin/lib/jpgraph/VERSION

    r6910 r9195  
    1 Revision: r958, Exported: 2007-12-07 22:59 
     1Revision: r995, Exported: 2008-04-15 06:00 
  • plugins/dwJpgraphPlugin/lib/jpgraph/jpg-config.inc.php

    r6910 r9195  
    3737// 
    3838//------------------------------------------------------------------------ 
    39 // DEFINE("CACHE_DIR","/tmp/jpgraph_cache/"); 
    40 // DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); 
    41 // DEFINE("MBTTF_DIR","/usr/share/fonts/ja/TrueType/"); 
     39DEFINE("CACHE_DIR","/tmp/jpgraph_cache/"); 
     40DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); 
     41DEFINE("MBTTF_DIR","/usr/share/fonts/ja/TrueType/"); 
    4242 
    4343//------------------------------------------------------------------------- 
     
    197197// specified group since otherwise it is impossible for Apache 
    198198// to set the specified group. 
    199 DEFINE("CACHE_FILE_GROUP","nobody"); 
     199DEFINE("CACHE_FILE_GROUP","wwwadmin"); 
    200200 
    201201// What permissions should the cached file have 
     
    224224DEFINE("_IMG_HANDLER","__handle"); 
    225225 
    226  
    227226?> 
  • plugins/dwJpgraphPlugin/lib/jpgraph/jpgraph.php

    r6910 r9195  
    1313require_once('jpgraph_errhandler.inc.php'); 
    1414require_once('jpgraph_ttf.inc.php'); 
     15require_once('gd_image.inc.php'); 
    1516 
    1617// Version info 
    17 DEFINE('JPG_VERSION','2.3'); 
     18DEFINE('JPG_VERSION','2.3.2-dev'); 
    1819 
    1920// Minimum required PHP version 
     
    6162  DEFINE('TTF_DIR','/usr/X11R6/lib/X11/fonts/truetype/'); 
    6263    } 
     64} 
     65 
     66if (!defined('MBTTF_DIR')) { 
     67    DEFINE('MBTTF_DIR','/usr/share/fonts/ja/TrueType/'); 
    6368} 
    6469 
     
    172177 
    173178// Line styles 
    174 DEFINE('LINESTYLE_DOTTED',1); 
    175 DEFINE('LINESTYLE_DASHED',2); 
    176 DEFINE('LINESTYLE_LONGDASH',3); 
    177 DEFINE('LINESTYLE_SOLID',4); 
     179DEFINE('LINESTYLE_SOLID',1); 
     180DEFINE('LINESTYLE_DOTTED',2); 
     181DEFINE('LINESTYLE_DASHED',3); 
     182DEFINE('LINESTYLE_LONGDASH',4); 
    178183 
    179184// For internal use only 
     
    187192    list($majorR, $minorR, $editR) = split('[/.-]', $aMinVersion); 
    188193   
    189     if ($majorC > $majorR) return true; 
     194    if ($majorC != $majorR) return false; 
    190195    if ($majorC < $majorR) return false; 
    191196    // same major - check ninor 
     
    202207if( !CheckPHPVersion(MIN_PHPVERSION) ) { 
    203208    JpGraphError::RaiseL(13,PHP_VERSION,MIN_PHPVERSION); 
     209    die(); 
    204210} 
    205211 
     
    232238// 
    233239if( isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG &&  
    234     !preg_match('|Deprecated|', $GLOBALS['php_errormsg']) ) { 
     240    !preg_match('/|Deprecated|/i', $GLOBALS['php_errormsg']) ) { 
    235241    JpGraphError::RaiseL(25004,$GLOBALS['php_errormsg']); 
    236242} 
     
    11651171  while( list($key,$value) = each($_GET) ) { 
    11661172      if( is_array($value) ) { 
    1167     $n = count($value); 
    1168     for( $i=0; $i < $n; ++$i ) { 
    1169         $urlarg .= '&amp;'.$key.'%5B%5D='.urlencode($value[$i]); 
     1173    foreach ( $value as $k => $v ) { 
     1174        $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode($v); 
    11701175    } 
    11711176      } 
     
    11811186  while( list($key,$value) = each($_POST) ) { 
    11821187      if( is_array($value) ) { 
    1183     $n = count($value); 
    1184     for( $i=0; $i < $n; ++$i ) { 
    1185         $urlarg .= '&amp;'.$key.'%5B%5D='.urlencode($value[$i]); 
     1188    foreach ( $value as $k => $v ) { 
     1189        $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode($v); 
    11861190    } 
    11871191      } 
     
    34183422 
    34193423      // Draw grid lines 
    3420       for($i=0; $i<$nbrgrids; ++$i) { 
     3424      switch( $this->type ) { 
     3425    case "solid":  $style = LINESTYLE_SOLID; break; 
     3426    case "dotted": $style = LINESTYLE_DOTTED; break; 
     3427    case "dashed": $style = LINESTYLE_DASHED; break; 
     3428    case "longdashed": $style = LINESTYLE_LONGDASH; break; 
     3429    default: 
     3430        $style = LINESTYLE_SOLID; break; 
     3431      } 
     3432 
     3433      for($i=0; $i < $nbrgrids; ++$i) { 
    34213434    $y=$aTicksPos[$i]; 
    3422     if( $this->type == "solid" ) 
    3423         $this->img->Line($xl,$y,$xr,$y); 
    3424     elseif( $this->type == "dotted" ) 
    3425         $this->img->DashedLine($xl,$y,$xr,$y,1,6); 
    3426     elseif( $this->type == "dashed" ) 
    3427         $this->img->DashedLine($xl,$y,$xr,$y,2,4); 
    3428     elseif( $this->type == "longdashed" ) 
    3429         $this->img->DashedLine($xl,$y,$xr,$y,8,6); 
     3435    $this->img->StyleLine($xl,$y,$xr,$y,$style); 
    34303436      } 
    34313437  } 
     
    54545460        $pos2 = $pos-1; // Sentinel 
    54555461    if( $pos > $pos2 ) { 
    5456         $alpha = substr($aColor,$pos+1); 
     5462        $alpha = str_replace(',','.',substr($aColor,$pos+1)); 
    54575463        $aColor = substr($aColor,0,$pos); 
    54585464    } 
     
    54705476      } 
    54715477      else { 
    5472     $adj = 0.0 + substr($aColor,$pos+1); 
     5478    $adj = 0.0 + str_replace(',','.',substr($aColor,$pos+1)); 
    54735479    $aColor = substr($aColor,0,$pos); 
    54745480      } 
     
    55415547} // Class 
    55425548 
    5543    
    5544 //=================================================== 
    5545 // CLASS Image 
    5546 // Description: Wrapper class with some goodies to form the 
    5547 // Interface to low level image drawing routines. 
    5548 //=================================================== 
    5549 class Image { 
    5550     public $left_margin=30,$right_margin=30,$top_margin=20,$bottom_margin=30; 
    5551     public $img=null; 
    5552     public $plotwidth=0,$plotheight=0; 
    5553     public $width=0, $height=0; 
    5554     public $rgb=null; 
    5555     public $current_color,$current_color_name; 
    5556     public $line_weight=1, $line_style=1; // Default line style is solid 
    5557     public $img_format; 
    5558     protected $expired=true; 
    5559     protected $lastx=0, $lasty=0; 
    5560     protected $obs_list=array(); 
    5561     protected $font_size=12,$font_family=FF_FONT1, $font_style=FS_NORMAL; 
    5562     protected $font_file=''; 
    5563     protected $text_halign="left",$text_valign="bottom"; 
    5564     protected $ttf=null; 
    5565     protected $use_anti_aliasing=false; 
    5566     protected $quality=null; 
    5567     protected $colorstack=array(),$colorstackidx=0; 
    5568     protected $canvascolor = 'white' ; 
    5569     protected $langconv = null ; 
    5570     protected $iInterlace=false; 
    5571     //--------------- 
    5572     // CONSTRUCTOR 
    5573     function Image($aWidth,$aHeight,$aFormat=DEFAULT_GFORMAT,$aSetAutoMargin=true) { 
    5574   $this->CreateImgCanvas($aWidth,$aHeight); 
    5575   if( $aSetAutoMargin ) 
    5576       $this->SetAutoMargin();    
    5577  
    5578   if( !$this->SetImgFormat($aFormat) ) { 
    5579       JpGraphError::RaiseL(25081,$aFormat);//("JpGraph: Selected graphic format is either not supported or unknown [$aFormat]"); 
    5580   } 
    5581   $this->ttf = new TTF(); 
    5582   $this->langconv = new LanguageConv(); 
    5583     } 
    5584  
    5585     // Enable interlacing in images 
    5586     function SetInterlace($aFlg=true) { 
    5587   $this->iInterlace=$aFlg; 
    5588     } 
    5589  
    5590     // Should we use anti-aliasing. Note: This really slows down graphics! 
    5591     function SetAntiAliasing($aFlg=true) { 
    5592   $this->use_anti_aliasing = $aFlg; 
    5593   if( function_exists('imageantialias') ) { 
    5594       imageantialias($this->img,$aFlg); 
    5595   } 
    5596   else { 
    5597       JpGraphError::RaiseL(25128);//('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.') 
    5598   } 
    5599     } 
    5600  
    5601     function CreateRawCanvas($aWidth=0,$aHeight=0) { 
    5602   if( $aWidth <= 1 || $aHeight <= 1 ) { 
    5603       JpGraphError::RaiseL(25082,$aWidth,$aHeight);//("Illegal sizes specified for width or height when creating an image, (width=$aWidth, height=$aHeight)"); 
    5604   } 
    5605  
    5606   if( USE_TRUECOLOR ) { 
    5607       $this->img = @imagecreatetruecolor($aWidth, $aHeight); 
    5608       if( $this->img < 1 ) { 
    5609     JpGraphError::RaiseL(25126); 
    5610     //die("Can't create truecolor image. Check that you really have GD2 library installed."); 
    5611       } 
    5612       $this->SetAlphaBlending(); 
    5613   } else { 
    5614       $this->img = @imagecreate($aWidth, $aHeight);  
    5615       if( $this->img < 1 ) { 
    5616     JpGraphError::RaiseL(25126); 
    5617     //die("<b>JpGraph Error:</b> Can't create image. Check that you really have the GD library installed."); 
    5618       } 
    5619   } 
    5620  
    5621   if( $this->iInterlace ) { 
    5622       imageinterlace($this->img,1); 
    5623   } 
    5624   if( $this->rgb != null )  
    5625       $this->rgb->img = $this->img ; 
    5626   else 
    5627       $this->rgb = new RGB($this->img);        
    5628     } 
    5629  
    5630     function CloneCanvasH() { 
    5631   $oldimage = $this->img; 
    5632   $this->CreateRawCanvas($this->width,$this->height); 
    5633   imagecopy($this->img,$oldimage,0,0,0,0,$this->width,$this->height); 
    5634   return $oldimage; 
    5635     } 
    5636      
    5637     function CreateImgCanvas($aWidth=0,$aHeight=0) { 
    5638  
    5639   $old = array($this->img,$this->width,$this->height); 
    5640    
    5641   $aWidth = round($aWidth); 
    5642   $aHeight = round($aHeight); 
    5643  
    5644   $this->width=$aWidth; 
    5645   $this->height=$aHeight;    
    5646  
    5647    
    5648   if( $aWidth==0 || $aHeight==0 ) { 
    5649       // We will set the final size later.  
    5650       // Note: The size must be specified before any other 
    5651       // img routines that stroke anything are called. 
    5652       $this->img = null; 
    5653       $this->rgb = null; 
    5654       return $old; 
    5655   } 
    5656    
    5657   $this->CreateRawCanvas($aWidth,$aHeight); 
    5658   // Set canvas color (will also be the background color for a  
    5659   // a pallett image 
    5660   $this->SetColor($this->canvascolor);   
    5661   $this->FilledRectangle(0,0,$aWidth,$aHeight); 
    5662  
    5663   return $old ; 
    5664     } 
    5665  
    5666     function CopyCanvasH($aToHdl,$aFromHdl,$aToX,$aToY,$aFromX,$aFromY,$aWidth,$aHeight,$aw=-1,$ah=-1) { 
    5667   if( $aw === -1 ) { 
    5668       $aw = $aWidth; 
    5669       $ah = $aHeight; 
    5670       $f = 'imagecopyresized'; 
    5671   } 
    5672   else { 
    5673       $f = 'imagecopyresampled'; 
    5674   } 
    5675   $f($aToHdl,$aFromHdl,$aToX,$aToY,$aFromX,$aFromY, $aWidth,$aHeight,$aw,$ah); 
    5676     } 
    5677  
    5678     function Copy($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1) { 
    5679   $this->CopyCanvasH($this->img,$fromImg,$toX,$toY,$fromX,$fromY, 
    5680          $toWidth,$toHeight,$fromWidth,$fromHeight); 
    5681     } 
    5682  
    5683     function CopyMerge($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1,$aMix=100) { 
    5684   if( $aMix == 100 ) { 
    5685       $this->CopyCanvasH($this->img,$fromImg, 
    5686              $toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth,$fromHeight); 
    5687   } 
    5688   else { 
    5689       if( ($fromWidth  != -1 && ($fromWidth != $toWidth))  || 
    5690     ($fromHeight != -1 && ($fromHeight != $fromHeight)) ) { 
    5691     // Create a new canvas that will hold the re-scaled original from image 
    5692     if( $toWidth <= 1 || $toHeight <= 1 ) { 
    5693         JpGraphError::RaiseL(25083);//('Illegal image size when copying image. Size for copied to image is 1 pixel or less.'); 
    5694     } 
    5695     if( USE_TRUECOLOR ) { 
    5696         $tmpimg = @imagecreatetruecolor($toWidth, $toHeight); 
    5697     } else { 
    5698         $tmpimg = @imagecreate($toWidth, $toHeight);   
    5699     }      
    5700     if( $tmpimg < 1 ) { 
    5701         JpGraphError::RaiseL(25084);//('Failed to create temporary GD canvas. Out of memory ?'); 
    5702     } 
    5703     $this->CopyCanvasH($tmpimg,$fromImg,0,0,0,0, 
    5704            $toWidth,$toHeight,$fromWidth,$fromHeight); 
    5705     $fromImg = $tmpimg; 
    5706       } 
    5707       imagecopymerge($this->img,$fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$aMix); 
    5708   } 
    5709     } 
    5710  
    5711     static function GetWidth($aImg=null) { 
    5712   if( $aImg === null )  
    5713       $aImg = $this->img; 
    5714   return imagesx($aImg); 
    5715     } 
    5716  
    5717     static function GetHeight($aImg=null) { 
    5718   if( $aImg === null )  
    5719       $aImg = $this->img; 
    5720   return imagesy($aImg); 
    5721     } 
    5722      
    5723     static function CreateFromString($aStr) { 
    5724   $img = imagecreatefromstring($aStr); 
    5725   if( $img === false ) { 
    5726       JpGraphError::RaiseL(25085);//('An image can not be created from the supplied string. It is either in a format not supported or the string is representing an corrupt image.'); 
    5727   } 
    5728   return $img; 
    5729     } 
    5730  
    5731     function SetCanvasH($aHdl) { 
    5732   $this->img = $aHdl; 
    5733   $this->rgb->img = $aHdl; 
    5734     } 
    5735  
    5736     function SetCanvasColor($aColor) { 
    5737   $this->canvascolor = $aColor ; 
    5738     } 
    5739  
    5740     function SetAlphaBlending($aFlg=true) { 
    5741   ImageAlphaBlending($this->img,$aFlg); 
    5742     } 
    5743  
    5744    
    5745     function SetAutoMargin() {   
    5746   GLOBAL $gJpgBrandTiming; 
    5747   $min_bm=5; 
    5748   /* 
    5749   if( $gJpgBrandTiming ) 
    5750       $min_bm=15;    
    5751   */ 
    5752   $lm = min(40,$this->width/7); 
    5753   $rm = min(20,$this->width/10); 
    5754   $tm = max(5,$this->height/7); 
    5755   $bm = max($min_bm,$this->height/7); 
    5756   $this->SetMargin($lm,$rm,$tm,$bm);     
    5757     } 
    5758  
    5759          
    5760     //--------------- 
    5761     // PUBLIC METHODS  
    5762    
    5763     function SetFont($family,$style=FS_NORMAL,$size=10) { 
    5764   $this->font_family=$family; 
    5765   $this->font_style=$style; 
    5766   $this->font_size=$size; 
    5767   $this->font_file=''; 
    5768   if( ($this->font_family==FF_FONT1 || $this->font_family==FF_FONT2) && $this->font_style==FS_BOLD ){ 
    5769       ++$this->font_family; 
    5770   } 
    5771   if( $this->font_family > FF_FONT2+1 ) { // A TTF font so get the font file 
    5772  
    5773       // Check that this PHP has support for TTF fonts 
    5774       if( !function_exists('imagettfbbox') ) { 
    5775     JpGraphError::RaiseL(25087);//('This PHP build has not been configured with TTF support. You need to recompile your PHP installation with FreeType support.'); 
    5776       } 
    5777       $this->font_file = $this->ttf->File($this->font_family,$this->font_style); 
    5778   } 
    5779     } 
    5780  
    5781     // Get the specific height for a text string 
    5782     function GetTextHeight($txt="",$angle=0) { 
    5783   $tmp = split("\n",$txt); 
    5784   $n = count($tmp); 
    5785   $m=0; 
    5786   for($i=0; $i< $n; ++$i) 
    5787       $m = max($m,strlen($tmp[$i])); 
    5788  
    5789   if( $this->font_family <= FF_FONT2+1 ) { 
    5790       if( $angle==0 ) { 
    5791     $h = imagefontheight($this->font_family); 
    5792     if( $h === false ) { 
    5793         JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); 
    5794     } 
    5795  
    5796     return $n*$h; 
    5797       } 
    5798       else { 
    5799     $w = @imagefontwidth($this->font_family); 
    5800     if( $w === false ) { 
    5801         JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); 
    5802     } 
    5803  
    5804     return $m*$w; 
    5805       } 
    5806   } 
    5807   else { 
    5808       $bbox = $this->GetTTFBBox($txt,$angle); 
    5809       return $bbox[1]-$bbox[5]; 
    5810   } 
    5811     } 
    5812    
    5813     // Estimate font height 
    5814     function GetFontHeight($angle=0) { 
    5815   $txt = "XOMg"; 
    5816   return $this->GetTextHeight($txt,$angle); 
    5817     } 
    5818    
    5819     // Approximate font width with width of letter "O" 
    5820     function GetFontWidth($angle=0) { 
    5821   $txt = 'O'; 
    5822   return $this->GetTextWidth($txt,$angle); 
    5823     } 
    5824    
    5825     // Get actual width of text in absolute pixels 
    5826     function GetTextWidth($txt,$angle=0) { 
    5827  
    5828   $tmp = split("\n",$txt); 
    5829   $n = count($tmp); 
    5830   if( $this->font_family <= FF_FONT2+1 ) { 
    5831  
    5832       $m=0; 
    5833       for($i=0; $i < $n; ++$i) { 
    5834     $l=strlen($tmp[$i]); 
    5835     if( $l > $m ) { 
    5836         $m = $l; 
    5837     } 
    5838       } 
    5839  
    5840       if( $angle==0 ) { 
    5841     $w = @imagefontwidth($this->font_family); 
    5842     if( $w === false ) { 
    5843         JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); 
    5844     } 
    5845     return $m*$w; 
    5846       } 
    5847       else { 
    5848     // 90 degrees internal so height becomes width 
    5849     $h = @imagefontheight($this->font_family);  
    5850     if( $h === false ) { 
    5851         JpGraphError::RaiseL(25089);//('You have a misconfigured GD font support. The call to imagefontheight() fails.'); 
    5852     } 
    5853     return $n*$h; 
    5854       } 
    5855   } 
    5856   else { 
    5857       // For TTF fonts we must walk through a lines and find the  
    5858       // widest one which we use as the width of the multi-line 
    5859       // paragraph 
    5860       $m=0; 
    5861       for( $i=0; $i < $n; ++$i ) { 
    5862     $bbox = $this->GetTTFBBox($tmp[$i],$angle); 
    5863     $mm =  $bbox[2] - $bbox[0]; 
    5864     if( $mm > $m )  
    5865         $m = $mm; 
    5866       } 
    5867       return $m; 
    5868   } 
    5869     } 
    5870    
    5871     // Draw text with a box around it 
    5872     function StrokeBoxedText($x,$y,$txt,$dir=0,$fcolor="white",$bcolor="black", 
    5873            $shadowcolor=false,$paragraph_align="left", 
    5874            $xmarg=6,$ymarg=4,$cornerradius=0,$dropwidth=3) { 
    5875  
    5876   if( !is_numeric($dir) ) { 
    5877       if( $dir=="h" ) $dir=0; 
    5878       elseif( $dir=="v" ) $dir=90; 
    5879       else JpGraphError::RaiseL(25090,$dir);//(" Unknown direction specified in call to StrokeBoxedText() [$dir]"); 
    5880   } 
    5881      
    5882   if( $this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2+1) {  
    5883       $width=$this->GetTextWidth($txt,$dir) ; 
    5884       $height=$this->GetTextHeight($txt,$dir) ; 
    5885   } 
    5886   else { 
    5887       $width=$this->GetBBoxWidth($txt,$dir) ; 
    5888       $height=$this->GetBBoxHeight($txt,$dir) ; 
    5889   } 
    5890  
    5891   $height += 2*$ymarg; 
    5892   $width  += 2*$xmarg; 
    5893  
    5894   if( $this->text_halign=="right" ) $x -= $width; 
    5895   elseif( $this->text_halign=="center" ) $x -= $width/2; 
    5896   if( $this->text_valign=="bottom" ) $y -= $height; 
    5897   elseif( $this->text_valign=="center" ) $y -= $height/2; 
    5898    
    5899   $olda = $this->SetAngle(0); 
    5900  
    5901   if( $shadowcolor ) { 
    5902       $this->PushColor($shadowcolor); 
    5903       $this->FilledRoundedRectangle($x-$xmarg+$dropwidth,$y-$ymarg+$dropwidth, 
    5904             $x+$width+$dropwidth,$y+$height-$ymarg+$dropwidth, 
    5905             $cornerradius); 
    5906       $this->PopColor(); 
    5907       $this->PushColor($fcolor); 
    5908       $this->FilledRoundedRectangle($x-$xmarg,$y-$ymarg, 
    5909             $x+$width,$y+$height-$ymarg, 
    5910             $cornerradius);    
    5911       $this->PopColor(); 
    5912       $this->PushColor($bcolor); 
    5913       $this->RoundedRectangle($x-$xmarg,$y-$ymarg, 
    5914             $x+$width,$y+$height-$ymarg,$cornerradius); 
    5915       $this->PopColor(); 
    5916   } 
    5917   else { 
    5918       if( $fcolor ) { 
    5919     $oc=$this->current_color; 
    5920     $this->SetColor($fcolor); 
    5921     $this->FilledRoundedRectangle($x-$xmarg,$y-$ymarg,$x+$width,$y+$height-$ymarg,$cornerradius); 
    5922     $this->current_color=$oc; 
    5923       } 
    5924       if( $bcolor ) { 
    5925     $oc=$this->current_color; 
    5926     $this->SetColor($bcolor);      
    5927     $this->RoundedRectangle($x-$xmarg,$y-$ymarg,$x+$width,$y+$height-$ymarg,$cornerradius); 
    5928     $this->current_color=$oc;      
    5929       } 
    5930   } 
    5931      
    5932   $h=$this->text_halign; 
    5933   $v=$this->text_valign; 
    5934   $this->SetTextAlign("left","top"); 
    5935   $this->StrokeText($x, $y, $txt, $dir, $paragraph_align); 
    5936   $bb = array($x-$xmarg,$y+$height-$ymarg,$x+$width,$y+$height-$ymarg, 
    5937         $x+$width,$y-$ymarg,$x-$xmarg,$y-$ymarg); 
    5938   $this->SetTextAlign($h,$v); 
    5939  
    5940   $this->SetAngle($olda); 
    5941  
    5942   return $bb; 
    5943     } 
    5944  
    5945     // Set text alignment  
    5946     function SetTextAlign($halign,$valign="bottom") { 
    5947   $this->text_halign=$halign; 
    5948   $this->text_valign=$valign; 
    5949     } 
    5950    
    5951  
    5952     function _StrokeBuiltinFont($x,$y,$txt,$dir=0,$paragraph_align="left",&$aBoundingBox,$aDebug=false) { 
    5953  
    5954   if( is_numeric($dir) && $dir!=90 && $dir!=0)  
    5955       JpGraphError::RaiseL(25091);//(" Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead."); 
    5956  
    5957   $h=$this->GetTextHeight($txt); 
    5958   $fh=$this->GetFontHeight(); 
    5959   $w=$this->GetTextWidth($txt); 
    5960    
    5961   if( $this->text_halign=="right")         
    5962       $x -= $dir==0 ? $w : $h; 
    5963   elseif( $this->text_halign=="center" ) { 
    5964       // For center we subtract 1 pixel since this makes the middle 
    5965       // be prefectly in the middle 
    5966       $x -= $dir==0 ? $w/2-1 : $h/2; 
    5967   } 
    5968   if( $this->text_valign=="top" ) 
    5969       $y += $dir==0 ? $h : $w; 
    5970   elseif( $this->text_valign=="center" )         
    5971       $y += $dir==0 ? $h/2 : $w/2; 
    5972    
    5973   if( $dir==90 ) { 
    5974       imagestringup($this->img,$this->font_family,$x,$y,$txt,$this->current_color); 
    5975       $aBoundingBox = array(round($x),round($y),round($x),round($y-$w),round($x+$h),round($y-$w),round($x+$h),round($y)); 
    5976             if( $aDebug ) { 
    5977     // Draw bounding box 
    5978     $this->PushColor('green'); 
    5979     $this->Polygon($aBoundingBox,true); 
    5980     $this->PopColor(); 
    5981       } 
    5982   } 
    5983   else { 
    5984       if( ereg("\n",$txt) ) {  
    5985     $tmp = split("\n",$txt); 
    5986     for($i=0; $i < count($tmp); ++$i) { 
    5987         $w1 = $this->GetTextWidth($tmp[$i]); 
    5988         if( $paragraph_align=="left" ) { 
    5989       imagestring($this->img,$this->font_family,$x,$y-$h+1+$i*$fh,$tmp[$i],$this->current_color); 
    5990         } 
    5991         elseif( $paragraph_align=="right" ) { 
    5992       imagestring($this->img,$this->font_family,$x+($w-$w1), 
    5993             $y-$h+1+$i*$fh,$tmp[$i],$this->current_color); 
    5994         } 
    5995         else { 
    5996       imagestring($this->img,$this->font_family,$x+$w/2-$w1/2, 
    5997             $y-$h+1+$i*$fh,$tmp[$i],$this->current_color); 
    5998         } 
    5999     } 
    6000       }  
    6001       else { 
    6002     //Put the text 
    6003     imagestring($this->img,$this->font_family,$x,$y-$h+1,$txt,$this->current_color); 
    6004       } 
    6005             if( $aDebug ) { 
    6006     // Draw the bounding rectangle and the bounding box 
    6007     $p1 = array(round($x),round($y),round($x),round($y-$h),round($x+$w),round($y-$h),round($x+$w),round($y)); 
    6008      
    6009     // Draw bounding box 
    6010     $this->PushColor('green'); 
    6011     $this->Polygon($p1,true); 
    6012     $this->PopColor(); 
    6013  
    6014             } 
    6015       $aBoundingBox=array(round($x),round($y),round($x),round($y-$h),round($x+$w),round($y-$h),round($x+$w),round($y)); 
    6016   } 
    6017     } 
    6018  
    6019     function AddTxtCR($aTxt) { 
    6020   // If the user has just specified a '\n' 
    6021   // instead of '\n\t' we have to add '\r' since 
    6022   // the width will be too muchy otherwise since when 
    6023   // we print we stroke the individually lines by hand. 
    6024   $e = explode("\n",$aTxt); 
    6025   $n = count($e); 
    6026   for($i=0; $i<$n; ++$i) { 
    6027       $e[$i]=str_replace("\r","",$e[$i]); 
    6028   } 
    6029   return implode("\n\r",$e); 
    6030     } 
    6031  
    6032     function GetTTFBBox($aTxt,$aAngle=0) { 
    6033   $bbox = @ImageTTFBBox($this->font_size,$aAngle,$this->font_file,$aTxt); 
    6034   if( $bbox === false ) { 
    6035       JpGraphError::RaiseL(25092,$this->font_file); 
    6036 //("There is either a configuration problem with TrueType or a problem reading font file (".$this->font_file."). Make sure file exists and is in a readable place for the HTTP process. (If 'basedir' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try uppgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library."); 
    6037   } 
    6038   return $bbox; 
    6039     } 
    6040  
    6041     function GetBBoxTTF($aTxt,$aAngle=0) { 
    6042   // Normalize the bounding box to become a minimum 
    6043   // enscribing rectangle 
    6044  
    6045   $aTxt = $this->AddTxtCR($aTxt); 
    6046  
    6047   if( !is_readable($this->font_file) ) { 
    6048       JpGraphError::RaiseL(25093,$this->font_file); 
    6049 //('Can not read font file ('.$this->font_file.') in call to Image::GetBBoxTTF. Please make sure that you have set a font before calling this method and that the font is installed in the TTF directory.'); 
    6050   } 
    6051   $bbox = $this->GetTTFBBox($aTxt,$aAngle); 
    6052  
    6053   if( $aAngle==0 )  
    6054       return $bbox; 
    6055   if( $aAngle >= 0 ) { 
    6056       if(  $aAngle <= 90 ) { //<=0     
    6057     $bbox = array($bbox[6],$bbox[1],$bbox[2],$bbox[1], 
    6058             $bbox[2],$bbox[5],$bbox[6],$bbox[5]); 
    6059       } 
    6060       elseif(  $aAngle <= 180 ) { //<= 2 
    6061     $bbox = array($bbox[4],$bbox[7],$bbox[0],$bbox[7], 
    6062             $bbox[0],$bbox[3],$bbox[4],$bbox[3]); 
    6063       } 
    6064       elseif(  $aAngle <= 270 )  { //<= 3 
    6065     $bbox = array($bbox[2],$bbox[5],$bbox[6],$bbox[5], 
    6066             $bbox[6],$bbox[1],$bbox[2],$bbox[1]); 
    6067       } 
    6068       else { 
    6069     $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], 
    6070             $bbox[4],$bbox[7],$bbox[0],$bbox[7]); 
    6071       } 
    6072   } 
    6073   elseif(  $aAngle < 0 ) { 
    6074       if( $aAngle <= -270 ) { // <= -3 
    6075     $bbox = array($bbox[6],$bbox[1],$bbox[2],$bbox[1], 
    6076             $bbox[2],$bbox[5],$bbox[6],$bbox[5]); 
    6077       } 
    6078       elseif( $aAngle <= -180 ) { // <= -2 
    6079     $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], 
    6080             $bbox[4],$bbox[7],$bbox[0],$bbox[7]); 
    6081       } 
    6082       elseif( $aAngle <= -90 ) { // <= -1 
    6083     $bbox = array($bbox[2],$bbox[5],$bbox[6],$bbox[5], 
    6084             $bbox[6],$bbox[1],$bbox[2],$bbox[1]); 
    6085       } 
    6086       else { 
    6087     $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], 
    6088             $bbox[4],$bbox[7],$bbox[0],$bbox[7]); 
    6089       } 
    6090   }  
    6091   return $bbox; 
    6092     } 
    6093  
    6094     function GetBBoxHeight($aTxt,$aAngle=0) { 
    6095   $box = $this->GetBBoxTTF($aTxt,$aAngle); 
    6096   return $box[1]-$box[7]+1; 
    6097     } 
    6098  
    6099     function GetBBoxWidth($aTxt,$aAngle=0) { 
    6100   $box = $this->GetBBoxTTF($aTxt,$aAngle); 
    6101   return $box[2]-$box[0]+1;  
    6102     } 
    6103  
    6104     function _StrokeTTF($x,$y,$txt,$dir=0,$paragraph_align="left",&$aBoundingBox,$debug=false) { 
    6105  
    6106   // Setupo default inter line margin for paragraphs to 
    6107   // 25% of the font height. 
    6108   $ConstLineSpacing = 0.25 ; 
    6109  
    6110   // Remember the anchor point before adjustment 
    6111   if( $debug ) { 
    6112       $ox=$x; 
    6113       $oy=$y; 
    6114   } 
    6115  
    6116   if( !ereg("\n",$txt) || ($dir>0 && ereg("\n",$txt)) ) { 
    6117       // Format a single line 
    6118  
    6119       $txt = $this->AddTxtCR($txt); 
    6120  
    6121       $bbox=$this->GetBBoxTTF($txt,$dir); 
    6122        
    6123       // Align x,y ot lower left corner of bbox 
    6124       $x -= $bbox[0]; 
    6125       $y -= $bbox[1]; 
    6126  
    6127       // Note to self: "topanchor" is deprecated after we changed the 
    6128       // bopunding box stuff.  
    6129       if( $this->text_halign=="right" || $this->text_halign=="topanchor" )  
    6130     $x -= $bbox[2]-$bbox[0]; 
    6131       elseif( $this->text_halign=="center" ) $x -= ($bbox[2]-$bbox[0])/2;  
    6132        
    6133       if( $this->text_valign=="top" ) $y += abs($bbox[5])+$bbox[1]; 
    6134       elseif( $this->text_valign=="center" ) $y -= ($bbox[5]-$bbox[1])/2;  
    6135  
    6136       ImageTTFText ($this->img, $this->font_size, $dir, $x, $y,  
    6137         $this->current_color,$this->font_file,$txt);  
    6138  
    6139       // Calculate and return the co-ordinates for the bounding box 
    6140       $box=@ImageTTFBBox($this->font_size,$dir,$this->font_file,$txt); 
    6141       $p1 = array(); 
    6142  
    6143  
    6144       for($i=0; $i < 4; ++$i) { 
    6145     $p1[] = round($box[$i*2]+$x); 
    6146     $p1[] = round($box[$i*2+1]+$y); 
    6147       } 
    6148       $aBoundingBox = $p1; 
    6149  
    6150       // Debugging code to highlight the bonding box and bounding rectangle 
    6151       // For text at 0 degrees the bounding box and bounding rectangle are the 
    6152       // same 
    6153             if( $debug ) { 
    6154     // Draw the bounding rectangle and the bounding box 
    6155     $box=@ImageTTFBBox($this->font_size,$dir,$this->font_file,$txt); 
    6156     $p = array(); 
    6157     $p1 = array(); 
    6158     for($i=0; $i < 4; ++$i) { 
    6159         $p[] = $bbox[$i*2]+$x; 
    6160         $p[] = $bbox[$i*2+1]+$y; 
    6161         $p1[] = $box[$i*2]+$x; 
    6162         $p1[] = $box[$i*2+1]+$y; 
    6163     } 
    6164  
    6165     // Draw bounding box 
    6166     $this->PushColor('green'); 
    6167     $this->Polygon($p1,true); 
    6168     $this->PopColor(); 
    6169      
    6170     // Draw bounding rectangle 
    6171     $this->PushColor('darkgreen'); 
    6172     $this->Polygon($p,true); 
    6173     $this->PopColor(); 
    6174      
    6175     // Draw a cross at the anchor point 
    6176     $this->PushColor('red'); 
    6177     $this->Line($ox-15,$oy,$ox+15,$oy); 
    6178     $this->Line($ox,$oy-15,$ox,$oy+15); 
    6179     $this->PopColor(); 
    6180             } 
    6181   } 
    6182   else { 
    6183       // Format a text paragraph 
    6184       $fh=$this->GetFontHeight(); 
    6185  
    6186       // Line margin is 25% of font height 
    6187       $linemargin=round($fh*$ConstLineSpacing); 
    6188       $fh += $linemargin; 
    6189       $w=$this->GetTextWidth($txt); 
    6190  
    6191       $y -= $linemargin/2; 
    6192       $tmp = split("\n",$txt); 
    6193       $nl = count($tmp); 
    6194       $h = $nl * $fh; 
    6195  
    6196       if( $this->text_halign=="right")         
    6197     $x -= $dir==0 ? $w : $h; 
    6198       elseif( $this->text_halign=="center" ) { 
    6199     $x -= $dir==0 ? $w/2 : $h/2; 
    6200       } 
    6201        
    6202       if( $this->text_valign=="top" ) 
    6203     $y += $dir==0 ? $h : $w; 
    6204       elseif( $this->text_valign=="center" )         
    6205     $y += $dir==0 ? $h/2 : $w/2; 
    6206  
    6207       // Here comes a tricky bit.  
    6208       // Since we have to give the position for the string at the 
    6209       // baseline this means thaht text will move slightly up 
    6210       // and down depending on any of it's character descend below 
    6211       // the baseline, for example a 'g'. To adjust the Y-position 
    6212       // we therefore adjust the text with the baseline Y-offset 
    6213       // as used for the current font and size. This will keep the 
    6214       // baseline at a fixed positoned disregarding the actual  
    6215       // characters in the string.  
    6216       $standardbox = $this->GetTTFBBox('Gg',$dir); 
    6217       $yadj = $standardbox[1]; 
    6218       $xadj = $standardbox[0]; 
    6219       $aBoundingBox = array(); 
    6220       for($i=0; $i < $nl; ++$i) { 
    6221     $wl = $this->GetTextWidth($tmp[$i]); 
    6222     $bbox = $this->GetTTFBBox($tmp[$i],$dir); 
    6223     if( $paragraph_align=="left" ) { 
    6224         $xl = $x;  
    6225     } 
    6226     elseif( $paragraph_align=="right" ) { 
    6227         $xl = $x + ($w-$wl); 
    6228     } 
    6229     else { 
    6230         // Center 
    6231         $xl = $x + $w/2 - $wl/2 ; 
    6232     } 
    6233  
    6234     $xl -= $bbox[0]; 
    6235     $yl = $y - $yadj;  
    6236     $xl = $xl - $xadj;  
    6237     ImageTTFText ($this->img, $this->font_size, $dir,  
    6238             $xl, $yl-($h-$fh)+$fh*$i, 
    6239             $this->current_color,$this->font_file,$tmp[$i]);  
    6240  
    6241     if( $debug  ) { 
    6242         // Draw the bounding rectangle around each line 
    6243         $box=@ImageTTFBBox($this->font_size,$dir,$this->font_file,$tmp[$i]); 
    6244         $p = array(); 
    6245         for($j=0; $j < 4; ++$j) { 
    6246       $p[] = $bbox[$j*2]+$xl; 
    6247       $p[] = $bbox[$j*2+1]+$yl-($h-$fh)+$fh*$i; 
    6248         } 
    6249          
    6250         // Draw bounding rectangle 
    6251         $this->PushColor('darkgreen'); 
    6252         $this->Polygon($p,true); 
    6253         $this->PopColor(); 
    6254     } 
    6255       } 
    6256  
    6257       // Get the bounding box 
    6258       $bbox = $this->GetBBoxTTF($txt,$dir); 
    6259       for($j=0; $j < 4; ++$j) { 
    6260     $bbox[$j*2]+= round($x); 
    6261     $bbox[$j*2+1]+= round($y - ($h-$fh) - $yadj); 
    6262       } 
    6263       $aBoundingBox = $bbox; 
    6264  
    6265       if( $debug ) {   
    6266     // Draw a cross at the anchor point 
    6267     $this->PushColor('red'); 
    6268     $this->Line($ox-25,$oy,$ox+25,$oy); 
    6269     $this->Line($ox,$oy-25,$ox,$oy+25); 
    6270     $this->PopColor(); 
    6271       } 
    6272  
    6273   } 
    6274     } 
    6275    
    6276     function StrokeText($x,$y,$txt,$dir=0,$paragraph_align="left",$debug=false) { 
    6277  
    6278   $x = round($x); 
    6279   $y = round($y); 
    6280  
    6281   // Do special language encoding 
    6282   $txt = $this->langconv->Convert($txt,$this->font_family); 
    6283  
    6284   if( !is_numeric($dir) ) 
    6285       JpGraphError::RaiseL(25094);//(" Direction for text most be given as an angle between 0 and 90."); 
    6286        
    6287   if( $this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2+1) {  
    6288       $this->_StrokeBuiltinFont($x,$y,$txt,$dir,$paragraph_align,$boundingbox,$debug); 
    6289   } 
    6290   elseif($this->font_family >= _FIRST_FONT && $this->font_family <= _LAST_FONT)  { 
    6291       $this->_StrokeTTF($x,$y,$txt,$dir,$paragraph_align,$boundingbox,$debug); 
    6292   } 
    6293   else 
    6294       JpGraphError::RaiseL(25095);//(" Unknown font font family specification. "); 
    6295   return $boundingbox; 
    6296     } 
    6297    
    6298     function SetMargin($lm,$rm,$tm,$bm) { 
    6299   $this->left_margin=$lm; 
    6300   $this->right_margin=$rm; 
    6301   $this->top_margin=$tm; 
    6302   $this->bottom_margin=$bm; 
    6303   $this->plotwidth=$this->width - $this->left_margin-$this->right_margin ;  
    6304   $this->plotheight=$this->height - $this->top_margin-$this->bottom_margin ; 
    6305   if( $this->width  > 0 && $this->height > 0 ) { 
    6306       if( $this->plotwidth < 0  || $this->plotheight < 0 ) 
    6307     JpGraphError::raise("To small plot area. ($lm,$rm,$tm,$bm : $this->plotwidth x $this->plotheight). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins."); 
    6308   } 
    6309     } 
    6310  
    6311     function SetTransparent($color) { 
    6312   imagecolortransparent ($this->img,$this->rgb->allocate($color)); 
    6313     } 
    6314    
    6315     function SetColor($color,$aAlpha=0) { 
    6316   $this->current_color_name = $color; 
    6317   $this->current_color=$this->rgb->allocate($color,$aAlpha); 
    6318   if( $this->current_color == -1 ) { 
    6319       $tc=imagecolorstotal($this->img); 
    6320       JpGraphError::RaiseL(25096); 
    6321 //("Can't allocate any more colors. Image has already allocated maximum of <b>$tc colors</b>. This might happen if you have anti-aliasing turned on together with a background image or perhaps gradient fill since this requires many, many colors. Try to turn off anti-aliasing. If there is still a problem try downgrading the quality of the background image to use a smaller pallete to leave some entries for your graphs. You should try to limit the number of colors in your background image to 64. If there is still problem set the constant DEFINE(\"USE_APPROX_COLORS\",true); in jpgraph.php This will use approximative colors when the palette is full. Unfortunately there is not much JpGraph can do about this since the palette size is a limitation of current graphic format and what the underlying GD library suppports.");  
    6322   } 
    6323   return $this->current_color; 
    6324     } 
    6325    
    6326     function PushColor($color) { 
    6327   if( $color != "" ) { 
    6328       $this->colorstack[$this->colorstackidx]=$this->current_color_name; 
    6329       $this->colorstack[$this->colorstackidx+1]=$this->current_color; 
    6330       $this->colorstackidx+=2; 
    6331       $this->SetColor($color); 
    6332   } 
    6333   else { 
    6334       JpGraphError::RaiseL(25097);//("Color specified as empty string in PushColor()."); 
    6335   } 
    6336     } 
    6337    
    6338     function PopColor() { 
    6339   if($this->colorstackidx<1) 
    6340       JpGraphError::RaiseL(25098);//(" Negative Color stack index. Unmatched call to PopColor()"); 
    6341   $this->current_color=$this->colorstack[--$this->colorstackidx]; 
    6342   $this->current_color_name=$this->colorstack[--$this->colorstackidx]; 
    6343     } 
    6344    
    6345    
    6346     function SetLineWeight($weight) { <