Package com.mxgraph.model

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


   */
  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

  /**
   * 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

        for (int i = 0; i < cells.length; i++)
        {
          if (model.isEdge(cells[i]))
          {
            mxGeometry geo = model.getGeometry(cells[i]);

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

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

                double dx = -pstate.getOrigin().getX();
                double dy = -pstate.getOrigin().getY();

                Object src = model.getTerminal(cells[i], true);

                if (src != null
                    && isCellDisconnectable(cells[i], src,
                        true))
                {
                  while (src != null && !hash.contains(src))
                  {
                    src = model.getParent(src);
                  }

                  if (src == null)
                  {
                    mxPoint pt = state.getAbsolutePoint(0);
                    geo.setTerminalPoint(
                        new mxPoint(pt.getX() / scale
                            - tr.getX() + dx, pt
                            .getY()
                            / scale
                            - tr.getY() + dy), true);
                    model.setTerminal(cells[i], null, true);
                  }
                }

                Object trg = model.getTerminal(cells[i], false);

                if (trg != null
                    && isCellDisconnectable(cells[i], trg,
                        false))
                {
                  while (trg != null && !hash.contains(trg))
                  {
                    trg = model.getParent(trg);
                  }

                  if (trg == null)
                  {
                    int n = state.getAbsolutePointCount() - 1;
                    mxPoint pt = state.getAbsolutePoint(n);
                    geo.setTerminalPoint(
                        new mxPoint(pt.getX() / scale
                            - tr.getX() + dx, pt
                            .getY()
                            / scale
                            - tr.getY() + dy),
View Full Code Here

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

          if (result == null)
          {
            result = new mxRectangle(geo);
          }
View Full Code Here

   * @param cell Cell whose locked state should be returned.
   * @return Returns true if the given cell is locked.
   */
  public boolean isCellLocked(Object cell)
  {
    mxGeometry geometry = model.getGeometry(cell);

    return isCellsLocked()
        || (geometry != null && model.isVertex(cell) && geometry
            .isRelative());
  }
View Full Code Here

      // 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

   * editor.
   */
  protected boolean useLabelBounds(mxCellState state)
  {
    mxIGraphModel model = state.getView().getGraph().getModel();
    mxGeometry geometry = model.getGeometry(state.getCell());

    return ((geometry != null && geometry.getOffset() != null
        && !geometry.isRelative() && (geometry.getOffset().getX() != 0 || geometry
        .getOffset().getY() != 0)) || model.isEdge(state.getCell()));
  }
View Full Code Here

      Object cell = state.getCell();

      if (model.isVertex(cell))
      {
        state.getView().updateCellState(state);
        mxGeometry geo = graph.getCellGeometry(cell);

        // Moves selection cells and non-relative vertices in
        // the first phase so that edge terminal points will
        // be updated in the second phase
        if ((dx != 0 || dy != 0) && geo != null
            && (!geo.isRelative() || deltas.get(state) != null))
        {
          state.setX(state.getX() + dx);
          state.setY(state.getY() + dy);
        }
      }
View Full Code Here

      }
     
      dirty = state.getView().getBoundingBox(state, false);

      // Moves selection vertices which are relative
      mxGeometry geo = graph.getCellGeometry(cell);

      if ((dx != 0 || dy != 0)
          && geo != null
          && geo.isRelative()
          && model.isVertex(cell)
          && (parentState == null
              || model.isVertex(parentState.getCell()) || deltas
              .get(state) != null))
      {
View Full Code Here

TOP

Related Classes of com.mxgraph.model.mxGeometry

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.