예제 #1
0
 /**
  * Draw a text
  *
  * @param awDriver $driver
  * @param awPoint $p Draw text at this point
  * @param awText $text The text
  * @param int $width Text box width
  */
 public function draw(awDriver $driver, awPoint $point, awText $text, $width = NULL)
 {
     $driver->string($this, $text, $point, $width);
 }
예제 #2
0
 /**
  * Draw the label
  *
  * @param awDriver $driver
  * @param awPoint $p Label center
  * @param int $key Text position in the array of texts (default to zero)
  */
 public function draw(awDriver $driver, awPoint $p, $key = 0)
 {
     if ($key % $this->interval !== 0) {
         return;
     }
     // Hide all labels
     if ($this->hide) {
         return;
     }
     // Key is hidden
     if (array_key_exists($key, $this->hideKey)) {
         return;
     }
     // Hide first label
     if ($key === 0 and $this->hideFirst) {
         return;
     }
     // Hide last label
     if ($key === count($this->texts) - 1 and $this->hideLast) {
         return;
     }
     $text = $this->getText($key);
     if ($text !== NULL) {
         // Value must be hidden
         if (in_array($text->getText(), $this->hideValue)) {
             return;
         }
         $x = $p->x;
         $y = $p->y;
         // Get padding
         list($left, $right, $top, $bottom) = $text->getPadding();
         //			$font = $text->getFont();
         $width = $driver->getTextWidth($text);
         $height = $driver->getTextHeight($text);
         switch ($this->hAlign) {
             case awLabel::RIGHT:
                 $x -= $width + $right;
                 break;
             case awLabel::CENTER:
                 $x -= ($width - $left + $right) / 2;
                 break;
             case awLabel::LEFT:
                 $x += $left;
                 break;
         }
         switch ($this->vAlign) {
             case awLabel::TOP:
                 $y -= $height + $bottom;
                 break;
             case awLabel::MIDDLE:
                 $y -= ($height - $top + $bottom) / 2;
                 break;
             case awLabel::BOTTOM:
                 $y += $top;
                 break;
         }
         $driver->string($text, $this->move->move($x, $y));
     }
 }