1<?php
2/**
3 * PHPExcel
4 *
5 * Copyright (c) 2006 - 2014 PHPExcel
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20 *
21 * @category   PHPExcel
22 * @package    PHPExcel_Worksheet_Drawing
23 * @copyright  Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
25 * @version    ##VERSION##, ##DATE##
26 */
27
28
29/**
30 * PHPExcel_Worksheet_Drawing_Shadow
31 *
32 * @category   PHPExcel
33 * @package    PHPExcel_Worksheet_Drawing
34 * @copyright  Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 */
36class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
37{
38	/* Shadow alignment */
39	const SHADOW_BOTTOM							= 'b';
40	const SHADOW_BOTTOM_LEFT					= 'bl';
41	const SHADOW_BOTTOM_RIGHT					= 'br';
42	const SHADOW_CENTER							= 'ctr';
43	const SHADOW_LEFT							= 'l';
44	const SHADOW_TOP							= 't';
45	const SHADOW_TOP_LEFT						= 'tl';
46	const SHADOW_TOP_RIGHT						= 'tr';
47
48	/**
49	 * Visible
50	 *
51	 * @var boolean
52	 */
53	private $_visible;
54
55	/**
56	 * Blur radius
57	 *
58	 * Defaults to 6
59	 *
60	 * @var int
61	 */
62	private $_blurRadius;
63
64	/**
65	 * Shadow distance
66	 *
67	 * Defaults to 2
68	 *
69	 * @var int
70	 */
71	private $_distance;
72
73	/**
74	 * Shadow direction (in degrees)
75	 *
76	 * @var int
77	 */
78	private $_direction;
79
80	/**
81	 * Shadow alignment
82	 *
83	 * @var int
84	 */
85	private $_alignment;
86
87	/**
88	 * Color
89	 *
90	 * @var PHPExcel_Style_Color
91	 */
92	private $_color;
93
94	/**
95	 * Alpha
96	 *
97	 * @var int
98	 */
99	private $_alpha;
100
101    /**
102     * Create a new PHPExcel_Worksheet_Drawing_Shadow
103     */
104    public function __construct()
105    {
106    	// Initialise values
107    	$this->_visible				= false;
108    	$this->_blurRadius			= 6;
109    	$this->_distance			= 2;
110    	$this->_direction			= 0;
111    	$this->_alignment			= PHPExcel_Worksheet_Drawing_Shadow::SHADOW_BOTTOM_RIGHT;
112    	$this->_color				= new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
113    	$this->_alpha				= 50;
114    }
115
116    /**
117     * Get Visible
118     *
119     * @return boolean
120     */
121    public function getVisible() {
122    	return $this->_visible;
123    }
124
125    /**
126     * Set Visible
127     *
128     * @param boolean $pValue
129     * @return PHPExcel_Worksheet_Drawing_Shadow
130     */
131    public function setVisible($pValue = false) {
132    	$this->_visible = $pValue;
133    	return $this;
134    }
135
136    /**
137     * Get Blur radius
138     *
139     * @return int
140     */
141    public function getBlurRadius() {
142    	return $this->_blurRadius;
143    }
144
145    /**
146     * Set Blur radius
147     *
148     * @param int $pValue
149     * @return PHPExcel_Worksheet_Drawing_Shadow
150     */
151    public function setBlurRadius($pValue = 6) {
152    	$this->_blurRadius = $pValue;
153    	return $this;
154    }
155
156    /**
157     * Get Shadow distance
158     *
159     * @return int
160     */
161    public function getDistance() {
162    	return $this->_distance;
163    }
164
165    /**
166     * Set Shadow distance
167     *
168     * @param int $pValue
169     * @return PHPExcel_Worksheet_Drawing_Shadow
170     */
171    public function setDistance($pValue = 2) {
172    	$this->_distance = $pValue;
173    	return $this;
174    }
175
176    /**
177     * Get Shadow direction (in degrees)
178     *
179     * @return int
180     */
181    public function getDirection() {
182    	return $this->_direction;
183    }
184
185    /**
186     * Set Shadow direction (in degrees)
187     *
188     * @param int $pValue
189     * @return PHPExcel_Worksheet_Drawing_Shadow
190     */
191    public function setDirection($pValue = 0) {
192    	$this->_direction = $pValue;
193    	return $this;
194    }
195
196   /**
197     * Get Shadow alignment
198     *
199     * @return int
200     */
201    public function getAlignment() {
202    	return $this->_alignment;
203    }
204
205    /**
206     * Set Shadow alignment
207     *
208     * @param int $pValue
209     * @return PHPExcel_Worksheet_Drawing_Shadow
210     */
211    public function setAlignment($pValue = 0) {
212    	$this->_alignment = $pValue;
213    	return $this;
214    }
215
216   /**
217     * Get Color
218     *
219     * @return PHPExcel_Style_Color
220     */
221    public function getColor() {
222    	return $this->_color;
223    }
224
225    /**
226     * Set Color
227     *
228     * @param 	PHPExcel_Style_Color $pValue
229     * @throws 	PHPExcel_Exception
230     * @return PHPExcel_Worksheet_Drawing_Shadow
231     */
232    public function setColor(PHPExcel_Style_Color $pValue = null) {
233   		$this->_color = $pValue;
234   		return $this;
235    }
236
237   /**
238     * Get Alpha
239     *
240     * @return int
241     */
242    public function getAlpha() {
243    	return $this->_alpha;
244    }
245
246    /**
247     * Set Alpha
248     *
249     * @param int $pValue
250     * @return PHPExcel_Worksheet_Drawing_Shadow
251     */
252    public function setAlpha($pValue = 0) {
253    	$this->_alpha = $pValue;
254    	return $this;
255    }
256
257	/**
258	 * Get hash code
259	 *
260	 * @return string	Hash code
261	 */
262	public function getHashCode() {
263    	return md5(
264    		  ($this->_visible ? 't' : 'f')
265    		. $this->_blurRadius
266    		. $this->_distance
267    		. $this->_direction
268    		. $this->_alignment
269    		. $this->_color->getHashCode()
270    		. $this->_alpha
271    		. __CLASS__
272    	);
273    }
274
275	/**
276	 * Implement PHP __clone to create a deep clone, not just a shallow copy.
277	 */
278	public function __clone() {
279		$vars = get_object_vars($this);
280		foreach ($vars as $key => $value) {
281			if (is_object($value)) {
282				$this->$key = clone $value;
283			} else {
284				$this->$key = $value;
285			}
286		}
287	}
288}
289