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