Examples of mxRectangle


Examples of com.mxgraph.util.mxRectangle

          {
            mxGeometry geo = model.getGeometry(cells[i]);
           
            if (geo != null)
            {
              mxRectangle size = new mxRectangle(0, 0, geo.getWidth(), geo.getHeight());
              Object top = cells[i];
              Object current = top;
             
              while (current != null)
              {
                top = current;
                current = model.getParent(current);
                mxRectangle tmp = (graph.isSwimlane(current)) ?
                    graph.getStartSize(current) :
                    new mxRectangle();
                size.setWidth(size.getWidth() + tmp.getWidth());
                size.setHeight(size.getHeight() + tmp.getHeight());
              }
             
              this.resizeSwimlane(top, size.getWidth(), size.getHeight());
            }
          }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

            model.setGeometry(swimlane, geo);
          }
        }
      }

      mxRectangle tmp = (graph.isSwimlane(swimlane)) ? graph
          .getStartSize(swimlane) : new mxRectangle();
      w -= tmp.getWidth();
      h -= tmp.getHeight();

      int childCount = model.getChildCount(swimlane);

      for (int i = 0; i < childCount; i++)
      {
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   *
   * @param cell <mxCell> for which the preferred size should be returned.
   */
  public mxRectangle getPreferredSizeForCell(Object cell)
  {
    mxRectangle result = null;

    if (cell != null)
    {
      mxCellState state = view.getState(cell);
      Map<String, Object> style = (state != null) ? state.style
          : getCellStyle(cell);

      if (style != null && !model.isEdge(cell))
      {
        double dx = 0;
        double dy = 0;

        // Adds dimension of image if shape is a label
        if (getImage(state) != null
            || mxUtils.getString(style, mxConstants.STYLE_IMAGE) != null)
        {
          if (mxUtils.getString(style, mxConstants.STYLE_SHAPE, "")
              .equals(mxConstants.SHAPE_LABEL))
          {
            if (mxUtils.getString(style,
                mxConstants.STYLE_VERTICAL_ALIGN, "").equals(
                mxConstants.ALIGN_MIDDLE))
            {
              dx += mxUtils.getDouble(style,
                  mxConstants.STYLE_IMAGE_WIDTH,
                  mxConstants.DEFAULT_IMAGESIZE);
            }

            if (mxUtils.getString(style, mxConstants.STYLE_ALIGN,
                "").equals(mxConstants.ALIGN_CENTER))
            {
              dy += mxUtils.getDouble(style,
                  mxConstants.STYLE_IMAGE_HEIGHT,
                  mxConstants.DEFAULT_IMAGESIZE);
            }
          }
        }

        // Adds spacings
        double spacing = mxUtils.getDouble(style,
            mxConstants.STYLE_SPACING);
        dx += 2 * spacing;
        dx += mxUtils.getDouble(style, mxConstants.STYLE_SPACING_LEFT);
        dx += mxUtils.getDouble(style, mxConstants.STYLE_SPACING_RIGHT);

        dy += 2 * spacing;
        dy += mxUtils.getDouble(style, mxConstants.STYLE_SPACING_TOP);
        dy += mxUtils
            .getDouble(style, mxConstants.STYLE_SPACING_BOTTOM);

        // LATER: Add space for collapse/expand icon if applicable

        // Adds space for label
        String value = getLabel(cell);

        if (value != null && value.length() > 0)
        {
          // FIXME: Check word-wrap style and balance width/height
          mxRectangle size = mxUtils.getLabelSize(value, style,
              isHtmlLabel(cell), 1);
          double width = size.getWidth() + dx;
          double height = size.getHeight() + dy;

          if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL,
              true))
          {
            double tmp = height;

            height = width;
            width = tmp;
          }

          if (gridEnabled)
          {
            width = snap(width + gridSize / 2);
            height = snap(height + gridSize / 2);
          }

          result = new mxRectangle(0, 0, width, height);
        }
        else
        {
          double gs2 = 4 * gridSize;
          result = new mxRectangle(0, 0, gs2, gs2);
        }
      }
    }

    return result;
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

      model.beginUpdate();
      try
      {
        for (int i = 0; i < cells.length; i++)
        {
          mxRectangle tmp = bounds[i];
          mxGeometry geo = model.getGeometry(cells[i]);

          if (geo != null
              && (geo.getX() != tmp.getX()
                  || geo.getY() != tmp.getY()
                  || geo.getWidth() != tmp.getWidth() || geo
                  .getHeight() != tmp.getHeight()))
          {
            geo = (mxGeometry) geo.clone();

            if (geo.isRelative())
            {
              mxPoint offset = geo.getOffset();

              if (offset != null)
              {
                offset.setX(offset.getX() + tmp.getX());
                offset.setY(offset.getY() + tmp.getY());
              }
            }
            else
            {
              geo.setX(tmp.getX());
              geo.setY(tmp.getY());
            }

            geo.setWidth(tmp.getWidth());
            geo.setHeight(tmp.getHeight());

            if (!geo.isRelative() && model.isVertex(cells[i])
                && !isAllowNegativeCoordinates())
            {
              geo.setX(Math.max(0, geo.getX()));
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

          double w = g.getWidth();
          double h = g.getHeight();

          if (isSwimlane(parent))
          {
            mxRectangle size = getStartSize(parent);

            x = size.getWidth();
            w -= size.getWidth();
            y = size.getHeight();
            h -= size.getHeight();
          }

          return new mxRectangle(x, y, w, h);
        }
      }
    }

    return null;
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

  /**
   * @param value the maximumGraphBounds to set
   */
  public void setMaximumGraphBounds(mxRectangle value)
  {
    mxRectangle oldValue = maximumGraphBounds;
    maximumGraphBounds = value;

    changeSupport.firePropertyChange("maximumGraphBounds", oldValue,
        maximumGraphBounds);
  }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

  public void constrainChild(Object cell)
  {
    if (cell != null)
    {
      mxGeometry geo = model.getGeometry(cell);
      mxRectangle area = (isConstrainChild(cell)) ? getCellContainmentArea(cell)
          : getMaximumGraphBounds();

      if (geo != null && area != null)
      {
        // Keeps child within the content area of the parent
        if (!geo.isRelative()
            && (geo.getX() < area.getX()
                || geo.getY() < area.getY()
                || area.getWidth() < geo.getX()
                    + geo.getWidth() || area.getHeight() < geo
                .getY() + geo.getHeight()))
        {
          double overlap = getOverlap(cell);

          if (area.getWidth() > 0)
          {
            geo.setX(Math.min(geo.getX(),
                area.getX() + area.getWidth() - (1 - overlap)
                    * geo.getWidth()));
          }

          if (area.getHeight() > 0)
          {
            geo.setY(Math.min(geo.getY(),
                area.getY() + area.getHeight() - (1 - overlap)
                    * geo.getHeight()));
          }

          geo.setX(Math.max(geo.getX(), area.getX() - geo.getWidth()
              * overlap));
          geo.setY(Math.max(geo.getY(), area.getY() - geo.getHeight()
              * overlap));
        }
      }
    }
  }
 
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

            tmp = graph.getModel().getParent(tmp);
          }
        }
      }

      mxRectangle dirty = lastDirty;

      lastDirty = preview.show();

      if (dirty != null)
      {
        dirty.add(lastDirty);
      }
      else
      {
        dirty = lastDirty;
      }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   * Returns the bounding box for the geometries of the vertices in the
   * given array of cells.
   */
  public mxRectangle getBoundingBoxFromGeometry(Object[] cells)
  {
    mxRectangle result = null;

    if (cells != null)
    {
      for (int i = 0; i < cells.length; i++)
      {
        if (getModel().isVertex(cells[i]))
        {
          mxGeometry geo = getCellGeometry(cells[i]);

          if (result == null)
          {
            result = new mxRectangle(geo);
          }
          else
          {
            result.add(geo);
          }
        }
      }
    }

View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   * Returns the bounds for the given cells.
   */
  public mxRectangle getBoundsForCells(Object[] cells, boolean includeEdges,
      boolean includeDescendants, boolean boundingBox)
  {
    mxRectangle result = null;

    if (cells != null && cells.length > 0)
    {
      for (int i = 0; i < cells.length; i++)
      {
        mxRectangle tmp = getCellBounds(cells[i], includeEdges,
            includeDescendants, boundingBox);

        if (tmp != null)
        {
          if (result == null)
          {
            result = new mxRectangle(tmp);
          }
          else
          {
            result.add(tmp);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.