use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class BorderArrangement method arrangeFN.
/**
* Arranges the container width a fixed width and no constraint on the
* height.
*
* @param container the container.
* @param g2 the graphics device.
* @param width the fixed width.
*
* @return The container size after arranging the contents.
*/
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, double width) {
double[] w = new double[5];
double[] h = new double[5];
RectangleConstraint c1 = new RectangleConstraint(width, null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE);
if (this.topBlock != null) {
Size2D size = this.topBlock.arrange(g2, c1);
w[0] = size.width;
h[0] = size.height;
}
if (this.bottomBlock != null) {
Size2D size = this.bottomBlock.arrange(g2, c1);
w[1] = size.width;
h[1] = size.height;
}
RectangleConstraint c2 = new RectangleConstraint(0.0, new Range(0.0, width), LengthConstraintType.RANGE, 0.0, null, LengthConstraintType.NONE);
if (this.leftBlock != null) {
Size2D size = this.leftBlock.arrange(g2, c2);
w[2] = size.width;
h[2] = size.height;
}
if (this.rightBlock != null) {
double maxW = Math.max(width - w[2], 0.0);
RectangleConstraint c3 = new RectangleConstraint(0.0, new Range(Math.min(w[2], maxW), maxW), LengthConstraintType.RANGE, 0.0, null, LengthConstraintType.NONE);
Size2D size = this.rightBlock.arrange(g2, c3);
w[3] = size.width;
h[3] = size.height;
}
h[2] = Math.max(h[2], h[3]);
h[3] = h[2];
if (this.centerBlock != null) {
RectangleConstraint c4 = new RectangleConstraint(width - w[2] - w[3], null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE);
Size2D size = this.centerBlock.arrange(g2, c4);
w[4] = size.width;
h[4] = size.height;
}
double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4]));
return arrange(container, g2, new RectangleConstraint(width, height));
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class BorderArrangement method arrangeRR.
/**
* Performs an arrangement with range constraints on both the vertical
* and horizontal sides.
*
* @param container the container.
* @param widthRange the allowable range for the container width.
* @param heightRange the allowable range for the container height.
* @param g2 the graphics device.
*
* @return The container size.
*/
protected Size2D arrangeRR(BlockContainer container, Range widthRange, Range heightRange, Graphics2D g2) {
double[] w = new double[5];
double[] h = new double[5];
if (this.topBlock != null) {
RectangleConstraint c1 = new RectangleConstraint(widthRange, heightRange);
Size2D size = this.topBlock.arrange(g2, c1);
w[0] = size.width;
h[0] = size.height;
}
if (this.bottomBlock != null) {
Range heightRange2 = Range.shift(heightRange, -h[0], false);
RectangleConstraint c2 = new RectangleConstraint(widthRange, heightRange2);
Size2D size = this.bottomBlock.arrange(g2, c2);
w[1] = size.width;
h[1] = size.height;
}
Range heightRange3 = Range.shift(heightRange, -(h[0] + h[1]));
if (this.leftBlock != null) {
RectangleConstraint c3 = new RectangleConstraint(widthRange, heightRange3);
Size2D size = this.leftBlock.arrange(g2, c3);
w[2] = size.width;
h[2] = size.height;
}
Range widthRange2 = Range.shift(widthRange, -w[2], false);
if (this.rightBlock != null) {
RectangleConstraint c4 = new RectangleConstraint(widthRange2, heightRange3);
Size2D size = this.rightBlock.arrange(g2, c4);
w[3] = size.width;
h[3] = size.height;
}
h[2] = Math.max(h[2], h[3]);
h[3] = h[2];
Range widthRange3 = Range.shift(widthRange, -(w[2] + w[3]), false);
if (this.centerBlock != null) {
RectangleConstraint c5 = new RectangleConstraint(widthRange3, heightRange3);
Size2D size = this.centerBlock.arrange(g2, c5);
w[4] = size.width;
h[4] = size.height;
}
double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3]));
double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4]));
if (this.topBlock != null) {
this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, width, h[0]));
}
if (this.bottomBlock != null) {
this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, height - h[1], width, h[1]));
}
if (this.leftBlock != null) {
this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], h[2]));
}
if (this.rightBlock != null) {
this.rightBlock.setBounds(new Rectangle2D.Double(width - w[3], h[0], w[3], h[3]));
}
if (this.centerBlock != null) {
this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], width - w[2] - w[3], height - h[0] - h[1]));
}
return new Size2D(width, height);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class ColumnArrangement method arrangeNF.
/**
* Calculates and sets the bounds of all the items in the specified
* container, subject to the given constraint. The <code>Graphics2D</code>
* can be used by some items (particularly items containing text) to
* calculate sizing parameters.
*
* @param container the container whose items are being arranged.
* @param constraint the size constraint.
* @param g2 the graphics device.
*
* @return The container size after the arrangement.
*/
protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
List blocks = container.getBlocks();
double height = constraint.getHeight();
if (height <= 0.0) {
height = Double.POSITIVE_INFINITY;
}
double x = 0.0;
double y = 0.0;
double maxWidth = 0.0;
List itemsInColumn = new ArrayList();
for (int i = 0; i < blocks.size(); i++) {
Block block = (Block) blocks.get(i);
Size2D size = block.arrange(g2, RectangleConstraint.NONE);
if (y + size.height <= height) {
itemsInColumn.add(block);
block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));
y = y + size.height + this.verticalGap;
maxWidth = Math.max(maxWidth, size.width);
} else {
if (itemsInColumn.isEmpty()) {
// place in this column (truncated) anyway
block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height - y)));
y = 0.0;
x = x + size.width + this.horizontalGap;
} else {
// start new column
itemsInColumn.clear();
x = x + maxWidth + this.horizontalGap;
y = 0.0;
maxWidth = size.width;
block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height)));
y = size.height + this.verticalGap;
itemsInColumn.add(block);
}
}
}
return new Size2D(x + maxWidth, constraint.getHeight());
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
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);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
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>).
*/
@Override
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()));
}
Aggregations