Пример #1
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'maxHeight':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1');
             }
             $this->properties['maxHeight'] = (double) $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'padding':
             if (!is_numeric($propertyValue) || $propertyValue < 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
             }
             $this->properties['padding'] = (int) $propertyValue;
             break;
         case 'symbolSize':
             if (!is_numeric($propertyValue) || $propertyValue < 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1');
             }
             $this->properties['symbolSize'] = (int) $propertyValue;
             break;
         case 'landscapeSize':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= int <= 1');
             }
             $this->properties['landscapeSize'] = (double) $propertyValue;
             break;
         case 'portraitSize':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= int <= 1');
             }
             $this->properties['portraitSize'] = (double) $propertyValue;
             break;
         case 'minimumSymbolSize':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= int <= 1');
             }
             $this->properties['minimumSymbolSize'] = (double) $propertyValue;
             break;
         case 'spacing':
             if (!is_numeric($propertyValue) || $propertyValue < 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
             }
             $this->properties['spacing'] = (int) $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'image':
             // Check for existance of file
             if (!is_file($propertyValue) || !is_readable($propertyValue)) {
                 throw new ezcBaseFileNotFoundException($propertyValue);
             }
             // Check for beeing an image file
             $data = getImageSize($propertyValue);
             if ($data === false) {
                 throw new ezcGraphInvalidImageFileException($propertyValue);
             }
             // SWF files are useless..
             if ($data[2] === 4) {
                 throw new ezcGraphInvalidImageFileException('We cant use SWF files like <' . $propertyValue . '>.');
             }
             $this->properties['image'] = $propertyValue;
             break;
         case 'repeat':
             if ($propertyValue >= 0 && $propertyValue <= 3) {
                 $this->properties['repeat'] = (int) $propertyValue;
             } else {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= int <= 3');
             }
             break;
         case 'position':
             // Overwrite parent position setter, to be able to use
             // combination of positions like
             //      ezcGraph::TOP | ezcGraph::CENTER
             if (is_int($propertyValue)) {
                 $this->properties['position'] = $propertyValue;
             } else {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'integer');
             }
             break;
         case 'color':
             // Use color as an alias to set background color for background
             $this->__set('background', $propertyValue);
             break;
         default:
             return parent::__set($propertyName, $propertyValue);
     }
 }
Пример #4
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'nullPosition':
             $this->properties['nullPosition'] = (double) $propertyValue;
             break;
         case 'axisSpace':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue >= 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float < 1');
             }
             $this->properties['axisSpace'] = (double) $propertyValue;
             break;
         case 'outerAxisSpace':
             if (!is_null($propertyValue) && (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue >= 1)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'null, or 0 <= float < 1');
             }
             $this->properties['outerAxisSpace'] = $propertyValue;
             break;
         case 'majorGrid':
             $this->properties['majorGrid'] = ezcGraphColor::create($propertyValue);
             break;
         case 'minorGrid':
             $this->properties['minorGrid'] = ezcGraphColor::create($propertyValue);
             break;
         case 'majorStep':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0');
             }
             $this->properties['majorStep'] = (double) $propertyValue;
             break;
         case 'minorStep':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0');
             }
             $this->properties['minorStep'] = (double) $propertyValue;
             break;
         case 'formatString':
             $this->properties['formatString'] = (string) $propertyValue;
             break;
         case 'label':
             $this->properties['label'] = (string) $propertyValue;
             break;
         case 'labelSize':
             if (!is_numeric($propertyValue) || $propertyValue <= 6) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 6');
             }
             $this->properties['labelSize'] = (int) $propertyValue;
             break;
         case 'labelMargin':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
             }
             $this->properties['labelMargin'] = (int) $propertyValue;
             break;
         case 'maxArrowHeadSize':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
             }
             $this->properties['maxArrowHeadSize'] = (int) $propertyValue;
             break;
         case 'minArrowHeadSize':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
             }
             $this->properties['minArrowHeadSize'] = (int) $propertyValue;
             break;
         case 'axisLabelRenderer':
             if ($propertyValue instanceof ezcGraphAxisLabelRenderer) {
                 $this->axisLabelRenderer = $propertyValue;
             } else {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphAxisLabelRenderer');
             }
             break;
         case 'labelCallback':
             if (is_callable($propertyValue)) {
                 $this->properties['labelCallback'] = $propertyValue;
             } else {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'callback function');
             }
             break;
         case 'chartPosition':
             if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1');
             }
             $this->properties['chartPosition'] = (double) $propertyValue;
             break;
         case 'labelRotation':
             if (!is_numeric($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float');
             }
             $this->properties['labelRotation'] = fmod((double) $propertyValue, 360.0);
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }