* @author Ekaterina Shliakhovetskaya
*/
class LegendAdapter extends LegendTitle {
public LegendAdapter(Plot plot, Chart chart) {
super(plot);
ChartLegend legend = chart.getLegend();
setPosition(RectangleEdge.BOTTOM);
StyleObjectModel cssLegendModel = (legend != null)
? legend.getStyleObjectModel()
: chart.getStyleObjectModel();
final boolean chartBackgroundPaintDefined = chart.getChartView().getBackgroundPaint() != null;
if (chartBackgroundPaintDefined) {
setBackgroundPaint(chart.getChartView().getBackgroundPaint());
} else {
setBackgroundPaint(cssLegendModel.getBackground());
}
StyleBorderModel border = cssLegendModel.getBorder();
if (border != null && !border.isNone()) {
setBorder(new BlockBorder(border.getColor()));
} else {
setBorder(new BlockBorder(cssLegendModel.getBackground()));
}
setMargin(cssLegendModel.getMargin(0), cssLegendModel.getMargin(1), cssLegendModel.getMargin(2), cssLegendModel.getMargin(3));
if (legend != null) {
LegendPosition position = legend.getPosition();
setPosition(position != null ? position.toRectangleEdge() : RectangleEdge.BOTTOM);
}
//from legend labels
ChartLabels labels = (legend != null) ? legend.getLabels() : null;
if (labels != null) {
StyleObjectModel cssLabelsModel = labels.getStyleObjectModel();
setItemPaint(cssLabelsModel.getColor());
setItemFont(CSSUtil.getFont(cssLabelsModel));
} else {