use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class GridArrangement method arrangeNN.
/**
* Arranges the container with no constraint on the width or height.
*
* @param container the container (<code>null</code> not permitted).
* @param g2 the graphics device.
*
* @return The size.
*/
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
double maxW = 0.0;
double maxH = 0.0;
List blocks = container.getBlocks();
Iterator iterator = blocks.iterator();
while (iterator.hasNext()) {
Block b = (Block) iterator.next();
if (b != null) {
Size2D s = b.arrange(g2, RectangleConstraint.NONE);
maxW = Math.max(maxW, s.width);
maxH = Math.max(maxH, s.height);
}
}
double width = this.columns * maxW;
double height = this.rows * maxH;
RectangleConstraint c = new RectangleConstraint(width, height);
return arrangeFF(container, g2, c);
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class GridArrangement method arrangeRN.
/**
* Arrange with a fixed width and no height constraint.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {
RectangleConstraint c1 = constraint.toUnconstrainedWidth();
Size2D size1 = arrange(container, g2, c1);
if (constraint.getWidthRange().contains(size1.getWidth())) {
return size1;
} else {
double w = constraint.getWidthRange().constrain(size1.getWidth());
RectangleConstraint c2 = constraint.toFixedWidth(w);
return arrange(container, g2, c2);
}
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
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);
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
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>).
*/
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.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class CategoryAxis method calculateTextBlockHeight.
/**
* A utility method for determining the height of a text block.
*
* @param block the text block.
* @param position the label position.
* @param g2 the graphics device.
*
* @return The height.
*/
protected double calculateTextBlockHeight(TextBlock block, CategoryLabelPosition position, Graphics2D g2) {
RectangleInsets insets = getTickLabelInsets();
Size2D size = block.calculateDimensions(g2);
Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight());
Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f);
double h = rotatedBox.getBounds2D().getHeight() + insets.getTop() + insets.getBottom();
return h;
}
Aggregations