Package com.mxgraph.util

Examples of com.mxgraph.util.mxRectangle


    {
      mxPerimeterFunction perimeter = getPerimeterFunction(terminal);

      if (perimeter != null && next != null)
      {
        mxRectangle bounds = getPerimeterBounds(terminal, border);

        if (bounds.getWidth() > 0 || bounds.getHeight() > 0)
        {
          point = perimeter.apply(bounds, terminal, next, orthogonal);
        }
      }
View Full Code Here


    if (label != null && label.length() > 0)
    {
      mxPoint offset = new mxPoint(mxUtils.getDouble(style, "dx"),
          mxUtils.getDouble(style, "dy"));
      mxRectangle vertexBounds = (!edge) ? state : null;
      state.setLabelBounds(mxUtils.getLabelPaintBounds(label, state
          .getStyle(), mxUtils.isTrue(style, "html", false), offset,
          vertexBounds, scale));
    }
View Full Code Here

          double x0 = graph.getGridSize();
          double y0 = x0;

          if (!moveTree)
          {
            mxRectangle g = getVertexBounds(root);

            if (g != null)
            {
              x0 = g.getX();
              y0 = g.getY();
            }
          }

          mxRectangle bounds = null;

          if (horizontal)
          {
            bounds = horizontalLayout(node, x0, y0, null);
          }
          else
          {
            bounds = verticalLayout(node, null, x0, y0, null);
          }

          if (bounds != null)
          {
            double dx = 0;
            double dy = 0;

            if (bounds.getX() < 0)
            {
              dx = Math.abs(x0 - bounds.getX());
            }

            if (bounds.getY() < 0)
            {
              dy = Math.abs(y0 - bounds.getY());
            }

            if (dx != 0 || dy != 0)
            {
              moveNode(node, dx, dy);
View Full Code Here

   */
  protected TreeNode createNode(Object cell)
  {
    TreeNode node = new TreeNode(cell);

    mxRectangle geo = getVertexBounds(cell);

    if (geo != null)
    {
      if (horizontal)
      {
        node.width = geo.getHeight();
        node.height = geo.getWidth();
      }
      else
      {
        node.width = geo.getWidth();
        node.height = geo.getHeight();
      }
    }

    return node;
  }
View Full Code Here

   */
  protected mxRectangle apply(TreeNode node, mxRectangle bounds)
  {
    mxIGraphModel model = graph.getModel();
    Object cell = node.cell;
    mxRectangle g = model.getGeometry(cell);

    if (cell != null && g != null)
    {
      if (isVertexMovable(cell))
      {
        g = setVertexLocation(cell, node.x, node.y);

        if (resizeParent)
        {
          parentsChanged.add(model.getParent(cell));
        }
      }

      if (bounds == null)
      {
        bounds = new mxRectangle(g.getX(), g.getY(), g.getWidth(),
            g.getHeight());
      }
      else
      {
        bounds = new mxRectangle(Math.min(bounds.getX(), g.getX()),
            Math.min(bounds.getY(), g.getY()), Math.max(
                bounds.getX() + bounds.getWidth(),
                g.getX() + g.getWidth()), Math.max(
                bounds.getY() + bounds.getHeight(), g.getY()
                    + g.getHeight()));
      }
    }

    return bounds;
  }
View Full Code Here

    int width = 0;
    int height = 0;
    int dx = 0;
    int dy = 0;

    mxRectangle tmp = getClip();

    if (tmp != null)
    {
      dx -= (int) tmp.getX();
      dy -= (int) tmp.getY();
      width = (int) tmp.getWidth();
      height = (int) tmp.getHeight();
    }
    else
    {
      int x = (int) Math.round(mxUtils.getDouble(attrs, "x"));
      int y = (int) Math.round(mxUtils.getDouble(attrs, "y"));
View Full Code Here

    }

    double currentYOffset = minEdgeJetty - prefVertEdgeOff;
    double maxYOffset = 0;

    mxRectangle parentBounds = getVertexBounds(parentCell);
    child = node.child;

    for (int j = 0; j < sortedCellsArray.length; j++)
    {
      Object childCell = sortedCellsArray[j].cell.cell;
      mxRectangle childBounds = getVertexBounds(childCell);

      Object[] edges = mxGraphModel.getEdgesBetween(model, parentCell,
          childCell);

      List<mxPoint> newPoints = new ArrayList<mxPoint>(3);
      double x = 0;
      double y = 0;

      for (int i = 0; i < edges.length; i++)
      {
        if (this.horizontal)
        {
          // Use opposite co-ords, calculation was done for
          //
          x = parentBounds.getX() + parentBounds.getWidth();
          y = parentBounds.getY() + currentXOffset;
          newPoints.add(new mxPoint(x, y));
          x = parentBounds.getX() + parentBounds.getWidth()
              + currentYOffset;
          newPoints.add(new mxPoint(x, y));
          y = childBounds.getY() + childBounds.getHeight() / 2.0;
          newPoints.add(new mxPoint(x, y));
          setEdgePoints(edges[i], newPoints);
        }
        else
        {
          x = parentBounds.getX() + currentXOffset;
          y = parentBounds.getY() + parentBounds.getHeight();
          newPoints.add(new mxPoint(x, y));
          y = parentBounds.getY() + parentBounds.getHeight()
              + currentYOffset;
          newPoints.add(new mxPoint(x, y));
          x = childBounds.getX() + childBounds.getWidth() / 2.0;
          newPoints.add(new mxPoint(x, y));
          setEdgePoints(edges[i], newPoints);
        }
      }
View Full Code Here

      if (comp.getParent() == null)
      {
        getGraphControl().add(comp, 0);
      }

      mxRectangle rect = overlay.getBounds(state);

      if (rect != null)
      {
        comp.setBounds(rect.getRectangle());
        comp.setVisible(true);
      }
      else
      {
        comp.setVisible(false);
View Full Code Here

   * Also compares the size of the buffer with the size of the graph and drops
   * the buffer if it has a different size.
   */
  public void checkTripleBuffer()
  {
    mxRectangle bounds = graph.getGraphBounds();
    int width = (int) Math.ceil(bounds.getX() + bounds.getWidth() + 2);
    int height = (int) Math.ceil(bounds.getY() + bounds.getHeight() + 2);

    if (tripleBuffer != null)
    {
      if (tripleBuffer.getWidth() != width
          || tripleBuffer.getHeight() != height)
View Full Code Here

   * Returns an <mxRectangle> that defines the bounds of the given cell
   * or the bounding box if <useBoundingBox> is true.
   */
  public mxRectangle getVertexBounds(Object vertex)
  {
    mxRectangle geo = graph.getModel().getGeometry(vertex);

    // Checks for oversize label bounding box and corrects
    // the return value accordingly
    if (useBoundingBox)
    {
      mxCellState state = graph.getView().getState(vertex);

      if (state != null)
      {
        double scale = graph.getView().getScale();
        mxRectangle tmp = state.getBoundingBox();

        double dx0 = (tmp.getX() - state.getX()) / scale;
        double dy0 = (tmp.getY() - state.getY()) / scale;
        double dx1 = (tmp.getX() + tmp.getWidth() - state.getX() - state
            .getWidth()) / scale;
        double dy1 = (tmp.getY() + tmp.getHeight() - state.getY() - state
            .getHeight()) / scale;

        geo = new mxRectangle(geo.getX() + dx0, geo.getY() + dy0,
            geo.getWidth() - dx0 + dx1, geo.getHeight() + -dy0
                + dy1);
      }
    }

    if (this.parent != null)
    {
      Object parent = graph.getModel().getParent(vertex);
      geo = (mxRectangle) geo.clone();

      if (parent != null && parent != this.parent)
      {
        mxPoint parentOffset = getParentOffset(parent);
        geo.setX(geo.getX() + parentOffset.getX());
        geo.setY(geo.getY() + parentOffset.getY());
      }
    }

    return new mxRectangle(geo);
  }
View Full Code Here

TOP

Related Classes of com.mxgraph.util.mxRectangle

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.