protected org.jgraph.graph.EdgeView createEdgeView(Object v) { return new org.jgraph.graph.EdgeView(v); // if (v instanceof ExecuteEdge){ // return new ExecuteView(v,this,cm); // } }
public Point2D getPerimeterPoint(EdgeView edge, Point2D source, Point2D p) { if (getPointCount() > 2) return getPoint(getPointCount() / 2); Point2D p0 = getPoint(0); Point2D pe = getPoint(getPointCount() - 1); return new Point2D.Double((pe.getX() + p0.getX()) / 2, (pe.getY() + p0 .getY()) / 2); } }
/** * Returns the absolute position of the main label * @return the absolute position of the main label */ protected Point2D getAbsoluteLabelPosition() { Point2D result = getAbsoluteLabelPositionFromRelative(GraphConstants.getLabelPosition(getAllAttributes())); return result; }
/** * Sets the <code>sourceView</code> of the edge. */ public void setSource(CellView sourceView) { sourceParentView = null; source = sourceView; if (source != null) points.set(0, source); else points.set(0, getPoint(0)); invalidate(); }
public void mouseDragged(MouseEvent event) { Rectangle2D dirty = edge.getBounds(); Point2D p = graph.fromScreen(new Point(event.getPoint())); Rectangle2D r = edge.getBounds(); if (r != null) { edgeModified = true; if (!GraphConstants.isLabelAlongEdge(edge.getAllAttributes())) { p = getRelativeLabelPosition(edge, p); } else { Point2D p0 = edge.getPoint(0); Point2D vector = edge.getLabelVector(); double dx = vector.getX(); double dy = vector.getY(); edge.setLabelPosition(p); } else { edge.setExtraLabelPosition(currentLabel, p); edge.update(graph.getGraphLayoutCache()); if (graph.isXorEnabled()) { overlay(graph.getGraphics()); if (source) disconnectable = disconnectable && ((orig.getSource() == null && orig .getSourceParentView() == null)
Object source = (edge.getSource() != null) ? edge.getSource() .getCell() : null; Object target = (edge.getTarget() != null) ? edge.getTarget() .getCell() : null; if (edgeModified && model.acceptsSource(edge.getCell(), source) && model.acceptsTarget(edge.getCell(), target)) { Point2D location = null; Object[] extraLabels = GraphConstants.getExtraLabels(edge .getAllAttributes()); if (label) { location = (Point2D) edge.getLabelPosition().clone(); value = graph.convertValueToString(orig); edge.setLabelPosition(initialLabelLocation); } else { location = (Point2D) edge.getExtraLabelPosition( currentLabel).clone(); value = extraLabels[currentLabel]; edge.setExtraLabelPosition(currentLabel, initialLabelLocation); edge.addExtraLabel(location, value); edge.update(graph.getGraphLayoutCache()); clone = false; Map tmp = (Map) nested.get(edge.getCell()); List controlPoints = GraphConstants.getPoints(tmp); List currentPoints = edge.getPoints();
CellView nodeFrom = edge.getSource(); CellView nodeTo = edge.getTarget(); nodeFrom = edge.getSourceParentView(); nodeTo = edge.getTargetParentView(); List points = edge.getPoints(); Object startPort = points.get(0); Object endPort = points.get(points.size() - 1); if (e == edge.getCell()) { position = i + 1; Point2D perimeterPoint = edge.getTarget() != null ? edge .getPoint(edge.getPointCount() - 1) : AbstractCellView .getCenterPoint(nodeTo); if (perimeterPoint == null) { 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.isLeaf()) return; boolean bendable = graph.isBendable() && GraphConstants.isBendable(edge.getAllAttributes()); int x = event.getX(); int y = event.getY(); currentPoint = edge.getPoint(index); currentIndex = index; source = index == 0; .getAllAttributes())) currentPoint = edge.getPoint(index); currentIndex = index; source = index == 0; && GraphConstants.isMoveable(edge.getAllAttributes()) && loc != null && loc.contains(x, y) && !isAddPointEvent(event) && !isRemovePointEvent(event) && graph.getEdgeLabelsMovable()) { initialLabelLocation = (Point2D) edge.getLabelPosition() .clone(); label = true; && GraphConstants.isMoveable(edge.getAllAttributes())) { for (int i = 0; i < extraLabelLocations.length; i++) { if (extraLabelLocations[i] != null
if (cellView instanceof EdgeView) { EdgeView edgeView = (EdgeView) cellView; if (edgeView.getSource() == null) { Point2D pt = edgeView.getPoint(0); if (pt != null) { if (ret == null) if (edgeView.getTarget() == null) { Point2D pt = edgeView.getPoint(edgeView .getPointCount() - 1); if (pt != null) { if (ret == null)
if (cells[i] instanceof EdgeView) { EdgeView view = (EdgeView) cells[i]; CellView port = view.getSource(); if (GraphConstants.isDisconnectable(view.getAllAttributes())) { if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setSource(null); cs.disconnect(view.getCell(), true); port = view.getTarget(); if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setTarget(null); cs.disconnect(view.getCell(), false);
Point2D p0 = getPoint(0); double dx = 0; double dy = 0; int n = getPointCount(); if (isLoop()) { for (int i = 1; i < n; i++) { Point2D point = getPoint(i); dx += point.getX() - p0.getX(); dy += point.getY() - p0.getY(); Point2D lastPoint = getPoint(0); double totalLength = 0; Point2D currentPoint = getPoint(i); dx = currentPoint.getX() - lastPoint.getX(); dy = currentPoint.getY() - lastPoint.getY(); double relativeX = getLabelPosition().getX()/(double)GraphConstants.PERMILLE; double labelXPositionDistance = relativeX * totalLength; totalLength = 0; lastPoint = getPoint(0); if (relativeX <= 0.0 || relativeX >= 1.0) { exactSegment = false; } else { for (int i = 1; i < n; i++) { Point2D currentPoint = getPoint(i); dx = currentPoint.getX() - lastPoint.getX(); dy = currentPoint.getY() - lastPoint.getY();
protected Point2D getRelativeLabelPosition(EdgeView edge, Point2D p) { int pointCount = edge.getPointCount(); Point2D p0 = edge.getPoint(0); Point2D pt = p0; Point2D tmp = edge.getPoint(i); Point2D last = edge.getPoint(1); Line2D line = new Line2D.Double(p0, last); double minDist = line.ptSegDistSq(p); line = new Line2D.Double(edge.getPoint(i), last); double dist = line.ptSegDistSq(p); last = edge.getPoint(i); pt = edge.getPoint(index); Point2D pt2 = edge.getPoint(index+1); Point2D storedRelativePosition = edge.convertRelativeLabelPositionToAbsolute(result); if (p.equals(storedRelativePosition)) { GraphConstants.setRemoveAttributes(edge.getAllAttributes(), new Object[] {GraphConstants.OFFSET}); edge.getAllAttributes().remove(GraphConstants.OFFSET); } else { Point2D off = new Point2D.Double(p.getX() - storedRelativePosition.getX(), p.getY() - storedRelativePosition.getY()); GraphConstants.setOffset(edge.getAllAttributes(), off);
if (edgeView.getPointCount() == 2) { Point2D p0 = edgeView.getPoint(0); Point2D p1 = edgeView.getPoint(1); if (rect.intersectsLine(p0.getX(), p0.getY(), p1.getX(), p1 .getY())) } else { Graphics2D g2 = (Graphics2D) graph.getGraphics(); if (g2.hit(rect, view.getShape(), true)) return true; return true; Object[] labels = GraphConstants.getExtraLabels(view .getAllAttributes()); if (labels != null) { for (int i = 0; i < labels.length; i++) {
Point2D point = edge.getPoint(0); String d = "M " + (point.getX() - dx) + " " + (point.getY() - dy); for (int i = 1; i < edge.getPointCount(); i++) { point = edge.getPoint(i); d += " L " + (point.getX() - dx) + " " + (point.getY() - dy); int mid = edge.getPointCount() / 2; if (edge.isLoop()) { Point2D tmp = edge.getPoint(0); Point2D tmp2 = edge.getLabelVector(); center = new Point((int) (tmp.getX() + tmp2.getX() - dx), (int) (tmp.getY() + tmp2.getY() - dy)); } else if (edge.getPointCount() % 2 == 1) { Point2D tmp = edge.getPoint(mid); center = new Point((int) (tmp.getX() - dx), (int) (tmp.getY() - dy)); } else { Point2D p1 = edge.getPoint(mid - 1); Point2D p2 = edge.getPoint(mid); center = new Point((int) (p1.getX() + (p2.getX() - p1.getX()) / 2 - dx), (int) (p1.getY() + (p2.getY() - p1.getY())
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; }
double dx = 0; double dy = 0; int n = getPointCount(); if (exactSegment) { Point2D lastPoint = getPoint(0); double totalLength = 0; Point2D currentPoint = getPoint(i); dx = currentPoint.getX() - lastPoint.getX(); dy = currentPoint.getY() - lastPoint.getY(); double relativeX = getLabelPosition().getX()/(double)GraphConstants.PERMILLE; double labelXPositionDistance = relativeX * totalLength; totalLength = 0; lastPoint = getPoint(0); if (relativeX <= 0.0 || relativeX >= 1.0) { return -1; } else { for (int i = 1; i < n; i++) { Point2D currentPoint = getPoint(i); dx = currentPoint.getX() - lastPoint.getX(); dy = currentPoint.getY() - lastPoint.getY();
setSource(source); if (target != null) setTarget(target); checkDefaultLabelPosition(); Point2D[] positions = GraphConstants .getExtraLabelPositions(allAttributes); endShape = null; lineShape = null; invalidate();
protected Shape createShape() int n = view.getPointCount(); if (n > 1) for (int i = 0; i < n; i++) p[i] = tmp.getAttributes().createPoint(tmp.getPoint(i));
/** * Returns the cached points for this edge. */ public Point2D getPoint(int index) { Object obj = points.get(index); if (index == 0 && sourceParentView != null) { return sourceParentView.getPerimeterPoint(this, getCenterPoint(sourceParentView), getNearestPoint(index == 0)); } else if (index == getPointCount() - 1 && targetParentView != null) { return targetParentView.getPerimeterPoint(this, getCenterPoint(targetParentView), getNearestPoint(index == 0)); } else if (obj instanceof PortView) // Port Location Seen From This Edge return ((PortView) obj).getLocation(this, getNearestPoint(index == 0)); else if (obj instanceof CellView) { // Should not happen Rectangle2D r = ((CellView) obj).getBounds(); return new Point2D.Double(r.getX(), r.getY()); } else if (obj instanceof Point2D) // Regular Point return (Point2D) obj; return null; }
if (view.isLeaf()) { Shape edgeShape = view.getShape(); : getFont()); Object[] labels = GraphConstants.getExtraLabels(view .getAllAttributes()); JGraph graph = (JGraph)this.graph.get(); if (labels != null) { false || !simpleExtraLabels); if (graph.getEditingCell() != view.getCell()) { g.setFont(getFont()); Object label = graph.convertValueToString(view);