public Object[] ungroupCells(Object[] cells){
  List<Object> result=new ArrayList<Object>();
  if (cells == null) {
    cells=getSelectionCells();
    List<Object> tmp=new ArrayList<Object>(cells.length);
    for (int i=0; i < cells.length; i++) {
      if (model.getChildCount(cells[i]) > 0) {
        tmp.add(cells[i]);
      }
    }
    cells=tmp.toArray();
  }
  if (cells != null && cells.length > 0) {
    model.beginUpdate();
    try {
      for (int i=0; i < cells.length; i++) {
        Object[] children=mxGraphModel.getChildren(model,cells[i]);
        if (children != null && children.length > 0) {
          Object parent=model.getParent(cells[i]);
          int index=model.getChildCount(parent);
          cellsAdded(children,parent,index,null,null,true);
          result.addAll(Arrays.asList(children));
        }
      }
      cellsRemoved(addAllEdges(cells));
      fireEvent(new mxEventObject(mxEvent.UNGROUP_CELLS,"cells",cells));
    }
  finally {
      model.endUpdate();
    }
  }
  return result.toArray();
}

public Object [ ] ungroupCells ( Object [ ] cells ) { List < Object > result = new ArrayList < Object > ( ) ; if ( cells == null ) { cells = getSelectionCells ( ) ; List < Object > tmp = new ArrayList < Object > ( cells . length ) ; for ( int i = 0 ; i < cells . length ; i ++ ) { if ( model . getChildCount ( cells [ i ] ) > 0 ) { tmp . add ( cells [ i ] ) ; } } cells = tmp . toArray ( ) ; } if ( cells != null && cells . length > 0 ) { model . beginUpdate ( ) ; try { for ( int i = 0 ; i < cells . length ; i ++ ) { Object [ ] children = mxGraphModel . getChildren ( model , cells [ i ] ) ; if ( children != null && children . length > 0 ) { Object parent = model . getParent ( cells [ i ] ) ; int index = model . getChildCount ( parent ) ; cellsAdded ( children , parent , index , null , null , true ) ; result . addAll ( Arrays . asList ( children ) ) ; } } cellsRemoved ( addAllEdges ( cells ) ) ; fireEvent ( new mxEventObject ( mxEvent . UNGROUP_CELLS , "cells" , cells ) ) ; } finally { model . endUpdate ( ) ; } } return result . toArray ( ) ; }
ungroups the given cells by moving the children the children to their parents parent and removing the empty groups .
