gcspy.vis.plugins.text
Class TextTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by gcspy.vis.plugins.text.TextTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class TextTableModel
extends javax.swing.table.AbstractTableModel

A table model for the text view

Author:
Richard Jones
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TextTableModel(ClientSpace space)
          Create a model for a table view of a space
 
Method Summary
 java.lang.String format(java.lang.String str)
          Format a column header
 java.lang.String format(java.lang.String[] strings)
          Format a column header
 java.lang.Class<?> getColumnClass(int col)
          Get the class of a column
 int getColumnCount()
           
 java.lang.String getColumnName(int col)
          Return either "Block" (for column 0) or a title combining the prefix/suffix string for this stream
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int col)
          Get a block name or a stream value
 boolean isCellEditable(int row, int col)
          No cells are editable
(package private)  void setData()
          Refresh the data for the space, and reset the sorting parameters Looks better if there is always a minimum number of rows.
(package private)  void setSpace(ClientSpace space)
          Set the space to view
 void sortAllRowsByColumn(int column)
          Sort the column by a particular column.
 void sortAllRowsByColumn(int column, boolean ascending)
          Sort the column by a particular column.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTableModel

TextTableModel(ClientSpace space)
Create a model for a table view of a space

Parameters:
space - The space
Method Detail

setSpace

void setSpace(ClientSpace space)
Set the space to view

Parameters:
space - the ClientSpace

setData

void setData()
Refresh the data for the space, and reset the sorting parameters Looks better if there is always a minimum number of rows.


getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Get a block name or a stream value

Parameters:
row - the tile
col - 0 for block name, else stream + 1

getColumnClass

public java.lang.Class<?> getColumnClass(int col)
Get the class of a column

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
col - the index of the column
Returns:
the class of the objects in this column

getColumnName

public java.lang.String getColumnName(int col)
Return either "Block" (for column 0) or a title combining the prefix/suffix string for this stream

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
col - The column index (i.e. stream ID + 1)
Returns:
a column heading string

format

public java.lang.String format(java.lang.String str)
Format a column header

Parameters:
str - a string for the header
Returns:
a centred representation of a string

format

public java.lang.String format(java.lang.String[] strings)
Format a column header

Parameters:
strings - an array of strings to be appended into a single header
Returns:
a centred representation of a string

isCellEditable

public boolean isCellEditable(int row,
                              int col)
No cells are editable

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Returns:
false

sortAllRowsByColumn

public void sortAllRowsByColumn(int column)
Sort the column by a particular column.

Parameters:
column - The column

sortAllRowsByColumn

public void sortAllRowsByColumn(int column,
                                boolean ascending)
Sort the column by a particular column.

Parameters:
column - The column
ascending - Whether to sort in ascending or descending order