/** * Returns a list where all instances of PortView are replaced by their * correspnding Point instance. * * @param points * the points to be cloned * @return the cloned points */ public List clonePoints(List points) { return clonePoints(points.toArray(), true); }
/** * Returns a list where all instances of PortView are replaced by their * correspnding Point instance. * * @param points * the points to be cloned * @return the cloned points */ public Point2D[] clonePoints(Point2D[] points) { List pts = clonePoints(points, true); Point2D[] newPoints = new Point2D[pts.size()]; pts.toArray(newPoints); return newPoints; }
/** * 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); }
/** * Clones special object entried in the given map. */ public AttributeMap cloneEntries(AttributeMap newMap) { // Clone Bounds Rectangle2D bounds = GraphConstants.getBounds(newMap); if (bounds != null) GraphConstants.setBounds(newMap, (Rectangle2D) (bounds.clone())); // Clone List Of Points List points = GraphConstants.getPoints(newMap); if (points != null) GraphConstants.setPoints(newMap, clonePoints(points)); // Clone extra label positions Point2D[] positions = GraphConstants.getExtraLabelPositions(newMap); if (positions != null) GraphConstants.setExtraLabelPositions(newMap, clonePoints(positions)); // Clone Edge Label Point2D label = GraphConstants.getLabelPosition(newMap); if (label != null) GraphConstants.setLabelPosition(newMap, (Point2D) label.clone()); return newMap; }