Search in sources :

Example 31 with Size2D

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

the class GridArrangement method arrangeNN.

/**
 * Arranges the container with no constraint on the width or height.
 *
 * @param container  the container (<code>null</code> not permitted).
 * @param g2  the graphics device.
 *
 * @return The size.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double maxW = 0.0;
    double maxH = 0.0;
    List blocks = container.getBlocks();
    Iterator iterator = blocks.iterator();
    while (iterator.hasNext()) {
        Block b = (Block) iterator.next();
        if (b != null) {
            Size2D s = b.arrange(g2, RectangleConstraint.NONE);
            maxW = Math.max(maxW, s.width);
            maxH = Math.max(maxH, s.height);
        }
    }
    double width = this.columns * maxW;
    double height = this.rows * maxH;
    RectangleConstraint c = new RectangleConstraint(width, height);
    return arrangeFF(container, g2, c);
}
Also used : Size2D(org.jfree.chart.util.Size2D) Iterator(java.util.Iterator) List(java.util.List)

Example 32 with Size2D

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

the class GridArrangement method arrangeRN.

/**
 * Arrange with a fixed width and no height constraint.
 *
 * @param container  the container.
 * @param constraint  the constraint.
 * @param g2  the graphics device.
 *
 * @return The size of the arrangement.
 */
protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    RectangleConstraint c1 = constraint.toUnconstrainedWidth();
    Size2D size1 = arrange(container, g2, c1);
    if (constraint.getWidthRange().contains(size1.getWidth())) {
        return size1;
    } else {
        double w = constraint.getWidthRange().constrain(size1.getWidth());
        RectangleConstraint c2 = constraint.toFixedWidth(w);
        return arrange(container, g2, c2);
    }
}
Also used : Size2D(org.jfree.chart.util.Size2D)

Example 33 with Size2D

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

the class GridArrangement method arrangeFN.

/**
 * Arrange with a fixed width and a height within a given range.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 * @param constraint  the constraint.
 *
 * @return The size of the arrangement.
 */
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
    double width = constraint.getWidth() / this.columns;
    RectangleConstraint bc = constraint.toFixedWidth(width);
    List blocks = container.getBlocks();
    double maxH = 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);
                maxH = Math.max(maxH, s.getHeight());
            }
        }
    }
    RectangleConstraint cc = constraint.toFixedHeight(maxH * this.rows);
    return arrange(container, g2, cc);
}
Also used : Size2D(org.jfree.chart.util.Size2D) List(java.util.List)

Example 34 with Size2D

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

the class LabelBlock 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) {
    g2.setFont(this.font);
    Size2D s = this.label.calculateDimensions(g2);
    return new Size2D(calculateTotalWidth(s.getWidth()), calculateTotalHeight(s.getHeight()));
}
Also used : Size2D(org.jfree.chart.util.Size2D)

Example 35 with Size2D

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

the class CategoryAxis method calculateTextBlockHeight.

/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block, CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight() + insets.getTop() + insets.getBottom();
    return h;
}
Also used : Size2D(org.jfree.chart.util.Size2D) Shape(java.awt.Shape) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.chart.util.RectangleInsets)

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