protected void reloadPoints(EdgeView edge) { relevantEdge = edge; r = new Rectangle[edge.getPointCount()]; for (int i = 0; i < r.length; i++) r[i] = new Rectangle(); invalidate(); }
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); } }
public static double getLength(CellView view) { double cost = 1; if (view instanceof EdgeView) { EdgeView edge = (EdgeView) view; Point2D last = null, current = null; for (int i = 0; i < edge.getPointCount(); i++) { current = edge.getPoint(i); if (last != null) cost += last.distance(current); last = current; } } return cost; }
/** * Estimates whether the transform for label should be applied. With the * transform, the label will be painted along the edge. To apply transform, * rotate graphics by the angle returned from {@link #getLabelAngle} * * @return true, if transform can be applied, false otherwise */ private boolean isLabelTransform(String label) { if (!isLabelTransformEnabled()) { return false; } Point2D p = getLabelPosition(view); if (p != null && label != null && label.length() > 0) { int sw = metrics.stringWidth(label); Point2D p1 = view.getPoint(0); Point2D p2 = view.getPoint(view.getPointCount() - 1); double length = Math.sqrt((p2.getX() - p1.getX()) * (p2.getX() - p1.getX()) + (p2.getY() - p1.getY()) * (p2.getY() - p1.getY())); if (!(length <= Double.NaN || length < sw)) { return true; } } return false; }
Point2D p2 = view.getPoint(view.getPointCount() - 1);
/** * */ public static double getLength(CellView view) { double cost = 1.0; if (view instanceof EdgeView) { EdgeView edge = (EdgeView) view; Point2D last = null, current = null; for (int i = 0; i < edge.getPointCount(); i++) { current = edge.getPoint(i); if (last != null) cost += last.distance(current); last = current; } } return cost; } }
/** * Subclassers can override this to decide whether or not "port magic" * should appear on a given edge. (Port magic means the port tries to make * the edge horizontal or vertical if the closest control point lies within * the bounds of the parent vertex.) */ protected boolean shouldInvokePortMagic(EdgeView edge) { return allowPortMagic && !(getParentView() instanceof EdgeView) && edge.getPointCount() > 2 && GraphConstants.getLineStyle(edge.getAllAttributes()) == GraphConstants.STYLE_ORTHOGONAL; }
int pointCount = getPointCount(); double[] segments = new double[pointCount];
double dx = 0; double dy = 0; int n = getPointCount(); if (exactSegment) {
double dy = 0; int n = getPointCount(); if (isLoop()) { for (int i = 1; i < n; i++) {
.getPointCount() - 1); if (pt != null) { if (ret == null)
protected Point2D getRelativeLabelPosition(EdgeView edge, Point2D p) { int pointCount = edge.getPointCount();
/** * 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; }
protected Shape createShape() int n = view.getPointCount(); if (n > 1)
if (edgeView.getPointCount() == 2) { Point2D p0 = edgeView.getPoint(0); Point2D p1 = edgeView.getPoint(1);
/** * 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); }
protected List routeEdge(GraphLayoutCache cache, EdgeView edge) { List newPoints = new ArrayList(); int n = edge.getPointCount(); Point2D from = edge.getPoint(0); newPoints.add(from);
edge.setSource(null); } else if (target) { edge.setPoint(edge.getPointCount() - 1, p); edge.setTarget(null);
controlPoints.set(0, edge.getPoint(0)); controlPoints.set(controlPoints.size() - 1, edge .getPoint(edge.getPointCount() - 1));
&& (edge.getSource() == null || currentIndex > 0) && (edge.getTarget() == null || currentIndex < edge .getPointCount() - 1)) { edge.removePoint(index); edgeModified = true; .getPoint()))); double min = Double.MAX_VALUE, dist = 0; for (int i = 0; i < edge.getPointCount() - 1; i++) { Point2D p = edge.getPoint(i); Point2D p1 = edge.getPoint(i + 1);