Examples of mxGraph


Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  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);
    }

    if (targetState != null)
    {
      ((mxICell) targetState.getCell()).insertEdge(cell, false);
    }

    mxGeometry geo = graph.getCellGeometry(previewState.getCell());

    geo.setTerminalPoint(startPoint, true);
    geo.setTerminalPoint(transformScreenPoint(x, y), false);

    revalidate(graph.getView().getState(graph.getDefaultParent()),
        previewState.getCell());
    fireEvent(new mxEventObject(mxEvent.CONTINUE, "event", e, "x", x, "y",
        y));

    // Repaints the dirty region
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  protected mxPoint transformScreenPoint(double x, double y)
  {
    mxGraph graph = graphComponent.getGraph();
    mxPoint tr = graph.getView().getTranslate();
    double scale = graph.getView().getScale();

    return new mxPoint(graph.snap(x / scale - tr.getX()), graph.snap(y / scale - tr.getY()));
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  public void revalidate(mxCellState pState, Object cell)
  {
    mxGraph graph = graphComponent.getGraph();
    mxCellState tmp = graph.getView().getState(cell);
    tmp.setInvalid(true);

    graph.getView().validateBounds(pState, cell);
    graph.getView().validatePoints(pState, cell);

    mxIGraphModel model = graph.getModel();
    int childCount = model.getChildCount(cell);

    for (int i = 0; i < childCount; i++)
    {
      revalidate(tmp, model.getChildAt(cell, i));
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  {
    Object result = (sourceState != null) ? sourceState.getCell() : null;

    if (previewState != null)
    {
      mxGraph graph = graphComponent.getGraph();

      graph.getModel().beginUpdate();
      try
      {
        mxICell cell = (mxICell) previewState.getCell();
        Object src = cell.getTerminal(true);
        Object trg = cell.getTerminal(false);

        if (src != null)
        {
          ((mxICell) src).removeEdge(cell, true);
        }

        if (trg != null)
        {
          ((mxICell) trg).removeEdge(cell, false);
        }

        if (commit)
        {
          result = graph.addCell(cell, null, null, src, trg);
        }

        fireEvent(new mxEventObject(mxEvent.STOP, "event", e, "commit",
            commit, "cell", (commit) ? result : null));

        // Clears the state before the model commits
        if (previewState != null)
        {
          Rectangle dirty = getDirtyRect();
          graph.getView().clear(cell, false, true);
          previewState = null;

          if (!commit && dirty != null)
          {
            graphComponent.getGraphControl().repaint(dirty);
          }
        }
      }
      finally
      {
        graph.getModel().endUpdate();
      }
    }

    sourceState = null;
    startPoint = null;
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  public Object[] getCells(mxCellState initialState)
  {
    mxGraph graph = graphComponent.getGraph();

    return graph.getMovableCells(graph.getSelectionCells());
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   * Returns the states that are affected by the move operation.
   */
  protected mxCellState[] getPreviewStates()
  {
    mxGraph graph = graphComponent.getGraph();
    Collection<mxCellState> result = new LinkedList<mxCellState>();

    for (Object cell : movingCells)
    {
      mxCellState cellState = graph.getView().getState(cell);

      if (cellState != null)
      {
        result.add(cellState);

        // Terminates early if too many cells
        if (result.size() >= threshold)
        {
          return null;
        }

        if (isContextPreview())
        {
          Object[] edges = graph.getAllEdges(new Object[] { cell });

          for (Object edge : edges)
          {
            if (!graph.isCellSelected(edge))
            {
              mxCellState edgeState = graph.getView().getState(
                  edge);

              if (edgeState != null)
              {
                // Terminates early if too many cells
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  protected mxRectangle getPlaceholderBounds(mxCellState startState)
  {
    mxGraph graph = graphComponent.getGraph();

    return graph.getView().getBounds(graph.getSelectionCells());
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   * Sets the translation of the preview.
   */
  public void update(MouseEvent e, double dx, double dy, boolean clone)
  {
    mxGraph graph = graphComponent.getGraph();

    if (placeholder != null)
    {
      Rectangle tmp = new Rectangle(placeholder);
      placeholder.x = initialPlaceholder.x + (int) dx;
      placeholder.y = initialPlaceholder.x + (int) dy;
      tmp.add(placeholder);
      graphComponent.getGraphControl().repaint(tmp);
    }
    else if (previewStates != null)
    {
      preview = createCellStatePreview();
      preview.setOpacity(graphComponent.getPreviewAlpha());

      // Combines the layout result with the move preview
      for (mxCellState previewState : previewStates)
      {
        preview.moveState(previewState, dx, dy, false, false);

        // FIXME: Move into show-handler?
        boolean visible = true;

        if ((dx != 0 || dy != 0) && clone && isContextPreview())
        {
          visible = false;
          Object tmp = previewState.getCell();

          while (!visible && tmp != null)
          {
            visible = graph.isCellSelected(tmp);
            tmp = graph.getModel().getParent(tmp);
          }
        }
      }

      mxRectangle dirty = lastDirty;
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  protected void reset()
  {
    mxGraph graph = graphComponent.getGraph();

    if (placeholder != null)
    {
      Rectangle tmp = placeholder;
      placeholder = null;
      graphComponent.getGraphControl().repaint(tmp);
    }

    if (isHideSelectionHandler())
    {
      graphComponent.getSelectionCellsHandler().setVisible(true);
    }

    // Revalidates the screen
    // TODO: Should only revalidate moved cells
    if (!isClonePreview() && previewStates != null)
    {
      graph.getView().revalidate();
    }

    previewStates = null;
    movingCells = null;
    startState = null;
View Full Code Here

Examples of com.mxgraph.view.mxGraph

      boolean clone, Object target)
  {
    Object[] cells = movingCells;
    reset();

    mxGraph graph = graphComponent.getGraph();
    graph.getModel().beginUpdate();
    try
    {
      if (commit)
      {
        double s = graph.getView().getScale();
        cells = graph.moveCells(cells, dx / s, dy / s, clone, target,
            e.getPoint());
      }

      fireEvent(new mxEventObject(mxEvent.STOP, "event", e, "commit",
          commit));
    }
    finally
    {
      graph.getModel().endUpdate();
    }

    return cells;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.