Package org.openfaces.component.chart

Examples of org.openfaces.component.chart.ChartLegend


* @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 {
View Full Code Here


    private void setupLegendLabels(PiePlot plot, Chart chart, PieChartView chartView) {
        if (!chart.isLegendVisible())
            return;

        ChartLegend legend = chart.getLegend();
        if (legend == null || legend.getLabels() == null)
            return;

        final ChartLabels labels = legend.getLabels();
        if (labels.getText() != null) {
            // simple text = the same string for every item
            plot.setLegendLabelGenerator(new PieSectionLabelGenerator() {
                public String generateSectionLabel(PieDataset pieDataset, Comparable comparable) {
                    return labels.getText();
View Full Code Here

    private void setupLegendLabels(PiePlot plot, Chart chart, PieChartView chartView) {
        if (!chart.isLegendVisible())
            return;

        ChartLegend legend = chart.getLegend();
        if (legend == null || legend.getLabels() == null)
            return;

        final ChartLabels labels = legend.getLabels();
        if (labels.getText() != null) {
            // simple text = the same string for every item
            plot.setLegendLabelGenerator(new PieSectionLabelGenerator() {
                public String generateSectionLabel(PieDataset pieDataset, Comparable comparable) {
                    return labels.getText();
View Full Code Here

TOP

Related Classes of org.openfaces.component.chart.ChartLegend

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.