Example usage for org.jfree.data.category CategoryDataset getColumnKey

List of usage examples for org.jfree.data.category CategoryDataset getColumnKey

Introduction

In this page you can find the example usage for org.jfree.data.category CategoryDataset getColumnKey.

Prototype

public Comparable getColumnKey(int column);

Source Link

Document

Returns the column key for a given index.

Usage

From source file:it.eng.spagobi.engines.chart.bo.charttypes.utils.MyCategoryToolTipGenerator.java

public String generateToolTip(CategoryDataset dataset, int row, int column) {
    logger.debug("IN");
    //String tooltip=super.generateToolTip(dataset, row, column);
    String rowName = "";
    String columnName = "";
    try {//from  w ww  .j  av a  2 s  . c o m
        Comparable rowNameC = (String) dataset.getRowKey(row);
        Comparable columnNameC = (String) dataset.getColumnKey(column);
        if (rowNameC != null)
            rowName = rowNameC.toString();
        if (columnNameC != null)
            columnName = columnNameC.toString();

    } catch (Exception e) {
        logger.error("error in recovering name of row and column");
        return "undef";
    }

    // check if there is a predefined FREETIP message
    if (enableFreeTip == true) {
        if (categoriesToolTips.get("FREETIP_X_" + columnName) != null) {
            String freeName = categoriesToolTips.get("FREETIP_X_" + columnName);
            return freeName;
        }
    }

    String columnTipName = columnName;
    String rowTipName = rowName;
    // check if tip name are defined, else use standard
    if (categoriesToolTips.get("TIP_X_" + columnName) != null) {
        columnTipName = categoriesToolTips.get("TIP_X_" + columnName);
    }
    // search for series, if seriesCaption has a relative value use it! 
    String serieNameToSearch = null;
    if (seriesCaption != null) {
        serieNameToSearch = seriesCaption.get(rowName);
    }
    if (serieNameToSearch == null)
        serieNameToSearch = rowName;

    if (serieToolTips.get("TIP_" + serieNameToSearch) != null) {
        rowTipName = serieToolTips.get("TIP_" + serieNameToSearch);
    }

    Number num = dataset.getValue(row, column);
    String numS = (num != null) ? " = " + num.toString() : "";
    String toReturn = "(" + columnTipName + ", " + rowTipName + ")" + numS;

    logger.debug("OUT");
    return toReturn;

}

From source file:hudson.graph.jfreechart.JFreeChartSupport.java

public JFreeChart createChart() {

    if (chartType == Graph.TYPE_STACKED_AREA) {
        jFreeChart = ChartFactory.createStackedAreaChart(null, // chart
                chartTitle, // // title 
                xAxisLabel, // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips
                false // urls
        );/*  w w w  . j av  a 2  s.c  o m*/
    } else if (chartType == Graph.TYPE_LINE) {
        jFreeChart = ChartFactory.createLineChart(null, // chart title
                chartTitle, // // title 
                xAxisLabel, // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips
                false // urls
        );
    }

    jFreeChart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = jFreeChart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    if (chartType == Graph.TYPE_LINE) {
        final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
        renderer.setBaseStroke(new BasicStroke(3));

        if (multiStageTimeSeries != null) {
            for (int i = 0; i < multiStageTimeSeries.size(); i++) {
                renderer.setSeriesPaint(i, multiStageTimeSeries.get(i).color);
            }
        }
    }

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Utils.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    if (chartType == Graph.TYPE_STACKED_AREA) {
        StackedAreaRenderer ar = new StackedAreaRenderer2() {

            @Override
            public Paint getItemPaint(int row, int column) {
                if (row == 2) {
                    return ColorPalette.BLUE;
                }
                if (row == 1) {
                    return ColorPalette.YELLOW;
                }
                if (row == 0) {
                    return ColorPalette.RED;
                }
                ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
                return key.getColor(row, column);
            }

            @Override
            public String generateURL(CategoryDataset dataset, int row, int column) {
                ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                return label.getLink(row, column);
            }

            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {
                ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                return label.getToolTip(row, column);
            }
        };
        plot.setRenderer(ar);
        ar.setSeriesPaint(0, ColorPalette.RED); // Failures.
        ar.setSeriesPaint(1, ColorPalette.YELLOW); // Skips.
        ar.setSeriesPaint(2, ColorPalette.BLUE); // Total.
    }

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return jFreeChart;
}

From source file:com.pureinfo.srm.reports.impl.CategoryChartBuilder.java

/**
 * @param _format/*from   w  w  w .j  a  v  a2 s.c o  m*/
 * @param _dataset
 */
