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 22require_once(dirname(__FILE__).'/Color.php'); 23 24class BackgroundStyle { 25 /** 26 * @todo I suspect using stripe and gradient are mutually 27 * exclusive, so it would be possible to simplify this interface 28 * somewhat. 29 */ 30 public function __construct(Color $backgroundColor, $stripe = false, Color $gradientStartColor = null, $gradientDecay = null, $borderWidth = 1, $borderDotSize = 0) { 31 $this->backgroundColor = $backgroundColor; 32 $this->stripe = $stripe; 33 $this->gradientStartColor = $gradientStartColor; 34 $this->gradientDecay = $gradientDecay; 35 $this->borderWidth = $borderWidth; 36 $this->borderDotSize = $borderDotSize; 37 } 38 39 public function getBackgroundColor() { 40 return $this->backgroundColor; 41 } 42 43 public function useStripe() { 44 return $this->stripe; 45 } 46 47 public function useGradient() { 48 return $this->gradientStartColor != null; 49 } 50 51 public function getGradientStartColor() { 52 if ($this->gradientStartColor == null) { 53 throw new Exception("Requested gradient start color, but gradient is not enabled"); 54 } 55 56 return $this->gradientStartColor; 57 } 58 59 public function getGradientDecay() { 60 if ($this->gradientStartColor == null) { 61 throw new Exception("Requested gradient decay, but gradient is not enabled"); 62 } 63 64 return $this->gradientDecay; 65 } 66 67 public function getBorderWidth() { 68 return $this->borderWidth; 69 } 70 71 public function getBorderDotSize() { 72 return $this->borderDotSize; 73 } 74 75 private $backgroundColor; 76 77 private $stripe; 78 79 private $gradientStartColor; 80 81 private $gradientDecay; 82 83 private $borderWidth; 84 85 private $borderDotSize; 86}