Search in sources :

Example 11 with Size2D

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

the class BorderArrangement method arrangeFR.

/**
 * Performs an arrangement with a fixed width and a range for the height.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 * @param constraint  the constraint.
 *
 * @return The container size after the arrangement.
 */
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    Size2D size1 = arrangeFN(container, g2, constraint.getWidth());
    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 12 with Size2D

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

the class BorderArrangement method arrange.

/**
 * Arranges the items in the specified container, subject to the given
 * constraint.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 * @param constraint  the constraint.
 *
 * @return The block size.
 */
public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    RectangleConstraint contentConstraint = container.toContentConstraint(constraint);
    Size2D contentSize = null;
    LengthConstraintType w = contentConstraint.getWidthConstraintType();
    LengthConstraintType h = contentConstraint.getHeightConstraintType();
    if (w == LengthConstraintType.NONE) {
        if (h == LengthConstraintType.NONE) {
            contentSize = arrangeNN(container, g2);
        } else if (h == LengthConstraintType.FIXED) {
            throw new RuntimeException("Not implemented.");
        } else if (h == LengthConstraintType.RANGE) {
            throw new RuntimeException("Not implemented.");
        }
    } else if (w == LengthConstraintType.FIXED) {
        if (h == LengthConstraintType.NONE) {
            contentSize = arrangeFN(container, g2, constraint.getWidth());
        } else if (h == LengthConstraintType.FIXED) {
            contentSize = arrangeFF(container, g2, constraint);
        } else if (h == LengthConstraintType.RANGE) {
            contentSize = arrangeFR(container, g2, constraint);
        }
    } else if (w == LengthConstraintType.RANGE) {
        if (h == LengthConstraintType.NONE) {
            throw new RuntimeException("Not implemented.");
        } else if (h == LengthConstraintType.FIXED) {
            throw new RuntimeException("Not implemented.");
        } else if (h == LengthConstraintType.RANGE) {
            contentSize = arrangeRR(container, constraint.getWidthRange(), constraint.getHeightRange(), g2);
        }
    }
    return new Size2D(container.calculateTotalWidth(contentSize.getWidth()), container.calculateTotalHeight(contentSize.getHeight()));
}
Also used : Size2D(org.jfree.chart.util.Size2D)

Example 13 with Size2D

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

the class CenterArrangement method arrangeFN.

/**
 * Arranges the blocks in the container with a fixed width and no height
 * constraint.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 * @param constraint  the constraint.
 *
 * @return The size.
 */
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    List blocks = container.getBlocks();
    Block b = (Block) blocks.get(0);
    Size2D s = b.arrange(g2, RectangleConstraint.NONE);
    double width = constraint.getWidth();
    Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, 0.0, s.width, s.height);
    b.setBounds(bounds);
    return new Size2D((width - s.width) / 2.0, s.height);
}
Also used : Size2D(org.jfree.chart.util.Size2D) Rectangle2D(java.awt.geom.Rectangle2D) List(java.util.List)

Example 14 with Size2D

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

the class ColumnArrangement method arrangeNN.

/**
 * Arranges the blocks without any constraints.  This puts all blocks
 * into a single column.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 *
 * @return The size after the arrangement.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double y = 0.0;
    double height = 0.0;
    double maxWidth = 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);
            height = height + sizes[i].getHeight();
            maxWidth = Math.max(sizes[i].width, maxWidth);
            block.setBounds(new Rectangle2D.Double(0.0, y, sizes[i].width, sizes[i].height));
            y = y + sizes[i].height + this.verticalGap;
        }
        if (blockCount > 1) {
            height = height + this.verticalGap * (blockCount - 1);
        }
        if (this.horizontalAlignment != HorizontalAlignment.LEFT) {
            for (int i = 0; i < blocks.size(); i++) {
                // Block b = (Block) blocks.get(i);
                if (this.horizontalAlignment == HorizontalAlignment.CENTER) {
                // TODO: shift block right by half
                } else if (this.horizontalAlignment == HorizontalAlignment.RIGHT) {
                // TODO: shift block over to right
                }
            }
        }
    }
    return new Size2D(maxWidth, height);
}
Also used : Size2D(org.jfree.chart.util.Size2D) Rectangle2D(java.awt.geom.Rectangle2D) List(java.util.List) ArrayList(java.util.ArrayList)

Example 15 with Size2D

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

the class CompositeTitle method arrange.

/**
 * Arranges the contents of the block, within the given constraints, and
 * returns the block size.
 *
 * @param g2  the graphics device.
 * @param constraint  the constraint (<code>null</code> not permitted).
 *
 * @return The block size (in Java2D units, never <code>null</code>).
 */
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
    RectangleConstraint contentConstraint = toContentConstraint(constraint);
    Size2D contentSize = this.container.arrange(g2, contentConstraint);
    return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));
}
Also used : Size2D(org.jfree.chart.util.Size2D) RectangleConstraint(org.jfree.chart.block.RectangleConstraint)

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