private void fillChartInfo(CategoryDataset _dataset, DecimalFormat _format) {
    int n = _dataset.getColumnCount();
    m_ChartInfo = new ChartInfo();
    m_ChartInfo.setChartTitle(m_sTitle);
    String[] labels = new String[n];
    for (int i = 0; i < n; i++) {
        labels[i] = "" + _dataset.getColumnKey(i);
        labels[i] += " = ";
        labels[i] += _format.format(_dataset.getValue(0, i));
    }
    m_ChartInfo.setLabels(labels);
    Point size = new Point(n > 20 ? ChartInfo.SIZE_WIDE : ChartInfo.SIZE_NORROW);
    if (n > 20)
        size.x += 40 * (n - 20);
    m_ChartInfo.setChartSize(size);
    m_ChartInfo.setLengedPosition(n > 20 ? ChartInfo.LENGEND_POSITION_BUTTOM : ChartInfo.LENGEND_POSITION_LEFT);
}

From source file:uk.ac.lkl.cram.ui.chart.LearningExperienceChartMaker.java

/**
 * Create a chart from the provide category dataset
 * @return a Chart that can be rendered in a ChartPanel
 *//*from ww w.j  av a2s . c o  m*/
@Override
protected JFreeChart createChart() {
    //Create a horizontal stacked bar chart from the chart factory, with no title, no axis labels, a legend, tooltips but no URLs
    JFreeChart chart = ChartFactory.createStackedBarChart(null, null, null, (CategoryDataset) dataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    //Get the plot from the chart
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //Remove offsets from the plot
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    //Hide the range lines
    plot.setRangeGridlinesVisible(false);
    //Get the renderer for the plot
    StackedBarRenderer sbRenderer = (StackedBarRenderer) plot.getRenderer();
    //Set the painter for the renderer (nothing fancy)
    sbRenderer.setBarPainter(new StandardBarPainter());
    //sbRenderer.setItemMargin(0.5); //Makes no difference
    //reduces width of bar as proportion of overall width
    sbRenderer.setMaximumBarWidth(0.5);
    //Render the bars as percentages
    sbRenderer.setRenderAsPercentages(true);
    //Set the colours for the bars
    sbRenderer.setSeriesPaint(0, PERSONALISED_COLOR);
    sbRenderer.setSeriesPaint(1, SOCIAL_COLOR);
    sbRenderer.setSeriesPaint(2, ONE_SIZE_FOR_ALL_COLOR);
    //Set the tooltips to render percentages
    sbRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset cd, int row, int column) {
            //Only interested in row, as there's only one column
            //TODO--really inefficient
            @SuppressWarnings("unchecked")
            List<Comparable> rows = cd.getRowKeys();
            Comparable columnKey = cd.getColumnKey(column);
            //Sum running total
            int total = 0;
            for (Comparable comparable : rows) {
                total += cd.getValue(comparable, columnKey).intValue();
            }
            //Get the value for the row (in our case the learning type)
            Comparable rowKey = cd.getRowKey(row);
            float value = cd.getValue(rowKey, columnKey).floatValue();
            //The tooltip is the value of the learning type divided by the total, expressed as a percentage
            @SuppressWarnings("StringBufferWithoutInitialCapacity")
            StringBuilder builder = new StringBuilder();
            builder.append("<html><center>");
            builder.append(cd.getRowKey(row));
            builder.append(" (");
            builder.append(FORMATTER.format(value / total));
            builder.append(")<br/>");
            builder.append("Double-click for more");
            return builder.toString();
        }
    });
    //Hide both axes
    CategoryAxis categoryAxis = plot.getDomainAxis();
    //categoryAxis.setCategoryMargin(0.5D);//Makes no difference
    categoryAxis.setVisible(false);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setVisible(false);
    return chart;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final Plot plot = chart.getPlot();
    final MultiplePiePlot mpp = (MultiplePiePlot) plot;
    final JFreeChart pc = mpp.getPieChart();
    configureSubChart(pc);/*from ww w  .  j  a va 2s .  co m*/

    final PiePlot pp = (PiePlot) pc.getPlot();
    if (StringUtils.isEmpty(getTooltipFormula()) == false) {
        pp.setToolTipGenerator(new FormulaPieTooltipGenerator(getRuntime(), getTooltipFormula()));
    }
    if (StringUtils.isEmpty(getUrlFormula()) == false) {
        pp.setURLGenerator(new FormulaPieURLGenerator(getRuntime(), getUrlFormula()));
    }

    if (shadowPaint != null) {
        pp.setShadowPaint(shadowPaint);
    }
    if (shadowXOffset != null) {
        pp.setShadowXOffset(shadowXOffset.doubleValue());
    }
    if (shadowYOffset != null) {
        pp.setShadowYOffset(shadowYOffset.doubleValue());
    }

    final CategoryDataset c = mpp.getDataset();
    if (c != null) {
        final String[] colors = getSeriesColor();
        final int keysSize = c.getColumnKeys().size();
        for (int i = 0; i < colors.length; i++) {
            if (keysSize > i) {
                pp.setSectionPaint(c.getColumnKey(i), parseColorFromString(colors[i]));
            }
        }
    }

    if (StringUtils.isEmpty(getLabelFont()) == false) {
        pp.setLabelFont(Font.decode(getLabelFont()));
    }

    if (Boolean.FALSE.equals(getItemsLabelVisible())) {
        pp.setLabelGenerator(null);
    } else {
        final ExpressionRuntime runtime = getRuntime();
        final Locale locale = runtime.getResourceBundleFactory().getLocale();

        final FastDecimalFormat fastPercent = new FastDecimalFormat(FastDecimalFormat.TYPE_PERCENT, locale);
        final FastDecimalFormat fastInteger = new FastDecimalFormat(FastDecimalFormat.TYPE_INTEGER, locale);

        final DecimalFormat numFormat = new DecimalFormat(fastInteger.getPattern(),
                new DecimalFormatSymbols(locale));
        numFormat.setRoundingMode(RoundingMode.HALF_UP);

        final DecimalFormat percentFormat = new DecimalFormat(fastPercent.getPattern(),
                new DecimalFormatSymbols(locale));
        percentFormat.setRoundingMode(RoundingMode.HALF_UP);

        final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator(
                multipieLabelFormat, numFormat, percentFormat);
        pp.setLabelGenerator(labelGen);
    }
}

