Ignore:
Timestamp:
Apr 13, 2019, 8:05:15 PM (5 years ago)
Author:
roby
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/grafici/jpgraph_canvas.php

    r2 r265  
    11<?php
    22/*=======================================================================
    3 // File:        JPGRAPH_CANVAS.PHP
    4 // Description: Canvas drawing extension for JpGraph
    5 // Created:     2001-01-08
    6 // Ver:         $Id: jpgraph_canvas.php 781 2006-10-08 08:07:47Z ljp $
    7 //
    8 // Copyright (c) Aditus Consulting. All rights reserved.
    9 //========================================================================
    10 */
     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 */
    1111
    1212//===================================================
     
    1616// primitives. Useful to auickoly produce some arbitrary
    1717// graphic which benefits from all the functionality in the
    18 // graph liek caching for example. 
     18// graph liek caching for example.
    1919//===================================================
    2020class CanvasGraph extends Graph {
    21 //---------------
    22 // CONSTRUCTOR
    23     function CanvasGraph($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) {
    24         $this->Graph($aWidth,$aHeight,$aCachedName,$timeout,$inline);
     21    //---------------
     22    // CONSTRUCTOR
     23    function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) {
     24        parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline);
    2525    }
    2626
    27 //---------------
    28 // PUBLIC METHODS       
     27    //---------------
     28    // PUBLIC METHODS
    2929
    3030    function InitFrame() {
    31         $this->StrokePlotArea();
     31        $this->StrokePlotArea();
    3232    }
    3333
    3434    // Method description
    3535    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();
     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();
    4747
    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);
     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);
    5656
    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;
     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;
    6262
    63         if( !$_csim ) {
     63        if( !$_csim ) {
    6464
    65             // Should we do any final image transformation
    66             if( $this->iImgTrans ) {
    67                 if( !class_exists('ImgTrans') ) {
    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        
     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                }
    7870
    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         }
     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        }
    9191    }
    9292} // Class
Note: See TracChangeset for help on using the changeset viewer.