|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JPGraph - Community Edition |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Graph; |
|
8
|
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Image; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* File: JPGRAPH_CANVAS.PHP |
|
13
|
|
|
* Description: Canvas drawing extension for JpGraph |
|
14
|
|
|
* Created: 2001-01-08 |
|
15
|
|
|
* Ver: $Id: jpgraph_canvas.php 1923 2010-01-11 13:48:49Z ljp $. |
|
16
|
|
|
* |
|
17
|
|
|
* Copyright (c) Asial Corporation. All rights reserved. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @class CanvasGraph |
|
22
|
|
|
* Description: Creates a simple canvas graph which |
|
23
|
|
|
* might be used together with the basic Image drawing |
|
24
|
|
|
* primitives. Useful to auickoly produce some arbitrary |
|
25
|
|
|
* graphic which benefits from all the functionality in the |
|
26
|
|
|
* graph liek caching for example. |
|
27
|
|
|
*/ |
|
28
|
|
|
final class CanvasGraph extends Graph |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var \Amenadiel\JpGraph\Graph\Scale\CanvasScale|null |
|
32
|
|
|
*/ |
|
33
|
|
|
public $scale; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param mixed $aWidth |
|
37
|
|
|
* @param mixed $aHeight |
|
38
|
|
|
* @param mixed $aCachedName |
|
39
|
|
|
* @param mixed $timeout |
|
40
|
|
|
* @param mixed $inline |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct($aWidth = 300, $aHeight = 200, $aCachedName = '', $timeout = 0, $inline = 1) |
|
43
|
|
|
{ |
|
44
|
|
|
parent::__construct($aWidth, $aHeight, $aCachedName, $timeout, $inline); |
|
45
|
|
|
} |
|
46
|
|
|
public function getScale() { |
|
47
|
|
|
return $this->scale; |
|
48
|
|
|
} |
|
49
|
|
|
/** |
|
50
|
|
|
* PUBLIC METHODS. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function InitFrame(): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->StrokePlotArea(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
// Method description |
|
58
|
|
|
/** |
|
59
|
|
|
* @return mixed|bool|void |
|
60
|
|
|
*/ |
|
61
|
|
|
public function Stroke($aStrokeFileName = '') |
|
62
|
|
|
{ |
|
63
|
|
|
if (null !== $this->texts) { |
|
64
|
|
|
for ($i = 0; Configs::safe_count($this->texts) > $i; ++$i) { |
|
65
|
|
|
$this->texts[$i]->Stroke($this->img); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (null !== $this->iTables) { |
|
70
|
|
|
for ($i = 0; Configs::safe_count($this->iTables) > $i; ++$i) { |
|
71
|
|
|
$this->iTables[$i]->Stroke($this->img); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
$this->StrokeTitles(); |
|
75
|
|
|
|
|
76
|
|
|
// If the filename is the predefined value = '_csim_special_' |
|
77
|
|
|
// we assume that the call to stroke only needs to do enough |
|
78
|
|
|
// to correctly generate the CSIM maps. |
|
79
|
|
|
// We use this variable to skip things we don't strictly need |
|
80
|
|
|
// to do to generate the image map to improve performance |
|
81
|
|
|
// a best we can. Therefor you will see a lot of tests !$_csim in the |
|
82
|
|
|
// code below. |
|
83
|
|
|
$_csim = (Configs::getConfig('_CSIM_SPECIALFILE') === $aStrokeFileName); |
|
84
|
|
|
|
|
85
|
|
|
// We need to know if we have stroked the plot in the |
|
86
|
|
|
// GetCSIMareas. Otherwise the CSIM hasn't been generated |
|
87
|
|
|
// and in the case of GetCSIM called before stroke to generate |
|
88
|
|
|
// CSIM without storing an image to disk GetCSIM must call Stroke. |
|
89
|
|
|
$this->iHasStroked = true; |
|
90
|
|
|
|
|
91
|
|
|
if (!$_csim) { |
|
92
|
|
|
// Should we do any final image transformation |
|
93
|
|
|
if ($this->iImgTrans) { |
|
94
|
|
|
$imgTrans = new Image\ImgTrans($this->img->img); |
|
95
|
|
|
$this->img->img = $imgTrans->Skew3D( |
|
96
|
|
|
$this->iImgTransHorizon, |
|
97
|
|
|
$this->iImgTransSkewDist, |
|
98
|
|
|
$this->iImgTransDirection, |
|
99
|
|
|
$this->iImgTransHighQ, |
|
100
|
|
|
$this->iImgTransMinSize, |
|
101
|
|
|
$this->iImgTransFillColor, |
|
102
|
|
|
$this->iImgTransBorder |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
// If the filename is given as the special Configs::getConfig('_IMG_HANDLER') |
|
107
|
|
|
// then the image handler is returned and the image is NOT |
|
108
|
|
|
// streamed back |
|
109
|
|
|
if (Configs::getConfig('_IMG_HANDLER') === $aStrokeFileName) { |
|
110
|
|
|
return $this->img->img; |
|
111
|
|
|
} |
|
112
|
|
|
// Finally stream the generated picture |
|
113
|
|
|
$this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); |
|
114
|
|
|
|
|
115
|
|
|
return true; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function SetScale($aAxisType = 'canvas', $xmin = 0, $xmax = 10, $ymin = 0, $ymax = 10): void |
|
120
|
|
|
{ |
|
121
|
|
|
$this->scale = new Scale\CanvasScale($this, $xmin, $xmax, $ymin, $ymax); |
|
122
|
|
|
$this->scale->Set($xmin, $xmax, $ymin, $ymax); |
|
123
|
|
|
} |
|
124
|
|
|
} // @class |
|
125
|
|
|
|
|
126
|
|
|
/* EOF */ |
|
127
|
|
|
|