Package com.mxgraph.view

Examples of com.mxgraph.view.mxCellState


          .getHeight());

      // Checks for oversize labels and offset the result
      if (useBoundingBox)
      {
        mxCellState state = graph.getView().getState(vertex);

        if (state != null)
        {
          double scale = graph.getView().getScale();
          mxRectangle box = state.getBoundingBox();
         
          if (state.getBoundingBox().getX() < state.getX())
          {
            x += (state.getX() - box.getX()) / scale;
            result.setWidth(box.getWidth());
          }
          if (state.getBoundingBox().getY() < state.getY())
          {
            y += (state.getY() - box.getY()) / scale;
            result.setHeight(box.getHeight());
          }
        }
      }
View Full Code Here


      previousStates = new LinkedList<mxCellState>();
      Iterator<mxCellState> it = deltas.keySet().iterator();

      while (it.hasNext())
      {
        mxCellState state = it.next();
        previousStates.addAll(snapshot(state));
      }
    }

    // Translates the states in step
    Iterator<mxCellState> 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()));
      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);
      }
      else
      {
        dirty = tmp;
      }
    }

    // Takes a snapshot of the states for later drawing. If the states
    // are not cloned then this does nothing and just expects a repaint
    // of the dirty rectangle.
    if (previousStates != null)
    {
      cellStates = new LinkedList<mxCellState>();
      it = deltas.keySet().iterator();

      while (it.hasNext())
      {
        mxCellState state = it.next();
        cellStates.addAll(snapshot(state));
      }

      // Restores the previous states
      restore(previousStates);
View Full Code Here

    mxGraph graph = graphComponent.getGraph();
    Iterator<mxCellState> it = snapshot.iterator();

    while (it.hasNext())
    {
      mxCellState state = it.next();
      mxCellState orig = graph.getView().getState(state.getCell());

      if (orig != null && orig != state)
      {
        restoreState(orig, state);
      }
View Full Code Here

    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

    // Paints the preview states
    Iterator<mxCellState> it = cellStates.iterator();

    while (it.hasNext())
    {
      mxCellState state = it.next();
      canvas.getGraphics().setComposite(
          AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
              getOpacityForCell(state.getCell())));
      paintPreviewState(canvas, state);
    }

    canvas.getGraphics().setComposite(previousComposite);
  }
View Full Code Here

    boolean handlesVisible = tmp.length <= getMaxHandlers();
    Rectangle handleBounds = null;

    for (int i = 0; i < tmp.length; i++)
    {
      mxCellState state = graph.getView().getState(tmp[i]);

      if (state != null)
      {
        mxCellHandler handler = (mxCellHandler) oldHandlers.get(tmp[i]);
View Full Code Here

    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

   * color. The state is returned regardless of the marker color and
   * valid state.
   */
  public mxCellState process(MouseEvent e)
  {
    mxCellState state = null;

    if (isEnabled())
    {
      state = getState(e);
      boolean isValid = (state != null) ? isValidState(state) : false;
View Full Code Here

    double y = 0;

    cells = currentGraph.getChildCells(currentGraph.getDefaultParent());
    boolean initialize = false;
    for (Object cell : cells) {
      mxCellState state = currentGraph.getView().getState(cell);
      if (!initialize) {
        x = state.getLabelBounds().getX();
        y = state.getLabelBounds().getY();
        initialize = true;
      }
      if (state.getLabelBounds().getX() < x)
        x = state.getLabelBounds().getX();

      if (state.getLabelBounds().getY() < y)
        y = state.getLabelBounds().getY();
    }
    if (initialize)
      currentGraph.moveCells(currentGraph.getChildCells(currentGraph.getDefaultParent()), -x, -y);

    double zoomfactor = currentGraph.getView().getScale();
View Full Code Here

    double x = 0;
    double y = 0;
    cells = currentGraph.getChildCells(currentGraph.getDefaultParent());
    for (Object cell : cells) {
      mxCellState state = currentGraph.getView().getState(cell);
      if (state != null) {
        currentGraph.getView().updateLabelBounds(state);
        if (state.getLabelBounds().getX() < x)
          x = state.getLabelBounds().getX();
        if (state.getLabelBounds().getY() < y)
          y = state.getLabelBounds().getY();
      }
    }
    if (x != 0 || y != 0)
      currentGraph.moveCells(currentGraph.getChildCells(currentGraph.getDefaultParent()), -x, -y);
    currentGraph.repaint();   
View Full Code Here

TOP

Related Classes of com.mxgraph.view.mxCellState

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.