Example usage for java.awt Rectangle union

List of usage examples for java.awt Rectangle union

Introduction

In this page you can find the example usage for java.awt Rectangle union.

Prototype

public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) 

Source Link

Document

Unions the pair of source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.

Usage

From source file:com.projity.pm.graphic.xbs.XbsLayout.java

private void setShape(GraphicNode node, Rectangle2D ref, double centerX, double centerY) {
    TexturedShape texturedShape = findShape(node);
    if (texturedShape == null)
        return;//from  w  w w . ja v a2s . com
    GeneralPath shape = texturedShape.toGeneralPath(ref.getWidth(), ref.getHeight(),
            centerX - ref.getWidth() / 2, centerY, null);
    node.setXbsShape(shape, centerX, centerY);
    Rectangle.union(bounds, network.scale(shape.getBounds()), bounds);
}

From source file:com.projity.pm.graphic.pert.PertLayout.java

public void updateBounds() {
    dependencyGraph.updatePertLevels();/*from  www.  jav  a 2  s . c  om*/

    GraphicConfiguration config = GraphicConfiguration.getInstance();

    Point2D origin = new Point2D.Double(config.getPertXOffset(), config.getPertYOffset());
    Rectangle2D ref = new Rectangle2D.Double(config.getPertXOffset(), config.getPertYOffset(),
            config.getPertCellWidth(), config.getPertCellHeight());
    int row = 0;
    int col = -1;
    setEmpty();
    for (Iterator i = cache.getIterator(); i.hasNext();) {
        GraphicNode current = (GraphicNode) i.next();
        int currentCol = cache.getPertLevel(current) - 1;
        if (currentCol <= col)
            row++;
        col = currentCol;

        TexturedShape texturedShape = findShape(current);
        if (texturedShape == null)
            continue;
        double centerX = origin.getX() + ref.getMaxX() * col + ref.getWidth() / 2;
        double centerY = origin.getY() + ref.getMaxY() * row + ref.getHeight() / 2;
        //System.out.println(centerX+"/"+centerY);
        GeneralPath shape = texturedShape.toGeneralPath(ref.getWidth(), ref.getHeight(),
                centerX - ref.getWidth() / 2, centerY, null);
        current.setPertShape(shape, centerX, centerY);
        Rectangle cellBounds = network.scale(shape.getBounds());
        if (isEmpty())
            bounds.setBounds(cellBounds);
        else
            Rectangle.union(bounds, cellBounds, bounds);
    }
    fireLayoutChanged();
}