/** * @param view * @return vertex! */ private VertexView getVertexView(CellView view) { CellView temp = view; while (temp != null) { if (temp instanceof VertexView) { return (VertexView) temp; } temp = temp.getParentView(); } return null; }
/** * Returns the point of <code>edge</code> at <code>index</code>. Avoids * calling <code>getLocation</code> on any ports of <code>edge</code>. * <br> * This is used from within getPoint to pass the nearest point to the * portview to find it's location. This uses the center point of the parent * view to determine the port view's location to avoid infinite recursion. */ protected Point2D getPointLocation(int index) { Object obj = points.get(index); if (obj instanceof Point2D) return (Point2D) obj; else if (obj instanceof PortView) { CellView vertex = ((CellView) obj).getParentView(); if (vertex != null) return getCenterPoint(vertex); } return null; }
protected Point2D getPointLocation(int index) { Object obj = points.get(index); if (obj instanceof Point2D) { return (Point2D) obj; } else if (obj instanceof VirtualNode) { return ((VirtualNode) obj).getPosition(); } else if (obj instanceof PortView) { VertexView vertex = (VertexView) ((CellView) obj) .getParentView(); if (vertex != null) { return vertex.getCenterPoint(); } } return null; }
/** * Completely reloads all roots from the model in the order returned by * DefaultGraphModel.getAll. This uses the current visibleSet and mapping to * fetch the cell views for the cells. */ protected void reloadRoots() { // Reorder roots Object[] orderedCells = DefaultGraphModel.getAll(graphModel); List newRoots = new ArrayList(); for (int i = 0; i < orderedCells.length; i++) { CellView view = getMapping(orderedCells[i], false); if (view != null) { view.refresh(this, this, true); if (view.getParentView() == null) { newRoots.add(view); } } } roots = newRoots; }
/** * 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)); }
protected List routeLoop(GraphLayoutCache cache, EdgeView edge) { List newPoints = new ArrayList(); newPoints.add(edge.getSource()); CellView sourceParent = (edge.getSource() != null) ? edge .getSource().getParentView() : edge.getSourceParentView(); if (sourceParent != null) { Point2D from = AbstractCellView.getCenterPoint(sourceParent); Rectangle2D rect = sourceParent.getBounds(); double width = rect.getWidth(); double height2 = rect.getHeight() / 2; double loopWidth = Math.min(20, Math.max(10, width / 8)); double loopHeight = Math.min(30, Math.max(12, Math.max( loopWidth + 4, height2 / 2))); newPoints.add(edge.getAttributes().createPoint( from.getX() - loopWidth, from.getY() - height2 - loopHeight * 1.2)); newPoints.add(edge.getAttributes().createPoint(from.getX(), from.getY() - height2 - 1.5 * loopHeight)); newPoints.add(edge.getAttributes().createPoint( from.getX() + loopWidth, from.getY() - height2 - loopHeight * 1.2)); newPoints.add(edge.getTarget()); return newPoints; } return null; }
/** * Returns true if the edge is a loop. */ public boolean isLoop() { return (getSource() != null && getSource() == getTarget()) || (sourceParentView != null && sourceParentView == targetParentView) || (sourceParentView != null && getTarget() != null && getTarget() .getParentView() == sourceParentView) || (targetParentView != null && getSource() != null && getSource() .getParentView() == targetParentView); }
protected void paintPort(Graphics g, CellView p) { boolean offset = (GraphConstants.getOffset(p.getAllAttributes()) != null); Rectangle2D r = (offset) ? p.getBounds() : p.getParentView() .getBounds(); r = graph.toScreen((Rectangle2D) r.clone()); int s = 3; r.setFrame(r.getX() - s, r.getY() - s, r.getWidth() + 2 * s, r .getHeight() + 2 * s); graph.getUI().paintCell(g, p, r, true); }
if (ports[i] != null) { Rectangle2D tmp = ports[i].getBounds(); Component parentRenderer = ports[i].getParentView() .getRendererComponent(graph, false, false, false); boolean withoutports = false;
CellView parentView = view.getParentView(); if (parentView != null) parentSet.add(parentView);
/** * Adds the specified model root cells to the view. Do not add a view that * is already in roots. */ public void insertViews(CellView[] views) { if (views != null) { refresh(views, true); for (int i = 0; i < views.length; i++) { if (views[i] != null && getMapping(views[i].getCell(), false) != null) { CellView parentView = views[i].getParentView(); Object parent = (parentView != null) ? parentView.getCell() : null; if (!graphModel.isPort(views[i].getCell()) && parent == null) { roots.add(views[i]); } } } } }
perimeterPoint = AbstractCellView.getCenterPoint(nodeTo); if (edge.getSource() == null || edge.getSource().getParentView() == null) { perimeterPoint); } else { from = edge.getSource().getParentView().getPerimeterPoint(edge, AbstractCellView.getCenterPoint(edge.getSource().getParentView()), (edge.getTarget() != null && edge.getTarget().getParentView() != null) ? AbstractCellView.getCenterPoint(edge.getTarget().getParentView()) : AbstractCellView.getCenterPoint(nodeTo)); if (edge.getTarget() == null || edge.getTarget().getParentView() == null) { // INV: nodeTo != null to = edge.getTarget().getParentView().getPerimeterPoint (edge, AbstractCellView.getCenterPoint(edge.getTarget().getParentView()), from);
return (view.getParentView() == null); } else { return true;
Object src = null; if (edgeView.getSource() != null && edgeView.getSource().getParentView() != null) src = edgeView.getSource().getParentView().getCell(); else if (edgeView.getSourceParentView() != null) src = edgeView.getSourceParentView().getCell(); && edgeView.getTarget().getParentView() != null) tgt = edgeView.getTarget().getParentView().getCell(); else if (edgeView.getTargetParentView() != null) tgt = edgeView.getTargetParentView().getCell();
Rectangle2D sourceBounds = null; if ((edge.getTarget() != null && edge.getTarget() .getParentView() != null) && (edge.getSource() != null && edge.getSource() .getParentView() != null)) { targetBounds = edge.getTarget().getParentView().getBounds(); sourceBounds = edge.getSource().getParentView().getBounds();
|| (orig.getSource() != null && GraphConstants .isDisconnectable(orig.getSource() .getParentView() .getAllAttributes())) || (orig .getSourceParentView() != null && GraphConstants || (orig.getTarget() != null && GraphConstants .isDisconnectable(orig.getTarget() .getParentView() .getAllAttributes())) || (orig .getTargetParentView() != null && GraphConstants edgeModified = true; if (edge.getSource() != null) { dirty.add(edge.getSource().getParentView() .getBounds()); dirty.add(edge.getTarget().getParentView() .getBounds()); } else { if (edge.getSource() != null) { dirty.add(edge.getSource().getParentView() .getBounds()); dirty.add(edge.getTarget().getParentView() .getBounds());
if (e.getClickCount() == graph.getEditClickCount() && focus != null && isEditable && focus.getParentView() == null && graph.isCellEditable(focus.getCell()) && handleEditTrigger(cell.getCell(), e)) {
port, false); Rectangle2D dirty = edge.getBounds(); dirty.add(portView.getParentView().getBounds()); if (GraphConstants.isConnectable(portView.getParentView() .getAllAttributes())) { Object cell = edge.getCell();
if (view != null) { if (ignoresCellsInGroups) { return view.isLeaf() && view.getParentView() == null; } else { return view.isLeaf();
if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setSource(null); if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setTarget(null);