Package ca.spatial.table
Class TransposeTable
java.lang.Object
javax.swing.table.AbstractTableModel
ca.spatial.table.AttributeStore
ca.spatial.table.TransposeTable
- All Implemented Interfaces:
PopupActivationListener
,Serializable
,Comparable
,EventListener
,ListSelectionListener
,TableModelListener
,TableModel
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.
The following object will transpose the rows and columns of this table,
pivoting on the TARGET column:
Note that the first column of the table will always be named with the
column that is being transposed.
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
TARGET | CURRENT | MINIMUM | MAXIMUM |
---|---|---|---|
feature.Area.Pj | 100 | 50 | 300 |
feature.Area.Sb | 250 | 50 | 300 |
feature.Area.Bf | 75 | 50 | 300 |
TransposeTable t = new TransposeTable(input, "TARGET", new String[] {"CURRENT", "MINIMUM", "MAXIMUM"});The table that is created will have the following shape
TARGET | feature.Area.Pj | feature.Area.Sb | feature.Area.Bf |
---|---|---|---|
CURRENT | 100 | 250 | 75 |
MINIMUM | 50 | 50 | 50 |
MAXIMUM | 300 | 300 | 300 |
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class ca.spatial.table.AttributeStore
SELECT_ADD, SELECT_FROM, SELECT_NEW
-
Constructor Summary
ConstructorsConstructorDescriptionTransposeTable(AttributeStore as, String columnName, String[] columns)
Set up the transposition. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the total number of periods that this store supportsint
Get the number of rows in this storegetSnapshot(boolean useSelected, Observer progress)
Get a snapshot of this table definition.String[]
getValueAt(int row, int column)
Get a cell value using the default period for the table.getValueAt(int row, int column, int period)
Get a cell valueint
getYearForPeriod(int period)
Get the ending year for a given period.void
Methods inherited from class ca.spatial.table.AttributeStore
absoluteFile, absoluteFile, absolutePath, absolutePath, addCellEditors, addMenuItems, addPopupActivationListener, addRelate, addRelate, addTableModelListener, addToGlobalStoreList, allowsEditing, booleanValue, booleanValue, buildIndex, calculate, calculateField, calculateField, canIndex, changeSelection, clearSelection, close, compareTo, decodeCharset, doubleValue, doubleValue, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportDBF, exportDBF, exportDBF, exportDBF, exportDBF, findColumn, findColumn, findSimilarColumnNames, getAttributeFormat, getCacheParent, getCachingLayer, getCachingLayer, getCanonicalName, getColumnClass, getColumnCount, getColumnName, getColumnNames, getContextPeriods, getCwd, getEditMode, getFullColumnName, getListSelectionModel, getMinMax, getMinMax, getMinMax, getMinMax, getMinMax, getOpenStore, getOpenStore, getOpenStore, getOpenStores, getPeriod, getPeriodWidth, getRowNodeRemap, getSelectedRowCount, getSelection, getSelection, getSelection, getShortName, getSnapshot, getStoreByShortName, getStoreByTitle, getSynchronizer, getTableName, getTableSpec, getTitle, hasIndex, identifyRecords, integerValue, integerValue, isCellEditable, isSelectedIndex, isSelectionEmpty, listify, listValue, listValue, lookupRow, makeLu, maybePopup, notifyPopupActivationListeners, openOrReuse, openOrReuse, queryTable, queryTable, quoteIfRequired, relativePath, removeFromGlobalStoreList, removePopupActivationListener, removeTableModelListener, select, select, selectAdd, selectFrom, selectNew, setCwd, setCwd, setEditMode, setListSelectionModel, setPeriod, setRowNodeRemap, setShortName, setTableSpec, setTitle, setValueAt, setValueAt, showCube, showTable, toString, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, valueChanged
Methods inherited from class javax.swing.table.AbstractTableModel
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
-
Constructor Details
-
TransposeTable
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
-
getTransposeColumnName
-
getTransposeColumns
-
getRowCount
public int getRowCount()Description copied from class:AttributeStore
Get the number of rows in this store- Specified by:
getRowCount
in interfaceTableModel
- Specified by:
getRowCount
in classAttributeStore
- 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 classAttributeStore
- 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 classAttributeStore
- Parameters:
period
- The period of interest- Returns:
- the year for a given period
-
getValueAt
Description copied from class:AttributeStore
Get a cell value- Specified by:
getValueAt
in classAttributeStore
- Parameters:
row
- The row containing the cellcolumn
- The column containing the cellperiod
- The period of interest- Returns:
- An object containing the cell value.
-
getValueAt
Description copied from class:AttributeStore
Get a cell value using the default period for the table.- Specified by:
getValueAt
in interfaceTableModel
- Overrides:
getValueAt
in classAttributeStore
- Parameters:
row
- The row containing the cellcolumn
- The column containing the cell- Returns:
- An object containing the cell value.
-
tableChanged
- Specified by:
tableChanged
in interfaceTableModelListener
-
getSnapshot
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 classAttributeStore
- 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.
-