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];
          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


          }

          if (orientation == SwingConstants.NORTH
              || orientation == SwingConstants.SOUTH)
          {
            newPoints.add(new mxPoint(positionX, topChannelY));
            newPoints.add(new mxPoint(positionX, bottomChannelY));
          }
          else
          {
            newPoints.add(new mxPoint(topChannelY, positionX));
            newPoints.add(new mxPoint(bottomChannelY, positionX));
          }

          limitX = Math.max(limitX, positionX);

          //          double currentY = (rankTopY[currentRank] + rankBottomY[currentRank]) / 2.0;
View Full Code Here

   * non-translated coordinate space and applies the grid.
   */
  public mxPoint getPointForEvent(MouseEvent e, boolean addOffset)
  {
    double s = graph.getView().getScale();
    mxPoint tr = graph.getView().getTranslate();
   
    double off = (addOffset) ? graph.getGridSize() / 2 : 0;
    double x = graph.snap(e.getX() / s - tr.getX() - off);
    double y = graph.snap(e.getY() / s - tr.getY() - off);

    return new mxPoint(x, y);
  }
View Full Code Here

        / scale);

    double dx = Math.max(0, (width - d.width) / 2);
    double dy = Math.max(0, (height - d.height) / 2);

    return new mxPoint(dx, dy);
  }
View Full Code Here

          || zoomPolicy == ZOOM_POLICY_PAGE);
      centerOnResize = false;
    }
    else if (pageVisible && centerPage)
    {
      mxPoint translate = getPageTranslate(graph.getView().getScale());
      graph.getView().setTranslate(translate);
    }
    else
    {
      getGraphControl().updatePreferredSize();
View Full Code Here

    mxGraphView view = graph.getView();
    double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100;

    if (newScale != view.getScale() && newScale > 0.01)
    {
      mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
          : new mxPoint();
      graph.getView().scaleAndTranslate(newScale, translate.getX(),
          translate.getY());

      if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty())
      {
        getGraphControl().scrollRectToVisible(
            view.getBoundingBox(graph.getSelectionCells())
View Full Code Here

  public void zoomTo(final double newScale, final boolean center)
  {
    mxGraphView view = graph.getView();
    final double scale = view.getScale();

    mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
        : new mxPoint();
    graph.getView().scaleAndTranslate(newScale, translate.getX(),
        translate.getY());

    // Causes two repaints on the scrollpane, namely one for the scale
    // change with the new preferred size and one for the change of
    // the scrollbar position. The latter cannot be done immediately
    // because the scrollbar keeps the value <= max - extent, and if
View Full Code Here

   *
   * Resets the zoom and panning in the view.
   */
  public void zoomActual()
  {
    mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(1)
        : new mxPoint();
    graph.getView()
        .scaleAndTranslate(1, translate.getX(), translate.getY());

    if (isPageVisible())
    {
      // Causes two repaints, see zoomTo for more details
      SwingUtilities.invokeLater(new Runnable()
View Full Code Here

        if (newScale > 0)
        {
          mxGraphView graphView = graph.getView();
          final double scale = graphView.getScale();
          mxPoint translate = (centerPage) ? getPageTranslate(newScale)
              : new mxPoint();
          graphView.scaleAndTranslate(newScale, translate.getX(),
              translate.getY());

          // Causes two repaints, see zoomTo for more details
          final double factor = newScale / scale;

          SwingUtilities.invokeLater(new Runnable()
View Full Code Here

    int w = (int) Math.max(8, icon.getIconWidth() * scale);
    int h = (int) Math.max(8, icon.getIconHeight() * scale);

    if (isEdge)
    {
      mxPoint pt = graph.getView().getPoint(state);

      x = (int) pt.getX() - w / 2;
      y = (int) pt.getY() - h / 2;
    }

    return new Rectangle(x, y, w, h);
  }
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.