Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/main/java/org/jfree/chart/block/FlowArrangement.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2,
double x = 0.0;
double y = 0.0;
double maxHeight = 0.0;
List<Block> itemsInRow = new ArrayList<>();
boolean haveItemsInRow = false;
for (Block block : blocks) {
Size2D size = block.arrange(g2, RectangleConstraint.NONE);
if (x + size.width <= width) {
itemsInRow.add(block);
haveItemsInRow = true;
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()) {
if (!haveItemsInRow) {
// place in this row (truncated) anyway
block.setBounds(
new Rectangle2D.Double(
Expand All @@ -199,7 +199,6 @@ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2,
}
else {
// start new row
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not reinitialize haveItemsInRow to false here?

Copy link
Author

@cinsttool cinsttool Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code clears the itemsInRow and adds an element to the itemsInRow afterwards in the same code block.

So I think the reinitialization is not required.

itemsInRow.clear();
x = 0.0;
y = y + maxHeight + this.verticalGap;
maxHeight = size.height;
Expand All @@ -209,7 +208,7 @@ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2,
)
);
x = size.width + this.horizontalGap;
itemsInRow.add(block);
haveItemsInRow = true;
}
}
}
Expand Down