protected void setChartLegend(JFreeChart jfreeChart, Integer baseFontSize)
{
//The legend visibility is already taken into account in the jfreeChart object's constructor
LegendTitle legend = jfreeChart.getLegend();
if (legend != null)
{
Font themeLegendFont = getFont((JRFont)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FONT), getChart().getLegendFont(), baseFontSize);
legend.setItemFont(themeLegendFont);
Color legendForecolor = getChart().getOwnLegendColor() != null ?
getChart().getOwnLegendColor() :
(getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) != null ?
(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) :
getChart().getLegendColor());
if(legendForecolor != null)
legend.setItemPaint(legendForecolor);
Color legendBackcolor = getChart().getOwnLegendBackgroundColor() != null ?
getChart().getOwnLegendBackgroundColor() :
(getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) != null ?
(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) :
getChart().getLegendBackgroundColor());
if(legendBackcolor != null)
legend.setBackgroundPaint(legendBackcolor);
BlockFrame frame = (BlockFrame)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FRAME);
if(frame != null)
legend.setFrame(frame);
HorizontalAlignment defaultLegendHAlignment = (HorizontalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_HORIZONTAL_ALIGNMENT);
if(defaultLegendHAlignment != null)
legend.setHorizontalAlignment(defaultLegendHAlignment);
VerticalAlignment defaultLegendVAlignment = (VerticalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_VERTICAL_ALIGNMENT);
if(defaultLegendVAlignment != null)
legend.setVerticalAlignment(defaultLegendVAlignment);
RectangleInsets defaultLegendPadding = (RectangleInsets)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_PADDING);
RectangleInsets legendPadding = legend.getPadding() != null ? legend.getPadding() : defaultLegendPadding;
if(legendPadding != null)
legend.setPadding(legendPadding);
RectangleEdge defaultLegendPosition = (RectangleEdge)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_POSITION);
if(getEdge(getChart().getLegendPositionValue(), defaultLegendPosition) != null)
legend.setPosition(getEdge(getChart().getLegendPositionValue(), defaultLegendPosition));
}
}