Class ChartLabelGenerator

  • All Implemented Interfaces:
    org.jfree.chart.labels.CategoryItemLabelGenerator, org.jfree.chart.labels.CategorySeriesLabelGenerator, org.jfree.chart.labels.CategoryToolTipGenerator, org.jfree.chart.labels.PieSectionLabelGenerator, org.jfree.chart.labels.PieToolTipGenerator

    public class ChartLabelGenerator
    extends java.lang.Object
    implements org.jfree.chart.labels.PieSectionLabelGenerator, org.jfree.chart.labels.PieToolTipGenerator, org.jfree.chart.labels.CategorySeriesLabelGenerator, org.jfree.chart.labels.CategoryItemLabelGenerator, org.jfree.chart.labels.CategoryToolTipGenerator
    A label generator that can be used for category datasets and pie datasets. Furthermore this class provides Renderer for the key data to generate the labeltext with other methods above toString().
    • Constructor Summary

      Constructors 
      Constructor Description
      ChartLabelGenerator()
      Crates a label generator with default values.
      ChartLabelGenerator​(java.lang.String labelFormat)
      Creates a label generator with a given label format.
      ChartLabelGenerator​(java.lang.String labelFormat, java.text.DateFormat dateFormat, java.text.NumberFormat numberFormat, java.text.NumberFormat percentFormat, java.lang.String nullValueString)
      Creates a label generator where all the values can be adjusted.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object[] createColumnItemArray​(org.jfree.data.category.CategoryDataset dataset, int column)
      Creates the array of items that can be passed to the MessageFormat class for creating labels.
      protected java.lang.Object[] createItemArray​(org.jfree.data.category.CategoryDataset dataset, int row, int column)
      Creates the array of items that can be passed to the MessageFormat class for creating labels.
      protected java.lang.Object[] createItemArray​(org.jfree.data.general.PieDataset dataset, java.lang.Comparable key)
      Creates the array of items that can be passed to the MessageFormat class for creating labels.
      protected java.lang.Object[] createRowItemArray​(org.jfree.data.category.CategoryDataset dataset, int row)
      Creates the array of items that can be passed to the MessageFormat class for creating labels.
      java.text.AttributedString generateAttributedSectionLabel​(org.jfree.data.general.PieDataset dataset, java.lang.Comparable key)
      Not used
      java.lang.String generateColumnLabel​(org.jfree.data.category.CategoryDataset dataset, int column)
      Generates a label for the specified row.
      java.lang.String generateLabel​(org.jfree.data.category.CategoryDataset dataset, int series)
      Generates a label for the specified series.
      java.lang.String generateLabel​(org.jfree.data.category.CategoryDataset dataset, int row, int column)
      Generates the label for an item in a dataset.
      java.lang.String generateRowLabel​(org.jfree.data.category.CategoryDataset dataset, int row)
      Generates a label for the specified row.
      java.lang.String generateSectionLabel​(org.jfree.data.general.PieDataset dataset, java.lang.Comparable key)
      Generates a label for a pie section.
      java.lang.String generateToolTip​(org.jfree.data.category.CategoryDataset dataset, int row, int column)
      Generates the tool tip text for an item in a dataset.
      java.lang.String generateToolTip​(org.jfree.data.general.PieDataset dataset, java.lang.Comparable key)
      Generates a tool tip text item for one section in a pie chart.
      ChartLabelGenerator.KeyRenderer getDefaultRenderer​(java.lang.Class clazz)
      Return the default renderer for this class
      void setDefaultRenderer​(java.lang.Class columnClass, ChartLabelGenerator.KeyRenderer renderer)
      Sets the renderer for a specific class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_LABEL_FORMAT

        public static final java.lang.String DEFAULT_LABEL_FORMAT
        The default section label format.
        See Also:
        Constant Field Values
      • DEFAULT_TOOLTIP_FORMAT

        public static final java.lang.String DEFAULT_TOOLTIP_FORMAT
        The default tooltip format.
        See Also:
        Constant Field Values
      • DEFAULT_ITEM_LABEL_FORMAT

        public static final java.lang.String DEFAULT_ITEM_LABEL_FORMAT
        The default item label format string.
        See Also:
        Constant Field Values
      • defaultRenderer

        protected java.util.Hashtable defaultRenderer
        The default renderer for labels
    • Constructor Detail

      • ChartLabelGenerator

        public ChartLabelGenerator()
        Crates a label generator with default values.
      • ChartLabelGenerator

        public ChartLabelGenerator​(java.lang.String labelFormat)
        Creates a label generator with a given label format.
        Parameters:
        labelFormat -
      • ChartLabelGenerator

        public ChartLabelGenerator​(java.lang.String labelFormat,
                                   java.text.DateFormat dateFormat,
                                   java.text.NumberFormat numberFormat,
                                   java.text.NumberFormat percentFormat,
                                   java.lang.String nullValueString)
        Creates a label generator where all the values can be adjusted.
        Parameters:
        labelFormat - The label format.
        dateFormat - The date format.
        numberFormat - The number format.
        percentFormat - The percent format.
        nullValueString - The string for null values
    • Method Detail

      • generateAttributedSectionLabel

        public java.text.AttributedString generateAttributedSectionLabel​(org.jfree.data.general.PieDataset dataset,
                                                                         java.lang.Comparable key)
        Not used
        Specified by:
        generateAttributedSectionLabel in interface org.jfree.chart.labels.PieSectionLabelGenerator
      • generateSectionLabel

        public java.lang.String generateSectionLabel​(org.jfree.data.general.PieDataset dataset,
                                                     java.lang.Comparable key)
        Generates a label for a pie section.
        Specified by:
        generateSectionLabel in interface org.jfree.chart.labels.PieSectionLabelGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        key - the section key (null not permitted).
        Returns:
        The label (possibly null).
      • generateToolTip

        public java.lang.String generateToolTip​(org.jfree.data.general.PieDataset dataset,
                                                java.lang.Comparable key)
        Generates a tool tip text item for one section in a pie chart.
        Specified by:
        generateToolTip in interface org.jfree.chart.labels.PieToolTipGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        key - the section key (null not permitted).
        Returns:
        The tool tip text (possibly null).
      • generateLabel

        public java.lang.String generateLabel​(org.jfree.data.category.CategoryDataset dataset,
                                              int series)
        Generates a label for the specified series.
        Specified by:
        generateLabel in interface org.jfree.chart.labels.CategorySeriesLabelGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        series - the series.
        Returns:
        A series label.
      • generateRowLabel

        public java.lang.String generateRowLabel​(org.jfree.data.category.CategoryDataset dataset,
                                                 int row)
        Generates a label for the specified row.
        Specified by:
        generateRowLabel in interface org.jfree.chart.labels.CategoryItemLabelGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        row - the row index (zero-based).
        Returns:
        The label.
      • generateColumnLabel

        public java.lang.String generateColumnLabel​(org.jfree.data.category.CategoryDataset dataset,
                                                    int column)
        Generates a label for the specified row.
        Specified by:
        generateColumnLabel in interface org.jfree.chart.labels.CategoryItemLabelGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        column - the column index (zero-based).
        Returns:
        The label.
      • generateLabel

        public java.lang.String generateLabel​(org.jfree.data.category.CategoryDataset dataset,
                                              int row,
                                              int column)
        Generates the label for an item in a dataset. Note: in the current dataset implementation, each row is a series, and each column contains values for a particular category.
        Specified by:
        generateLabel in interface org.jfree.chart.labels.CategoryItemLabelGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        row - the row index (zero-based).
        column - the column index (zero-based).
        Returns:
        The label (possibly null).
      • generateToolTip

        public java.lang.String generateToolTip​(org.jfree.data.category.CategoryDataset dataset,
                                                int row,
                                                int column)
        Generates the tool tip text for an item in a dataset. Note: in the current dataset implementation, each row is a series, and each column contains values for a particular category.
        Specified by:
        generateToolTip in interface org.jfree.chart.labels.CategoryToolTipGenerator
        Parameters:
        dataset - the dataset (null not permitted).
        row - the row index (zero-based).
        column - the column index (zero-based).
        Returns:
        The tooltip text (possibly null).
      • createColumnItemArray

        protected java.lang.Object[] createColumnItemArray​(org.jfree.data.category.CategoryDataset dataset,
                                                           int column)
        Creates the array of items that can be passed to the MessageFormat class for creating labels.
        Parameters:
        dataset - the dataset (null not permitted).
        series - the series (zero-based index).
        Returns:
        The items (never null).
      • createRowItemArray

        protected java.lang.Object[] createRowItemArray​(org.jfree.data.category.CategoryDataset dataset,
                                                        int row)
        Creates the array of items that can be passed to the MessageFormat class for creating labels.
        Parameters:
        dataset - the dataset (null not permitted).
        series - the series (zero-based index).
        Returns:
        The items (never null).
      • createItemArray

        protected java.lang.Object[] createItemArray​(org.jfree.data.general.PieDataset dataset,
                                                     java.lang.Comparable key)
        Creates the array of items that can be passed to the MessageFormat class for creating labels. The returned array contains four values: String;
        Parameters:
        dataset - the dataset (null not permitted).
        key - the key (null not permitted).
        Returns:
        The items (never null).
      • createItemArray

        protected java.lang.Object[] createItemArray​(org.jfree.data.category.CategoryDataset dataset,
                                                     int row,
                                                     int column)
        Creates the array of items that can be passed to the MessageFormat class for creating labels.
        Parameters:
        dataset - the dataset (null not permitted).
        row - the row index (zero-based).
        column - the column index (zero-based).
        Returns:
        The items (never null).
      • setDefaultRenderer

        public void setDefaultRenderer​(java.lang.Class columnClass,
                                       ChartLabelGenerator.KeyRenderer renderer)
        Sets the renderer for a specific class.
        Parameters:
        columnClass - The class for the renderer to use.
        renderer - The renderer.
      • getDefaultRenderer

        public ChartLabelGenerator.KeyRenderer getDefaultRenderer​(java.lang.Class clazz)
        Return the default renderer for this class
        Parameters:
        clazz - The class.
        Returns:
        the renderer for this class.