/** * Creates a rectangle of suitable type for this attribute map at the * position of the point passed in * * @param pt * the position of the new rectangle * @return a new rectangle the specified coordinates of zero size */ public Rectangle2D createRect(Point2D pt) { return createRect(pt, 0); }
/** * Creates a rectangle of suitable type for this attribute map * * @param x * the x-coordinate position of the new rectangle * @param y * the y-coordinate position of the new rectangle * @param w * the width of the new rectangle * @param h * the height of the new rectangle * @param grow1 * the amount both dimensions are to be increased by and the * position coorindates of the rectangle are to be decreased by * @param grow2 * the additional amount by which both dimensions are to be * increased by * @return a new rectangle at the coordinates and of the dimensions passed * in */ public Rectangle2D createRect(double x, double y, double w, double h, double grow1, double grow2) { return createRect(x - grow1, y - grow1, w + grow1 + grow2, h + grow1 + grow2); }
/** * Creates a rectangle of suitable type for this attribute map at the * position of the point passed in with lengths <code>size</code> * * @param pt * the position of the new rectangle * @param size * the length of both sides of the rectangle * @return a new rectangle the specified position and dimensions */ public Rectangle2D createRect(Point2D pt, double size) { if (pt != null) { return createRect(pt.getX(), pt.getY(), size, size); } return null; }
/** * Clones the rectangle passed in * * @param rect * the rectangle to clone * * @return a copy of the rectangle passed in */ public Rectangle2D createRect(Rectangle2D rect) { if (rect != null) { return createRect(rect.getX(), rect.getY(), rect.getWidth(), rect .getHeight()); } return null; }
/** * Creates a clone of the rectangle passed in and manipulates it by * <code>grow1</code> and <code>grow2</code> * * @param grow1 * the amount both dimensions are to be increased by and the * position coorindates of the rectangle are to be decreased by * @param grow2 * the additional amount by which both dimensions are to be * increased by * @return a new rectangle at the coordinates and of the dimensions passed * in */ public Rectangle2D createRect(Rectangle2D rect, double grow1, double grow2) { if (rect != null) { return createRect(rect.getX(), rect.getY(), rect.getWidth(), rect .getHeight(), grow1, grow2); } return null; }
/** * Overrides the parent method to udpate the cached points. */ public void update(GraphLayoutCache cache) { super.update(cache); bounds = GraphConstants.getBounds(allAttributes); if (bounds == null) { bounds = allAttributes.createRect(defaultBounds); GraphConstants.setBounds(allAttributes, bounds); } groupBounds = null; }
/** * Returns an attributeMap for the specified position and color. */ public static Map createBounds(AttributeMap map, int x, int y, Color c) { GraphConstants.setBounds(map, map.createRect(x, y, 90, 30)); GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder()); GraphConstants.setBackground(map, c.darker().darker()); GraphConstants .setGradientColor(map, c.brighter().brighter().brighter()); GraphConstants.setForeground(map, Color.white); if (GraphConstants.DEFAULTFONT != null) { GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont( Font.BOLD, 12)); } GraphConstants.setOpaque(map, true); return map; }
dummyBounds = attrs.createRect(bounds.getX(), bounds.getY(), 0, 0); } else { dummyBounds = attrs.createRect(0, 0, 0, 0);
protected void cellWillCollapse(Object cell) { GraphModel model = getModel(); if (movesParentsOnCollapse) { CellView view = getMapping(cell, false); if (view != null && !view.isLeaf()) { // Uses view-local attribute if available AttributeMap attrs = view.getAttributes(); if (!attrs.contains(GraphConstants.BOUNDS) && !localAttributes.contains(GraphConstants.BOUNDS)) attrs = model.getAttributes(cell); // Moves the group to the origin of the children Rectangle2D src = GraphConstants.getBounds(attrs); Rectangle2D b = view.getBounds(); // FIXME: What if the group is exactly at "defaultBounds"? if (resizesParentsOnCollapse || src == null || src.equals(VertexView.defaultBounds)) { src = attrs.createRect(b.getX(), b.getY(), b.getWidth() * collapseXScale, b.getHeight() * collapseYScale); attrs.applyValue(GraphConstants.BOUNDS, src); } else { src.setFrame(b.getX(), b.getY(), src.getWidth(), src .getHeight()); } } } }
/** * 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); }