Class TransposeTable

All Implemented Interfaces:
PopupActivationListener, Serializable, Comparable, EventListener, ListSelectionListener, TableModelListener, TableModel

public class TransposeTable extends AttributeStore implements TableModelListener
This class transposes rows from one table into columns in the new table. One column is chosen as the pivot column, and the values from the rows in this column will be used as column headings in the new table.

A list of numeric columns from the original table are selected to become rows in the new table.

Suppose you have a table that looks like

Sample table
TARGETCURRENTMINIMUMMAXIMUM
feature.Area.Pj10050300
feature.Area.Sb25050300
feature.Area.Bf7550300
The following object will transpose the rows and columns of this table, pivoting on the TARGET column:
 TransposeTable t = new TransposeTable(input, "TARGET", 
    new String[] {"CURRENT", "MINIMUM", "MAXIMUM"});
 
The table that is created will have the following shape
Resulting table
TARGETfeature.Area.Pjfeature.Area.Sbfeature.Area.Bf
CURRENT10025075
MINIMUM505050
MAXIMUM300300300
Note that the first column of the table will always be named with the column that is being transposed.
See Also:
Serialized Form
  • Constructor Details

    • TransposeTable

      public TransposeTable(AttributeStore as, String columnName, String[] columns)
      Set up the transposition.
      Parameters:
      as - The original attribute store to transpose.
      columnName - The name of the column in the original table that will contain the column headings in the transposed table.
      columns - The names of the columns in the original table that will be turned into rows in the transposed table. These columns must contain numeric data.
  • Method Details

    • getParentStore

      public AttributeStore getParentStore()
    • getTransposeColumnName

      public String getTransposeColumnName()
    • getTransposeColumns

      public String[] getTransposeColumns()
    • getRowCount

      public int getRowCount()
      Description copied from class: AttributeStore
      Get the number of rows in this store
      Specified by:
      getRowCount in interface TableModel
      Specified by:
      getRowCount in class AttributeStore
      Returns:
      the number of rows in this store
    • getPeriodCount

      public int getPeriodCount()
      Description copied from class: AttributeStore
      Get the total number of periods that this store supports
      Specified by:
      getPeriodCount in class AttributeStore
      Returns:
      The number of periods in this store
    • getYearForPeriod

      public int getYearForPeriod(int period)
      Description copied from class: AttributeStore
      Get the ending year for a given period.
      Specified by:
      getYearForPeriod in class AttributeStore
      Parameters:
      period - The period of interest
      Returns:
      the year for a given period
    • getValueAt

      public Object getValueAt(int row, int column, int period)
      Description copied from class: AttributeStore
      Get a cell value
      Specified by:
      getValueAt in class AttributeStore
      Parameters:
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
      Returns:
      An object containing the cell value.
    • getValueAt

      public Object getValueAt(int row, int column)
      Description copied from class: AttributeStore
      Get a cell value using the default period for the table.
      Specified by:
      getValueAt in interface TableModel
      Overrides:
      getValueAt in class AttributeStore
      Parameters:
      row - The row containing the cell
      column - The column containing the cell
      Returns:
      An object containing the cell value.
    • tableChanged

      public void tableChanged(TableModelEvent e)
      Specified by:
      tableChanged in interface TableModelListener
    • getSnapshot

      public AttributeStore getSnapshot(boolean useSelected, Observer progress)
      Get a snapshot of this table definition. This will request snpashots of the input data store, in case any of those are crosstabs. The results will be contained in the snapshot and will not change even if the underlying data set changes.
      Overrides:
      getSnapshot in class AttributeStore
      Parameters:
      useSelected - The calculations will only be computed on the selected records.
      progress - A reference to a progress widget that will be updated with the progress of the calculations.
      Returns:
      This method will return a new shapshot that captures the state of the table definition for the input current data sets.