[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Chart/ -> GridLines.php (source)

   1  <?php
   2  
   3  /**
   4   * Created by PhpStorm.
   5   * User: Wiktor Trzonkowski
   6   * Date: 7/2/14
   7   * Time: 2:36 PM
   8   */
   9  
  10  class PHPExcel_Chart_GridLines extends PHPExcel_Chart_Properties
  11  {
  12  
  13    /**
  14     * Properties of Class:
  15     * Object State (State for Minor Tick Mark) @var bool
  16     * Line Properties @var  array of mixed
  17     * Shadow Properties @var  array of mixed
  18     * Glow Properties @var  array of mixed
  19     * Soft Properties @var  array of mixed
  20     *
  21     */
  22  
  23      private $objectState = false;
  24  
  25      private $lineProperties = array(
  26          'color' => array(
  27              'type' => self::EXCEL_COLOR_TYPE_STANDARD,
  28              'value' => null,
  29              'alpha' => 0
  30          ),
  31          'style' => array(
  32              'width' => '9525',
  33              'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
  34              'dash' => self::LINE_STYLE_DASH_SOLID,
  35              'cap' => self::LINE_STYLE_CAP_FLAT,
  36              'join' => self::LINE_STYLE_JOIN_BEVEL,
  37              'arrow' => array(
  38                  'head' => array(
  39                      'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
  40                      'size' => self::LINE_STYLE_ARROW_SIZE_5
  41                  ),
  42                  'end' => array(
  43                      'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
  44                      'size' => self::LINE_STYLE_ARROW_SIZE_8
  45                  ),
  46              )
  47          )
  48      );
  49  
  50      private $shadowProperties = array(
  51          'presets' => self::SHADOW_PRESETS_NOSHADOW,
  52          'effect' => null,
  53          'color' => array(
  54              'type' => self::EXCEL_COLOR_TYPE_STANDARD,
  55              'value' => 'black',
  56              'alpha' => 85,
  57          ),
  58          'size' => array(
  59              'sx' => null,
  60              'sy' => null,
  61              'kx' => null
  62          ),
  63          'blur' => null,
  64          'direction' => null,
  65          'distance' => null,
  66          'algn' => null,
  67          'rotWithShape' => null
  68      );
  69  
  70      private $glowProperties = array(
  71          'size' => null,
  72          'color' => array(
  73              'type' => self::EXCEL_COLOR_TYPE_STANDARD,
  74              'value' => 'black',
  75              'alpha' => 40
  76          )
  77      );
  78  
  79      private $softEdges = array(
  80          'size' => null
  81       );
  82  
  83      /**
  84       * Get Object State
  85       *
  86       * @return bool
  87       */
  88  
  89      public function getObjectState()
  90      {
  91          return $this->objectState;
  92      }
  93  
  94      /**
  95       * Change Object State to True
  96       *
  97       * @return PHPExcel_Chart_GridLines
  98       */
  99  
 100      private function activateObject()
 101      {
 102          $this->objectState = true;
 103  
 104          return $this;
 105      }
 106  
 107      /**
 108       * Set Line Color Properties
 109       *
 110       * @param string $value
 111       * @param int $alpha
 112       * @param string $type
 113       */
 114  
 115      public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
 116      {
 117          $this->activateObject()
 118              ->lineProperties['color'] = $this->setColorProperties(
 119                  $value,
 120                  $alpha,
 121                  $type
 122              );
 123      }
 124  
 125      /**
 126       * Set Line Color Properties
 127       *
 128       * @param float $line_width
 129       * @param string $compound_type
 130       * @param string $dash_type
 131       * @param string $cap_type
 132       * @param string $join_type
 133       * @param string $head_arrow_type
 134       * @param string $head_arrow_size
 135       * @param string $end_arrow_type
 136       * @param string $end_arrow_size
 137       */
 138  
 139      public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
 140      {
 141          $this->activateObject();
 142          (!is_null($line_width))
 143                  ? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
 144                  : null;
 145          (!is_null($compound_type))
 146                  ? $this->lineProperties['style']['compound'] = (string) $compound_type
 147                  : null;
 148          (!is_null($dash_type))
 149                  ? $this->lineProperties['style']['dash'] = (string) $dash_type
 150                  : null;
 151          (!is_null($cap_type))
 152                  ? $this->lineProperties['style']['cap'] = (string) $cap_type
 153                  : null;
 154          (!is_null($join_type))
 155                  ? $this->lineProperties['style']['join'] = (string) $join_type
 156                  : null;
 157          (!is_null($head_arrow_type))
 158                  ? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
 159                  : null;
 160          (!is_null($head_arrow_size))
 161                  ? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
 162                  : null;
 163          (!is_null($end_arrow_type))
 164                  ? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
 165                  : null;
 166          (!is_null($end_arrow_size))
 167                  ? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
 168                  : null;
 169      }
 170  
 171      /**
 172       * Get Line Color Property
 173       *
 174       * @param string $parameter
 175       *
 176       * @return string
 177       */
 178  
 179      public function getLineColorProperty($parameter)
 180      {
 181          return $this->lineProperties['color'][$parameter];
 182      }
 183  
 184      /**
 185       * Get Line Style Property
 186       *
 187       * @param    array|string $elements
 188       *
 189       * @return string
 190       */
 191  
 192      public function getLineStyleProperty($elements)
 193      {
 194          return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
 195      }
 196  
 197      /**
 198       * Set Glow Properties
 199       *
 200       * @param    float $size
 201       * @param    string $color_value
 202       * @param    int $color_alpha
 203       * @param    string $color_type
 204       *
 205       */
 206  
 207      public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
 208      {
 209          $this
 210                  ->activateObject()
 211                  ->setGlowSize($size)
 212                  ->setGlowColor($color_value, $color_alpha, $color_type);
 213      }
 214  
 215      /**
 216       * Get Glow Color Property
 217       *
 218       * @param string $property
 219       *
 220       * @return string
 221       */
 222  
 223      public function getGlowColor($property)
 224      {
 225          return $this->glowProperties['color'][$property];
 226      }
 227  
 228      /**
 229       * Get Glow Size
 230       *
 231       * @return string
 232       */
 233  
 234      public function getGlowSize()
 235      {
 236          return $this->glowProperties['size'];
 237      }
 238  
 239      /**
 240       * Set Glow Size
 241       *
 242       * @param float $size
 243       *
 244       * @return PHPExcel_Chart_GridLines
 245       */
 246  
 247      private function setGlowSize($size)
 248      {
 249          $this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
 250  
 251          return $this;
 252      }
 253  
 254      /**
 255       * Set Glow Color
 256       *
 257       * @param string $color
 258       * @param int $alpha
 259       * @param string $type
 260       *
 261       * @return PHPExcel_Chart_GridLines
 262       */
 263  
 264      private function setGlowColor($color, $alpha, $type)
 265      {
 266          if (!is_null($color)) {
 267              $this->glowProperties['color']['value'] = (string) $color;
 268          }
 269          if (!is_null($alpha)) {
 270              $this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
 271          }
 272          if (!is_null($type)) {
 273              $this->glowProperties['color']['type'] = (string) $type;
 274          }
 275  
 276          return $this;
 277      }
 278  
 279      /**
 280       * Get Line Style Arrow Parameters
 281       *
 282       * @param string $arrow_selector
 283       * @param string $property_selector
 284       *
 285       * @return string
 286       */
 287  
 288      public function getLineStyleArrowParameters($arrow_selector, $property_selector)
 289      {
 290          return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
 291      }
 292  
 293      /**
 294       * Set Shadow Properties
 295       *
 296       * @param int $sh_presets
 297       * @param string $sh_color_value
 298       * @param string $sh_color_type
 299       * @param int $sh_color_alpha
 300       * @param string $sh_blur
 301       * @param int $sh_angle
 302       * @param float $sh_distance
 303       *
 304       */
 305  
 306      public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null)
 307      {
 308          $this->activateObject()
 309              ->setShadowPresetsProperties((int) $sh_presets)
 310              ->setShadowColor(
 311                  is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
 312                  is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
 313                  is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
 314              )
 315              ->setShadowBlur($sh_blur)
 316              ->setShadowAngle($sh_angle)
 317              ->setShadowDistance($sh_distance);
 318      }
 319  
 320      /**
 321       * Set Shadow Presets Properties
 322       *
 323       * @param int $shadow_presets
 324       *
 325       * @return PHPExcel_Chart_GridLines
 326       */
 327  
 328      private function setShadowPresetsProperties($shadow_presets)
 329      {
 330          $this->shadowProperties['presets'] = $shadow_presets;
 331          $this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
 332  
 333          return $this;
 334      }
 335  
 336      /**
 337       * Set Shadow Properties Values
 338       *
 339       * @param array $properties_map
 340       * @param * $reference
 341       *
 342       * @return PHPExcel_Chart_GridLines
 343       */
 344  
 345      private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
 346      {
 347          $base_reference = $reference;
 348          foreach ($properties_map as $property_key => $property_val) {
 349              if (is_array($property_val)) {
 350                  if ($reference === null) {
 351                      $reference = & $this->shadowProperties[$property_key];
 352                  } else {
 353                      $reference = & $reference[$property_key];
 354                  }
 355                  $this->setShadowProperiesMapValues($property_val, $reference);
 356              } else {
 357                  if ($base_reference === null) {
 358                      $this->shadowProperties[$property_key] = $property_val;
 359                  } else {
 360                      $reference[$property_key] = $property_val;
 361                  }
 362              }
 363          }
 364  
 365          return $this;
 366      }
 367  
 368      /**
 369       * Set Shadow Color
 370       *
 371       * @param string $color
 372       * @param int $alpha
 373       * @param string $type
 374       * @return PHPExcel_Chart_GridLines
 375       */
 376      private function setShadowColor($color, $alpha, $type)
 377      {
 378          if (!is_null($color)) {
 379              $this->shadowProperties['color']['value'] = (string) $color;
 380          }
 381          if (!is_null($alpha)) {
 382              $this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
 383          }
 384          if (!is_null($type)) {
 385              $this->shadowProperties['color']['type'] = (string) $type;
 386          }
 387  
 388          return $this;
 389      }
 390  
 391      /**
 392       * Set Shadow Blur
 393       *
 394       * @param float $blur
 395       *
 396       * @return PHPExcel_Chart_GridLines
 397       */
 398      private function setShadowBlur($blur)
 399      {
 400          if ($blur !== null) {
 401              $this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
 402          }
 403  
 404          return $this;
 405      }
 406  
 407      /**
 408       * Set Shadow Angle
 409       *
 410       * @param int $angle
 411       * @return PHPExcel_Chart_GridLines
 412       */
 413  
 414      private function setShadowAngle($angle)
 415      {
 416          if ($angle !== null) {
 417              $this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
 418          }
 419  
 420          return $this;
 421      }
 422  
 423      /**
 424       * Set Shadow Distance
 425       *
 426       * @param float $distance
 427       * @return PHPExcel_Chart_GridLines
 428       */
 429      private function setShadowDistance($distance)
 430      {
 431          if ($distance !== null) {
 432              $this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
 433          }
 434  
 435          return $this;
 436      }
 437  
 438      /**
 439       * Get Shadow Property
 440       *
 441       * @param string $elements
 442       * @param array $elements
 443       * @return string
 444       */
 445      public function getShadowProperty($elements)
 446      {
 447          return $this->getArrayElementsValue($this->shadowProperties, $elements);
 448      }
 449  
 450      /**
 451       * Set Soft Edges Size
 452       *
 453       * @param float $size
 454       */
 455      public function setSoftEdgesSize($size)
 456      {
 457          if (!is_null($size)) {
 458              $this->activateObject();
 459              $softEdges['size'] = (string) $this->getExcelPointsWidth($size);
 460          }
 461      }
 462  
 463      /**
 464       * Get Soft Edges Size
 465       *
 466       * @return string
 467       */
 468      public function getSoftEdgesSize()
 469      {
 470          return $this->softEdges['size'];
 471      }
 472  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1