/** * 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; } }