/** * */ public static Object[] filterCells(Object[] cells, Filter filter) { ArrayList<Object> result = null; if (cells != null) { result = new ArrayList<Object>(cells.length); for (int i = 0; i < cells.length; i++) { if (filter.filter(cells[i])) { result.add(cells[i]); } } } return (result != null) ? result.toArray() : null; }
/** * Creates a collection of cells using the visitor pattern. */ public static Collection<Object> filterDescendants(mxIGraphModel model, Filter filter, Object parent) { List<Object> result = new ArrayList<Object>(); if (filter == null || filter.filter(parent)) { result.add(parent); } int childCount = model.getChildCount(parent); for (int i = 0; i < childCount; i++) { Object child = model.getChildAt(parent, i); result.addAll(filterDescendants(model, filter, child)); } return result; }
/** * */ public static Object[] filterCells(Object[] cells, Filter filter) { ArrayList<Object> result = null; if (cells != null) { result = new ArrayList<Object>(cells.length); for (int i = 0; i < cells.length; i++) { if (filter.filter(cells[i])) { result.add(cells[i]); } } } return (result != null) ? result.toArray() : null; }
/** * Creates a collection of cells using the visitor pattern. */ public static Collection<Object> filterDescendants(mxIGraphModel model, Filter filter, Object parent) { List<Object> result = new ArrayList<Object>(); if (filter == null || filter.filter(parent)) { result.add(parent); } int childCount = model.getChildCount(parent); for (int i = 0; i < childCount; i++) { Object child = model.getChildAt(parent, i); result.addAll(filterDescendants(model, filter, child)); } return result; }