Examples of mxGeometry


Examples of com.mxgraph.model.mxGeometry

  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;
        }
      }
    }

    // Applies the size of the refernece to the newly added swimlane
    if (geo != null)
    {
      resizeSwimlane(swimlane, geo.getWidth(), geo.getHeight());
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

        // 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)
              {
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

    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);
          }
        }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      // Finds the required coordinate for the alignment
      if (param == null)
      {
        for (int i = 0; i < cells.length; i++)
        {
          mxGeometry geo = getCellGeometry(cells[i]);

          if (geo != null && !model.isEdge(cells[i]))
          {
            if (param == null)
            {
              if (align == null
                  || align.equals(mxConstants.ALIGN_LEFT))
              {
                param = geo.getX();
              }
              else if (align.equals(mxConstants.ALIGN_CENTER))
              {
                param = geo.getX() + geo.getWidth() / 2;
                break;
              }
              else if (align.equals(mxConstants.ALIGN_RIGHT))
              {
                param = geo.getX() + geo.getWidth();
              }
              else if (align.equals(mxConstants.ALIGN_TOP))
              {
                param = geo.getY();
              }
              else if (align.equals(mxConstants.ALIGN_MIDDLE))
              {
                param = geo.getY() + geo.getHeight() / 2;
                break;
              }
              else if (align.equals(mxConstants.ALIGN_BOTTOM))
              {
                param = geo.getY() + geo.getHeight();
              }
            }
            else
            {
              double tmp = Double.parseDouble(String
                  .valueOf(param));

              if (align == null
                  || align.equals(mxConstants.ALIGN_LEFT))
              {
                param = Math.min(tmp, geo.getX());
              }
              else if (align.equals(mxConstants.ALIGN_RIGHT))
              {
                param = Math.max(tmp,
                    geo.getX() + geo.getWidth());
              }
              else if (align.equals(mxConstants.ALIGN_TOP))
              {
                param = Math.min(tmp, geo.getY());
              }
              else if (align.equals(mxConstants.ALIGN_BOTTOM))
              {
                param = Math.max(tmp,
                    geo.getY() + geo.getHeight());
              }
            }
          }
        }
      }

      // Aligns the cells to the coordinate
      model.beginUpdate();
      try
      {
        double tmp = Double.parseDouble(String.valueOf(param));

        for (int i = 0; i < cells.length; i++)
        {
          mxGeometry geo = getCellGeometry(cells[i]);

          if (geo != null && !model.isEdge(cells[i]))
          {
            geo = (mxGeometry) geo.clone();

            if (align == null
                || align.equals(mxConstants.ALIGN_LEFT))
            {
              geo.setX(tmp);
            }
            else if (align.equals(mxConstants.ALIGN_CENTER))
            {
              geo.setX(tmp - geo.getWidth() / 2);
            }
            else if (align.equals(mxConstants.ALIGN_RIGHT))
            {
              geo.setX(tmp - geo.getWidth());
            }
            else if (align.equals(mxConstants.ALIGN_TOP))
            {
              geo.setY(tmp);
            }
            else if (align.equals(mxConstants.ALIGN_MIDDLE))
            {
              geo.setY(tmp - geo.getHeight() / 2);
            }
            else if (align.equals(mxConstants.ALIGN_BOTTOM))
            {
              geo.setY(tmp - geo.getHeight());
            }

            model.setGeometry(cells[i], geo);

            if (isResetEdgesOnMove())
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      {
        // 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);
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * @param cells
   * @return Returns a new group cell.
   */
  public Object createGroupCell(Object[] cells)
  {
    mxCell group = new mxCell("", new mxGeometry(), null);
    group.setVertex(true);
    group.setConnectable(false);

    return group;
  }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

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

        if (geo != null)
        {
          Object[] children = getChildCells(cells[i]);

          if (children != null && children.length > 0)
          {
            mxRectangle childBounds = getBoundingBoxFromGeometry(children);

            if (childBounds.getWidth() > 0
                && childBounds.getHeight() > 0)
            {
              mxRectangle size = (isSwimlane(cells[i])) ? getStartSize(cells[i])
                  : new mxRectangle();

              geo = (mxGeometry) geo.clone();

              if (moveParent)
              {
                geo.setX(geo.getX() + childBounds.getX()
                    - size.getWidth() - border);
                geo.setY(geo.getY() + childBounds.getY()
                    - size.getHeight() - border);
              }

              geo.setWidth(childBounds.getWidth()
                  + size.getWidth() + 2 * border);
              geo.setHeight(childBounds.getHeight()
                  + size.getHeight() + 2 * border);

              model.setGeometry(cells[i], geo);
              moveCells(children,
                  -childBounds.getX() + size.getWidth()
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

          {
            clones[i] = null;
          }
          else
          {
            mxGeometry g = model.getGeometry(clones[i]);

            if (g != null)
            {
              mxCellState state = view.getState(cells[i]);
              mxCellState pstate = view.getState(model
                  .getParent(cells[i]));

              if (state != null && pstate != null)
              {
                double dx = pstate.getOrigin().getX();
                double dy = pstate.getOrigin().getY();

                if (model.isEdge(clones[i]))
                {
                  // Checks if the source is cloned or sets the terminal point
                  Object src = model.getTerminal(cells[i],
                      true);

                  while (src != null && !tmp.contains(src))
                  {
                    src = model.getParent(src);
                  }

                  if (src == null)
                  {
                    mxPoint pt = state.getAbsolutePoint(0);
                    g.setTerminalPoint(
                        new mxPoint(pt.getX() / scale
                            - trans.getX(), pt
                            .getY()
                            / scale
                            - trans.getY()), true);
                  }

                  // Checks if the target is cloned or sets the terminal point
                  Object trg = model.getTerminal(cells[i],
                      false);

                  while (trg != null && !tmp.contains(trg))
                  {
                    trg = model.getParent(trg);
                  }

                  if (trg == null)
                  {
                    mxPoint pt = state
                        .getAbsolutePoint(state
                            .getAbsolutePointCount() - 1);
                    g.setTerminalPoint(
                        new mxPoint(pt.getX() / scale
                            - trans.getX(), pt
                            .getY()
                            / scale
                            - trans.getY()), false);
                  }

                  // Translates the control points
                  List<mxPoint> points = g.getPoints();

                  if (points != null)
                  {
                    Iterator<mxPoint> it = points
                        .iterator();

                    while (it.hasNext())
                    {
                      mxPoint pt = it.next();
                      pt.setX(pt.getX() + dx);
                      pt.setY(pt.getY() + dy);
                    }
                  }
                }
                else
                {
                  g.setX(g.getX() + dx);
                  g.setY(g.getY() + dy);
                }
              }
            }
          }
        }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * @return Returns the new vertex to be inserted.
   */
  public Object createVertex(Object parent, String id, Object value,
      double x, double y, double width, double height, String style)
  {
    mxGeometry geometry = new mxGeometry(x, y, width, height);
    mxCell vertex = new mxCell(value, geometry, style);

    vertex.setId(id);
    vertex.setVertex(true);
    vertex.setConnectable(true);
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * @return Returns the new edge to be inserted.
   */
  public Object createEdge(Object parent, String id, Object value,
      Object source, Object target, String style)
  {
    mxCell edge = new mxCell(value, new mxGeometry(), style);

    edge.setId(id);
    edge.setEdge(true);
    edge.getGeometry().setRelative(true);

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.