Package com.mxgraph.util

Examples of com.mxgraph.util.mxRectangle


  {
    if (pageVisible)
    {
      Dimension d = getPreferredSizeForPage();

      return new mxRectangle(new Rectangle(d));
    }
    else
    {
      return new mxRectangle(new Rectangle(graphControl.getSize()));
    }
  }
View Full Code Here


  /**
   * Returns the scaled preferred size for the current graph.
   */
  protected Dimension getScaledPreferredSizeForGraph()
  {
    mxRectangle bounds = graph.getGraphBounds();
    int border = graph.getBorder();

    return new Dimension(
        (int) Math.round(bounds.getX() + bounds.getWidth()) + border
            + 1, (int) Math.round(bounds.getY()
            + bounds.getHeight())
            + border + 1);
  }
View Full Code Here

  {
    mxCellState state = graph.getView().getState(cell);

    if (state != null)
    {
      mxRectangle bounds = state;

      if (center)
      {
        bounds = (mxRectangle) bounds.clone();

        bounds.setX(bounds.getCenterX() - getWidth() / 2);
        bounds.setWidth(getWidth());
        bounds.setY(bounds.getCenterY() - getHeight() / 2);
        bounds.setHeight(getHeight());
      }

      getGraphControl().scrollRectToVisible(bounds.getRectangle());
    }
  }
View Full Code Here

      canvas.setGraphics((Graphics2D) g);
      canvas.setScale(1 / pageScale);

      view.revalidate();

      mxRectangle graphBounds = graph.getGraphBounds();
      Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
          + graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
          .getY() + graphBounds.getHeight()) + 1);

      int w = (int) (printFormat.getImageableWidth());
      int h = (int) (printFormat.getImageableHeight());
      int cols = (int) Math.max(
          Math.ceil((double) (pSize.width - 5) / (double) w), 1);
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

              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 (parent != null)
            {
              mxRectangle size = graph.getStartSize(parent);
              dx += size.getWidth();
              dy += size.getHeight();

              // Resize parent swimlane
              if (resizeParent && !graph.isCellCollapsed(parent))
              {
                mxGeometry g = model.getGeometry(parent);

                if (g != null)
                {
                  double width = bounds.getWidth()
                      + size.getWidth() - bounds.getX()
                      + 2 * x0;
                  double height = bounds.getHeight()
                      + size.getHeight() - bounds.getY()
                      + 2 * y0;

                  g = (mxGeometry) g.clone();

                  if (g.getWidth() > width)
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)
  {
    mxRectangle g = graph.getModel().getGeometry(node.cell);

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

      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

   * (non-Javadoc)
   * @see com.mxgraph.canvas.mxICanvas#drawLabel()
   */
  public Object drawLabel(String label, mxCellState state, boolean html)
  {
    mxRectangle bounds = state.getLabelBounds();

    if (drawLabels && bounds != null)
    {
      int x = (int) bounds.getX() + translate.x;
      int y = (int) bounds.getY() + translate.y;
      int w = (int) bounds.getWidth();
      int h = (int) bounds.getHeight();
      Map<String, Object> style = state.getStyle();

      return drawText(label, x, y, w, h, style);
    }

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.