/** * Returns the absolute position of the specified extra label * @param index the index of the extra label * @return the absolute position of the specified extra label */ protected Point2D getAbsoluteExtraLabelPosition(int index) { Point2D[] positions = GraphConstants .getExtraLabelPositions(getAllAttributes()); if (positions != null && positions.length > index) { Point2D result = getAbsoluteLabelPositionFromRelative(positions[index]); return result; } return null; }
/** * Returns the label position of the specified view in the given graph. */ public Point2D getExtraLabelPosition(EdgeView view, int index) { setView(view); Point2D[] pts = GraphConstants.getExtraLabelPositions(view .getAllAttributes()); if (pts != null && index < pts.length) return getLabelPosition(pts[index]); return null; }
/** * Adds an extra label. */ public void addExtraLabel(Point2D location, Object label) { Object[] extraLabels = GraphConstants .getExtraLabels(getAllAttributes()); Point2D[] positions = GraphConstants .getExtraLabelPositions(getAllAttributes()); // Inserts a new extra label if (extraLabels == null) { extraLabels = new Object[1]; positions = new Point2D[1]; } else { Object[] tmp = new Object[extraLabels.length + 1]; System.arraycopy(extraLabels, 0, tmp, 0, extraLabels.length); extraLabels = tmp; Point2D[] pts = new Point2D[positions.length + 1]; System.arraycopy(positions, 0, pts, 0, positions.length); positions = pts; } int newIndex = extraLabels.length - 1; extraLabels[newIndex] = label; positions[newIndex] = location; GraphConstants.setExtraLabels(getAllAttributes(), extraLabels); GraphConstants.setExtraLabelPositions(getAllAttributes(), positions); }
/** * Removes the point at position <code>index</code>. */ public void removeExtraLabel(int index) { Object[] labels = GraphConstants.getExtraLabels(getAllAttributes()); Point2D[] pts = GraphConstants .getExtraLabelPositions(getAllAttributes()); if (labels == null || labels.length > 1) { Object[] newLabels = new Object[labels.length - 1]; Point2D[] newPts = new Point2D[pts.length - 1]; System.arraycopy(labels, 0, newLabels, 0, index); if (index < newLabels.length) System.arraycopy(labels, index + 1, newLabels, index, newLabels.length - index); System.arraycopy(pts, 0, newPts, 0, index); if (index < newPts.length) System.arraycopy(pts, index + 1, newPts, index, newPts.length - index); GraphConstants.setExtraLabels(getAllAttributes(), newLabels); GraphConstants.setExtraLabelPositions(getAllAttributes(), newPts); } else { // TODO: Remove via REMOVEATTRIBUTES GraphConstants.setExtraLabels(getAllAttributes(), new Object[0]); GraphConstants.setExtraLabelPositions(getAllAttributes(), new Point2D[0]); } }
.getExtraLabelPositions(allAttributes); if (positions != null) { extraLabelPositions = new Point2D[positions.length];
else GraphConstants.setExtraLabels(am,new Object[]{""}); if (GraphConstants.getExtraLabelPositions(am)==null) GraphConstants.setExtraLabelPositions(am,new Point[]{new Point(0, 20)}); Hashtable naryEdgeAtts=naryedge.getAttributes();
/** * 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; }