Package com.mxgraph.model

Examples of com.mxgraph.model.mxGeometry


    if (targetState != null)
    {
      ((mxICell) targetState.getCell()).insertEdge(cell, false);
    }

    mxGeometry geo = graph.getCellGeometry(previewState.getCell());

    geo.setTerminalPoint(startPoint, true);
    geo.setTerminalPoint(transformScreenPoint(x, y), false);

    revalidate(previewState);
    fireEvent(new mxEventObject(mxEvent.CONTINUE, "event", e, "x", x, "y",
        y));
View Full Code Here


      else
      {
        // Clones the cell state and updates the absolute points using
        // the current state of this handle. This is required for
        // computing the correct perimeter points and edge style.
        mxGeometry geometry = graphComponent.getGraph()
            .getCellGeometry(state.getCell());
        mxCellState clone = (mxCellState) state.clone();
        List<mxPoint> points = geometry.getPoints();
        mxGraphView view = clone.getView();

        if (isSource || isTarget)
        {
          marker.process(e);
View Full Code Here

   * 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())
View Full Code Here

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

            .setX(state.getOrigin().getX() + offset.getX());
        state.getOrigin()
            .setY(state.getOrigin().getY() + offset.getY());
      }

      mxGeometry geo = graph.getCellGeometry(state.getCell());

      if (geo != null)
      {
        if (!model.isEdge(state.getCell()))
        {
          mxPoint origin = state.getOrigin();
          offset = geo.getOffset();

          if (offset == null)
          {
            offset = EMPTY_POINT;
          }

          if (geo.isRelative() && pState != null)
          {
            if (model.isEdge(pState.getCell()))
            {
              mxPoint orig = getPoint(pState, geo);
             
              if (orig != null)
              {
                origin.setX(origin.getX()
                    + (orig.getX() / scale) - pState.getOrigin().getX()
                    - translate.getX());
                origin.setY(origin.getY()
                    + (orig.getY() / scale) - pState.getOrigin().getY()
                    - translate.getY());
              }
            }
            else
            {
              origin.setX(origin.getX() + geo.getX()
                  * pState.getWidth() / scale + offset.getX());
              origin.setY(origin.getY() + geo.getY()
                  * pState.getHeight() / scale
                  + offset.getY());
            }
          }
          else
          {
            state.setAbsoluteOffset(new mxPoint(scale
                * offset.getX(), scale * offset.getY()));
            origin.setX(origin.getX() + geo.getX());
            origin.setY(origin.getY() + geo.getY());
          }
        }

        state.setX(scale
            * (translate.getX() + state.getOrigin().getX()));
        state.setY(scale
            * (translate.getY() + state.getOrigin().getY()));
        state.setWidth(scale * geo.getWidth());
        state.setHeight(scale * geo.getHeight());

        if (model.isVertex(state.getCell()))
        {
          updateVertexState(state, geo);
        }
View Full Code Here

      // labels or no wrapping is applied if the width is set to 0
      mxRectangle vertexBounds = state;

      if (graph.getModel().isEdge(cell))
      {
        mxGeometry geo = graph.getCellGeometry(cell);

        if (geo != null && geo.getWidth() > 0)
        {
          vertexBounds = new mxRectangle(0, 0, geo.getWidth()
              * this.getScale(), 0);
        }
        else
        {
          vertexBounds = null;
View Full Code Here

    }

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

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

   * 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

     * Prints out some useful information about the cell in the tooltip.
     */
    public String getToolTipForCell(Object cell)
    {
      String tip = "<html>";
      mxGeometry geo = getModel().getGeometry(cell);
      mxCellState state = getView().getState(cell);

      if (getModel().isEdge(cell))
      {
        tip += "points={";

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

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

            while (it.hasNext())
            {
              mxPoint point = it.next();
              tip += "[x=" + numberFormat.format(point.getX())
                  + ",y=" + numberFormat.format(point.getY())
                  + "],";
            }

            tip = tip.substring(0, tip.length() - 1);
          }
        }

        tip += "}<br>";
        tip += "absPoints={";

        if (state != null)
        {

          for (int i = 0; i < state.getAbsolutePointCount(); i++)
          {
            mxPoint point = state.getAbsolutePoint(i);
            tip += "[x=" + numberFormat.format(point.getX())
                + ",y=" + numberFormat.format(point.getY())
                + "],";
          }

          tip = tip.substring(0, tip.length() - 1);
        }

        tip += "}";
      }
      else
      {
        tip += "geo=[";

        if (geo != null)
        {
          tip += "x=" + numberFormat.format(geo.getX()) + ",y="
              + numberFormat.format(geo.getY()) + ",width="
              + numberFormat.format(geo.getWidth()) + ",height="
              + numberFormat.format(geo.getHeight());
        }

        tip += "]<br>";
        tip += "state=[";

View Full Code Here

    for (int i = 0; i < numRows; i++)
    {
      for (int j = 0; j < numColumns; j++)
      {
        Object currVertex = vertices[i * numColumns + j];
        mxGeometry geometry = model.getGeometry(currVertex);
        geometry.setX(j * xSpacing);
        geometry.setY(i * ySpacing);
      }
    }
  };
 
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.