Class GroupedCategoryDataset

  • All Implemented Interfaces:
    java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, org.jfree.data.category.CategoryDataset, org.jfree.data.general.Dataset, org.jfree.data.general.DatasetChangeListener, org.jfree.data.KeyedValues2D, org.jfree.data.Values2D

    public class GroupedCategoryDataset
    extends org.jfree.data.general.AbstractDataset
    implements org.jfree.data.category.CategoryDataset, org.jfree.data.general.DatasetChangeListener, java.io.Serializable
    This class provides methods for automatic grouping of data for the GroupedStackedBarRenderer. This class acts as a dataset itselves, but retrievs the actual data from datasets, that can be added to in order to group data from the datasets with equal row keys.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.jfree.chart.axis.SubCategoryAxis axis
      The category axis for groups
      protected java.util.Map datasets
      The datasets for the Group
      protected java.util.Map keyToDataset
      The map with group rowkeys and datasets for easy and fast access to the original datasets
      protected java.util.List keyToGroup
      The list of assigned groups
      protected org.jfree.data.KeyToGroupMap keytogroupmap
      The map for assigning series to groups
      protected java.util.Map keyToRowKey
      The map with group rowkeys and original rowkeys for easy and fast access to the original datasets
      protected org.jfree.chart.renderer.category.GroupedStackedBarRenderer renderer
      The bar renderer for groups.
    • Constructor Summary

      Constructors 
      Constructor Description
      GroupedCategoryDataset()
      Creates an initial dataset.
      GroupedCategoryDataset​(org.jfree.chart.JFreeChart chart)
      Creates a dataset and retrieves the GroupedStackedBarRenderer and the SubCategoryAxis from the chart.
      GroupedCategoryDataset​(org.jfree.chart.renderer.category.GroupedStackedBarRenderer renderer, org.jfree.chart.axis.SubCategoryAxis axis)
      Creates a dataset, that is linked to a GroupedStackedBarRenderer for assigne the groupmaps and to the SubCategoryAxis to create subcategories.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCategoryDataset​(org.jfree.data.category.CategoryDataset dataset, java.lang.String name)
      Adds a dataset and (if the dataset is not empty) assigning groups for each rowkey to the renderer and adding subcategories to the axis.
      void cleanup()
      Removes all references to assigned objects.
      void datasetChanged​(org.jfree.data.general.DatasetChangeEvent event)
      A dataset has changed.
      int getColumnCount()
      Returns the total number of different columns in the datasets.
      int getColumnIndex​(java.lang.Comparable key)
      Returns the column index for a given key.
      java.lang.Comparable getColumnKey​(int column)
      Returns a column key.
      java.util.List getColumnKeys()
      Returns the column keys.
      java.util.List getList​(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Returns the List for a given group rowkey and column key.
      java.lang.Comparable getOriginalRowKey​(java.lang.Comparable rowKey)
      Returns the original rowkey from a group rowkey
      int getRowCount()
      Returns the total number of all rows in the datasets.
      int getRowIndex​(java.lang.Comparable key)
      Returns the row index for a given key.
      java.lang.Comparable getRowKey​(int row)
      Returns a row key.
      java.util.List getRowKeys()
      Returns the row keys.
      java.lang.Number getValue​(int row, int column)
      Returns a value from the table.
      java.lang.Number getValue​(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Returns the value for a pair of keys.
      • Methods inherited from class org.jfree.data.general.AbstractDataset

        addChangeListener, clone, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.jfree.data.general.Dataset

        addChangeListener, getGroup, removeChangeListener, setGroup
    • Field Detail

      • datasets

        protected java.util.Map datasets
        The datasets for the Group
      • axis

        protected org.jfree.chart.axis.SubCategoryAxis axis
        The category axis for groups
      • renderer

        protected org.jfree.chart.renderer.category.GroupedStackedBarRenderer renderer
        The bar renderer for groups.
      • keytogroupmap

        protected org.jfree.data.KeyToGroupMap keytogroupmap
        The map for assigning series to groups
      • keyToGroup

        protected java.util.List keyToGroup
        The list of assigned groups
      • keyToRowKey

        protected java.util.Map keyToRowKey
        The map with group rowkeys and original rowkeys for easy and fast access to the original datasets
      • keyToDataset

        protected java.util.Map keyToDataset
        The map with group rowkeys and datasets for easy and fast access to the original datasets
    • Constructor Detail

      • GroupedCategoryDataset

        public GroupedCategoryDataset()
        Creates an initial dataset.
      • GroupedCategoryDataset

        public GroupedCategoryDataset​(org.jfree.chart.renderer.category.GroupedStackedBarRenderer renderer,
                                      org.jfree.chart.axis.SubCategoryAxis axis)
        Creates a dataset, that is linked to a GroupedStackedBarRenderer for assigne the groupmaps and to the SubCategoryAxis to create subcategories.
        Parameters:
        renderer - The GroupedStackedBarRenderer.
        axis - The SubCategoryAxis.
      • GroupedCategoryDataset

        public GroupedCategoryDataset​(org.jfree.chart.JFreeChart chart)
        Creates a dataset and retrieves the GroupedStackedBarRenderer and the SubCategoryAxis from the chart.
        Parameters:
        chart -
    • Method Detail

      • addCategoryDataset

        public void addCategoryDataset​(org.jfree.data.category.CategoryDataset dataset,
                                       java.lang.String name)
        Adds a dataset and (if the dataset is not empty) assigning groups for each rowkey to the renderer and adding subcategories to the axis.
        Parameters:
        dataset - The dataset.
        name - The name for the dataset.
      • cleanup

        public void cleanup()
        Removes all references to assigned objects.
      • getRowCount

        public int getRowCount()
        Returns the total number of all rows in the datasets.
        Specified by:
        getRowCount in interface org.jfree.data.Values2D
        Returns:
        The row count.
      • getColumnCount

        public int getColumnCount()
        Returns the total number of different columns in the datasets.
        Specified by:
        getColumnCount in interface org.jfree.data.Values2D
        Returns:
        The column count.
      • getColumnKeys

        public java.util.List getColumnKeys()
        Returns the column keys.
        Specified by:
        getColumnKeys in interface org.jfree.data.KeyedValues2D
        Returns:
        The keys.
      • getRowKeys

        public java.util.List getRowKeys()
        Returns the row keys.
        Specified by:
        getRowKeys in interface org.jfree.data.KeyedValues2D
        Returns:
        The keys.
      • getRowIndex

        public int getRowIndex​(java.lang.Comparable key)
        Returns the row index for a given key.
        Specified by:
        getRowIndex in interface org.jfree.data.KeyedValues2D
        Parameters:
        key - the row keys.
        Returns:
        The row index.
      • getColumnIndex

        public int getColumnIndex​(java.lang.Comparable key)
        Returns the column index for a given key.
        Specified by:
        getColumnIndex in interface org.jfree.data.KeyedValues2D
        Parameters:
        key - the column key.
        Returns:
        The column index.
      • getRowKey

        public java.lang.Comparable getRowKey​(int row)
        Returns a row key.
        Specified by:
        getRowKey in interface org.jfree.data.KeyedValues2D
        Parameters:
        row - the row index (zero-based).
        Returns:
        The row key.
      • getColumnKey

        public java.lang.Comparable getColumnKey​(int column)
        Returns a column key.
        Specified by:
        getColumnKey in interface org.jfree.data.KeyedValues2D
        Parameters:
        column - the column index (zero-based).
        Returns:
        The column key.
      • getValue

        public java.lang.Number getValue​(int row,
                                         int column)
        Returns a value from the table.
        Specified by:
        getValue in interface org.jfree.data.Values2D
        Parameters:
        row - the row index (zero-based).
        column - the column index (zero-based).
        Returns:
        The value (possibly null).
      • getValue

        public java.lang.Number getValue​(java.lang.Comparable rowKey,
                                         java.lang.Comparable columnKey)
        Returns the value for a pair of keys.
        Specified by:
        getValue in interface org.jfree.data.KeyedValues2D
        Parameters:
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
        Returns:
        The value (possibly null).
      • datasetChanged

        public void datasetChanged​(org.jfree.data.general.DatasetChangeEvent event)
        A dataset has changed. Assign all new rowkeys as groups to the renderer and delete no longer existing rowkeys from the maps.
        Specified by:
        datasetChanged in interface org.jfree.data.general.DatasetChangeListener
        Parameters:
        event - The event.
      • getList

        public java.util.List getList​(java.lang.Comparable rowKey,
                                      java.lang.Comparable columnKey)
        Returns the List for a given group rowkey and column key. The proper dataset and original rowkey is retrieved from the maps.
        Parameters:
        rowKey - The group rowkey.
        columnKey - The columnkey.
        Returns:
        The list.
      • getOriginalRowKey

        public java.lang.Comparable getOriginalRowKey​(java.lang.Comparable rowKey)
        Returns the original rowkey from a group rowkey