/** * Creates a point of suitable type for this attribute map with the same * values as the point passed in * * @param p * the point whose values the new point are to be based on * @return a new copy of the point passed in */ public Point2D createPoint(Point2D p) { if (p != null) { return createPoint(p.getX(), p.getY()); } return null; }
public void initialiseDefaultPoints(){ List controlPoints = GraphConstants.getPoints(allAttributes); if (controlPoints == null) { controlPoints = new ArrayList(4); controlPoints.add(allAttributes.createPoint(10, 10)); controlPoints.add(allAttributes.createPoint(20, 20)); GraphConstants.setPoints(allAttributes, controlPoints); } points=controlPoints; }
/** * Returns a list where all instances of PortView are replaced by their * correspnding Point instance. */ public List clonePoints(Object[] points, boolean convertPortViews) { // TODO: Change the list in-place? ArrayList newList = new ArrayList(points.length); for (int i = 0; i < points.length; i++) { // Clone Point Object point = points[i]; if (point instanceof PortView && convertPortViews) point = createPoint(((PortView) point).getLocation()); else if (point instanceof Point2D) point = createPoint((Point2D) point); newList.add(point); } return newList; }
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; }
public Point2D getPoint(int index) { Object obj = points.get(index); if (obj instanceof PortView) { return ((PortView) obj).getLocation(this, getPointLocation((index == 0) ? 1 : points .size() - 2)); } else if (obj instanceof VirtualNode) { return ((VirtualNode) obj).getPosition(); } else if (obj instanceof CellView) { System.err.println("CellView!"); Rectangle2D r = ((CellView) obj).getBounds(); return getAttributes().createPoint(r.getX(), r.getY()); } else if (obj instanceof Point2D) // Regular Point return (Point2D) obj; return null; }
Point2D p = createPoint(bounds.getX(), bounds.getY()); Point2D loc = (Point2D) p.clone(); p.setLocation(origin.getX()
for (int i = 0; i < n; i++) p[i] = tmp.getAttributes().createPoint(tmp.getPoint(i));
if (controlPoints == null) { controlPoints = new ArrayList(4); controlPoints.add(allAttributes.createPoint(10, 10)); controlPoints.add(allAttributes.createPoint(20, 20)); GraphConstants.setPoints(allAttributes, controlPoints);
/** * Apply the <code>key</code> to <code>value</code> * * @param key * the map key whose value is to be altered * @param value * the new value to be applied to the specified key * @return the old value. */ public Object applyValue(Object key, Object value) { // In all other cases we put the new value into the // map. If we encounter a list (of points) or rectangle // these will be cloned before insertion. Cloning includes // replacing the rectangle/points with serializable objects. if (value instanceof Rectangle2D) value = createRect((Rectangle2D) value); if (value instanceof Point2D) value = createPoint((Point2D) value); if (value instanceof Point2D[]) value = clonePoints((Point2D[]) value); if (value instanceof List) // FIXME: PointList interface? value = clonePoints((List) value); return put(key, value); }
} else if (edge.getSource() != null) { Rectangle2D b = edge.getSource().getBounds(); from = edge.getAttributes().createPoint(b.getCenterX(), b.getCenterY()); else if (target != null) { Rectangle2D b = target.getBounds(); to = edge.getAttributes().createPoint(b.getCenterX(), b.getCenterY()); routed[0] = edge.getAttributes().createPoint(x2, from.getY()); routed[1] = edge.getAttributes().createPoint(x2, to.getY()); if (targetBounds.contains(routed[0]) || targetBounds.contains(routed[1]) || (sourceBounds.contains(routed[1]))) { routed[0] = edge.getAttributes().createPoint( from.getX(), y2); routed[1] = edge.getAttributes().createPoint( to.getX(), y2); routed[0] = edge.getAttributes().createPoint( from.getX(), y2); routed[1] = edge.getAttributes().createPoint(to.getX(), y2); if (targetBounds.contains(routed[0])