Search in sources :

Example 6 with Size2D

use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.

the class GridArrangementTest method testFN.

/**
 * Test arrangement with a fixed width and no height constraint.
 */
@Test
public void testFN() {
    BlockContainer c = createTestContainer1();
    RectangleConstraint constraint = new RectangleConstraint(100.0, null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE);
    Size2D s = c.arrange(null, constraint);
    assertEquals(100.0, s.width, EPSILON);
    assertEquals(33.0, s.height, EPSILON);
}
Also used : Size2D(org.jfree.ui.Size2D) Test(org.junit.Test)

Example 7 with Size2D

use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.

the class GridArrangementTest method testRF.

/**
 * Test arrangement with a range for the width and a fixed height.
 */
@Test
public void testRF() {
    BlockContainer c = createTestContainer1();
    RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, 60.0), 100.0);
    Size2D s = c.arrange(null, constraint);
    assertEquals(60.0, s.width, EPSILON);
    assertEquals(100.0, s.height, EPSILON);
}
Also used : Size2D(org.jfree.ui.Size2D) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 8 with Size2D

use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.

the class GridArrangementTest method testRN.

/**
 * Test arrangement with a range for the width and no height constraint.
 */
@Test
public void testRN() {
    BlockContainer c = createTestContainer1();
    RectangleConstraint constraint = RectangleConstraint.NONE.toRangeWidth(new Range(40.0, 60.0));
    Size2D s = c.arrange(null, constraint);
    assertEquals(60.0, s.width, EPSILON);
    assertEquals(33.0, s.height, EPSILON);
}
Also used : Size2D(org.jfree.ui.Size2D) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 9 with Size2D

use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.

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.ui.Size2D) Rectangle2D(java.awt.geom.Rectangle2D) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with Size2D

use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.

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.ui.Size2D) List(java.util.List)

Aggregations

Size2D (org.jfree.ui.Size2D)62 Test (org.junit.Test)19 Rectangle2D (java.awt.geom.Rectangle2D)18 Range (org.jfree.data.Range)14 List (java.util.List)10 RectangleConstraint (org.jfree.chart.block.RectangleConstraint)8 RectangleEdge (org.jfree.ui.RectangleEdge)5 Graphics2D (java.awt.Graphics2D)4 BufferedImage (java.awt.image.BufferedImage)4 ArrayList (java.util.ArrayList)4 LengthConstraintType (org.jfree.chart.block.LengthConstraintType)4 RectangleInsets (org.jfree.ui.RectangleInsets)4 FontMetrics (java.awt.FontMetrics)3 Shape (java.awt.Shape)3 Point2D (java.awt.geom.Point2D)2 BlockParams (org.jfree.chart.block.BlockParams)2 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)2 G2TextMeasurer (org.jfree.text.G2TextMeasurer)2 Arc2D (java.awt.geom.Arc2D)1 Iterator (java.util.Iterator)1