Examples of mxGraph


Examples of com.mxgraph.view.mxGraph

    if (state != null)
    {
      result.add((mxCellState) state.clone());

      mxGraph graph = graphComponent.getGraph();
      mxIGraphModel model = graph.getModel();
      Object cell = state.getCell();
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        result.addAll(snapshot(graph.getView().getState(
            model.getChildAt(cell, i))));
      }
    }

    return result;
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  protected void translateState(mxCellState parentState, mxCellState state,
      double dx, double dy)
  {
    if (state != null)
    {
      mxGraph graph = graphComponent.getGraph();
      mxIGraphModel model = graph.getModel();
      Object cell = state.getCell();

      if (model.isVertex(cell))
      {
        // LATER: Use hashtable to store initial state bounds
        state.setInvalid(true);
        graph.getView().validateBounds(parentState, cell);
        mxGeometry geo = graph.getCellGeometry(cell);

        // Moves selection cells and non-relative vertices in
        // the first phase so that edge terminal points will
        // be updated in the second phase
        if ((dx != 0 || dy != 0) && geo != null
            && (!geo.isRelative() || deltas.get(state) != null))
        {
          state.setX(state.getX() + dx);
          state.setY(state.getY() + dy);
        }
      }

      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        translateState(state,
            graph.getView().getState(model.getChildAt(cell, i)),
            dx, dy);
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  {
    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
      state.setInvalid(true);
      dirty = graph.getView().validatePoints(parentState, cell);

      // 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

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  public void addEdges(mxCellState state)
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();
    Object cell = state.getCell();
    int edgeCount = model.getEdgeCount(cell);

    for (int i = 0; i < edgeCount; i++)
    {
      mxCellState state2 = graph.getView().getState(
          model.getEdgeAt(cell, i));

      if (state2 != null)
      {
        moveState(state2, 0, 0);
View Full Code Here

Examples of com.mxgraph.view.mxGraph

        rect.translate(idx, idy);
        preview.setBounds(rect);
      }
      else
      {
        mxGraph graph = graphComponent.getGraph();
        double scale = graph.getView().getScale();

        if (gridEnabledEvent)
        {
          dx = graph.snap(dx / scale) * scale;
          dy = graph.snap(dy / scale) * scale;
        }

        mxRectangle bounds = union(getState(), dx, dy, index);
        bounds.setWidth(bounds.getWidth() + 1);
        bounds.setHeight(bounds.getHeight() + 1);
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  /**
   *
   */
  protected void moveLabel(MouseEvent e)
  {
    mxGraph graph = graphComponent.getGraph();
    mxGeometry geometry = graph.getModel().getGeometry(state.getCell());

    if (geometry != null)
    {
      double scale = graph.getView().getScale();
      mxPoint pt = new mxPoint(e.getPoint());

      if (gridEnabledEvent)
      {
        pt = graphComponent.snapScaledPoint(pt);
      }

      double dx = (pt.getX() - first.x) / scale;
      double dy = (pt.getY() - first.y) / scale;

      if (constrainedEvent)
      {
        if (Math.abs(dx) > Math.abs(dy))
        {
          dy = 0;
        }
        else
        {
          dx = 0;
        }
      }

      mxPoint offset = geometry.getOffset();

      if (offset == null)
      {
        offset = new mxPoint();
      }

      dx += offset.getX();
      dy += offset.getY();

      geometry = (mxGeometry) geometry.clone();
      geometry.setOffset(new mxPoint(Math.round(dx), Math.round(dy)));
      graph.getModel().setGeometry(state.getCell(), geometry);
    }
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

   *
   * @param e
   */
  protected void resizeCell(MouseEvent e)
  {
    mxGraph graph = graphComponent.getGraph();
    double scale = graph.getView().getScale();

    Object cell = state.getCell();
    mxGeometry geometry = graph.getModel().getGeometry(cell);

    if (geometry != null)
    {
      double dx = (e.getX() - first.x) / scale;
      double dy = (e.getY() - first.y) / scale;

      if (isLabel(index))
      {
        geometry = (mxGeometry) geometry.clone();

        if (geometry.getOffset() != null)
        {
          dx += geometry.getOffset().getX();
          dy += geometry.getOffset().getY();
        }

        if (gridEnabledEvent)
        {
          dx = graph.snap(dx);
          dy = graph.snap(dy);
        }

        geometry.setOffset(new mxPoint(dx, dy));
        graph.getModel().setGeometry(cell, geometry);
      }
      else
      {
        mxRectangle bounds = union(geometry, dx, dy, index);
        Rectangle rect = bounds.getRectangle();

        // Snaps new bounds to grid (unscaled)
        if (gridEnabledEvent)
        {
          int x = (int) graph.snap(rect.x);
          int y = (int) graph.snap(rect.y);
          rect.width = (int) graph.snap(rect.width - x + rect.x);
          rect.height = (int) graph.snap(rect.height - y + rect.y);
          rect.x = x;
          rect.y = y;
        }

        graph.resizeCell(cell, new mxRectangle(rect));
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  public Transferable createTransferable(JComponent c)
  {
    if (c instanceof mxGraphComponent)
    {
      mxGraphComponent graphComponent = (mxGraphComponent) c;
      mxGraph graph = graphComponent.getGraph();

      if (!graph.isSelectionEmpty())
      {
        originalCells = graphComponent.getExportableCells(graph
            .getSelectionCells());

        if (originalCells.length > 0)
        {
          ImageIcon icon = (transferImageEnabled) ? createTransferableImage(
View Full Code Here

Examples of com.mxgraph.view.mxGraph

   *
   */
  public mxGraphTransferable createGraphTransferable(
      mxGraphComponent graphComponent, Object[] cells, ImageIcon icon)
  {
    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);
View Full Code Here

Examples of com.mxgraph.view.mxGraph

  {
    boolean result = false;

    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);
      }
      else
      {
        int gs = graph.getGridSize();

        dx = importCount * gs;
        dy = importCount * gs;
      }

 
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.