예제 #1
0
 /**
  * Draws the layers content on the image
  * @param zibo\library\image\Image $image The image to draw upon
  * @param zibo\library\diagram\Diagram $diagram The diagram we're drawing
  * @return null
  */
 public function draw(Image $image, Diagram $diagram)
 {
     $grid = $diagram->getGrid();
     $width = $image->getWidth();
     $height = $image->getHeight();
     $cellDimension = $grid->getCellDimension();
     $margin = $diagram->getMargin();
     $cellWidth = $cellDimension->getWidth();
     $cellHeight = $cellDimension->getHeight();
     // take margin into account and go out of the image to start the grid
     $loopX = $loopY = $this->helperLocation - 1;
     $x = $margin;
     while ($x > 0) {
         $x -= $cellWidth;
         $loopX--;
     }
     $y = $margin;
     while ($y > 0) {
         $y -= $cellHeight;
         $loopY--;
     }
     // draw the X-axis
     for (; $x < $width; $x += $cellWidth) {
         $loopX++;
         if ($loopX == $this->helperLocation) {
             $color = $this->helperColor;
             $loopX = 0;
         } else {
             $color = $this->gridColor;
         }
         $image->drawLine(new Point($x, 0), new Point($x, $height), $color);
     }
     // draw the Y-axis
     for (; $y < $height; $y += $cellHeight) {
         $loopY++;
         if ($loopY == $this->helperLocation) {
             $color = $this->helperColor;
             $loopY = 0;
         } else {
             $color = $this->gridColor;
         }
         $image->drawLine(new Point(0, $y), new Point($width, $y), $color);
     }
 }
 /**
  * Draw the connection on the provided image
  * @param zibo\library\image\Image $image
  * @return null
  */
 public function draw(Image $image)
 {
     $previousPoint = null;
     foreach ($this->points as $point) {
         if (!$previousPoint) {
             $previousPoint = $point;
             continue;
         }
         $image->drawLine($previousPoint, $point, $this->color);
         $previousPoint = $point;
     }
 }
 /**
  * Draws the object on the provided image
  * @param zibo\library\image\Image $image The image to draw upon
  * @param zibo\library\image\Point $point The top left corner to start drawing
  * @return null
  */
 public function draw(Image $image, Point $point)
 {
     $x = $point->getX();
     $y = $point->getY();
     $width = $this->dimension->getWidth();
     $height = $this->dimension->getHeight();
     $textX = $x + $this->paddingLeft;
     // draw the box
     $image->fillRoundedRectangle($point, $this->dimension, 3, $this->backgroundColor);
     $image->drawRoundedRectangle($point, $this->dimension, 3, $this->frontColor);
     // draw the title bar
     $title = $this->meta->getName();
     // . ($this->isLinkModel ? ' (L)' : '');
     $image->drawText(new Point($textX, $point->getY() + $this->paddingTop), $this->frontColor, $title);
     $lineY = $y + 2 * $this->paddingTop + self::CHARACTER_HEIGHT + $this->paddingBottom;
     $image->drawLine(new Point($x, $lineY), new Point($x + $width, $lineY), $this->frontColor);
     // draw the fields
     $fieldY = $lineY + $this->paddingTop;
     $fields = $this->meta->getFields();
     foreach ($fields as $fieldName => $field) {
         $label = '+ ' . $field->getName() . ': ' . $this->getFieldType($field);
         $this->fieldPoints[$fieldName] = new Point($x, ceil($fieldY + $this->paddingTop + 1));
         $image->drawText(new Point($textX, $fieldY), $this->frontColor, $label);
         $fieldY += $this->paddingTop + self::CHARACTER_HEIGHT;
     }
 }