Examples of mxIGraphModel


Examples of com.mxgraph.model.mxIGraphModel

   */
  protected void cellsResized(Object[] cells)
  {
    if (cells != null)
    {
      mxIGraphModel model = this.getGraph().getModel();
     
      model.beginUpdate();
      try
      {
        // Finds the top-level swimlanes and adds offsets
        for (int i = 0; i < cells.length; i++)
        {
          if (!this.isSwimlaneIgnored(cells[i]))
          {
            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());
            }
          }
        }
      }
      finally
      {
        model.endUpdate();
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * on <horizontal>. If <horizontal> is true, then the width is set, otherwise,
   * the height is set.
   */
  protected void resizeSwimlane(Object swimlane, double w, double h)
  {
    mxIGraphModel model = getGraph().getModel();

    model.beginUpdate();
    try
    {
      if (!this.isSwimlaneIgnored(swimlane))
      {
        mxGeometry geo = model.getGeometry(swimlane);

        if (geo != null)
        {
          boolean horizontal = isCellHorizontal(swimlane);

          if ((horizontal && geo.getHeight() != h)
              || (!horizontal && geo.getWidth() != w))
          {
            geo = (mxGeometry) geo.clone();

            if (horizontal)
            {
              geo.setHeight(h);
            }
            else
            {
              geo.setWidth(w);
            }

            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++)
      {
        Object child = model.getChildAt(swimlane, i);
        resizeSwimlane(child, w, h);
      }
    }
    finally
    {
      model.endUpdate();
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   */
  protected void cellsAdded(Object[] cells)
  {
    if (cells != null)
    {
      mxIGraphModel model = getGraph().getModel();

      model.beginUpdate();
      try
      {
        for (int i = 0; i < cells.length; i++)
        {
          if (!isSwimlaneIgnored(cells[i]))
          {
            swimlaneAdded(cells[i]);
          }
        }
      }
      finally
      {
        model.endUpdate();
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * sibling can be found then the parent swimlane is resized so that the
   * new swimlane fits into the parent swimlane.
   */
  protected void swimlaneAdded(Object swimlane)
  {
    mxIGraphModel model = getGraph().getModel();
    Object parent = model.getParent(swimlane);
    int childCount = model.getChildCount(parent);
    mxGeometry geo = null;

    // Finds the first valid sibling swimlane as reference
    for (int i = 0; i < childCount; i++)
    {
      Object child = model.getChildAt(parent, i);

      if (child != swimlane && !this.isSwimlaneIgnored(child))
      {
        geo = model.getGeometry(child);

        if (geo != null)
        {
          break;
        }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

    tmp.setInvalid(true);

    graph.getView().validateBounds(pState, cell);
    graph.getView().validatePoints(pState, cell);

    mxIGraphModel model = graph.getModel();
    int childCount = model.getChildCount(cell);

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

Examples of com.mxgraph.model.mxIGraphModel

    boolean source = isSource(index);

    if (source || isTarget(index))
    {
      mxGraph graph = graphComponent.getGraph();
      mxIGraphModel model = graph.getModel();
      Object terminal = model.getTerminal(state.getCell(), source);

      if ((terminal == null && !graph.isTerminalPointMovable(
          state.getCell(), source))
          || (terminal != null && !graph.isCellDisconnectable(
              state.getCell(), terminal, source)))
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

  /**
   * Moves the edges control point with the given index to the given point.
   */
  protected void movePoint(Object edge, int pointIndex, mxPoint point)
  {
    mxIGraphModel model = graphComponent.getGraph().getModel();
    mxGeometry geometry = model.getGeometry(edge);

    if (geometry != null)
    {
      model.beginUpdate();
      try
      {
        geometry = (mxGeometry) geometry.clone();

        if (isSource(index) || isTarget(index))
        {
          connect(edge, null, isSource(index), false);
          geometry.setTerminalPoint(point, isSource(index));
        }
        else
        {
          List<mxPoint> pts = geometry.getPoints();

          if (pts == null)
          {
            pts = new ArrayList<mxPoint>();
            geometry.setPoints(pts);
          }

          if (pts != null)
          {
            if (pointIndex <= pts.size())
            {
              pts.set(pointIndex - 1, point);
            }
            else if (pointIndex - 1 <= pts.size())
            {
              pts.add(pointIndex - 1, point);
            }
          }
        }

        model.setGeometry(edge, geometry);
      }
      finally
      {
        model.endUpdate();
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   */
  protected void connect(Object edge, Object terminal, boolean isSource,
      boolean isClone)
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();

    model.beginUpdate();
    try
    {
      if (isClone)
      {
        Object clone = graph.cloneCells(new Object[] { edge })[0];

        Object parent = model.getParent(edge);
        graph.addCells(new Object[] { clone }, parent);

        Object other = model.getTerminal(edge, !isSource);
        graph.connectCell(clone, other, !isSource);

        graph.setSelectionCell(clone);
        edge = clone;
      }

      // Passes an empty constraint to reset constraint information
      graph.connectCell(edge, terminal, isSource,
          new mxConnectionConstraint());
    }
    finally
    {
      model.endUpdate();
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * Moves the label to the given position.
   */
  protected void moveLabelTo(mxCellState edgeState, double x, double y)
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();
    mxGeometry geometry = model.getGeometry(state.getCell());

    if (geometry != null)
    {
      geometry = (mxGeometry) geometry.clone();

      // Resets the relative location stored inside the geometry
      mxPoint pt = graph.getView().getRelativePoint(edgeState, x, y);
      geometry.setX(pt.getX());
      geometry.setY(pt.getY());

      // Resets the offset inside the geometry to find the offset
      // from the resulting point
      double scale = graph.getView().getScale();
      geometry.setOffset(new mxPoint(0, 0));
      pt = graph.getView().getPoint(edgeState, geometry);
      geometry.setOffset(new mxPoint(Math.round((x - pt.getX()) / scale),
          Math.round((y - pt.getY()) / scale)));

      model.setGeometry(edgeState.getCell(), geometry);
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

          mxICell dropCell = (mxICell) cells[0];

          if (targetCell.isVertex() == dropCell.isVertex()
              || targetCell.isEdge() == dropCell.isEdge())
          {
            mxIGraphModel model = graph.getModel();
            model.setStyle(target, model.getStyle(cells[0]));
            graph.setSelectionCell(target);

            return null;
          }
        }
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.