Package com.mxgraph.util

Examples of com.mxgraph.util.mxPoint


  public mxPoint snapScaledPoint(mxPoint pt, double dx, double dy)
  {
    if (pt != null)
    {
      double scale = graph.getView().getScale();
      mxPoint trans = graph.getView().getTranslate();

      pt.setX((graph.snap(pt.getX() / scale - trans.getX() + dx / scale) + trans
          .getX()) * scale - dx);
      pt.setY((graph.snap(pt.getY() / scale - trans.getY() + dy / scale) + trans
          .getY()) * scale - dy);
    }

    return pt;
  }
View Full Code Here


    // Gets the current state of the view
    mxGraphView view = graph.getView();

    // Stores the old state of the view
    boolean eventsEnabled = view.isEventsEnabled();
    mxPoint translate = view.getTranslate();

    // Disables firing of scale events so that there is no
    // repaint or update of the original graph while pages
    // are being printed
    view.setEventsEnabled(false);

    // Uses the view to create temporary cell states for each cell
    mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
        1 / pageScale);

    try
    {
      view.setTranslate(new mxPoint(0, 0));

      mxGraphics2DCanvas canvas = createCanvas();
      canvas.setGraphics((Graphics2D) g);
      canvas.setScale(1 / pageScale);
View Full Code Here

  /**
   *
   */
  protected Rectangle paintBackgroundPage(Graphics g)
  {
    mxPoint translate = graph.getView().getTranslate();
    double scale = graph.getView().getScale();

    int x0 = (int) Math.round(translate.getX() * scale) - 1;
    int y0 = (int) Math.round(translate.getY() * scale) - 1;

    Dimension d = getPreferredSizeForPage();
    int w = (int) Math.round(d.width * scale) + 2;
    int h = (int) Math.round(d.height * scale) + 2;

View Full Code Here

   */
  protected void paintBackgroundImage(Graphics g)
  {
    if (backgroundImage != null)
    {
      mxPoint translate = graph.getView().getTranslate();
      double scale = graph.getView().getScale();

      g.drawImage(backgroundImage.getImage(),
          (int) (translate.getX() * scale),
          (int) (translate.getY() * scale),
          (int) (backgroundImage.getIconWidth() * scale),
          (int) (backgroundImage.getIconHeight() * scale), this);
    }
  }
View Full Code Here

      {
        minStepping /= 2;
      }

      // Fetches some global display state information
      mxPoint trans = graph.getView().getTranslate();
      double scale = graph.getView().getScale();
      double tx = trans.getX() * scale;
      double ty = trans.getY() * scale;

      // Sets the distance of the grid lines in pixels
      double stepping = gridSize * scale;

      if (stepping < minStepping)
View Full Code Here

            && isFitPage()
            && graphComponent.getHorizontalScrollBar().isVisible()
            && graphComponent.getVerticalScrollBar().isVisible();
        double graphScale = graphComponent.getGraph().getView()
            .getScale();
        mxPoint trans = graphComponent.getGraph().getView()
            .getTranslate();

        int w = (int) outlineSize.getWidth() - 2 * outlineBorder;
        int h = (int) outlineSize.getHeight() - 2 * outlineBorder;

        if (magnifyPage)
        {
          gw -= 2 * Math.round(trans.getX() * graphScale);
          gh -= 2 * Math.round(trans.getY() * graphScale);
        }

        newScale = Math.min((double) w / gw, (double) h / gh);

        dx += (int) Math
            .round((outlineSize.getWidth() - gw * newScale) / 2);
        dy += (int) Math
            .round((outlineSize.getHeight() - gh * newScale) / 2);

        if (magnifyPage)
        {
          dx -= Math.round(trans.getX() * newScale * graphScale);
          dy -= Math.round(trans.getY() * newScale * graphScale);
        }
      }
    }

    if (newScale != scale || translate.x != dx || translate.y != dy)
View Full Code Here

    Element elem = document.createElement("v:shape");

    if (strokeColor != null && strokeWidth > 0)
    {
      mxPoint pt = pts.get(0);
      Rectangle r = new Rectangle(pt.getPoint());

      StringBuilder buf = new StringBuilder("m " + Math.round(pt.getX())
          + " " + Math.round(pt.getY()));

      for (int i = 1; i < pts.size(); i++)
      {
        pt = pts.get(i);
        buf.append(" l " + Math.round(pt.getX()) + " "
            + Math.round(pt.getY()));

        r = r.union(new Rectangle(pt.getPoint()));
      }

      String d = buf.toString();
      elem.setAttribute("path", d);
      elem.setAttribute("filled", "false");
View Full Code Here

      {
        mxGeometry geo = getGeometry(edge);

        if (geo != null)
        {
          mxPoint origin1 = getOrigin(getParent(edge));
          mxPoint origin2 = getOrigin(cell);

          double dx = origin2.getX() - origin1.getX();
          double dy = origin2.getY() - origin1.getY();

          geo = (mxGeometry) geo.clone();
          geo.translate(-dx, -dy);
          setGeometry(edge, geo);
        }
View Full Code Here

   * Returns the absolute, accumulated origin for the children inside the
   * given parent.
   */
  public mxPoint getOrigin(Object cell)
  {
    mxPoint result = null;

    if (cell != null)
    {
      result = getOrigin(getParent(cell));

      if (!isEdge(cell))
      {
        mxGeometry geo = getGeometry(cell);

        if (geo != null)
        {
          result.setX(result.getX() + geo.getX());
          result.setY(result.getY() + geo.getY());
        }
      }
    }
    else
    {
      result = new mxPoint();
    }

    return result;
  }
View Full Code Here

        mxLine parallel = labelGlyphs[j].glyphGeometry;

        if (labelGlyphs[j].visible && parallel != null
            && parallel != mxCurve.INVALID_POSITION)
        {
          mxPoint parallelEnd = parallel.getEndPoint();
          double x = parallelEnd.getX();
          double rotation = (Math.atan(parallelEnd.getY() / x));

          if (x < 0)
          {
            // atan only ranges from -PI/2 to PI/2, have to offset
            // for negative x values
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.