Package com.mxgraph.util

Examples of com.mxgraph.util.mxPoint


    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


          {
            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=[";

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

        tip += "]";
      }

      mxPoint trans = getView().getTranslate();

      tip += "<br>scale=" + numberFormat.format(getView().getScale())
          + ", translate=[x=" + numberFormat.format(trans.getX())
          + ",y=" + numberFormat.format(trans.getY()) + "]";
      tip += "</html>";

      return tip;
    }
View Full Code Here

    if (strokeColor != null && strokeWidth > 0)
    {
      // Draws the start marker
      Object marker = style.get(mxConstants.STYLE_STARTARROW);

      mxPoint pt = pts.get(1);
      mxPoint p0 = pts.get(0);
      mxPoint offset = null;

      if (marker != null)
      {
        float size = (mxUtils.getFloat(style,
            mxConstants.STYLE_STARTSIZE,
            mxConstants.DEFAULT_MARKERSIZE));
        offset = drawMarker(group, marker, pt, p0, size, tmpStroke,
            strokeColor);
      }
      else
      {
        double dx = pt.getX() - p0.getX();
        double dy = pt.getY() - p0.getY();

        double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
        double nx = dx * strokeWidth / dist;
        double ny = dy * strokeWidth / dist;

        offset = new mxPoint(nx / 2, ny / 2);
      }

      // Applies offset to the point
      if (offset != null)
      {
        p0 = (mxPoint) p0.clone();
        p0.setX(p0.getX() + offset.getX());
        p0.setY(p0.getY() + offset.getY());

        offset = null;
      }

      // Draws the end marker
      marker = style.get(mxConstants.STYLE_ENDARROW);

      pt = pts.get(pts.size() - 2);
      mxPoint pe = pts.get(pts.size() - 1);

      if (marker != null)
      {
        float size = (mxUtils.getFloat(style,
            mxConstants.STYLE_ENDSIZE,
            mxConstants.DEFAULT_MARKERSIZE));
        offset = drawMarker(group, marker, pt, pe, size, tmpStroke,
            strokeColor);
      }
      else
      {
        double dx = pt.getX() - p0.getX();
        double dy = pt.getY() - p0.getY();

        double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
        double nx = dx * strokeWidth / dist;
        double ny = dy * strokeWidth / dist;

        offset = new mxPoint(nx / 2, ny / 2);
      }

      // Applies offset to the point
      if (offset != null)
      {
        pe = (mxPoint) pe.clone();
        pe.setX(pe.getX() + offset.getX());
        pe.setY(pe.getY() + offset.getY());

        offset = null;
      }

      // Draws the line segments
      double arcSize = mxConstants.LINE_ARCSIZE * scale;
      pt = p0;
      String d = "M " + pt.getX() + " " + pt.getY();

      for (int i = 1; i < pts.size() - 1; i++)
      {
        mxPoint tmp = pts.get(i);
        double dx = pt.getX() - tmp.getX();
        double dy = pt.getY() - tmp.getY();

        if ((rounded && i < pts.size() - 1) && (dx != 0 || dy != 0))
        {
          // Draws a line from the last point to the current
          // point with a spacing of size off the current point
          // into direction of the last point
          double dist = Math.sqrt(dx * dx + dy * dy);
          double nx1 = dx * Math.min(arcSize, dist / 2) / dist;
          double ny1 = dy * Math.min(arcSize, dist / 2) / dist;

          double x1 = tmp.getX() + nx1;
          double y1 = tmp.getY() + ny1;
          d += " L " + x1 + " " + y1;

          // Draws a curve from the last point to the current
          // point with a spacing of size off the current point
          // into direction of the next point
          mxPoint next = pts.get(i + 1);
          dx = next.getX() - tmp.getX();
          dy = next.getY() - tmp.getY();

          dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
          double nx2 = dx * Math.min(arcSize, dist / 2) / dist;
          double ny2 = dy * Math.min(arcSize, dist / 2) / dist;

          double x2 = tmp.getX() + nx2;
          double y2 = tmp.getY() + ny2;

          d += " Q " + tmp.getX() + " " + tmp.getY() + " " + x2 + " "
              + y2;
          tmp = new mxPoint(x2, y2);
        }
        else
        {
          d += " L " + tmp.getX() + " " + tmp.getY();
        }
View Full Code Here

    if (scale != this.scale || dx != translate.getX()
        || dy != translate.getY())
    {
      this.scale = scale;
      translate = new mxPoint(dx, dy);

      if (isEventsEnabled())
      {
        revalidate();
      }
View Full Code Here

   * Draws the specified marker as a child path in the given parent.
   */
  public mxPoint drawMarker(Element parent, Object type, mxPoint p0,
      mxPoint pe, float size, float strokeWidth, String color)
  {
    mxPoint offset = null;

    // Computes the norm and the inverse norm
    double dx = pe.getX() - p0.getX();
    double dy = pe.getY() - p0.getY();

View Full Code Here

      }
      else if (cell != currentRoot && parentState != null)
      {
        state.getAbsoluteOffset().setX(0);
        state.getAbsoluteOffset().setY(0);
        state.setOrigin(new mxPoint(parentState.getOrigin()));
        mxGeometry geo = graph.getCellGeometry(cell);

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

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

            if (geo.isRelative())
            {
              origin.setX(origin.getX() + geo.getX()
                  * parentState.getWidth() / scale
                  + offset.getX());
              origin.setY(origin.getY() + geo.getY()
                  * parentState.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());
            }
          }

          // Updates the cell state's bounds
          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(cell))
          {
            updateVertexLabelOffset(state);
          }

          // Updates the cached label
          updateLabel(state);
        }
      }

      // Applies child offset to origin
      mxPoint offset = graph.getChildOffsetForCell(cell);

      if (offset != null)
      {
        state.getOrigin()
            .setX(state.getOrigin().getX() + offset.getX());
        state.getOrigin()
            .setY(state.getOrigin().getY() + offset.getY());
      }
    }

    // Recursively validates the child bounds
    if (state != null
View Full Code Here

          state.setAbsoluteOffset(getPoint(state, geo));
        }
        else if (geo != null && geo.isRelative() && parentState != null
            && model.isEdge(parentState.getCell()))
        {
          mxPoint origin = getPoint(parentState, geo);

          if (origin != null)
          {
            state.setX(origin.getX());
            state.setY(origin.getY());

            origin.setX((origin.getX() / scale) - translate.getX());
            origin.setY((origin.getY() / scale) - translate.getY());
            state.setOrigin(origin);

            childMoved(parentState, state);
          }
        }
