Examples of mxIGraphModel


Examples of com.mxgraph.model.mxIGraphModel

     */
    protected void cellDrawn(mxICanvas canvas, mxCellState state)
    {
      if (isFoldingEnabled() && canvas instanceof mxGraphics2DCanvas)
      {
        mxIGraphModel model = graph.getModel();
        mxGraphics2DCanvas g2c = (mxGraphics2DCanvas) canvas;
        Graphics2D g2 = g2c.getGraphics();

        // Draws the collapse/expand icons
        boolean isEdge = model.isEdge(state.getCell());

        if (state.getCell() != graph.getCurrentRoot()
            && (model.isVertex(state.getCell()) || isEdge))
        {
          ImageIcon icon = getFoldingIcon(state);

          if (icon != null)
          {
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxGraph graph = graphComponent.getGraph();
        mxIGraphModel model = graph.getModel();

        Object source = null;
        Object target = null;

        Object[] cells = graph.getSelectionCells();

        for (int i = 0; i < cells.length; i++)
        {
          if (model.isVertex(cells[i]))
          {
            if (source == null)
            {
              source = cells[i];
            }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

      mxGraph graph = mxGraphActions.getGraph(e);

      if (graph != null && !graph.isSelectionEmpty())
      {
        Object[] cells = graph.getSelectionCells();
        mxIGraphModel model = graph.getModel();

        model.beginUpdate();
        try
        {
          for (int i = 0; i < cells.length; i++)
          {
            graph.updateCellSize(cells[i]);
          }
        }
        finally
        {
          model.endUpdate();
        }
      }
    }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxGraph graph = graphComponent.getGraph();
        mxIGraphModel model = graph.getModel();

        Object parent = graph.getDefaultParent();
        Object[] cells = graph.getSelectionCells();

        for (int i = 0; i < cells.length; i++)
        {
          if (model.getChildCount(cells[i]) > 0)
          {
            parent = cells[i];
            break;
          }
        }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

          editorPane.requestFocus();
          editorPane.select(start, ende);
        }
        else
        {
          mxIGraphModel model = graphComponent.getGraph().getModel();
          model.beginUpdate();
          try
          {
            graphComponent.stopEditing(false);
            graphComponent.getGraph().toggleCellStyleFlags(
                mxConstants.STYLE_FONTSTYLE,
                (bold) ? mxConstants.FONT_BOLD
                    : mxConstants.FONT_ITALIC);
          }
          finally
          {
            model.endUpdate();
          }
        }
      }
    }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   */
  protected void connect(Object edge, Object terminal, boolean isSource,
      boolean isClone)
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();

    model.beginUpdate();
    try
    {
      if (isClone)
      {
        Object clone = graph.cloneCells(new Object[] { edge })[0];

        Object parent = model.getParent(edge);
        graph.addCells(new Object[] { clone }, parent);

        Object other = model.getTerminal(edge, !isSource);
        graph.connectCell(clone, other, !isSource);

        graph.setSelectionCell(clone);
        edge = clone;
      }

      // Passes an empty constraint to reset constraint information
      graph.connectCell(edge, terminal, isSource,
          new mxConnectionConstraint());
    }
    finally
    {
      model.endUpdate();
    }
  }
View Full Code Here

Examples of com.mxgraph.model.mxIGraphModel

   * Moves the label to the given position.
   */
  protected void moveLabelTo(mxCellState edgeState, double x, double y)
  {
    mxGraph graph = graphComponent.getGraph();
    mxIGraphModel model = graph.getModel();
    mxGeometry geometry = model.getGeometry(state.getCell());

    if (geometry != null)
    {
      geometry = (mxGeometry) geometry.clone();

      // Resets the relative location stored inside the geometry
      mxPoint pt = graph.getView().getRelativePoint(edgeState, x, y);
      geometry.setX(pt.getX());
      geometry.setY(pt.getY());

      // Resets the offset inside the geometry to find the offset
      // from the resulting point
      double scale = graph.getView().getScale();
      geometry.setOffset(new mxPoint(0, 0));
      pt = graph.getView().getPoint(edgeState, geometry);
      geometry.setOffset(new mxPoint(Math.round((x - pt.getX()) / scale),
          Math.round((y - pt.getY()) / scale)));

      model.setGeometry(edgeState.getCell(), geometry);
    }
  }
View Full Code Here

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

   * 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
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.