/** * Gets the group attribute of the GraphSave class * *@param graph Description of Parameter *@param cell Description of Parameter *@return The group value */ private static boolean isGroup(JGraph graph, Object cell) { // Map the Cell to its View CellView view = graph.getGraphLayoutCache().getMapping(cell, false); if (view != null) { return !view.isLeaf(); } return false; }
/** * Returns the topmost cell view at the specified location using the view's * bounds on non-leafs to check for containment. If reverse is true this * will return the innermost view. */ public CellView getTopmostViewAt(double x, double y, boolean reverse, boolean leafsOnly) { Rectangle2D r = new Rectangle2D.Double(x, y, 1, 1); Object[] cells = getDescendants(getRoots()); for (int i = (reverse) ? cells.length - 1 : 0; i >= 0 && i < cells.length; i += (reverse) ? -1 : +1) { CellView view = getGraphLayoutCache().getMapping(cells[i], false); if (view != null && (!leafsOnly || view.isLeaf()) && ((view.isLeaf() && view.intersects(this, r)) || (!view .isLeaf() && view.getBounds().contains(x, y)))) return view; } return null; }
/** * A helper method to return various arrays of cells that are visible in * this cache. For example, to get all selected vertices in a graph, do * <code>graph.getSelectionCells(graph.getGraphLayoutCache().getCells(false, true, false, false));</code> */ public Object[] getCells(boolean groups, boolean vertices, boolean ports, boolean edges) { CellView[] views = getCellViews(); List result = new ArrayList(views.length); GraphModel model = getModel(); for (int i = 0; i < views.length; i++) { Object cell = views[i].getCell(); boolean isEdge = model.isEdge(cell); if ((ports || !model.isPort(cell))) { if (((((ports || vertices) && !isEdge) || (edges && isEdge)) && views[i] .isLeaf()) || (groups && !views[i].isLeaf())) result.add(views[i].getCell()); } } return result.toArray(); }
/** * Gets the group attribute of the Editor object * *@param cell Description of Parameter *@return The group value */ public boolean isGroup(Object cell) { // Map the Cell to its View CellView view = getGraph().getGraphLayoutCache().getMapping(cell, false); if (view != null) { return!view.isLeaf(); } return false; }
boolean active = (c == null); for (int i = 0; i < cells.length; i++) { if (cells[i] != null && (!leafsOnly || cells[i].isLeaf()) && cells[i].intersects(this, r)) {
public void updateAutoSize(CellView view) { if (!view.isLeaf()) { CellView[] children = view.getChildViews(); Rectangle2D rect = GraphConstants.getBounds(children[0] .getAllAttributes()); double x = rect.getMaxX() + 10; double y = rect.getY(); for (int index = 1; index < children.length; index++) { Rectangle2D childRect = GraphConstants .getBounds(children[index].getAllAttributes()); childRect.setFrame(x, y, childRect.getWidth(), childRect .getHeight()); x += childRect.getWidth() + 10; children[index].update(); } } else { super.updateAutoSize(view); } }
protected void cellWillCollapse(Object cell) { GraphModel model = getModel(); if (movesParentsOnCollapse) { CellView view = getMapping(cell, false); if (view != null && !view.isLeaf()) { // Uses view-local attribute if available AttributeMap attrs = view.getAttributes(); if (!attrs.contains(GraphConstants.BOUNDS) && !localAttributes.contains(GraphConstants.BOUNDS)) attrs = model.getAttributes(cell); // Moves the group to the origin of the children Rectangle2D src = GraphConstants.getBounds(attrs); Rectangle2D b = view.getBounds(); // FIXME: What if the group is exactly at "defaultBounds"? if (resizesParentsOnCollapse || src == null || src.equals(VertexView.defaultBounds)) { src = attrs.createRect(b.getX(), b.getY(), b.getWidth() * collapseXScale, b.getHeight() * collapseYScale); attrs.applyValue(GraphConstants.BOUNDS, src); } else { src.setFrame(b.getX(), b.getY(), src.getWidth(), src .getHeight()); } } } }
&& (PREVIEW_EDGE_GROUPS || edge.isLeaf())) {
/** * Returns the nearest point wrt to the source or target. This method * returns the next or previous point or port in the points list, eg. if * source is true it returns the location of the point or port at index 1 * without calling the getLocation method on any ports.<br> * Likewise, the method returns the location at index getPointCount()-2 if * source is false. */ protected Point2D getNearestPoint(boolean source) { if (getPointCount() == 2) { if (source && target instanceof PortView && GraphConstants.getOffset(target.getAllAttributes()) != null) { return ((PortView) target).getLocation(this); } if (!source && this.source instanceof PortView && GraphConstants.getOffset(this.source.getAllAttributes()) != null) { return ((PortView) this.source).getLocation(this); } if (source && targetParentView != null && targetParentView.isLeaf()) return getCenterPoint(targetParentView); else if (!source && sourceParentView != null && sourceParentView.isLeaf()) return getCenterPoint(sourceParentView); } return getPointLocation((source) ? 1 : getPointCount() - 2); }
.getGraphLayoutCache() .getMapping(cells[i], false); if (view != null && !view.isLeaf()) { double dx = p.getX() - tmp.getX();
/** * Used for move into group to find the target group. */ protected CellView findUnselectedInnermostGroup(double x, double y) { Object[] cells = graph.getDescendants(graph.getRoots()); for (int i = cells.length - 1; i >= 0; i--) { CellView view = graph.getGraphLayoutCache().getMapping( cells[i], false); if (view != null && !view.isLeaf() && !context.contains(view.getCell()) && view.getBounds().contains(x, y)) return view; } return null; }
if (!view.isLeaf()) { CellView[] children = view.getChildViews(); for (int i = 0; i < children.length; i++)
public void translate(int dx, int dy) { // System.err.println(view.getCell() + ": Translate by " + dx + ", " + dy); if (view.isLeaf()) { model.getAttributes(node).translate(dx, dy); } else { CellView[] cells = view.getChildViews(); for (int index = 0; index < cells.length; index++) { CellView child = cells[index]; model.getAttributes(child.getCell()).translate(dx, dy); child.refresh(model, mapper, false); } } view.refresh(model, mapper, false); } };
boolean isForceMarquee = isForceMarqueeEvent(e); boolean isEditable = graph.isGroupsEditable() || (focus != null && focus.isLeaf()); if (!isForceMarquee) { if (e.getClickCount() == graph.getEditClickCount()