use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class BorderArrangement method arrangeFR.
/**
* Performs an arrangement with a fixed width and a range for the height.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The container size after the arrangement.
*/
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
Size2D size1 = arrangeFN(container, g2, constraint.getWidth());
if (constraint.getHeightRange().contains(size1.getHeight())) {
return size1;
} else {
double h = constraint.getHeightRange().constrain(size1.getHeight());
RectangleConstraint c2 = constraint.toFixedHeight(h);
return arrange(container, g2, c2);
}
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class BorderArrangement method arrange.
/**
* Arranges the items in the specified container, subject to the given
* constraint.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The block size.
*/
public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
RectangleConstraint contentConstraint = container.toContentConstraint(constraint);
Size2D contentSize = null;
LengthConstraintType w = contentConstraint.getWidthConstraintType();
LengthConstraintType h = contentConstraint.getHeightConstraintType();
if (w == LengthConstraintType.NONE) {
if (h == LengthConstraintType.NONE) {
contentSize = arrangeNN(container, g2);
} else if (h == LengthConstraintType.FIXED) {
throw new RuntimeException("Not implemented.");
} else if (h == LengthConstraintType.RANGE) {
throw new RuntimeException("Not implemented.");
}
} else if (w == LengthConstraintType.FIXED) {
if (h == LengthConstraintType.NONE) {
contentSize = arrangeFN(container, g2, constraint.getWidth());
} else if (h == LengthConstraintType.FIXED) {
contentSize = arrangeFF(container, g2, constraint);
} else if (h == LengthConstraintType.RANGE) {
contentSize = arrangeFR(container, g2, constraint);
}
} else if (w == LengthConstraintType.RANGE) {
if (h == LengthConstraintType.NONE) {
throw new RuntimeException("Not implemented.");
} else if (h == LengthConstraintType.FIXED) {
throw new RuntimeException("Not implemented.");
} else if (h == LengthConstraintType.RANGE) {
contentSize = arrangeRR(container, constraint.getWidthRange(), constraint.getHeightRange(), g2);
}
}
return new Size2D(container.calculateTotalWidth(contentSize.getWidth()), container.calculateTotalHeight(contentSize.getHeight()));
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class CenterArrangement method arrangeFN.
/**
* Arranges the blocks in the container with a fixed width and no height
* constraint.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size.
*/
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
List blocks = container.getBlocks();
Block b = (Block) blocks.get(0);
Size2D s = b.arrange(g2, RectangleConstraint.NONE);
double width = constraint.getWidth();
Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, 0.0, s.width, s.height);
b.setBounds(bounds);
return new Size2D((width - s.width) / 2.0, s.height);
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
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.chart.util.Size2D in project graphcode2vec by graphcode2vec.
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>).
*/
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