Examples of mxGeometry


Examples of com.mxgraph.model.mxGeometry

    }

    if (pt == null && terminal == null)
    {
      mxPoint orig = edge.getOrigin();
      mxGeometry geo = graph.getCellGeometry(edge.cell);
      pt = geo.getTerminalPoint(source);

      if (pt != null)
      {
        pt = new mxPoint(scale
            * (translate.getX() + pt.getX() + orig.getX()), scale
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * 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();

      if (geometry.isRelative() && pointCount > 1)
      {
        double totalLength = edgeState.getLength();
        double[] segments = edgeState.getSegments();

        // Works which line segment the point of the label is closest to
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

          double x0 = graph.getGridSize();
          double y0 = x0;

          if (!moveTree || model.getParent(parent) == model.getRoot())
          {
            mxGeometry g = model.getGeometry(root);

            if (g != null)
            {
              x0 = g.getX();
              y0 = g.getY();
            }
          }

          mxRectangle bounds = null;

          if (horizontal)
          {
            bounds = horizontalLayout(node, x0, y0, null);
          }
          else
          {
            bounds = verticalLayout(node, null, x0, y0, null);
          }

          if (bounds != null)
          {
            double dx = 0;
            double dy = 0;

            if (bounds.getX() < 0)
            {
              dx = Math.abs(x0 - bounds.getX());
            }

            if (bounds.getY() < 0)
            {
              dy = Math.abs(y0 - bounds.getY());
            }

            if (parent != null)
            {
              mxRectangle size = graph.getStartSize(parent);
              dx += size.getWidth();
              dy += size.getHeight();

              // Resize parent swimlane
              if (resizeParent && !graph.isCellCollapsed(parent))
              {
                mxGeometry g = model.getGeometry(parent);

                if (g != null)
                {
                  double width = bounds.getWidth()
                      + size.getWidth() - bounds.getX()
                      + 2 * x0;
                  double height = bounds.getHeight()
                      + size.getHeight() - bounds.getY()
                      + 2 * y0;

                  g = (mxGeometry) g.clone();

                  if (g.getWidth() > width)
                  {
                    dx += (g.getWidth() - width) / 2;
                  }
                  else
                  {
                    g.setWidth(width);
                  }

                  if (g.getHeight() > height)
                  {
                    if (horizontal)
                    {
                      dy += (g.getHeight() - height) / 2;
                    }
                  }
                  else
                  {
                    g.setHeight(height);
                  }

                  model.setGeometry(parent, g);
                }
              }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      Double miny = null;

      for (int i = 0; i < vertexArray.length; i++)
      {
        Object vertex = vertexArray[i];
        mxGeometry geo = model.getGeometry(vertex);

        if (geo != null)
        {
          cellLocation[i][0] -= geo.getWidth() / 2.0;
          cellLocation[i][1] -= geo.getHeight() / 2.0;

          double x = graph.snap(cellLocation[i][0]);
          double y = graph.snap(cellLocation[i][1]);
          setVertexLocation(vertex, x, y);
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

   * 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

Examples of com.mxgraph.model.mxGeometry

  public Object createTargetVertex(MouseEvent e, Object source)
  {
    mxGraph graph = graphComponent.getGraph();
    Object clone = graph.cloneCells(new Object[] { source })[0];
    mxIGraphModel model = graph.getModel();
    mxGeometry geo = model.getGeometry(clone);

    if (geo != null)
    {
      mxPoint point = graphComponent.getPointForEvent(e);
      geo.setX(graph.snap(point.getX() - geo.getWidth() / 2));
      geo.setY(graph.snap(point.getY() - geo.getHeight() / 2));
    }

    return clone;
  }
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

                mxCellState pstate = graph.getView().getState(
                    dropTarget);

                if (pstate != null)
                {
                  mxGeometry geo = graph.getModel()
                      .getGeometry(vertex);

                  mxPoint origin = pstate.getOrigin();
                  geo.setX(geo.getX() - origin.getX());
                  geo.setY(geo.getY() - origin.getY());
                }
              }
              else
              {
                dropTarget = graph.getDefaultParent();
View Full Code Here

Examples of com.mxgraph.model.mxGeometry

      if (model.isVertex(cell))
      {
        // LATER: Use hashtable to store initial state bounds
        state.setInvalid(true);
        graph.getView().validateBounds(parentState, cell);
        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

Examples of com.mxgraph.model.mxGeometry

      // (relative) positions of any (relative) children
      state.setInvalid(true);
      dirty = graph.getView().validatePoints(parentState, cell);

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

Examples of com.mxgraph.model.mxGeometry

   *
   */
  protected void moveLabel(MouseEvent e)
  {
    mxGraph graph = graphComponent.getGraph();
    mxGeometry geometry = graph.getModel().getGeometry(state.getCell());

    if (geometry != null)
    {
      double scale = graph.getView().getScale();
      mxPoint pt = new mxPoint(e.getPoint());

      if (gridEnabledEvent)
      {
        pt = graphComponent.snapScaledPoint(pt);
      }

      double dx = (pt.getX() - first.x) / scale;
      double dy = (pt.getY() - first.y) / scale;

      if (constrainedEvent)
      {
        if (Math.abs(dx) > Math.abs(dy))
        {
          dy = 0;
        }
        else
        {
          dx = 0;
        }
      }

      mxPoint offset = geometry.getOffset();

      if (offset == null)
      {
        offset = new mxPoint();
      }

      dx += offset.getX();
      dy += offset.getY();

      geometry = (mxGeometry) geometry.clone();
      geometry.setOffset(new mxPoint(Math.round(dx), Math.round(dy)));
      graph.getModel().setGeometry(state.getCell(), geometry);
    }
  }
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.