source: trunk/client/modules/Elezioni/grafici/jpgraph_canvas.php@ 417

Last change on this file since 417 was 284, checked in by roby, 6 years ago
File size: 3.5 KB
RevLine 
[2]1<?php
2/*=======================================================================
[284]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 */
[2]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
[284]18// graph liek caching for example.
[2]19//===================================================
20class CanvasGraph extends Graph {
[284]21 //---------------
22 // CONSTRUCTOR
23 function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) {
24 parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline);
[2]25 }
26
[284]27 //---------------
28 // PUBLIC METHODS
[2]29
30 function InitFrame() {
[284]31 $this->StrokePlotArea();
[2]32 }
33
34 // Method description
35 function Stroke($aStrokeFileName="") {
[284]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();
[2]47
[284]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);
[2]56
[284]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;
[2]62
[284]63 if( !$_csim ) {
[2]64
[284]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 }
[2]70
[284]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 }
[2]91 }
92} // Class
93
94/* EOF */
[284]95?>
Note: See TracBrowser for help on using the repository browser.