- Timestamp:
- Apr 13, 2019, 8:05:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/modules/Elezioni/grafici/jpgraph_iconplot.php
r2 r265 1 1 <?php 2 2 //======================================================================= 3 // File: 4 // Description: PHP4 Graph Plotting library. Extension module.5 // Created: 6 // Ver: $Id: jpgraph_iconplot.php 781 2006-10-08 08:07:47Z ljp $3 // File: JPGRAPH_ICONPLOT.PHP 4 // Description: Extension module to add icons to plots 5 // Created: 2004-02-18 6 // Ver: $Id: jpgraph_iconplot.php 1404 2009-06-28 15:25:41Z ljp $ 7 7 // 8 // Copyright (c) A ditus Consulting. All rights reserved.8 // Copyright (c) Asial Corporation. All rights reserved. 9 9 //======================================================================== 10 10 … … 25 25 26 26 27 function IconPlot($aFile="",$aX=0,$aY=0,$aScale=1.0,$aMix=100) {28 29 30 31 32 33 34 35 27 function __construct($aFile="",$aX=0,$aY=0,$aScale=1.0,$aMix=100) { 28 $this->iFile = $aFile; 29 $this->iX=$aX; 30 $this->iY=$aY; 31 $this->iScale= $aScale; 32 if( $aMix < 0 || $aMix > 100 ) { 33 JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.'); 34 } 35 $this->iMix = $aMix ; 36 36 } 37 37 38 38 function SetCountryFlag($aFlag,$aX=0,$aY=0,$aScale=1.0,$aMix=100,$aStdSize=3) { 39 40 41 42 43 44 45 46 47 39 $this->iCountryFlag = $aFlag; 40 $this->iX=$aX; 41 $this->iY=$aY; 42 $this->iScale= $aScale; 43 if( $aMix < 0 || $aMix > 100 ) { 44 JpGraphError::RaiseL(8001);//'Mix value for icon must be between 0 and 100.'); 45 } 46 $this->iMix = $aMix; 47 $this->iCountryStdSize = $aStdSize; 48 48 } 49 49 50 50 function SetPos($aX,$aY) { 51 52 51 $this->iX=$aX; 52 $this->iY=$aY; 53 53 } 54 54 55 55 function CreateFromString($aStr) { 56 56 $this->iImgString = $aStr; 57 57 } 58 58 59 59 function SetScalePos($aX,$aY) { 60 61 60 $this->iScalePosX = $aX; 61 $this->iScalePosY = $aY; 62 62 } 63 63 64 64 function SetScale($aScale) { 65 65 $this->iScale = $aScale; 66 66 } 67 67 68 68 function SetMix($aMix) { 69 70 71 72 69 if( $aMix < 0 || $aMix > 100 ) { 70 JpGraphError::RaiseL(8001);//('Mix value for icon must be between 0 and 100.'); 71 } 72 $this->iMix = $aMix ; 73 73 } 74 74 75 75 function SetAnchor($aXAnchor='left',$aYAnchor='center') { 76 77 78 79 80 81 76 if( !in_array($aXAnchor,$this->iAnchors) || 77 !in_array($aYAnchor,$this->iAnchors) ) { 78 JpGraphError::RaiseL(8002);//("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'"); 79 } 80 $this->iHorAnchor=$aXAnchor; 81 $this->iVertAnchor=$aYAnchor; 82 82 } 83 83 84 84 function PreStrokeAdjust($aGraph) { 85 85 // Nothing to do ... 86 86 } 87 87 88 88 function DoLegend($aGraph) { 89 89 // Nothing to do ... 90 90 } 91 91 92 92 function Max() { 93 93 return array(false,false); 94 94 } 95 95 … … 105 105 106 106 function Min() { 107 107 return array(false,false); 108 108 } 109 109 110 110 function StrokeMargin(&$aImg) { 111 111 return true; 112 112 } 113 113 114 function Stroke($aImg,$axscale ,$ayscale) {115 114 function Stroke($aImg,$axscale=null,$ayscale=null) { 115 $this->StrokeWithScale($aImg,$axscale,$ayscale); 116 116 } 117 117 118 118 function StrokeWithScale($aImg,$axscale,$ayscale) { 119 if( $this->iScalePosX=== null ||120 $this->iScalePosY=== null ) {121 122 123 124 125 126 127 119 if( $this->iScalePosX === null || $this->iScalePosY === null || 120 $axscale === null || $ayscale === null ) { 121 $this->_Stroke($aImg); 122 } 123 else { 124 $this->_Stroke($aImg, 125 round($axscale->Translate($this->iScalePosX)), 126 round($ayscale->Translate($this->iScalePosY))); 127 } 128 128 } 129 129 130 130 function GetWidthHeight() { 131 132 131 $dummy=0; 132 return $this->_Stroke($dummy,null,null,true); 133 133 } 134 134 135 135 function _Stroke($aImg,$x=null,$y=null,$aReturnWidthHeight=false) { 136 137 JpGraphError::RaiseL(8003);//('It is not possible to specify both an image file and a country flag for the same icon.'); 138 139 140 141 142 143 144 136 if( $this->iFile != '' && $this->iCountryFlag != '' ) { 137 JpGraphError::RaiseL(8003);//('It is not possible to specify both an image file and a country flag for the same icon.'); 138 } 139 if( $this->iFile != '' ) { 140 $gdimg = Graph::LoadBkgImage('',$this->iFile); 141 } 142 elseif( $this->iImgString != '') { 143 $gdimg = Image::CreateFromString($this->iImgString); 144 } 145 145 146 147 148 149 150 151 152 153 146 else { 147 if( ! class_exists('FlagImages',false) ) { 148 JpGraphError::RaiseL(8004);//('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.'); 149 } 150 $fobj = new FlagImages($this->iCountryStdSize); 151 $dummy=''; 152 $gdimg = $fobj->GetImgByName($this->iCountryFlag,$dummy); 153 } 154 154 155 $iconw = imagesx($gdimg); 156 $iconh = imagesy($gdimg); 157 158 if( $aReturnWidthHeight ) { 159 return array(round($iconw*$this->iScale),round($iconh*$this->iScale)); 160 } 155 $iconw = imagesx($gdimg); 156 $iconh = imagesy($gdimg); 161 157 162 if( $x !== null && $y !== null ) { 163 $this->iX = $x; $this->iY = $y; 164 } 165 if( $this->iX >= 0 && $this->iX <= 1.0 ) { 166 $w = imagesx($aImg->img); 167 $this->iX = round($w*$this->iX); 168 } 169 if( $this->iY >= 0 && $this->iY <= 1.0 ) { 170 $h = imagesy($aImg->img); 171 $this->iY = round($h*$this->iY); 172 } 158 if( $aReturnWidthHeight ) { 159 return array(round($iconw*$this->iScale),round($iconh*$this->iScale)); 160 } 173 161 174 if( $this->iHorAnchor == 'center' ) 175 $this->iX -= round($iconw*$this->iScale/2); 176 if( $this->iHorAnchor == 'right' ) 177 $this->iX -= round($iconw*$this->iScale); 178 if( $this->iVertAnchor == 'center' ) 179 $this->iY -= round($iconh*$this->iScale/2); 180 if( $this->iVertAnchor == 'bottom' ) 181 $this->iY -= round($iconh*$this->iScale); 162 if( $x !== null && $y !== null ) { 163 $this->iX = $x; $this->iY = $y; 164 } 165 if( $this->iX >= 0 && $this->iX <= 1.0 ) { 166 $w = imagesx($aImg->img); 167 $this->iX = round($w*$this->iX); 168 } 169 if( $this->iY >= 0 && $this->iY <= 1.0 ) { 170 $h = imagesy($aImg->img); 171 $this->iY = round($h*$this->iY); 172 } 182 173 183 $aImg->CopyMerge($gdimg,$this->iX,$this->iY,0,0, 184 round($iconw*$this->iScale),round($iconh*$this->iScale), 185 $iconw,$iconh, 186 $this->iMix); 174 if( $this->iHorAnchor == 'center' ) 175 $this->iX -= round($iconw*$this->iScale/2); 176 if( $this->iHorAnchor == 'right' ) 177 $this->iX -= round($iconw*$this->iScale); 178 if( $this->iVertAnchor == 'center' ) 179 $this->iY -= round($iconh*$this->iScale/2); 180 if( $this->iVertAnchor == 'bottom' ) 181 $this->iY -= round($iconh*$this->iScale); 182 183 $aImg->CopyMerge($gdimg,$this->iX,$this->iY,0,0, 184 round($iconw*$this->iScale),round($iconh*$this->iScale), 185 $iconw,$iconh, 186 $this->iMix); 187 187 } 188 188 }
Note:
See TracChangeset
for help on using the changeset viewer.