Example usage for org.apache.poi.xssf.usermodel XSSFChart getTitle

List of usage examples for org.apache.poi.xssf.usermodel XSSFChart getTitle

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFChart getTitle.

Prototype

public XDDFTitle getTitle() 

Source Link

Usage

From source file:com.vaadin.addon.spreadsheet.charts.converter.xssfreader.XSSFChartReader.java

private String getTitle(XSSFChart chart, List<AbstractSeriesData> plotData) {
    String title = "";

    final CTChart ctChart = chart.getCTChart();

    if (ctChart.isSetTitle()) {
        title = "" + chart.getTitle();

        // default title
        if (title.isEmpty() && plotData.size() > 0 && plotData.get(0).name != null) {
            title = plotData.get(0).name.toUpperCase();
        }/* ww w .j a  v  a2 s .co  m*/
    }

    return title;
}

From source file:org.tiefaces.components.websheet.utility.ChartUtility.java

License:MIT License

/**
 * init chart data.// ww w  .j  a  va2  s .  c  o  m
 * 
 * @param chartId
 *            chartId.
 * @param chart
 *            chart.
 * @param wb
 *            wb.
 * @return chartdata.
 */
public static ChartData initChartDataFromXSSFChart(final String chartId, final XSSFChart chart,
        final XSSFWorkbook wb) {

    ThemesTable themeTable = wb.getStylesSource().getTheme();

    ChartData chartData = new ChartData();
    XSSFRichTextString chartTitle = chart.getTitle();
    if (chartTitle != null) {
        chartData.setTitle(chartTitle.toString());
    }
    CTChart ctChart = chart.getCTChart();
    ChartType chartType = ChartUtility.getChartType(ctChart);
    if (chartType == null) {
        throw new IllegalChartException("Unknown chart type");
    }

    chartData.setBgColor(ColorUtility.getBgColor(ctChart.getPlotArea(), themeTable));

    chartData.setId(chartId);
    chartData.setType(chartType);

    List<CTCatAx> ctCatAxList = ctChart.getPlotArea().getCatAxList();
    if ((ctCatAxList != null) && (!ctCatAxList.isEmpty())) {
        chartData.setCatAx(new ChartAxis(ctCatAxList.get(0)));
    }
    List<CTValAx> ctValAxList = ctChart.getPlotArea().getValAxList();
    if ((ctValAxList != null) && (!ctValAxList.isEmpty())) {
        chartData.setValAx(new ChartAxis(ctValAxList.get(0)));
    }

    ChartObject ctObj = chartType.createChartObject();

    if (ctObj == null) {
        throw new IllegalChartException("Cannot create chart object.");
    }

    setUpChartData(chartData, ctChart, themeTable, ctObj);

    return chartData;
}