From source file:gov.nih.nci.cma.web.graphing.GEPlot.java

public String generateGeometricMeanIntensityChart(String xAxisLabel, String yAxisLabel, HttpSession session,
        PrintWriter pw) {/*from   www. ja  va 2  s .  co m*/
    String gmfilename = "";

    JFreeChart gmChart = null;
    try {

        gmChart = ChartFactory.createBarChart(null, xAxisLabel, // domain axis label
                yAxisLabel, gmDataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
        gmChart.setBackgroundPaint(java.awt.Color.white);
        // lets start some customization to retro fit w/jcharts lookand feel
        CategoryPlot plot = gmChart.getCategoryPlot();
        CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
        axis.setLowerMargin(0.02); // two percent
        axis.setCategoryMargin(0.20); // 20 percent
        axis.setUpperMargin(0.02); // two percent
        //StatisticalBarRenderer renderer = new StatisticalBarRenderer();
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        // BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setItemMargin(0.01); // one percent
        renderer.setDrawBarOutline(true);
        renderer.setOutlinePaint(Color.BLACK);
        renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {

            public String generateToolTip(CategoryDataset dataset, int series, int item) {
                String stdDev = (String) stdDevMap
                        .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item));

                return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : "
                        + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>"
                        + "<br/>Std. Dev.: " + stdDev + "<br/>";
            }

        });

        plot.setRenderer(renderer);

        gmChart.removeLegend();
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        //gmfilename = ServletUtilities.saveChartAsPNG(gmChart, imgW, 400, info, session);
        gmfilename = ServletUtilities.saveChartAsPNG(gmChart, imgW, 400, info, session);
        ChartUtilities.writeImageMap(pw, gmfilename, info, new CustomOverlibToolTipTagFragmentGenerator(),
                new StandardURLTagFragmentGenerator());

    } catch (Exception e) {
        System.out.println("Exception - " + e.toString());
        e.printStackTrace(System.out);
    }
    return gmfilename;
}

From source file:gov.nih.nci.cma.web.graphing.GEPlot.java

public String generateLog2Chart(String xAxisLabel, String yAxisLabel, HttpSession session, PrintWriter pw) {
    String log2Filename = "";

    JFreeChart log2Chart = null;//from w ww . j  a va 2s .  co m
    try {

        log2Chart = ChartFactory.createBarChart(null, xAxisLabel, // domain axis label
                yAxisLabel, log2Dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
        log2Chart.setBackgroundPaint(java.awt.Color.white);
        // lets start some customization to retro fit w/jcharts lookand feel
        CategoryPlot plot = log2Chart.getCategoryPlot();
        CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
        axis.setLowerMargin(0.02); // two percent
        axis.setCategoryMargin(0.20); // 20 percent
        axis.setUpperMargin(0.02); // two percent
        StatisticalBarRenderer renderer = new StatisticalBarRenderer();

        // BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setItemMargin(0.01); // one percent
        renderer.setDrawBarOutline(true);
        renderer.setOutlinePaint(Color.BLACK);
        renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {

            public String generateToolTip(CategoryDataset dataset, int series, int item) {
                String stdDev = (String) stdDevMap
                        .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item));

                return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : "
                        + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>"
                        + "<br/>Std. Dev.: " + stdDev + "<br/>";
            }

        });

        // LegendTitle lg = chart.getLegend();
        plot.setRenderer(renderer);

        // lets generate a custom legend - assumes theres only one source?
        //LegendItemCollection lic = log2Chart.getLegend().getSources()[0].getLegendItems();
        //legendHtml = LegendCreator.buildLegend(lic, "Probesets");
        log2Chart.removeLegend();
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        log2Filename = ServletUtilities.saveChartAsPNG(log2Chart, imgW, 400, info, session);
        ChartUtilities.writeImageMap(pw, log2Filename, info, new CustomOverlibToolTipTagFragmentGenerator(),
                new StandardURLTagFragmentGenerator());

    } catch (Exception e) {
        System.out.println("Exception - " + e.toString());
        e.printStackTrace(System.out);
    }
    return log2Filename;
}

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * /*from   w  w w.  j a va2 s .  c  o m*/
 * @return
 */
