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