Package com.mxgraph.util

Examples of com.mxgraph.util.mxPoint


   */
  public void paintPolyline(mxPoint[] points, boolean rounded)
  {
    if (points != null && points.length > 1)
    {
      mxPoint pt = points[0];
      mxPoint pe = points[points.length - 1];

      double arcSize = mxConstants.LINE_ARCSIZE * scale;

      GeneralPath path = new GeneralPath();
      path.moveTo((float) pt.getX(), (float) pt.getY());

      // Draws the line segments
      for (int i = 1; i < points.length - 1; i++)
      {
        mxPoint tmp = points[i];
        double dx = pt.getX() - tmp.getX();
        double dy = pt.getY() - tmp.getY();

        if ((rounded && i < points.length - 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;
          path.lineTo((float) x1, (float) 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 = points[i + 1];

          // Uses next non-overlapping point
          while (i < points.length - 2 && Math.round(next.getX() - tmp.getX()) == 0 && Math.round(next.getY() - tmp.getY()) == 0)
          {
            next = points[i + 2];
            i++;
          }
         
          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;

          path.quadTo((float) tmp.getX(), (float) tmp.getY(),
              (float) x2, (float) y2);
          tmp = new mxPoint(x2, y2);
        }
        else
        {
          path.lineTo((float) tmp.getX(), (float) tmp.getY());
        }
View Full Code Here


    {
      Object tmp = view.getCurrentRoot();
      view.currentRoot = previous;
      previous = tmp;

      mxPoint translate = view.graph.getTranslateForRoot(view
          .getCurrentRoot());

      if (translate != null)
      {
        view.translate = new mxPoint(-translate.getX(),
            translate.getY());
      }

      // Removes all existing cell states and revalidates
      view.reload();
      up = !up;
View Full Code Here

    if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed()
        && current != null)
    {
      mxGraph graph = graphComponent.getGraph();
      double scale = graph.getView().getScale();
      mxPoint tr = graph.getView().getTranslate();
      current.setX(current.getX() / scale - tr.getX());
      current.setY(current.getY() / scale - tr.getY());
      current.setWidth(current.getWidth() / scale);
      current.setHeight(current.getHeight() / scale);

      Object cell = insertCell(current);
      eventSource.fireEvent(new mxEventObject(mxEvent.INSERT, "cell",
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

            state.getOrigin().getX() + pState.getOrigin().getX());
        state.getOrigin().setY(
            state.getOrigin().getY() + pState.getOrigin().getY());
      }

      mxPoint offset = graph.getChildOffsetForCell(state.getCell());

      if (offset != null)
      {
        state.getOrigin()
            .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());
          }
        }
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.getCell());
      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

   *            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

   */
  public void updateFloatingTerminalPoint(mxCellState edge,
      mxCellState start, mxCellState end, boolean source)
  {
    start = getTerminalPort(edge, start, source);
    mxPoint next = getNextPoint(edge, end, source);
    double border = mxUtils.getDouble(edge.getStyle(),
        mxConstants.STYLE_PERIMETER_SPACING);
    border += mxUtils.getDouble(edge.getStyle(),
        (source) ? mxConstants.STYLE_SOURCE_PERIMETER_SPACING
            : mxConstants.STYLE_TARGET_PERIMETER_SPACING);
    mxPoint pt = getPerimeterPoint(start, next, graph.isOrthogonal(edge),
        border);
    edge.setAbsoluteTerminalPoint(pt, source);
  }
View Full Code Here

   *            Optional border between the perimeter and the shape.
   */
  public mxPoint getPerimeterPoint(mxCellState terminal, mxPoint next,
      boolean orthogonal, double border)
  {
    mxPoint point = null;

    if (terminal != null)
    {
      mxPerimeterFunction perimeter = getPerimeterFunction(terminal);

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.