Examples of mxIGraphModel


Examples of com.mxgraph.model.mxIGraphModel

    {
      roots = graph.findTreeRoots(parent);
    }

    this.roots = roots;
    mxIGraphModel model = graph.getModel();

    model.beginUpdate();
    try
    {
      run(parent);

      if (isResizeParent() && !graph.isCellCollapsed(parent))
      {
        graph.updateGroupBounds(new Object[] { parent },
            getParentBorder(), isMoveParent());
      }
    }
    finally
    {
      model.endUpdate();
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

  {
    mxRectangle result = null;

    if (cells != null && cells.length > 0)
    {
      mxIGraphModel model = graph.getModel();

      for (int i = 0; i < cells.length; i++)
      {
        if (model.isVertex(cells[i]) || model.isEdge(cells[i]))
        {
          mxCellState state = getState(cells[i]);

          if (state != null)
          {
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

  {
    removeState(cell);

    if (recurse && (force || cell != currentRoot))
    {
      mxIGraphModel model = graph.getModel();
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        clear(model.getChildAt(cell, i), force, recurse);
      }
    }
    else
    {
      invalidate(cell);
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * Invalidates the state of the given cell, all its descendants and
   * connected edges.
   */
  public void invalidate(Object cell)
  {
    mxIGraphModel model = graph.getModel();
    cell = (cell != null) ? cell : model.getRoot();
    mxCellState state = getState(cell);

    if (state == null || !state.isInvalid())
    {
      if (state != null)
      {
        state.setInvalid(true);
      }

      // Recursively invalidates all descendants
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        Object child = model.getChildAt(cell, i);
        invalidate(child);
      }

      // Propagates invalidation to all connected edges
      int edgeCount = model.getEdgeCount(cell);

      for (int i = 0; i < edgeCount; i++)
      {
        invalidate(model.getEdgeAt(cell, i));
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * @param parentState Object that represents the state of the parent cell.
   * @param cell Cell for which the bounds in the state should be updated.
   */
  public void validateBounds(mxCellState parentState, Object cell)
  {
    mxIGraphModel model = graph.getModel();
    mxCellState state = getState(cell, true);

    if (state != null && state.isInvalid())
    {
      if (!graph.isCellVisible(cell))
      {
        removeState(cell);
      }
      else if (cell != currentRoot && parentState != null)
      {
        state.getAbsoluteOffset().setX(0);
        state.getAbsoluteOffset().setY(0);
        state.setOrigin(new mxPoint(parentState.getOrigin()));
        mxGeometry geo = graph.getCellGeometry(cell);

        if (geo != null)
        {
          if (!model.isEdge(cell))
          {
            mxPoint origin = state.getOrigin();
            mxPoint offset = geo.getOffset();

            if (offset == null)
            {
              offset = EMPTY_POINT;
            }

            if (geo.isRelative())
            {
              origin.setX(origin.getX() + geo.getX()
                  * parentState.getWidth() / scale
                  + offset.getX());
              origin.setY(origin.getY() + geo.getY()
                  * parentState.getHeight() / scale
                  + offset.getY());
            }
            else
            {
              state.setAbsoluteOffset(new mxPoint(scale
                  * offset.getX(), scale * offset.getY()));
              origin.setX(origin.getX() + geo.getX());
              origin.setY(origin.getY() + geo.getY());
            }
          }

          // Updates the cell state's bounds
          state.setX(scale
              * (translate.getX() + state.getOrigin().getX()));
          state.setY(scale
              * (translate.getY() + state.getOrigin().getY()));
          state.setWidth(scale * geo.getWidth());
          state.setHeight(scale * geo.getHeight());

          if (model.isVertex(cell))
          {
            updateVertexLabelOffset(state);
          }

          // Updates the cached label
          updateLabel(state);
        }
      }

      // Applies child offset to origin
      mxPoint offset = graph.getChildOffsetForCell(cell);

      if (offset != null)
      {
        state.getOrigin()
            .setX(state.getOrigin().getX() + offset.getX());
        state.getOrigin()
            .setY(state.getOrigin().getY() + offset.getY());
      }
    }

    // Recursively validates the child bounds
    if (state != null
        && (!graph.isCellCollapsed(cell) || cell == currentRoot))
    {
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        validateBounds(state, model.getChildAt(cell, i));
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * @param cell Cell for which the points in the state should be updated.
   * @return Returns the bounding box for the given cell.
   */
  public mxRectangle validatePoints(mxCellState parentState, Object cell)
  {
    mxIGraphModel model = graph.getModel();
    mxCellState state = getState(cell);
    mxRectangle bbox = null;

    if (state != null)
    {
      if (state.isInvalid())
      {
        mxGeometry geo = graph.getCellGeometry(cell);

        if (geo != null && model.isEdge(cell))
        {
          // Updates the points on the source terminal if its an edge
          mxCellState source = getState(getVisibleTerminal(cell, true));

          if (source != null && model.isEdge(source.getCell())
              && !model.isAncestor(source, cell))
          {
            mxCellState tmp = getState(model.getParent(source
                .getCell()));
            validatePoints(tmp, source);
          }

          // Updates the points on the source terminal if its an edge
          mxCellState target = getState(getVisibleTerminal(cell,
              false));

          if (target != null && model.isEdge(target.getCell())
              && !model.isAncestor(target, cell))
          {
            mxCellState tmp = getState(model.getParent(target
                .getCell()));
            validatePoints(tmp, target);
          }

          updateFixedTerminalPoints(state, source, target);
          updatePoints(state, geo.getPoints(), source, target);
          updateFloatingTerminalPoints(state, source, target);
          updateEdgeBounds(state);
          state.setAbsoluteOffset(getPoint(state, geo));
        }
        else if (geo != null && geo.isRelative() && parentState != null
            && model.isEdge(parentState.getCell()))
        {
          mxPoint origin = getPoint(parentState, geo);

          if (origin != null)
          {
            state.setX(origin.getX());
            state.setY(origin.getY());

            origin.setX((origin.getX() / scale) - translate.getX());
            origin.setY((origin.getY() / scale) - translate.getY());
            state.setOrigin(origin);

            childMoved(parentState, state);
          }
        }

        state.setInvalid(false);
      }

      if (model.isEdge(cell) || model.isVertex(cell))
      {
        updateLabelBounds(state);
        bbox = new mxRectangle(updateBoundingBox(state));
      }
    }

    if (state != null
        && (!graph.isCellCollapsed(cell) || cell == currentRoot))
    {
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        Object child = model.getChildAt(cell, i);
        mxRectangle bounds = validatePoints(state, child);

        if (bounds != null)
        {
          if (bbox == null)
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

    // Children of relative edge children need to validate
    // their bounds after their parent state was updated
    if (!graph.isCellCollapsed(cell) || cell == currentRoot)
    {
      mxIGraphModel model = graph.getModel();
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        validateBounds(child, model.getChildAt(cell, i));
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * should be returned.
   * @return Returns the visible source or target terminal.
   */
  public Object getVisibleTerminal(Object edge, boolean source)
  {
    mxIGraphModel model = graph.getModel();
    Object result = model.getTerminal(edge, source);
    Object best = result;

    while (result != null && result != currentRoot)
    {
      if (!graph.isCellVisible(best) || graph.isCellCollapsed(result))
      {
        best = result;
      }

      result = model.getParent(result);
    }

    // Checks if the result is not a layer
    if (model.getParent(best) == model.getRoot())
    {
      best = null;
    }

    return best;
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * Gets the relative point that describes the given, absolute label
   * position for the given edge state.
   */
  public mxPoint getRelativePoint(mxCellState edgeState, double x, double y)
  {
    mxIGraphModel model = graph.getModel();
    mxGeometry geometry = model.getGeometry(edgeState.getCell());

    if (geometry != null)
    {
      int pointCount = edgeState.getAbsolutePointCount();

View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

      this.up = (root == null);

      if (!up)
      {
        Object tmp = view.getCurrentRoot();
        mxIGraphModel model = view.graph.getModel();

        while (tmp != null)
        {
          if (tmp == root)
          {
            up = true;
            break;
          }

          tmp = model.getParent(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.