Examples of mxIGraphModel


Examples of com.mxgraph.model.mxIGraphModel

   * Returns true if the label bounds of the state should be used for the
   * editor.
   */
  protected boolean useLabelBounds(mxCellState state)
  {
    mxIGraphModel model = state.getView().getGraph().getModel();
    mxGeometry geometry = model.getGeometry(state.getCell());

    return ((geometry != null && geometry.getOffset() != null
        && !geometry.isRelative() && (geometry.getOffset().getX() != 0 || geometry
        .getOffset().getY() != 0)) || model.isEdge(state.getCell()));
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

  /**
   * Returns the bounds to be used for the editor.
   */
  public Rectangle getEditorBounds(mxCellState state, double scale)
  {
    mxIGraphModel model = state.getView().getGraph().getModel();
    Rectangle bounds = null;

    if (useLabelBounds(state))
    {
      bounds = state.getLabelBounds().getRectangle();
      bounds.height += 10;
    }
    else
    {
      bounds = state.getRectangle();
    }

    // Applies the horizontal and vertical label positions
    if (model.isVertex(state.getCell()))
    {
      String horizontal = mxUtils.getString(state.getStyle(),
          mxConstants.STYLE_LABEL_POSITION, mxConstants.ALIGN_CENTER);

      if (horizontal.equals(mxConstants.ALIGN_LEFT))
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

    mxGraphView view = graphComponent.getGraph().getView();
    view.addListener(mxEvent.SCALE, resetHandler);
    view.addListener(mxEvent.TRANSLATE, resetHandler);
    view.addListener(mxEvent.SCALE_AND_TRANSLATE, resetHandler);

    mxIGraphModel model = graphComponent.getGraph().getModel();
    model.addListener(mxEvent.CHANGE, resetHandler);

    marker = new mxCellMarker(graphComponent)
    {
      /**
       *
 
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   */
  public Object createTargetVertex(MouseEvent e, Object source)
  {
    mxGraph graph = graphComponent.getGraph();
    Object clone = graph.cloneCells(new Object[] { source })[0];
    mxIGraphModel model = graph.getModel();
    mxGeometry geo = model.getGeometry(clone);

    if (geo != null)
    {
      mxPoint point = graphComponent.getPointForEvent(e);
      geo.setX(graph.snap(point.getX() - geo.getWidth() / 2));
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * Returns a dirty rectangle to be repainted in mxGraphControl.
   */
  public mxRectangle show()
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();

    // Stores a copy of the cell states
    List<mxCellState> previousStates = null;

    if (isCloned())
    {
      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)
      {
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

    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.model.mxIGraphModel

      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.model.mxIGraphModel

    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.model.mxIGraphModel

   *
   */
  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.model.mxIGraphModel

     * Draws the child edges and/or all other children in the given cell
     * depending on the boolean arguments.
     */
    protected void drawChildren(Object cell, boolean edges, boolean others)
    {
      mxIGraphModel model = graph.getModel();
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        Object child = model.getChildAt(cell, i);
        boolean isEdge = model.isEdge(child);

        if ((others && !isEdge) || (edges && isEdge))
        {
          drawCell(canvas, model.getChildAt(cell, i));
        }
      }
    }
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.