<?php |
<?php |
/*======================================================================= |
/*======================================================================= |
// File: JPGRAPH_CANVAS.PHP |
// File: JPGRAPH_CANVAS.PHP |
// Description: Canvas drawing extension for JpGraph |
// Description: Canvas drawing extension for JpGraph |
// Created: 2001-01-08 |
// Created: 2001-01-08 |
// Ver: $Id: jpgraph_canvas.php 1106 2009-02-22 20:16:35Z ljp $ |
// Ver: $Id: jpgraph_canvas.php 1106 2009-02-22 20:16:35Z ljp $ |
// |
// |
// Copyright (c) Aditus Consulting. All rights reserved. |
// Copyright (c) Aditus Consulting. All rights reserved. |
//======================================================================== |
//======================================================================== |
*/ |
*/ |
|
|
//=================================================== |
//=================================================== |
// CLASS CanvasGraph |
// CLASS CanvasGraph |
// Description: Creates a simple canvas graph which |
// Description: Creates a simple canvas graph which |
// might be used together with the basic Image drawing |
// might be used together with the basic Image drawing |
// primitives. Useful to auickoly produce some arbitrary |
// primitives. Useful to auickoly produce some arbitrary |
// graphic which benefits from all the functionality in the |
// graphic which benefits from all the functionality in the |
// graph liek caching for example. |
// graph liek caching for example. |
//=================================================== |
//=================================================== |
class CanvasGraph extends Graph { |
class CanvasGraph extends Graph { |
//--------------- |
//--------------- |
// CONSTRUCTOR |
// CONSTRUCTOR |
function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) { |
function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) { |
parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline); |
parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline); |
} |
} |
|
|
//--------------- |
//--------------- |
// PUBLIC METHODS |
// PUBLIC METHODS |
|
|
function InitFrame() { |
function InitFrame() { |
$this->StrokePlotArea(); |
$this->StrokePlotArea(); |
} |
} |
|
|
// Method description |
// Method description |
function Stroke($aStrokeFileName="") { |
function Stroke($aStrokeFileName="") { |
if( $this->texts != null ) { |
if( $this->texts != null ) { |
for($i=0; $i < count($this->texts); ++$i) { |
for($i=0; $i < count($this->texts); ++$i) { |
$this->texts[$i]->Stroke($this->img); |
$this->texts[$i]->Stroke($this->img); |
} |
} |
} |
} |
if( $this->iTables !== null ) { |
if( $this->iTables !== null ) { |
for($i=0; $i < count($this->iTables); ++$i) { |
for($i=0; $i < count($this->iTables); ++$i) { |
$this->iTables[$i]->Stroke($this->img); |
$this->iTables[$i]->Stroke($this->img); |
} |
} |
} |
} |
$this->StrokeTitles(); |
$this->StrokeTitles(); |
|
|
// If the filename is the predefined value = '_csim_special_' |
// If the filename is the predefined value = '_csim_special_' |
// we assume that the call to stroke only needs to do enough |
// we assume that the call to stroke only needs to do enough |
// to correctly generate the CSIM maps. |
// to correctly generate the CSIM maps. |
// We use this variable to skip things we don't strictly need |
// We use this variable to skip things we don't strictly need |
// to do to generate the image map to improve performance |
// to do to generate the image map to improve performance |
// a best we can. Therefor you will see a lot of tests !$_csim in the |
// a best we can. Therefor you will see a lot of tests !$_csim in the |
// code below. |
// code below. |
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); |
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); |
|
|
// We need to know if we have stroked the plot in the |
// We need to know if we have stroked the plot in the |
// GetCSIMareas. Otherwise the CSIM hasn't been generated |
// GetCSIMareas. Otherwise the CSIM hasn't been generated |
// and in the case of GetCSIM called before stroke to generate |
// and in the case of GetCSIM called before stroke to generate |
// CSIM without storing an image to disk GetCSIM must call Stroke. |
// CSIM without storing an image to disk GetCSIM must call Stroke. |
$this->iHasStroked = true; |
$this->iHasStroked = true; |
|
|
if( !$_csim ) { |
if( !$_csim ) { |
|
|
// Should we do any final image transformation |
// Should we do any final image transformation |
if( $this->iImgTrans ) { |
if( $this->iImgTrans ) { |
if( !class_exists('ImgTrans') ) { |
if( !class_exists('ImgTrans') ) { |
require_once('jpgraph_imgtrans.php'); |
require_once('jpgraph_imgtrans.php'); |
} |
} |
|
|
$tform = new ImgTrans($this->img->img); |
$tform = new ImgTrans($this->img->img); |
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, |
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, |
$this->iImgTransDirection,$this->iImgTransHighQ, |
$this->iImgTransDirection,$this->iImgTransHighQ, |
$this->iImgTransMinSize,$this->iImgTransFillColor, |
$this->iImgTransMinSize,$this->iImgTransFillColor, |
$this->iImgTransBorder); |
$this->iImgTransBorder); |
} |
} |
|
|
|
|
// If the filename is given as the special _IMG_HANDLER |
// If the filename is given as the special _IMG_HANDLER |
// then the image handler is returned and the image is NOT |
// then the image handler is returned and the image is NOT |
// streamed back |
// streamed back |
if( $aStrokeFileName == _IMG_HANDLER ) { |
if( $aStrokeFileName == _IMG_HANDLER ) { |
return $this->img->img; |
return $this->img->img; |
} |
} |
else { |
else { |
// Finally stream the generated picture |
// Finally stream the generated picture |
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); |
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); |
return true; |
return true; |
} |
} |
} |
} |
} |
} |
} // Class |
} // Class |
|
|
/* EOF */ |
/* EOF */ |
?> |
?> |