Package com.mxgraph.util

Examples of com.mxgraph.util.mxRectangle


      else
      {
        d = getScaledPreferredSizeForGraph();
      }

      mxRectangle min = graph.getMinimumGraphSize();

      if (min != null)
      {
        d.width = (int) Math.max(d.width,
            Math.round(min.getWidth() * scale));
        d.height = (int) Math.max(d.height,
            Math.round(min.getHeight() * scale));
      }

      if (!getPreferredSize().equals(d))
      {
        setPreferredSize(d);
View Full Code Here


      Rectangle rect = null;

      // Takes rotation into account
      double rotation = mxUtils.getDouble(state.getStyle(),
          mxConstants.STYLE_ROTATION);
      mxRectangle tmp = mxUtils.getBoundingBox(new mxRectangle(state),
          rotation);

      // Adds scaled stroke width
      int border = (int) Math
          .ceil(mxUtils.getDouble(state.getStyle(),
              mxConstants.STYLE_STROKEWIDTH)
              * graph.getView().getScale()) + 1;
      tmp.grow(border);

      if (mxUtils.isTrue(state.getStyle(), mxConstants.STYLE_SHADOW))
      {
        tmp.setWidth(tmp.getWidth() + mxConstants.SHADOW_OFFSETX);
        tmp.setHeight(tmp.getHeight() + mxConstants.SHADOW_OFFSETX);
      }

      // Adds the bounds of the label
      if (state.getLabelBounds() != null)
      {
        tmp.add(state.getLabelBounds());
      }

      rect = tmp.getRectangle();
      return rect;
    }
View Full Code Here

  {
    mxGraph graph = graphComponent.getGraph();
    mxPoint tr = graph.getView().getTranslate();
    double scale = graph.getView().getScale();

    mxRectangle bounds = graph.getPaintBounds(cells);

    // Removes the scale and translation from the bounds
    bounds.setX(bounds.getX() / scale - tr.getX());
    bounds.setY(bounds.getY() / scale - tr.getY());
    bounds.setWidth(bounds.getWidth() / scale);
    bounds.setHeight(bounds.getHeight() / scale);

    return createGraphTransferable(graphComponent, cells, bounds, icon);
  }
View Full Code Here

    try
    {
      mxGraph graph = graphComponent.getGraph();
      double scale = graph.getView().getScale();
      mxRectangle bounds = gt.getBounds();
      double dx = 0, dy = 0;

      // Computes the offset for the placement of the imported cells
      if (location != null && bounds != null)
      {
        mxPoint translate = graph.getView().getTranslate();

        dx = location.getX() - (bounds.getX() + translate.getX())
            * scale;
        dy = location.getY() - (bounds.getY() + translate.getY())
            * scale;

        // Keeps the cells aligned to the grid
        dx = graph.snap(dx / scale);
        dy = graph.snap(dy / scale);
View Full Code Here

   * @param icon
   * @param cell
   */
  public void addTemplate(final String name, ImageIcon icon, mxCell cell)
  {
    mxRectangle bounds = (mxGeometry) cell.getGeometry().clone();
    final mxGraphTransferable t = new mxGraphTransferable(
        new Object[] { cell }, bounds);

    // Scales the image if it's too large for the library
    if (icon != null)
View Full Code Here

        {
          public void invoke(Object source, mxEventObject evt)
          {
            String buffer = (graphComponent.getTripleBuffer() != null) ? ""
                : " (unbuffered)";
            mxRectangle dirty = (mxRectangle) evt
                .getProperty("region");

            if (dirty == null)
            {
              status("Repaint all" + buffer);
            }
            else
            {
              status("Repaint: x=" + (int) (dirty.getX()) + " y="
                  + (int) (dirty.getY()) + " w="
                  + (int) (dirty.getWidth()) + " h="
                  + (int) (dirty.getHeight()) + buffer);
            }
          }
        });
  }
View Full Code Here

   */
  protected void updateShape(AbstractView<?> viewObject) {
    mxCell cell = getCell(viewObject);
    if (cell != null) {
      modelGraph.resizeCell(cell,
          new mxRectangle(viewObject.getX(), viewObject.getY(),
              viewObject.getWidth(), viewObject.getHeight()));
      repaint(viewObject);
    }

  }
View Full Code Here

    modelGraph.repaint();
  }

  protected void repaint(AbstractView<?> view) {
    if(view.getBounds() != null){
      modelGraph.repaint(new mxRectangle(Rectangle2DUtils.expand(
        view.getBounds(), REPAINT_PROTRUDE)));
    }
  }
View Full Code Here

  @Override
  public mxRectangle getBounds(mxCellState state) {
    double scale = state.getView().getScale();
    Point2D offset = getOffset();
    return new mxRectangle(offset.getX() + state.getX() - scale * image.getWidth(null), offset.getY()
        + state.getY() - scale * image.getHeight(null), scale * image.getWidth(null), scale
        * image.getHeight(null));

  }
 
View Full Code Here

  }
 
  private void init()
  {
    m_graph = new mxGraph();
    m_graph.setMinimumGraphSize(new mxRectangle(0,0,400,400));
    layout = new mxOrganicLayout (m_graph);
    m_graph.setCellsDeletable(false);
    m_graph.setCellsDisconnectable(false);
    m_graph.setCellsEditable(false);
    m_graph.setAutoOrigin(true);
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.