Ejemplo n.º 1
0
 /**
  * Function: getBoundsForCells
  * 
  * Returns the bounds for the given cells.
  */
 function getBoundsForCells($cells, $includeEdges = false, $includeDescendants = false, $boundingBox = false)
 {
     $cellCount = sizeof($cells);
     $result = null;
     if ($cellCount > 0) {
         for ($i = 0; $i < $cellCount; $i++) {
             $bounds = $this->getCellBounds($cells[$i], $includeEdges, $includeDescendants, $boundingBox);
             if ($bounds != null) {
                 if ($result == null) {
                     $result = new mxRectangle($bounds->x, $bounds->y, $bounds->width, $bounds->height);
                 } else {
                     $result->add($bounds);
                 }
             }
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Function: getPerimeterBounds
  * 
  * Returns the <mxRectangle> that should be used as the perimeter of the
  * cell.
  */
 function getPerimeterBounds($border = 0)
 {
     $bounds = new mxRectangle($this->x, $this->y, $this->width, $this->height);
     if ($border != 0) {
         $bounds->grow($border);
     }
     return $bounds;
 }
Ejemplo n.º 3
0
 /**
  * Function: updateBoundingBox
  * 
  * Updates the bounding box in the given cell state.
  */
 function updateBoundingBox($state)
 {
     // Gets the cell bounds and adds shadows and markers
     $rect = new mxRectangle($state->x, $state->y, $state->width, $state->height);
     $style = $state->style;
     // Adds extra pixels for the marker and stroke assuming
     // that the border stroke is centered around the bounds
     // and the first pixel is drawn inside the bounds
     $strokeWidth = max(1, mxUtils::getNumber($style, mxConstants::$STYLE_STROKEWIDTH, 1) * $this->scale);
     $strokeWidth -= max(1, $strokeWidth / 2);
     if ($this->graph->model->isEdge($state->cell)) {
         $ms = 0;
         if (isset($style[mxConstants::$STYLE_ENDARROW]) || isset($style[mxConstants::$STYLE_STARTARROW])) {
             $ms = round(mxConstants::$DEFAULT_MARKERSIZE * $this->scale);
         }
         // Adds the strokewidth
         $rect->grow($ms + $strokeWidth);
         // Adds worst case border for an arrow shape
         if (mxUtils::getValue($style, mxConstants::$STYLE_SHAPE) == mxConstants::$SHAPE_ARROW) {
             $rect->grow(mxConstants::$ARROW_WIDTH / 2);
         }
     } else {
         $rect->grow($strokeWidth);
     }
     // Adds extra pixels for the shadow
     if (mxUtils::getValue($style, mxConstants::$STYLE_SHADOW, false) == true) {
         $rect->width += mxConstants::$SHADOW_OFFSETX;
         $rect->height += mxConstants::$SHADOW_OFFSETY;
     }
     // Adds oversize images in labels
     if (mxUtils::getValue($style, mxConstants::$STYLE_SHAPE) == mxConstants::$SHAPE_LABEL) {
         if (mxUtils::getValue($style, mxConstants::$STYLE_IMAGE) != null) {
             $w = mxUtils::$getValue($style, mxConstants::$STYLE_IMAGE_WIDTH, mxConstants::$DEFAULT_IMAGESIZE) * $this->scale;
             $h = mxUtils::$getValue($style, mxConstants::$STYLE_IMAGE_HEIGHT, mxConstants::$DEFAULT_IMAGESIZE) * $this->scale;
             $x = $state->x;
             $y = 0;
             $imgAlign = mxUtils::getValue($style, mxConstants::$STYLE_IMAGE_ALIGN, mxConstants::$ALIGN_CENTER);
             $imgValign = mxUtils::getValue(style, mxConstants::$STYLE_IMAGE_VERTICAL_ALIGN, mxConstants::$ALIGN_MIDDLE);
             if ($imgAlign == mxConstants::$ALIGN_RIGHT) {
                 $x += $state->width - $w;
             } else {
                 if ($imgAlign == mxConstants::$ALIGN_CENTER) {
                     $x += ($state->width - $w) / 2;
                 }
             }
             if ($imgValign == mxConstants::$ALIGN_TOP) {
                 $y = $state->y;
             } else {
                 if ($imgValign == mxConstants::$ALIGN_BOTTOM) {
                     $y = $state->y + $state->height - $h;
                 } else {
                     $y = $state->y + ($state->height - $h) / 2;
                 }
             }
             $rect->add(new mxRectangle($x, $y, $w, $h));
         }
     }
     // No need to add rotated rectangle bounds here because
     // GD does not support rotation
     // Unifies the cell bounds and the label bounds
     $rect->add($state->labelBounds);
     $state->boundingBox = $rect;
     return $rect;
 }
Ejemplo n.º 4
0
 /**
  * Constructor: mxGeometry
  *
  * Constructs a new object to describe the size and location
  * of a vertex or the control points of an edge.
  */
 function mxGeometry($x = 0, $y = 0, $width = 0, $height = 0)
 {
     parent::mxRectangle($x, $y, $width, $height);
 }