For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
6.1 KiB

  1. <?php
  2. /**
  3. * PHPExcel_Worksheet_Drawing_Shadow
  4. *
  5. * Copyright (c) 2006 - 2015 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 - 2015 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. class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
  28. {
  29. /* Shadow alignment */
  30. const SHADOW_BOTTOM = 'b';
  31. const SHADOW_BOTTOM_LEFT = 'bl';
  32. const SHADOW_BOTTOM_RIGHT = 'br';
  33. const SHADOW_CENTER = 'ctr';
  34. const SHADOW_LEFT = 'l';
  35. const SHADOW_TOP = 't';
  36. const SHADOW_TOP_LEFT = 'tl';
  37. const SHADOW_TOP_RIGHT = 'tr';
  38. /**
  39. * Visible
  40. *
  41. * @var boolean
  42. */
  43. private $visible;
  44. /**
  45. * Blur radius
  46. *
  47. * Defaults to 6
  48. *
  49. * @var int
  50. */
  51. private $blurRadius;
  52. /**
  53. * Shadow distance
  54. *
  55. * Defaults to 2
  56. *
  57. * @var int
  58. */
  59. private $distance;
  60. /**
  61. * Shadow direction (in degrees)
  62. *
  63. * @var int
  64. */
  65. private $direction;
  66. /**
  67. * Shadow alignment
  68. *
  69. * @var int
  70. */
  71. private $alignment;
  72. /**
  73. * Color
  74. *
  75. * @var PHPExcel_Style_Color
  76. */
  77. private $color;
  78. /**
  79. * Alpha
  80. *
  81. * @var int
  82. */
  83. private $alpha;
  84. /**
  85. * Create a new PHPExcel_Worksheet_Drawing_Shadow
  86. */
  87. public function __construct()
  88. {
  89. // Initialise values
  90. $this->visible = false;
  91. $this->blurRadius = 6;
  92. $this->distance = 2;
  93. $this->direction = 0;
  94. $this->alignment = PHPExcel_Worksheet_Drawing_Shadow::SHADOW_BOTTOM_RIGHT;
  95. $this->color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
  96. $this->alpha = 50;
  97. }
  98. /**
  99. * Get Visible
  100. *
  101. * @return boolean
  102. */
  103. public function getVisible()
  104. {
  105. return $this->visible;
  106. }
  107. /**
  108. * Set Visible
  109. *
  110. * @param boolean $pValue
  111. * @return PHPExcel_Worksheet_Drawing_Shadow
  112. */
  113. public function setVisible($pValue = false)
  114. {
  115. $this->visible = $pValue;
  116. return $this;
  117. }
  118. /**
  119. * Get Blur radius
  120. *
  121. * @return int
  122. */
  123. public function getBlurRadius()
  124. {
  125. return $this->blurRadius;
  126. }
  127. /**
  128. * Set Blur radius
  129. *
  130. * @param int $pValue
  131. * @return PHPExcel_Worksheet_Drawing_Shadow
  132. */
  133. public function setBlurRadius($pValue = 6)
  134. {
  135. $this->blurRadius = $pValue;
  136. return $this;
  137. }
  138. /**
  139. * Get Shadow distance
  140. *
  141. * @return int
  142. */
  143. public function getDistance()
  144. {
  145. return $this->distance;
  146. }
  147. /**
  148. * Set Shadow distance
  149. *
  150. * @param int $pValue
  151. * @return PHPExcel_Worksheet_Drawing_Shadow
  152. */
  153. public function setDistance($pValue = 2)
  154. {
  155. $this->distance = $pValue;
  156. return $this;
  157. }
  158. /**
  159. * Get Shadow direction (in degrees)
  160. *
  161. * @return int
  162. */
  163. public function getDirection()
  164. {
  165. return $this->direction;
  166. }
  167. /**
  168. * Set Shadow direction (in degrees)
  169. *
  170. * @param int $pValue
  171. * @return PHPExcel_Worksheet_Drawing_Shadow
  172. */
  173. public function setDirection($pValue = 0)
  174. {
  175. $this->direction = $pValue;
  176. return $this;
  177. }
  178. /**
  179. * Get Shadow alignment
  180. *
  181. * @return int
  182. */
  183. public function getAlignment()
  184. {
  185. return $this->alignment;
  186. }
  187. /**
  188. * Set Shadow alignment
  189. *
  190. * @param int $pValue
  191. * @return PHPExcel_Worksheet_Drawing_Shadow
  192. */
  193. public function setAlignment($pValue = 0)
  194. {
  195. $this->alignment = $pValue;
  196. return $this;
  197. }
  198. /**
  199. * Get Color
  200. *
  201. * @return PHPExcel_Style_Color
  202. */
  203. public function getColor()
  204. {
  205. return $this->color;
  206. }
  207. /**
  208. * Set Color
  209. *
  210. * @param PHPExcel_Style_Color $pValue
  211. * @throws PHPExcel_Exception
  212. * @return PHPExcel_Worksheet_Drawing_Shadow
  213. */
  214. public function setColor(PHPExcel_Style_Color $pValue = null)
  215. {
  216. $this->color = $pValue;
  217. return $this;
  218. }
  219. /**
  220. * Get Alpha
  221. *
  222. * @return int
  223. */
  224. public function getAlpha()
  225. {
  226. return $this->alpha;
  227. }
  228. /**
  229. * Set Alpha
  230. *
  231. * @param int $pValue
  232. * @return PHPExcel_Worksheet_Drawing_Shadow
  233. */
  234. public function setAlpha($pValue = 0)
  235. {
  236. $this->alpha = $pValue;
  237. return $this;
  238. }
  239. /**
  240. * Get hash code
  241. *
  242. * @return string Hash code
  243. */
  244. public function getHashCode()
  245. {
  246. return md5(
  247. ($this->visible ? 't' : 'f') .
  248. $this->blurRadius .
  249. $this->distance .
  250. $this->direction .
  251. $this->alignment .
  252. $this->color->getHashCode() .
  253. $this->alpha .
  254. __CLASS__
  255. );
  256. }
  257. /**
  258. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  259. */
  260. public function __clone()
  261. {
  262. $vars = get_object_vars($this);
  263. foreach ($vars as $key => $value) {
  264. if (is_object($value)) {
  265. $this->$key = clone $value;
  266. } else {
  267. $this->$key = $value;
  268. }
  269. }
  270. }
  271. }