View Full Code Here

   */
  public void updateFixedTerminalPoint(mxCellState edge,
      mxCellState terminal, boolean source,
      mxConnectionConstraint constraint)
  {
    mxPoint pt = null;

    if (constraint != null)
    {
      pt = graph.getConnectionPoint(terminal, constraint);
    }

    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
            * (translate.getY() + pt.getY() + orig.getY()));
      }
    }

    edge.setAbsoluteTerminalPoint(pt, source);
  }
View Full Code Here

  /**
   * Transforms the given control point to an absolute point.
   */
  public mxPoint transformControlPoint(mxCellState state, mxPoint pt)
  {
    mxPoint origin = state.getOrigin();

    return new mxPoint(scale
        * (pt.getX() + translate.getX() + origin.getX()), scale
        * (pt.getY() + translate.getY() + origin.getY()));
  }
View Full Code Here

   * @param target Cell state that represents the target terminal.
   */
  public void updateFloatingTerminalPoints(mxCellState state,
      mxCellState source, mxCellState target)
  {
    mxPoint p0 = state.getAbsolutePoint(0);
    mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1);

    if (pe == null && target != null)
    {
      updateFloatingTerminalPoint(state, target, source, false);
    }
View Full Code Here

TOP

Related Classes of com.mxgraph.util.mxPoint

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.