Package com.mxgraph.util

Examples of com.mxgraph.util.mxRectangle


            } else {
                highlightedEdge = null;
            }
        }
        if (!cellsToRepaint.isEmpty()) {
            mxRectangle bounds = model.getPaintBounds(cellsToRepaint.toArray());
            model.repaint(bounds);
        }
    }
View Full Code Here


            for (Revision rev : revsOnPath) {
                mxCell cell = cellMap.get(rev);
                if (cell != lastCell) {
                    lastCell = positionCell(lastCell, relativePosition, nextY, cell);
                    relativePosition = SwingConstants.RIGHT;
                    mxRectangle rect = lastCell.getGeometry();
                    widestY = Math.max(widestY, rect.getY() + rect.getHeight());
                }
            }
            nextY = widestY + SVNRevisionGraph.CELL_SPACING;
            i++;
        }
        //Now adjust x position in order of revision numbers
        for (i = 1; i < revisions.size(); i++) {
            Revision rev = revisions.get(i);
            Revision prevRev = revisions.get(i - 1);
            mxCell cell = cellMap.get(rev);
            mxCell prevCell = cellMap.get(prevRev);
            if (cell != prevCell) {
                Rectangle rect = cell.getGeometry().getRectangle();
                positionCell(prevCell,
                        rev.getRevisionNumber() > prevRev.getRevisionNumber() ? SwingConstants.RIGHT : SwingConstants.BOTTOM,
                        rect.getY(), cell);
            }
        }
    }
View Full Code Here

        }
    }

    private mxCell positionCell(mxCell neighborCell, int relativePosition, Double preferredY, mxCell targetCell) {
        //Calculate position from neighbor
        mxRectangle neighborRect = null;
        if (neighborCell == null) {
            if (relativePosition == SwingConstants.BOTTOM)
                neighborRect = new mxRectangle(SVNRevisionGraph.CELL_SPACING, 0, 0, 0);
            else if (relativePosition == SwingConstants.RIGHT)
                neighborRect = new mxRectangle(0, SVNRevisionGraph.CELL_SPACING, 0, 0);
        } else {
            neighborRect = neighborCell.getGeometry();
        }
        double x = 0, y = 0;
        if (relativePosition == SwingConstants.BOTTOM) {
            x = neighborRect.getX();
            y = neighborRect.getY() + neighborRect.getHeight() + SVNRevisionGraph.CELL_SPACING;
        } else if (relativePosition == SwingConstants.RIGHT) {
            x = neighborRect.getX() + neighborRect.getWidth() + SVNRevisionGraph.CELL_SPACING;
            y = neighborRect.getY();
        }
        if (preferredY != null) {
            y = preferredY;
        }

        mxRectangle preferredSize = getPreferredSizeForCell(targetCell);
        neighborRect = new mxRectangle(x, y, preferredSize.getWidth(), preferredSize.getHeight());
        resizeCell(targetCell, neighborRect);
        return targetCell;
    }
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

    int imgHeight = (int) (mxUtils.getInt(style,
        mxConstants.STYLE_IMAGE_HEIGHT, mxConstants.DEFAULT_IMAGESIZE) * scale);
    int spacing = (int) (mxUtils
        .getInt(style, mxConstants.STYLE_SPACING, 2) * scale);

    mxRectangle imageBounds = new mxRectangle(state);

    if (imgAlign.equals(mxConstants.ALIGN_CENTER))
    {
      imageBounds.setX(imageBounds.getX()
          + (imageBounds.getWidth() - imgWidth) / 2);
    }
    else if (imgAlign.equals(mxConstants.ALIGN_RIGHT))
    {
      imageBounds.setX(imageBounds.getX() + imageBounds.getWidth()
          - imgWidth - spacing - 2);
    }
    else
    // LEFT
    {
      imageBounds.setX(imageBounds.getX() + spacing + 4);
    }

    if (imgValign.equals(mxConstants.ALIGN_TOP))
    {
      imageBounds.setY(imageBounds.getY() + spacing);
    }
    else if (imgValign.equals(mxConstants.ALIGN_BOTTOM))
    {
      imageBounds.setY(imageBounds.getY() + imageBounds.getHeight()
          - imgHeight - spacing);
    }
    else
    // MIDDLE
    {
      imageBounds.setY(imageBounds.getY()
          + (imageBounds.getHeight() - imgHeight) / 2);
    }

    imageBounds.setWidth(imgWidth);
    imageBounds.setHeight(imgHeight);

    return imageBounds.getRectangle();
  }
View Full Code Here

  public void refresh(mxCellState state)
  {
    this.state = state;
    handles = createHandles();
    mxGraph graph = graphComponent.getGraph();
    mxRectangle tmp = graph.getBoundingBox(state.getCell());

    if (tmp != null)
    {
      bounds = tmp.getRectangle();

      if (handles != null)
      {
        for (int i = 0; i < handles.length; i++)
        {
View Full Code Here

          model.getParent(state.getCell()));
      translateState(parentState, state, delta.getX(), delta.getY());
    }

    // Revalidates the states in step
    mxRectangle dirty = null;
    it = deltas.keySet().iterator();

    while (it.hasNext())
    {
      mxCellState state = it.next();
      mxPoint delta = deltas.get(state);
      mxCellState parentState = graph.getView().getState(
          model.getParent(state.getCell()));
      mxRectangle tmp = revalidateState(parentState, state, delta.getX(),
          delta.getY());

      if (dirty != null)
      {
        dirty.add(tmp);
View Full Code Here

   *
   */
  protected mxRectangle revalidateState(mxCellState parentState,
      mxCellState state, double dx, double dy)
  {
    mxRectangle dirty = null;

    if (state != null)
    {
      mxGraph graph = graphComponent.getGraph();
      mxIGraphModel model = graph.getModel();
      Object cell = state.getCell();
     
      // Updates the edge terminal points and restores the
      // (relative) positions of any (relative) children
      if (model.isEdge(cell))
      {
        state.getView().updateCellState(state);
      }
     
      dirty = state.getView().getBoundingBox(state, false);

      // Moves selection vertices which are relative
      mxGeometry geo = graph.getCellGeometry(cell);

      if ((dx != 0 || dy != 0)
          && geo != null
          && geo.isRelative()
          && model.isVertex(cell)
          && (parentState == null
              || model.isVertex(parentState.getCell()) || deltas
              .get(state) != null))
      {
        state.setX(state.getX() + dx);
        state.setY(state.getY() + dy);

        // TODO: Check this change
        dirty.setX(dirty.getX() + dx);
        dirty.setY(dirty.getY() + dy);

        graph.getView().updateLabelBounds(state);
      }

      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        mxRectangle tmp = revalidateState(state, graph.getView()
            .getState(model.getChildAt(cell, i)), dx, dy);

        if (dirty != null)
        {
          dirty.add(tmp);
View Full Code Here

  public void update(MouseEvent e, mxCellState targetState, double x, double y)
  {
    mxGraph graph = graphComponent.getGraph();
    mxICell cell = (mxICell) previewState.getCell();

    mxRectangle dirty = graphComponent.getGraph().getPaintBounds(
        new Object[] { previewState.getCell() });

    if (cell.getTerminal(false) != null)
    {
      cell.getTerminal(false).removeEdge(cell, false);
View Full Code Here

   */
  protected Rectangle getDirtyRect(mxRectangle dirty)
  {
    if (previewState != null)
    {
      mxRectangle tmp = graphComponent.getGraph().getPaintBounds(
          new Object[] { previewState.getCell() });

      if (dirty != null)
      {
        dirty.add(tmp);
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.