/** * 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 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; }
if (cellView instanceof EdgeView) { EdgeView edgeView = (EdgeView) cellView; if (edgeView.getSource() == null) { Point2D pt = edgeView.getPoint(0); if (pt != null) {
List newPoints = new ArrayList(); CellView nodeFrom = edge.getSource(); CellView nodeTo = edge.getTarget(); 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()) :
Point2D from = edge.getPoint(0); newPoints.add(from); if (edge.getSource() instanceof PortView) { newPoints.set(0, edge.getSource()); from = ((PortView) edge.getSource()).getLocation(); } else if (edge.getSource() != null) { Rectangle2D b = edge.getSource().getBounds(); from = edge.getAttributes().createPoint(b.getCenterX(), b.getCenterY()); 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();
protected ConnectionSet createConnectionSet(EdgeView view, boolean verbose) { Object edge = view.getCell(); GraphModel model = graph.getModel(); ConnectionSet cs = new ConnectionSet(); Object sourcePort = null, targetPort = null; if (view.getSource() != null) sourcePort = view.getSource().getCell(); else if (view.getSourceParentView() != null) sourcePort = model.getSource(edge); if (view.getTarget() != null) targetPort = view.getTarget().getCell(); else if (view.getTargetParentView() != null) targetPort = model.getTarget(edge); if (view.getTarget() != null) targetPort = view.getTarget().getCell(); if (verbose || (sourcePort != model.getSource(edge) && source)) cs.connect(edge, sourcePort, true); if (verbose || (targetPort != model.getTarget(edge) && target)) cs.connect(edge, targetPort, false); return cs; }
if (source) disconnectable = disconnectable && ((orig.getSource() == null && orig .getSourceParentView() == null) || (orig.getSource() != null && GraphConstants .isDisconnectable(orig.getSource() .getParentView() .getAllAttributes())) || (orig if (acceptSource || acceptTarget || !(source || target)) { edgeModified = true; if (edge.getSource() != null) { dirty.add(edge.getSource().getParentView() .getBounds()); overlay(graph.getGraphics()); } else { if (edge.getSource() != null) { dirty.add(edge.getSource().getParentView() .getBounds());
/** * Adds the connections in <code>views</code> to the connection set. */ public void addConnections(CellView[] views) { for (int i = 0; i < views.length; i++) { if (views[i] instanceof EdgeView) { EdgeView edgeView = (EdgeView) views[i]; Object edge = edgeView.getCell(); CellView sourceView = edgeView.getSource(); CellView targetView = edgeView.getTarget(); Object source = null; if (sourceView != null) source = sourceView.getCell(); Object target = null; if (targetView != null) target = targetView.getCell(); connect(edge, source, target); } } }
Object cell = edge.getCell(); if (source && graph.getModel().acceptsSource(cell, port)) { if (edge.getSource() != portView) { edgeModified = true; if (graph.isXorEnabled()) {
/** * Overrides the parent method to udpate the cached points, source and * target port. If the source or target is removed, a point is inserted into * the array of points. */ public void refresh(GraphLayoutCache cache, CellMapper mapper, boolean createDependentViews) { // Makes sure the manual control points are passed to // the router instead of the cached control points after // changes to the edge (normally manual point changes). initialiseDefaultPoints(); super.refresh(cache, mapper, createDependentViews); // Re-sync source- and targetportviews GraphModel model = cache.getModel(); Object modelSource = model.getSource(cell); Object modelTarget = model.getTarget(cell); setSource(mapper.getMapping(modelSource, createDependentViews)); setTarget(mapper.getMapping(modelTarget, createDependentViews)); if (modelSource != null && getSource() == null) sourceParentView = getVisibleParent(model, mapper, modelSource); else sourceParentView = null; if (modelTarget != null && getTarget() == null) targetParentView = getVisibleParent(model, mapper, modelTarget); else targetParentView = null; }
&& !target && bendable && (edge.getSource() == null || currentIndex > 0) && (edge.getTarget() == null || currentIndex < edge .getPointCount() - 1)) {
if (cells[i] instanceof EdgeView) { EdgeView view = (EdgeView) cells[i]; CellView port = view.getSource(); if (GraphConstants.isDisconnectable(view.getAllAttributes())) { if (port != null