Package com.mxgraph.util

Examples of com.mxgraph.util.mxRectangle


   * if includeEdge is true.
   */
  public mxRectangle getCellBounds(Object cell, boolean includeEdges,
      boolean includeDescendants, boolean boundingBox)
  {
    mxRectangle result = null;
    Object[] cells;

    // Recursively includes connected edges
    if (includeEdges)
    {
      Set<Object> allCells = new HashSet<Object>();
      allCells.add(cell);

      Set<Object> edges = new HashSet<Object>(
          Arrays.asList(getEdges(cell)));

      while (!edges.isEmpty() && !allCells.containsAll(edges))
      {
        allCells.addAll(edges);

        Set<Object> tmp = new HashSet<Object>();
        Iterator<Object> it = edges.iterator();

        while (it.hasNext())
        {
          Object edge = it.next();
          tmp.addAll(Arrays.asList(getEdges(edge)));
        }

        edges = tmp;
      }

      cells = allCells.toArray();
    }
    else
    {
      cells = new Object[] { cell };
    }

    if (boundingBox)
    {
      result = view.getBoundingBox(cells);
    }
    else
    {
      result = view.getBounds(cells);
    }

    // Recursively includes the bounds of the children
    if (includeDescendants)
    {
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        mxRectangle tmp = getCellBounds(model.getChildAt(cell, i),
            includeEdges, true, boundingBox);

        if (result != null)
        {
          result.add(tmp);
View Full Code Here


   * @param swimlane <mxCell> whose start size should be returned.
   * @return Returns the startsize for the given swimlane.
   */
  public mxRectangle getStartSize(Object swimlane)
  {
    mxRectangle result = new mxRectangle();
    mxCellState state = view.getState(swimlane);
    Map<String, Object> style = (state != null) ? state.getStyle()
        : getCellStyle(swimlane);

    if (style != null)
    {
      double size = mxUtils.getDouble(style, mxConstants.STYLE_STARTSIZE,
          mxConstants.DEFAULT_STARTSIZE);

      if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
      {
        result.setHeight(size);
      }
      else
      {
        result.setWidth(size);
      }
    }

    return result;
  }
View Full Code Here

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

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

          break;
        }
      }
    }

    mxRectangle dirty = processChanges(changes, true, ignoreDirty);
    view.validate();

    if (isAutoOrigin())
    {
      updateOrigin();
    }

    if (!ignoreDirty)
    {
      mxRectangle tmp = processChanges(changes, false, ignoreDirty);

      if (tmp != null)
      {
        if (dirty == null)
        {
View Full Code Here

  public void refresh(mxCellState state)
  {
    this.state = state;
    handles = createHandles();
    mxGraph graph = graphComponent.getGraph();
    mxRectangle tmp = graph.getBoundingBox(state.getCell());

    if (tmp != null)
    {
      bounds = tmp.getRectangle();

      if (handles != null)
      {
        for (int i = 0; i < handles.length; i++)
        {
View Full Code Here

   * The first validation is required to compute the bounds of the graph
   * while the second validation is required to apply the new translate.
   */
  protected void updateOrigin()
  {
    mxRectangle bounds = getGraphBounds();

    if (bounds != null)
    {
      double scale = getView().getScale();
      double x = bounds.getX() / scale - getBorder();
      double y = bounds.getY() / scale - getBorder();

      if (x < 0 || y < 0)
      {
        double x0 = Math.min(0, x);
        double y0 = Math.min(0, y);
View Full Code Here

   * is required.
   */
  public mxRectangle processChanges(List<mxUndoableChange> changes,
      boolean invalidate, boolean ignoreDirty)
  {
    mxRectangle bounds = null;
    Iterator<mxUndoableChange> it = changes.iterator();

    while (it.hasNext())
    {
      mxRectangle rect = processChange(it.next(), invalidate, ignoreDirty);

      if (bounds == null)
      {
        bounds = rect;
      }
View Full Code Here

   * model.
   */
  public mxRectangle processChange(mxUndoableChange change,
      boolean invalidate, boolean ignoreDirty)
  {
    mxRectangle result = null;

    if (change instanceof mxRootChange)
    {
      result = (ignoreDirty) ? null : getGraphBounds();

      if (invalidate)
      {
        clearSelection();
        removeStateForCell(((mxRootChange) change).getPrevious());

        if (isResetViewOnRootChange())
        {
          view.setEventsEnabled(false);

          try
          {
            view.scaleAndTranslate(1, 0, 0);
          }
          finally
          {
            view.setEventsEnabled(true);
          }
        }

      }

      fireEvent(new mxEventObject(mxEvent.ROOT));
    }
    else if (change instanceof mxChildChange)
    {
      mxChildChange cc = (mxChildChange) change;

      // Repaints the parent area if it is a rendered cell (vertex or
      // edge) otherwise only the child area is repainted, same holds
      // if the parent and previous are the same object, in which case
      // only the child area needs to be repainted (change of order)
      if (!ignoreDirty)
      {
        if (cc.getParent() != cc.getPrevious())
        {
          if (model.isVertex(cc.getParent())
              || model.isEdge(cc.getParent()))
          {
            result = getBoundingBox(cc.getParent(), true, true);
          }

          if (model.isVertex(cc.getPrevious())
              || model.isEdge(cc.getPrevious()))
          {
            if (result != null)
            {
              result.add(getBoundingBox(cc.getPrevious(), true,
                  true));
            }
            else
            {
              result = getBoundingBox(cc.getPrevious(), true,
View Full Code Here

    if (group == null)
    {
      group = createGroupCell(cells);
    }

    mxRectangle bounds = getBoundsForGroup(group, cells, border);

    if (cells.length > 0 && bounds != null)
    {
      Object parent = model.getParent(cells[0]);

      model.beginUpdate();
      try
      {
        // Checks if the group has a geometry and
        // creates one if one does not exist
        if (getCellGeometry(group) == null)
        {
          model.setGeometry(group, new mxGeometry());
        }

        // Adds the children into the group and moves
        int index = model.getChildCount(group);
        cellsAdded(cells, group, index, null, null, false);
        cellsMoved(cells, -bounds.getX(), -bounds.getY(), false, true);

        // Adds the group into the parent and resizes
        index = model.getChildCount(parent);
        cellsAdded(new Object[] { group }, parent, index, null, null,
            false);
View Full Code Here

   * cell is a swimlane the title region is added to the bounds.
   */
  public mxRectangle getBoundsForGroup(Object group, Object[] children,
      double border)
  {
    mxRectangle result = getBoundingBoxFromGeometry(children);

    if (result != null)
    {
      if (isSwimlane(group))
      {
        mxRectangle size = getStartSize(group);

        result.setX(result.getX() - size.getWidth());
        result.setY(result.getY() - size.getHeight());
        result.setWidth(result.getWidth() + size.getWidth());
        result.setHeight(result.getHeight() + size.getHeight());
      }

      // Adds the border
      result.setX(result.getX() - border);
      result.setY(result.getY() - border);
View Full Code Here

TOP

Related Classes of com.mxgraph.util.mxRectangle

Copyright © 2018 www.massapicom. 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.