eladmena wrote:I believe truncating is a good way to show long legend labels, wrapping can exceed the height of the legend with long ones.
When truncating, tooltips would be a good idea, so the user can see the full label.
I'll add the changes you mentioned to FlowArranagement class, and add the following lines of code to constrain the legend area:
Code: Select all
BlockContainer itemContainer = legend.getItemContainer();
itemContainer.setWidth(0.33);
I do not believe that the width or height of a BlockContainer or of a Block in general are ever requested during the layout process. AFAIK, the layout process is built on the arrange()-methods.
So I would rather recommend to add the changes to the AbstractBlock and JFreeChart classes, and use a maxWidth of 0.33, a maxWidthUnitType of UnitType.RELATIVE, and set useMaxWidth to true.
The addition to the AbstractBlock and JFreeChart classes will help to restrict the size used for layouting a title to only a fraction of the available chart width and to leave sufficient space to render the plot.
The addition to FlowArrangement that I mentioned will only change how a Block is laid out within the availabe width.
BTW, a LegendTitle at the left or right edge of a chart uses a ColumnArrangement to arrange the legend items. Even if you changed the FlowArrangement class, I will not have an effect.
Concerning the tool tips: the tool tip for a legend item is created by the renderer. See AbstractCategoryItemRenderer.setLegendItemToolTipGenerator(CategorySeriesLabelGenerator generator). The default legendItemToolTipGenerator is null --> no tooltips.