Search in sources :

Example 26 with Size2D

use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.

the class FlowArrangement method arrangeNN.

/**
 * Arranges the blocks without any constraints.  This puts all blocks
 * into a single row.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 *
 * @return The size after the arrangement.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double x = 0.0;
    double width = 0.0;
    double maxHeight = 0.0;
    List blocks = container.getBlocks();
    int blockCount = blocks.size();
    if (blockCount > 0) {
        Size2D[] sizes = new Size2D[blocks.size()];
        for (int i = 0; i < blocks.size(); i++) {
            Block block = (Block) blocks.get(i);
            sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
            width = width + sizes[i].getWidth();
            maxHeight = Math.max(sizes[i].height, maxHeight);
            block.setBounds(new Rectangle2D.Double(x, 0.0, sizes[i].width, sizes[i].height));
            x = x + sizes[i].width + this.horizontalGap;
        }
        if (blockCount > 1) {
            width = width + this.horizontalGap * (blockCount - 1);
        }
        if (this.verticalAlignment != VerticalAlignment.TOP) {
            for (int i = 0; i < blocks.size(); i++) {
                // Block b = (Block) blocks.get(i);
                if (this.verticalAlignment == VerticalAlignment.CENTER) {
                // TODO: shift block down by half
                } else if (this.verticalAlignment == VerticalAlignment.BOTTOM) {
                // TODO: shift block down to bottom
                }
            }
        }
    }
    return new Size2D(width, maxHeight);
}
Also used : Size2D(org.jfree.chart.util.Size2D) Rectangle2D(java.awt.geom.Rectangle2D) List(java.util.List) ArrayList(java.util.ArrayList)

Example 27 with Size2D

use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.

the class GridArrangement method arrangeNF.

/**
 * Arrange with a fixed height and no constraint for the width.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 * @param constraint  the constraint.
 *
 * @return The size of the arrangement.
 */
protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    double height = constraint.getHeight() / this.rows;
    RectangleConstraint bc = constraint.toFixedHeight(height);
    List blocks = container.getBlocks();
    double maxW = 0.0;
    for (int r = 0; r < this.rows; r++) {
        for (int c = 0; c < this.columns; c++) {
            int index = r * this.columns + c;
            if (index >= blocks.size()) {
                break;
            }
            Block b = (Block) blocks.get(index);
            if (b != null) {
                Size2D s = b.arrange(g2, bc);
                maxW = Math.max(maxW, s.getWidth());
            }
        }
    }
    RectangleConstraint cc = constraint.toFixedWidth(maxW * this.columns);
    return arrange(container, g2, cc);
}
Also used : Size2D(org.jfree.chart.util.Size2D) List(java.util.List)

Example 28 with Size2D

use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.

the class GridArrangement method arrangeFR.

/**
 * Arrange with a fixed width and a height within a given range.
 *
 * @param container  the container.
 * @param constraint  the constraint.
 * @param g2  the graphics device.
 *
 * @return The size of the arrangement.
 */
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    RectangleConstraint c1 = constraint.toUnconstrainedHeight();
    Size2D size1 = arrange(container, g2, c1);
    if (constraint.getHeightRange().contains(size1.getHeight())) {
        return size1;
    } else {
        double h = constraint.getHeightRange().constrain(size1.getHeight());
        RectangleConstraint c2 = constraint.toFixedHeight(h);
        return arrange(container, g2, c2);
    }
}
Also used : Size2D(org.jfree.chart.util.Size2D)

Example 29 with Size2D

use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.

the class GridArrangement method arrangeRR.

/**
 * Arrange with ranges for both the width and height constraints.
 *
 * @param container  the container.
 * @param constraint  the constraint.
 * @param g2  the graphics device.
 *
 * @return The size of the arrangement.
 */
protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    Size2D size1 = arrange(container, g2, RectangleConstraint.NONE);
    if (constraint.getWidthRange().contains(size1.getWidth())) {
        if (constraint.getHeightRange().contains(size1.getHeight())) {
            return size1;
        } else {
            // width is OK, but height must be constrained
            double h = constraint.getHeightRange().constrain(size1.getHeight());
            RectangleConstraint cc = new RectangleConstraint(size1.getWidth(), h);
            return arrangeFF(container, g2, cc);
        }
    } else {
        if (constraint.getHeightRange().contains(size1.getHeight())) {
            // height is OK, but width must be constrained
            double w = constraint.getWidthRange().constrain(size1.getWidth());
            RectangleConstraint cc = new RectangleConstraint(w, size1.getHeight());
            return arrangeFF(container, g2, cc);
        } else {
            double w = constraint.getWidthRange().constrain(size1.getWidth());
            double h = constraint.getHeightRange().constrain(size1.getHeight());
            RectangleConstraint cc = new RectangleConstraint(w, h);
            return arrangeFF(container, g2, cc);
        }
    }
}
Also used : Size2D(org.jfree.chart.util.Size2D)

Example 30 with Size2D

use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.

the class GridArrangement method arrangeFF.

/**
 * Arranges the container with a fixed overall width and height.
 *
 * @param container  the container (<code>null</code> not permitted).
 * @param g2  the graphics device.
 * @param constraint  the constraint (<code>null</code> not permitted).
 *
 * @return The size following the arrangement.
 */
protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    double width = constraint.getWidth() / this.columns;
    double height = constraint.getHeight() / this.rows;
    List blocks = container.getBlocks();
    for (int c = 0; c < this.columns; c++) {
        for (int r = 0; r < this.rows; r++) {
            int index = r * this.columns + c;
            if (index >= blocks.size()) {
                break;
            }
            Block b = (Block) blocks.get(index);
            if (b != null) {
                b.setBounds(new Rectangle2D.Double(c * width, r * height, width, height));
            }
        }
    }
    return new Size2D(this.columns * width, this.rows * height);
}
Also used : Size2D(org.jfree.chart.util.Size2D) Rectangle2D(java.awt.geom.Rectangle2D) List(java.util.List)

Aggregations

Size2D (org.jfree.chart.util.Size2D)49 Rectangle2D (java.awt.geom.Rectangle2D)21 List (java.util.List)10 RectangleConstraint (org.jfree.chart.block.RectangleConstraint)8 Iterator (java.util.Iterator)5 RectangleEdge (org.jfree.chart.util.RectangleEdge)5 Range (org.jfree.data.Range)5 FontMetrics (java.awt.FontMetrics)4 Shape (java.awt.Shape)4 ArrayList (java.util.ArrayList)4 LengthConstraintType (org.jfree.chart.block.LengthConstraintType)4 RectangleInsets (org.jfree.chart.util.RectangleInsets)4 Point2D (java.awt.geom.Point2D)2 BlockParams (org.jfree.chart.block.BlockParams)2 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)2 G2TextMeasurer (org.jfree.chart.text.G2TextMeasurer)2 Arc2D (java.awt.geom.Arc2D)1 AxisLocation (org.jfree.chart.axis.AxisLocation)1 AxisSpace (org.jfree.chart.axis.AxisSpace)1 BlockContainer (org.jfree.chart.block.BlockContainer)1