/** * Returns a an array with the visible cells in <code>cells</code>. */ public Object[] getVisibleCells(Object[] cells) { if (cells != null) { List result = new ArrayList(cells.length); for (int i = 0; i < cells.length; i++) if (isVisible(cells[i])) result.add(cells[i]); return result.toArray(); } return null; }
private boolean isVisible(DefaultGraphCell cell) { return this.target.getGraphLayoutCache().isVisible(cell); }
/** * Checks if the port or one of its parents is visible. */ protected boolean hasVisibleParent(Object cell, Set invisible) { boolean isVisible = false; do { isVisible = (invisible == null || !invisible.contains(cell)) ? isVisible(cell) : false; cell = getModel().getParent(cell); } while (cell != null && !isVisible); return isVisible; }
/** * Obtains all hidden vertices of the specified cell * @param cell the cell whose children are to be determined * @return all the child hidden vertices */ private Set getHiddenChildren(Object cell) { List cellChildren = DefaultGraphModel.getDescendants(model, new Object[] {cell}); Set cells = new HashSet(); cells.add(cell); Iterator iter = cellChildren.iterator(); while (iter.hasNext()) { Object childCell = iter.next(); if (DefaultGraphModel.isVertex(model, childCell) && !graphLayoutCache.isVisible(childCell)) { cells.add(childCell); } } return cells; }
/** * Returns an new consistent array of views for the ports. */ public CellView[] createTemporaryPortViews() { GraphModel model = graph.getModel(); ArrayList result = new ArrayList(); Iterator it = allCells.iterator(); while (it.hasNext()) { Object cand = it.next(); if (model.isPort(cand) && graph.getGraphLayoutCache().isVisible(cand)) result.add(getMapping(cand, true)); } // List -> CellView[] Conversion CellView[] array = new CellView[result.size()]; result.toArray(array); return array; }
protected void showCellsForChange(GraphModelEvent.GraphModelChange change) { Object[] inserted = change.getInserted(); if (inserted != null && showsInsertedConnections) { for (int i = 0; i < inserted.length; i++) { if (!isVisible(inserted[i])) { Object source = graphModel.getSource(inserted[i]); Object target = graphModel.getTarget(inserted[i]); if ((source != null || target != null) && (isVisible(source) && isVisible(target))) setVisibleImpl(new Object[] { inserted[i] }, true); } } } if (change.getConnectionSet() != null) { Set changedSet = change.getConnectionSet().getChangedEdges(); if (changedSet != null && showsChangedConnections) { Object[] changed = changedSet.toArray(); for (int i = 0; i < changed.length; i++) { if (!isVisible(changed[i])) { Object source = graphModel.getSource(changed[i]); Object target = graphModel.getTarget(changed[i]); if ((source != null || target != null) && (isVisible(source) && isVisible(target)) && !isVisible(changed[i])) setVisibleImpl(new Object[] { changed[i] }, true); } } } } }
/** * Constructs a graph context for <code>cells</code> with respect to the * connections defined in the model, and the views in the view of * <code>graph</code>. */ public GraphContext(JGraph graph, Object[] cells) { GraphModel model = graph.getModel(); allCells = new HashSet(DefaultGraphModel.getDescendants(model, cells)); graphLayoutCache = graph.getGraphLayoutCache(); this.graph = graph; this.cells = cells; // Count Visible Non-Port Cells cellSet = new HashSet(); Iterator it = allCells.iterator(); while (it.hasNext()) { Object cell = it.next(); if (graphLayoutCache.isVisible(cell)) { cellSet.add(cell); if (!model.isPort(cell)) cellCount++; } } }
if (!visibleCells || isVisible(fanout[i])) { Object neighbour = DefaultGraphModel.getOpposite(model, fanout[i], cell); && (exclude == null || !exclude.contains(neighbour)) && !localExclude.contains(neighbour) && (!visibleCells || isVisible(neighbour))) { localExclude.add(neighbour); neighbours.add(neighbour);
protected Collection getParentPorts(Object cell) { // does nothing if a parent is already visible Object parent = graphModel.getParent(cell); while (parent != null) { if (isVisible(parent)) return null; parent = graphModel.getParent(parent); } // Else returns the parent and all ports parent = graphModel.getParent(cell); Collection collection = getPorts(parent); collection.add(parent); return collection; }
&& (!visibleCells || isVisible(edges[i]))) {
/** * Returns the view for the specified cell. If create is true and no view is * found then a view is created using createView(Object). */ public CellView getMapping(Object cell, boolean create) { if (cell == null) return null; CellView view = (CellView) mapping.get(cell); if (view == null && create && isVisible(cell)) { view = (CellView) hiddenMapping.get(cell); if (view != null) { putMapping(cell, view); hiddenMapping.remove(cell); } else { view = factory.createView(graphModel, cell); putMapping(cell, view); view.refresh(this, this, true); // Create Dependent // Views view.update(this); } } return view; }
/** * Invoked after a cell has been selected in the mouseReleased method. * This can be used to do something interesting if the cell was already * selected, in which case this implementation selects the parent. * Override if you want different behaviour, such as start editing. */ protected void postProcessSelection(MouseEvent e, Object cell, boolean wasSelected) { if (wasSelected && graph.isCellSelected(cell) && e.getModifiers() != 0) { Object parent = cell; Object nextParent = null; while (((nextParent = graphModel.getParent(parent)) != null) && graphLayoutCache.isVisible(nextParent)) parent = nextParent; selectCellForEvent(parent, e); lastFocus = focus; focus = graphLayoutCache.getMapping(parent, false); } }
CellView edge = graphLayoutCache.getMapping(obj, false); if (!cellSet.contains(obj) && graphLayoutCache.isVisible(obj) && edge != null && (PREVIEW_EDGE_GROUPS || edge.isLeaf())) {
/** * Returns the <code>CellView</code> that is mapped to <code>cell</code> * in the graph context. New views are created based on whether cell is * contained in the context. The <code>create</code>-flag is ignored. */ public CellView getMapping(Object cell, boolean create) { if (cell != null) { CellView view = (CellView) views.get(cell); if (view != null) return view; else if (contains(cell) || (graph.getModel().isPort(cell) && create && graph .getGraphLayoutCache().isVisible(cell))) return createMapping(cell); else return graphLayoutCache.getMapping(cell, false); } return null; }
Object childCell = model.getChild(cell, i); if (DefaultGraphModel.isVertex(model, childCell) && graphLayoutCache.isVisible(childCell) && cell != childCell) { translate(childCell, dx, dy);
AttributeMap attrs = graph.getAttributes(cell); if (!isCellSelected(cell) && graph.getGraphLayoutCache().isVisible(cell) && (attrs == null || GraphConstants.isSelectable(attrs))) { GraphModel model = graph.getModel();
for (int i = 0; i < edges.length; i++) { connected = connected || graphLayoutCache.isVisible(edges[i]);