|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JPGraph v4.0.3 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Graph; |
|
8
|
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Util; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @class RectPattern |
|
13
|
|
|
* // Base class for pattern hierarchi that is used to display patterned |
|
14
|
|
|
* // bands on the graph. Any subclass that doesn't override Stroke() |
|
15
|
|
|
* // must at least implement method DoPattern($aImg) which is responsible |
|
16
|
|
|
* // for drawing the pattern onto the graph. |
|
17
|
|
|
*/ |
|
18
|
|
|
class RectPattern |
|
19
|
|
|
{ |
|
20
|
|
|
protected $color; |
|
21
|
|
|
protected $weight; |
|
22
|
|
|
protected $rect; |
|
23
|
|
|
protected $doframe = true; |
|
24
|
|
|
protected $linespacing; // Line spacing in pixels |
|
25
|
|
|
protected $iBackgroundColor = -1; // Default is no background fill |
|
26
|
|
|
|
|
27
|
|
|
public function __construct($aColor, $aWeight = 1) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->color = $aColor; |
|
30
|
|
|
$this->weight = $aWeight; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function SetBackground($aBackgroundColor) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->iBackgroundColor = $aBackgroundColor; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function SetPos($aRect) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->rect = $aRect; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function ShowFrame($aShow = true) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->doframe = $aShow; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function SetDensity($aDens) |
|
49
|
|
|
{ |
|
50
|
|
|
if ($aDens < 1 || $aDens > 100) { |
|
51
|
|
|
Util\JpGraphError::RaiseL(16001, $aDens); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
//(" Desity for pattern must be between 1 and 100. (You tried $aDens)"); |
|
55
|
|
|
// 1% corresponds to linespacing=50 |
|
56
|
|
|
// 100 % corresponds to linespacing 1 |
|
57
|
|
|
$this->linespacing = floor(((100 - $aDens) / 100.0) * 50) + 1; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function Stroke($aImg) |
|
61
|
|
|
{ |
|
62
|
|
|
if ($this->rect == null) { |
|
63
|
|
|
Util\JpGraphError::RaiseL(16002); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
//(" No positions specified for pattern."); |
|
67
|
|
|
|
|
68
|
|
|
if (!(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor == -1)) { |
|
69
|
|
|
$aImg->SetColor($this->iBackgroundColor); |
|
70
|
|
|
$aImg->FilledRectangle($this->rect->x, $this->rect->y, $this->rect->xe, $this->rect->ye); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$aImg->SetColor($this->color); |
|
74
|
|
|
$aImg->SetLineWeight($this->weight); |
|
75
|
|
|
|
|
76
|
|
|
// Virtual function implemented by subclass |
|
77
|
|
|
$this->DoPattern($aImg); |
|
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
// Frame around the pattern area |
|
80
|
|
|
if ($this->doframe) { |
|
81
|
|
|
$aImg->Rectangle($this->rect->x, $this->rect->y, $this->rect->xe, $this->rect->ye); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|