private ChartPanel getChartPanel() {

    if (chartPanel == null) {

        renderer = new StackedBarRenderer();
        renderer.setMaximumBarWidth(0.05);
        renderer.setShadowVisible(false);

        renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {

                WaterfallCategory wfCategory = (WaterfallCategory) dataset.getColumnKey(column);
                return wfCategory.getTooltip();
            }
        });
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.INSIDE9, TextAnchor.CENTER_LEFT));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.INSIDE9, TextAnchor.CENTER_LEFT));

        // Set up plot
        CategoryPlot plot = new CategoryPlot(new DefaultCategoryDataset(), getCategoryAxis(), getTimeAxis(),
                renderer);
        plot.setOrientation(PlotOrientation.HORIZONTAL);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePosition(CategoryAnchor.END);

        JFreeChart chart = new JFreeChart(plot);
        chartPanel = new ChartPanel(chart, 400, 200, 200, 200, 2000, 5000, true, false, false, false, false,
                true);
        chartPanel.setMouseZoomable(false);
        chartPanel.setRangeZoomable(false);
        chartPanel.setDomainZoomable(false);
        chartPanel.addChartMouseListener(new ChartMouseListener() {

            @Override
            public void chartMouseMoved(ChartMouseEvent arg0) {
                // Do Nothing
            }

            @Override
            public void chartMouseClicked(ChartMouseEvent event) {

                //TODO Add listner info or separate the listener.
                if (event.getEntity() instanceof CategoryItemEntity) {
                    CategoryItemEntity xyitem = (CategoryItemEntity) event.getEntity();
                    WaterfallCategory wfCategory = (WaterfallCategory) xyitem.getColumnKey();
                    if (wfCategory != null && wfCategory.getReqResp() != null) {
                        int count = event.getTrigger().getClickCount();
                        if (count > 1) {
                            waterfallTab.updateMainFrame(wfCategory.getSession());
                        } else {
                            popup.refresh(wfCategory.getReqResp(), wfCategory.getIndex());
                            if (!popup.getPopupDialog().isVisible()) {
                                popup.getPopupDialog().setVisible(true);
                            }
                        }
                    }
                }

            }
        });
    }

    return chartPanel;
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10));
    renderer.setItemLabelAnchorOffset(15);

    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF));
    renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF));
    renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF));
    renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77));
    renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC));
    renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00));
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);/*from  w  w w  . j av  a  2 s. c  o  m*/
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT));
    renderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT));
}

From source file:org.pentaho.chart.plugin.api.ChartItemLabelGenerator.java

/**
 * This method is over-ridden to get the actual data value into the item label along with
 * custom formatting defined for the series in the chart definition document.
 * {0} maps to data value/* w w w.  j ava 2s. c  o m*/
 * {1} maps to column name
 *
 * @param dataset category dataset
 * @param row     Row number
 * @param column  Column number
 * @return String Final label string for the given series
 */
public String generateLabel(final CategoryDataset dataset, final int row, final int column) {
    if (dataset == null) {
        return null;
    }
    try {
        final Object data = dataset.getValue(row, column);
        if (data != null) {
            final ChartElement ce = map.get(Integer.valueOf(column));
            if (ce != null) {
                final LayoutStyle layoutStyle = ce.getLayoutStyle();

                //Format the item label text
                final String messageFormat = ((CSSStringValue) layoutStyle
                        .getValue(ChartStyleKeys.ITEM_LABEL_TEXT)).getValue();//$NON-NLS-1$
                String result = MessageFormat.format(messageFormat, data, dataset.getColumnKey(column));

                //Get the font variant to convert the label text to upper case if the
                //font variant is set to small-caps
                final CSSValue variant = layoutStyle.getValue(FontStyleKeys.FONT_VARIANT);
                if (FontVariant.SMALL_CAPS.equals(variant)) {
                    result = result.toUpperCase();
                }
                return result;
            }
        }
    } catch (IndexOutOfBoundsException ignore) {
        //Ignore this exception as we are not directly causing it.
    }

    return null;
}