/** * Returns the bounds to be used to highlight the given cell view. * * @param graph * @param cellView * @return */ protected Rectangle getHighlightBounds(JGraph graph, CellView cellView) { boolean offset = (GraphConstants.getOffset(cellView.getAllAttributes()) != null); Rectangle2D r = (offset) ? cellView.getBounds() : cellView .getParentView().getBounds(); r = graph.toScreen((Rectangle2D) r.clone()); int s = 3; return new Rectangle((int) (r.getX() - s), (int) (r.getY() - s), (int) (r.getWidth() + 2 * s), (int) (r.getHeight() + 2 * s)); }
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); } };
Object cell = view.getCell(); String valueStr = graph.convertValueToString(cell); boolean label = (valueStr != null && valueStr.length() > 0); boolean icon = GraphConstants.getIcon(view.getAllAttributes()) != null; if (label || icon) { boolean focus = (getFocusedCell() == cell) && graph.hasFocus(); Component component = view.getRendererComponent(graph, focus, false, false); if (component != null) { Dimension d = component.getPreferredSize(); int inset = 2 * GraphConstants.getInset(view .getAllAttributes()); d.width += inset; d.height += inset; if (view.getBounds() == null) { if (graphLayoutCache != null) { view.update(null); } else if (graph.getGraphLayoutCache() != null) { view.update(graph.getGraphLayoutCache()); } else { view.update(null); Rectangle2D bounds = view.getBounds(); return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
public void update(CellView view) { if (view != null) { view.update(this); CellView[] children = view.getChildViews(); for (int i = 0; i < children.length; i++) update(children[i]); } }
public void refresh(CellView view, boolean create) { if (view != null) { view.refresh(this, this, create); CellView[] children = view.getChildViews(); for (int i = 0; i < children.length; i++) refresh(children[i], create); } }
for (int i = 0; i < all.length; i++) { CellView orig = graphLayoutCache .getMapping(all[i].getCell(), false); AttributeMap attr = orig.getAllAttributes(); all[i].changeAttributes( graph.getGraphLayoutCache(), (AttributeMap) attr.clone()); all[i].refresh(graph.getGraphLayoutCache(), context, false); .getBounds().clone() : null; if (targetGroup != null) { Rectangle2D tmp = graph .toScreen((Rectangle2D) targetGroup .getBounds().clone()); if (dirty != null) dirty.add(tmp);
boolean sel = graph.isCellSelected(view.getCell()); Component component = view.getRendererComponent(graph, sel, bfocus, preview); Stroke oldstr = ((Graphics2D) g).getStroke(); if (view.getCell() instanceof DefaultEdge) { found = found || ((DefaultPort) (((DefaultEdge) view.getCell()) .getTarget())).getParent().equals( toPaint.elementAt(k)) || ((DefaultPort) (((DefaultEdge) view.getCell()) .getSource())).getParent().equals( toPaint.elementAt(k)); if (!found) { if (((DefaultPort) (((DefaultEdge) view.getCell()) .getTarget())).getParent() != null && nAryEdge .isAssignableFrom(((DefaultPort) (((DefaultEdge) view .getCell()).getTarget())) .getParent().getClass())) { .getCell()).getTarget())).getParent(); found = found || evaluateIfDefaultGraphCellHasToBeHighlighted( toPaint.elementAt(k)); } else { if (((DefaultPort) (((DefaultEdge) view.getCell())
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); } }
public double getHeight() { return view.getBounds().getHeight(); }
public Component getRendererComponent(JGraph graph, CellView view, boolean sel, boolean focus, boolean preview) { return RenderComponentManager.retrievePanel("MentalStateProcessor", ((Entity)((DefaultGraphCell)(view.getCell())).getUserObject()).getPrefs(graph.getModel().getAttributes(view.getCell())).getView()); }
.getAllAttributes()); Rectangle2D rect = parent.getBounds(); if (rect != null && src != null) { double dx = src.getX() - rect.getX(); AttributeMap attrs = view.getAttributes(); if (!attrs.contains(GraphConstants.BOUNDS)) attrs = model.getAttributes(view.getCell()); attrs.translate(dx, dy);
/** * 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; }
.getX() - s, e.getY() - s, 2 * s, 2 * s)); lastFocus = focus; focus = (focus != null && focus.intersects(graph, r)) ? focus : null; cell = graph.getNextSelectableViewAt(focus, e.getX(), e.getY()); boolean isForceMarquee = isForceMarqueeEvent(e); boolean isEditable = graph.isGroupsEditable() || (focus != null && focus.isLeaf()); if (!isForceMarquee) { if (e.getClickCount() == graph.getEditClickCount() && focus != null && isEditable && focus.getParentView() == null && graph.isCellEditable(focus.getCell()) && handleEditTrigger(cell.getCell(), e)) { e.consume(); cell = null; && !graph.isCellSelected(cell.getCell())) { selectCellForEvent(cell.getCell(), e); focus = cell; if (handle != null) {
Rectangle2D bounds = (view.getAttributes() != null) ? GraphConstants .getBounds(view.getAttributes()) : null; AttributeMap attrs = getModel().getAttributes(view.getCell()); if (bounds == null) bounds = GraphConstants.getBounds(attrs); if (bounds != null) { boolean autosize = GraphConstants.isAutoSize(view .getAllAttributes()); boolean resize = GraphConstants.isResize(view .getAllAttributes()); if (autosize || resize) { Dimension2D d = getUI().getPreferredSize(this, view); if (view.getAttributes() != null) view.getAttributes().remove(GraphConstants.RESIZE); attrs.remove(GraphConstants.RESIZE); view.refresh(getGraphLayoutCache(), getGraphLayoutCache(), 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; }
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()); } } } }
public Hashtable<String, CollectionPanel> parentHasVisibleContainers( DefaultGraphCell object) { CellView[] views = glc.getAllViews(); Hashtable<String, CollectionPanel> vc = new Hashtable<String, CollectionPanel>(); for (CellView cv : views) { if (cv.getCell() == object) { if (cv instanceof VertexView) { if (((VertexView) cv).getRenderer() instanceof CompositeRenderer) { cv.refresh(glc, new GraphContext(jg, new Object[] { ((VertexView) cv).getCell() }), false); Component element = ((VertexView) cv) .getRendererComponent(jg, false, false, false); // to // set // the // entity CompositeRenderer jc = (CompositeRenderer) ((VertexView) cv) .getRenderer(); vc = evaluate(jc, (ingenias.editor.entities.Entity) object .getUserObject(),jg.getModel().getAttributes(object)); } } } } return vc; }
.getRootsAsCollection(getModel())); if (modelRoots.contains(views[i].getCell()) && remembersCellViews) { hiddenMapping.put(views[i].getCell(), views[i]); view.refresh(this, this, false); CellView parentView = view.getParentView(); if (parentView != null) parentSet.add(parentView);
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)) { .getCell())) { return cells[i]; } else if (first == null)
for (int i = 0; i < ports.length; i++) { if (ports[i] != null) { Rectangle2D tmp = ports[i].getBounds(); Component parentRenderer = ports[i].getParentView() .getRendererComponent(graph, false, false, false); boolean withoutports = false; try {