1<?php
2
3/**
4 *    pChart - a PHP class to build charts!
5 *
6 *    http://pchart.sourceforge.net
7 *
8 *    This program is free software: you can redistribute it and/or modify
9 *    it under the terms of the GNU General Public License as published by
10 *    the Free Software Foundation, either version 1,2,3 of the License, or
11 *    (at your option) any later version.
12 *
13 *    This program is distributed in the hope that it will be useful,
14 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *    GNU General Public License for more details.
17 *
18 *    You should have received a copy of the GNU General Public License
19 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22class BackgroundStyle {
23    /**
24     * @todo I suspect using stripe and gradient are mutually
25     * exclusive, so it would be possible to simplify this interface
26     * somewhat.
27     */
28    public function __construct(Color $backgroundColor, $stripe = false, Color $gradientStartColor = null, $gradientDecay = null, $borderWidth = 1, $borderDotSize = 0) {
29        $this->backgroundColor    = $backgroundColor;
30        $this->stripe             = $stripe;
31        $this->gradientStartColor = $gradientStartColor;
32        $this->gradientDecay      = $gradientDecay;
33        $this->borderWidth        = $borderWidth;
34        $this->borderDotSize      = $borderDotSize;
35    }
36
37    public function getBackgroundColor() {
38        return $this->backgroundColor;
39    }
40
41    public function useStripe() {
42        return $this->stripe;
43    }
44
45    public function useGradient() {
46        return $this->gradientStartColor != null;
47    }
48
49    public function getGradientStartColor() {
50        if($this->gradientStartColor == null) {
51            throw new Exception("Requested gradient start color, but gradient is not enabled");
52        }
53
54        return $this->gradientStartColor;
55    }
56
57    public function getGradientDecay() {
58        if($this->gradientStartColor == null) {
59            throw new Exception("Requested gradient decay, but gradient is not enabled");
60        }
61
62        return $this->gradientDecay;
63    }
64
65    public function getBorderWidth() {
66        return $this->borderWidth;
67    }
68
69    public function getBorderDotSize() {
70        return $this->borderDotSize;
71    }
72
73    private $backgroundColor;
74
75    private $stripe;
76
77    private $gradientStartColor;
78
79    private $gradientDecay;
80
81    private $borderWidth;
82
83    private $borderDotSize;
84}