Examples of mxGeometry


Examples of com.mxgraph.model.mxGeometry

          if (o1 != null && cells[i] != parent && parent != previous)
          {
            mxCellState oldState = view.getState(previous);
            mxPoint o2 = (oldState != null) ? oldState.getOrigin()
                : zero;
            mxGeometry geo = model.getGeometry(cells[i]);

            if (geo != null)
            {
              double dx = o2.getX() - o1.getX();
              double dy = o2.getY() - o1.getY();

              geo = (mxGeometry) geo.clone();
              geo.translate(dx, dy);

              if (!geo.isRelative() && model.isVertex(cells[i])
                  && !isAllowNegativeCoordinates())
              {
                geo.setX(Math.max(0, geo.getX()));
                geo.setY(Math.max(0, geo.getY()));
              }

              model.setGeometry(cells[i], geo);
            }
          }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

          for (int j = 0; j < edges.length; j++)
          {
            if (!cellSet.contains(edges[j]))
            {
              mxGeometry geo = model.getGeometry(edges[j]);

              if (geo != null)
              {
                mxCellState state = view.getState(edges[j]);

                if (state != null)
                {
                  geo = (mxGeometry) geo.clone();
                  boolean source = view.getVisibleTerminal(
                      edges[j], true) == cells[i];
                  int n = (source) ? 0 : state
                      .getAbsolutePointCount() - 1;
                  mxPoint pt = state.getAbsolutePoint(n);

                  geo.setTerminalPoint(new mxPoint(pt.getX()
                      / scale - tr.getX(), pt.getY()
                      / scale - tr.getY()), source);
                  model.setTerminal(edges[j], null, source);
                  model.setGeometry(edges[j], geo);
                }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   */
  public void swapBounds(Object cell, boolean willCollapse)
  {
    if (cell != null)
    {
      mxGeometry geo = model.getGeometry(cell);

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

        updateAlternateBounds(cell, geo, willCollapse);
        geo.swap();

        model.setGeometry(cell, geo);
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

    {
      model.beginUpdate();
      try
      {
        mxRectangle size = getPreferredSizeForCell(cell);
        mxGeometry geo = model.getGeometry(cell);

        if (size != null && geo != null)
        {
          boolean collapsed = isCellCollapsed(cell);
          geo = (mxGeometry) geo.clone();

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

            if (cellStyle == null)
            {
              cellStyle = "";
            }

            if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL,
                true))
            {
              cellStyle = mxUtils.setStyle(cellStyle,
                  mxConstants.STYLE_STARTSIZE,
                  String.valueOf(size.getHeight() + 8));

              if (collapsed)
              {
                geo.setHeight(size.getHeight() + 8);
              }

              geo.setWidth(size.getWidth());
            }
            else
            {
              cellStyle = mxUtils.setStyle(cellStyle,
                  mxConstants.STYLE_STARTSIZE,
                  String.valueOf(size.getWidth() + 8));

              if (collapsed)
              {
                geo.setWidth(size.getWidth() + 8);
              }

              geo.setHeight(size.getHeight());
            }

            model.setStyle(cell, cellStyle);
          }
          else
          {
            geo.setWidth(size.getWidth());
            geo.setHeight(size.getHeight());
          }

          if (!ignoreChildren && !collapsed)
          {
            mxRectangle bounds = view.getBounds(mxGraphModel
                .getChildren(model, cell));

            if (bounds != null)
            {
              mxPoint tr = view.getTranslate();
              double scale = view.getScale();

              double width = (bounds.getX() + bounds.getWidth())
                  / scale - geo.getX() - tr.getX();
              double height = (bounds.getY() + bounds.getHeight())
                  / scale - geo.getY() - tr.getY();

              geo.setWidth(Math.max(geo.getWidth(), width));
              geo.setHeight(Math.max(geo.getHeight(), height));
            }
          }

          cellsResized(new Object[] { cell },
              new mxRectangle[] { geo });
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      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()));
              geo.setY(Math.max(0, geo.getY()));
            }

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

            if (isExtendParent(cells[i]))
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

  public void extendParent(Object cell)
  {
    if (cell != null)
    {
      Object parent = model.getParent(cell);
      mxGeometry p = model.getGeometry(parent);

      if (parent != null && p != null && !isCellCollapsed(parent))
      {
        mxGeometry geo = model.getGeometry(cell);

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

          p.setWidth(Math.max(p.getWidth(),
              geo.getX() + geo.getWidth()));
          p.setHeight(Math.max(p.getHeight(),
              geo.getY() + geo.getHeight()));

          cellsResized(new Object[] { parent },
              new mxRectangle[] { p });
        }
      }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * Translates the geometry of the given cell and stores the new,
   * translated geometry in the model as an atomic change.
   */
  public void translateCell(Object cell, double dx, double dy)
  {
    mxGeometry geo = model.getGeometry(cell);

    if (geo != null)
    {
      geo = (mxGeometry) geo.clone();
      geo.translate(dx, dy);

      if (!geo.isRelative() && model.isVertex(cell)
          && !isAllowNegativeCoordinates())
      {
        geo.setX(Math.max(0, geo.getX()));
        geo.setY(Math.max(0, geo.getY()));
      }

      if (geo.isRelative() && !model.isEdge(cell))
      {
        if (geo.getOffset() == null)
        {
          geo.setOffset(new mxPoint(dx, dy));
        }
        else
        {
          mxPoint offset = geo.getOffset();

          offset.setX(offset.getX() + dx);
          offset.setY(offset.getY() + dy);
        }
      }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      {
        return getMaximumGraphBounds();
      }
      else if (parent != null && parent != getDefaultParent())
      {
        mxGeometry g = model.getGeometry(parent);

        if (g != null)
        {
          double x = 0;
          double y = 0;
          double w = g.getWidth();
          double h = g.getHeight();

          if (isSwimlane(parent))
          {
            mxRectangle size = getStartSize(parent);
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   */
  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.model.mxGeometry

  /**
   * Resets the control points of the given edge.
   */
  public Object resetEdge(Object edge)
  {
    mxGeometry geo = model.getGeometry(edge);

    if (geo != null)
    {
      // Resets the control points
      List<mxPoint> points = geo.getPoints();

      if (points != null && !points.isEmpty())
      {
        geo = (mxGeometry) geo.clone();
        geo.setPoints(null);
        model.setGeometry(edge, geo);
      }
    }

    return edge;
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.