use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class GridArrangementTest method testGridNotFull_NN.
/**
* The arrangement should be able to handle less blocks than grid spaces.
*/
@Test
public void testGridNotFull_NN() {
Block b1 = new EmptyBlock(5, 5);
BlockContainer c = new BlockContainer(new GridArrangement(2, 3));
c.add(b1);
Size2D s = c.arrange(null, RectangleConstraint.NONE);
assertEquals(15.0, s.getWidth(), EPSILON);
assertEquals(10.0, s.getHeight(), EPSILON);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class GridArrangementTest method testNullBlock_FF.
/**
* The arrangement should be able to handle null blocks in the layout.
*/
@Test
public void testNullBlock_FF() {
BlockContainer c = new BlockContainer(new GridArrangement(1, 1));
c.add(null);
Size2D s = c.arrange(null, new RectangleConstraint(20, 10));
assertEquals(20.0, s.getWidth(), EPSILON);
assertEquals(10.0, s.getHeight(), EPSILON);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
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>).
*/
@Override
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()));
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class FlowArrangement method arrangeFN.
/**
* Arranges the blocks in the container with a fixed width and no height
* constraint.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size.
*/
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
List blocks = container.getBlocks();
double width = constraint.getWidth();
double x = 0.0;
double y = 0.0;
double maxHeight = 0.0;
List itemsInRow = new ArrayList();
for (int i = 0; i < blocks.size(); i++) {
Block block = (Block) blocks.get(i);
Size2D size = block.arrange(g2, RectangleConstraint.NONE);
if (x + size.width <= width) {
itemsInRow.add(block);
block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));
x = x + size.width + this.horizontalGap;
maxHeight = Math.max(maxHeight, size.height);
} else {
if (itemsInRow.isEmpty()) {
// place in this row (truncated) anyway
block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));
x = 0.0;
y = y + size.height + this.verticalGap;
} else {
// start new row
itemsInRow.clear();
x = 0.0;
y = y + maxHeight + this.verticalGap;
maxHeight = size.height;
block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));
x = size.width + this.horizontalGap;
itemsInRow.add(block);
}
}
}
return new Size2D(constraint.getWidth(), y + maxHeight);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
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);
}
Aggregations