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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations