1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * JPGraph v4.0.3 |
||||
5 | */ |
||||
6 | |||||
7 | namespace Amenadiel\JpGraph\Plot; |
||||
8 | |||||
9 | use Amenadiel\JpGraph\Graph; |
||||
10 | use Amenadiel\JpGraph\Image; |
||||
11 | use Amenadiel\JpGraph\Util; |
||||
12 | |||||
13 | /** |
||||
14 | * File: JPGRAPH_ICONPLOT.PHP |
||||
15 | * // Description: Extension module to add icons to plots |
||||
16 | * // Created: 2004-02-18 |
||||
17 | * // Ver: $Id: jpgraph_iconplot.php 1404 2009-06-28 15:25:41Z ljp $ |
||||
18 | * // |
||||
19 | * // Copyright (c) Asial Corporation. All rights reserved. |
||||
20 | */ |
||||
21 | |||||
22 | /** |
||||
23 | * @class IconPlot |
||||
24 | * // Description: Make it possible to add a (small) image |
||||
25 | * // to the graph |
||||
26 | */ |
||||
27 | class IconPlot |
||||
28 | { |
||||
29 | public $iX = 0; |
||||
30 | public $iY = 0; |
||||
31 | public $iScale = 1.0; |
||||
32 | public $iMix = 100; |
||||
33 | private $iHorAnchor = 'left'; |
||||
34 | private $iVertAnchor = 'top'; |
||||
35 | private $iFile = ''; |
||||
36 | private $iAnchors = ['left', 'right', 'top', 'bottom', 'center']; |
||||
37 | private $iCountryFlag = ''; |
||||
38 | private $iCountryStdSize = 3; |
||||
39 | private $iScalePosY; |
||||
40 | private $iScalePosX; |
||||
41 | private $iImgString = ''; |
||||
42 | |||||
43 | public function __construct($aFile = '', $aX = 0, $aY = 0, $aScale = 1.0, $aMix = 100) |
||||
44 | { |
||||
45 | $this->iFile = $aFile; |
||||
46 | $this->iX = $aX; |
||||
47 | $this->iY = $aY; |
||||
48 | $this->iScale = $aScale; |
||||
49 | if ($aMix < 0 || $aMix > 100) { |
||||
50 | Util\JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.'); |
||||
51 | } |
||||
52 | $this->iMix = $aMix; |
||||
53 | } |
||||
54 | |||||
55 | public function SetCountryFlag($aFlag, $aX = 0, $aY = 0, $aScale = 1.0, $aMix = 100, $aStdSize = 3) |
||||
56 | { |
||||
57 | $this->iCountryFlag = $aFlag; |
||||
58 | $this->iX = $aX; |
||||
59 | $this->iY = $aY; |
||||
60 | $this->iScale = $aScale; |
||||
61 | if ($aMix < 0 || $aMix > 100) { |
||||
62 | Util\JpGraphError::RaiseL(8001); //'Mix value for icon must be between 0 and 100.'); |
||||
63 | } |
||||
64 | $this->iMix = $aMix; |
||||
65 | $this->iCountryStdSize = $aStdSize; |
||||
66 | } |
||||
67 | |||||
68 | public function SetPos($aX, $aY) |
||||
69 | { |
||||
70 | $this->iX = $aX; |
||||
71 | $this->iY = $aY; |
||||
72 | } |
||||
73 | |||||
74 | public function CreateFromString($aStr) |
||||
75 | { |
||||
76 | $this->iImgString = $aStr; |
||||
77 | } |
||||
78 | |||||
79 | public function SetScalePos($aX, $aY) |
||||
80 | { |
||||
81 | $this->iScalePosX = $aX; |
||||
82 | $this->iScalePosY = $aY; |
||||
83 | } |
||||
84 | |||||
85 | public function SetScale($aScale) |
||||
86 | { |
||||
87 | $this->iScale = $aScale; |
||||
88 | } |
||||
89 | |||||
90 | public function SetMix($aMix) |
||||
91 | { |
||||
92 | if ($aMix < 0 || $aMix > 100) { |
||||
93 | Util\JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.'); |
||||
94 | } |
||||
95 | $this->iMix = $aMix; |
||||
96 | } |
||||
97 | |||||
98 | public function SetAnchor($aXAnchor = 'left', $aYAnchor = 'center') |
||||
99 | { |
||||
100 | if (!in_array($aXAnchor, $this->iAnchors, true) || |
||||
101 | !in_array($aYAnchor, $this->iAnchors, true)) { |
||||
102 | Util\JpGraphError::RaiseL(8002); //("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'"); |
||||
103 | } |
||||
104 | $this->iHorAnchor = $aXAnchor; |
||||
105 | $this->iVertAnchor = $aYAnchor; |
||||
106 | } |
||||
107 | |||||
108 | public function PreStrokeAdjust($aGraph) |
||||
0 ignored issues
–
show
|
|||||
109 | { |
||||
110 | // Nothing to do ... |
||||
111 | } |
||||
112 | |||||
113 | public function DoLegend($aGraph) |
||||
0 ignored issues
–
show
The parameter
$aGraph is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
114 | { |
||||
115 | // Nothing to do ... |
||||
116 | } |
||||
117 | |||||
118 | public function Max() |
||||
119 | { |
||||
120 | return [false, false]; |
||||
121 | } |
||||
122 | |||||
123 | // The next four function are framework function tht gets called |
||||
124 | // from Gantt and is not menaiungfull in the context of Icons but |
||||
125 | // they must be implemented to avoid errors. |
||||
126 | public function GetMaxDate() |
||||
127 | { |
||||
128 | return false; |
||||
129 | } |
||||
130 | |||||
131 | public function GetMinDate() |
||||
132 | { |
||||
133 | return false; |
||||
134 | } |
||||
135 | |||||
136 | public function GetLineNbr() |
||||
137 | { |
||||
138 | return 0; |
||||
139 | } |
||||
140 | |||||
141 | public function GetAbsHeight() |
||||
142 | { |
||||
143 | return 0; |
||||
144 | } |
||||
145 | |||||
146 | public function Min() |
||||
147 | { |
||||
148 | return [false, false]; |
||||
149 | } |
||||
150 | |||||
151 | public function StrokeMargin(&$aImg) |
||||
0 ignored issues
–
show
The parameter
$aImg is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
152 | { |
||||
153 | return true; |
||||
154 | } |
||||
155 | |||||
156 | public function Stroke($aImg, $axscale = null, $ayscale = null) |
||||
157 | { |
||||
158 | $this->StrokeWithScale($aImg, $axscale, $ayscale); |
||||
159 | } |
||||
160 | |||||
161 | public function StrokeWithScale($aImg, $axscale, $ayscale) |
||||
162 | { |
||||
163 | if ($this->iScalePosX === null || $this->iScalePosY === null || |
||||
164 | $axscale === null || $ayscale === null) { |
||||
165 | $this->_Stroke($aImg); |
||||
166 | } else { |
||||
167 | $this->_Stroke( |
||||
168 | $aImg, |
||||
169 | round($axscale->Translate($this->iScalePosX)), |
||||
170 | round($ayscale->Translate($this->iScalePosY)) |
||||
171 | ); |
||||
172 | } |
||||
173 | } |
||||
174 | |||||
175 | public function GetWidthHeight() |
||||
176 | { |
||||
177 | $dummy = 0; |
||||
178 | |||||
179 | return $this->_Stroke($dummy, null, null, true); |
||||
180 | } |
||||
181 | |||||
182 | public function _Stroke($aImg, $x = null, $y = null, $aReturnWidthHeight = false) |
||||
183 | { |
||||
184 | if ($this->iFile != '' && $this->iCountryFlag != '') { |
||||
185 | Util\JpGraphError::RaiseL(8003); //('It is not possible to specify both an image file and a country flag for the same icon.'); |
||||
186 | } |
||||
187 | if ($this->iFile != '') { |
||||
188 | $gdimg = Graph\Graph::LoadBkgImage('', $this->iFile); |
||||
189 | } elseif ($this->iImgString != '') { |
||||
190 | $gdimg = Image\Image::CreateFromString($this->iImgString); |
||||
191 | } else { |
||||
192 | $fobj = new Image\FlagImages($this->iCountryStdSize); |
||||
193 | $dummy = ''; |
||||
194 | $gdimg = $fobj->GetImgByName($this->iCountryFlag, $dummy); |
||||
195 | } |
||||
196 | |||||
197 | $iconw = imagesx($gdimg); |
||||
198 | $iconh = imagesy($gdimg); |
||||
199 | |||||
200 | if ($aReturnWidthHeight) { |
||||
201 | return [round($iconw * $this->iScale), round($iconh * $this->iScale)]; |
||||
202 | } |
||||
203 | |||||
204 | if ($x !== null && $y !== null) { |
||||
205 | $this->iX = $x; |
||||
206 | $this->iY = $y; |
||||
207 | } |
||||
208 | if ($this->iX >= 0 && $this->iX <= 1.0) { |
||||
209 | $w = imagesx($aImg->img); |
||||
210 | $this->iX = round($w * $this->iX); |
||||
211 | } |
||||
212 | if ($this->iY >= 0 && $this->iY <= 1.0) { |
||||
213 | $h = imagesy($aImg->img); |
||||
214 | $this->iY = round($h * $this->iY); |
||||
215 | } |
||||
216 | |||||
217 | if ($this->iHorAnchor == 'center') { |
||||
218 | $this->iX -= round($iconw * $this->iScale / 2); |
||||
219 | } |
||||
220 | |||||
221 | if ($this->iHorAnchor == 'right') { |
||||
222 | $this->iX -= round($iconw * $this->iScale); |
||||
223 | } |
||||
224 | |||||
225 | if ($this->iVertAnchor == 'center') { |
||||
226 | $this->iY -= round($iconh * $this->iScale / 2); |
||||
227 | } |
||||
228 | |||||
229 | if ($this->iVertAnchor == 'bottom') { |
||||
230 | $this->iY -= round($iconh * $this->iScale); |
||||
231 | } |
||||
232 | |||||
233 | $aImg->CopyMerge( |
||||
234 | $gdimg, |
||||
235 | $this->iX, |
||||
236 | $this->iY, |
||||
237 | 0, |
||||
238 | 0, |
||||
239 | round($iconw * $this->iScale), |
||||
240 | round($iconh * $this->iScale), |
||||
241 | $iconw, |
||||
242 | $iconh, |
||||
243 | $this->iMix |
||||
244 | ); |
||||
245 | } |
||||
246 | } |
||||
247 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.