org.jscience.io.fits
Class FitsTableData

java.lang.Object
  extended by org.jscience.io.fits.FitsData
      extended by org.jscience.io.fits.FitsTableData
All Implemented Interfaces:
javax.swing.table.TableModel
Direct Known Subclasses:
FitsASCIITableData, FitsBinTableData

public abstract class FitsTableData
extends FitsData
implements javax.swing.table.TableModel

This abstract class represents the data in either a FITS ASCII table or a FITS BINTABLE. The data implement the Swing TableModel interface, so they can be accessed in a way natural to Java. In particular, an object of this class may be displayed in a JTable component. Rows and columns are numbered starting at zero, as is natural in Java. People used to the FORTRAN convention of numbering from "1" used in the FITS files themselves may need to be careful.


Field Summary
 
Fields inherited from class org.jscience.io.fits.FitsData
data, interpreter, isComplete, PADDING, setter, valid_bytes
 
Constructor Summary
FitsTableData(FitsHeader header)
          Create a table object, reading the column information from the given header
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
          add a listener to the table which will be alerted when the table changes
 int findColumn(java.lang.String name)
          returns the column number for a given column name, or -1 if there is no such column in the table.
protected  void fireTableModelEvent(int row, int col)
          send a TableModelEvent to all the listeners that a given cell has changed.
protected  void fireTableModelEvent(javax.swing.event.TableModelEvent e)
          send a TableModelEvent to all the listeners.
 FitsColumn getColumn(int col)
          returns the column object for a given column number.
 java.lang.Class getColumnClass(int col)
          returns the Java class of the data in a column
 int getColumnCount()
          returns the number of columns in the table
 java.lang.String getColumnName(int col)
          returns the name of a given column.
 int getRowCount()
          returns the number of rows in the table
protected  void goToElement(int row, FitsColumn column)
          reposition the reader to read the given table element
 boolean isCellEditable(int row, int col)
          always returns true.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          remove a listener from the table.
 
Methods inherited from class org.jscience.io.fits.FitsData
available, blockCount, createFrom, data, goToByte, incrementValidBytes, isComplete, setValidBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
getValueAt, setValueAt
 

Constructor Detail

FitsTableData

public FitsTableData(FitsHeader header)
              throws FitsException
Create a table object, reading the column information from the given header

Parameters:
header - the HDU header used to extract column information
Throws:
FitsException - if the FITS format is incorrect.
Method Detail

getColumn

public FitsColumn getColumn(int col)
returns the column object for a given column number.

Parameters:
col - the column number - the first column is numbered "0", despite the fact that it is numbered "1" in the FITS file itself.
Returns:
the specified column.

goToElement

protected void goToElement(int row,
                           FitsColumn column)
reposition the reader to read the given table element

Parameters:
row - the desired row of the column, with the first row numbered "0".
column - the column object corresponding to the desired column.

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
add a listener to the table which will be alerted when the table changes

Specified by:
addTableModelListener in interface javax.swing.table.TableModel
Parameters:
l - the listener to add

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
remove a listener from the table.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Parameters:
l - the listener to remove

fireTableModelEvent

protected void fireTableModelEvent(javax.swing.event.TableModelEvent e)
send a TableModelEvent to all the listeners. Note a listener should not remove iteself in its tableChanged method.

Parameters:
e - DOCUMENT ME!

fireTableModelEvent

protected void fireTableModelEvent(int row,
                                   int col)
send a TableModelEvent to all the listeners that a given cell has changed.

Parameters:
row - - the row which has changed. The first row is "0".
col - - the columns wich has changed. The first columns is "0".

getColumnClass

public java.lang.Class getColumnClass(int col)
returns the Java class of the data in a column

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Parameters:
col - - the index of the desired column. The first column is numbered "0"
Returns:
DOCUMENT ME!

getColumnCount

public int getColumnCount()
returns the number of columns in the table

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
DOCUMENT ME!

getColumnName

public java.lang.String getColumnName(int col)
returns the name of a given column. This is a name suitable for display in a table header. It may have the units of the column appended to the column nam egiven in the TTYPEn keyword. To get the raw column name without decoration use getColumn(int) to get the column object and then FitsColumn.getName().

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
col - the desired column. The first column is numbered "0".
Returns:
the decorated name of the column suitible for display

findColumn

public int findColumn(java.lang.String name)
returns the column number for a given column name, or -1 if there is no such column in the table. The name is the raw undecorated column name in the FITS TTYPEn keyword.

Parameters:
name - the undecorated name of the desired column
Returns:
the index of the desired columns, or -1 if there is no such column. The first column is numbered "0".

getRowCount

public int getRowCount()
returns the number of rows in the table

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
DOCUMENT ME!

isCellEditable

public boolean isCellEditable(int row,
                              int col)
always returns true. This could be modified in the future if we wish to mark some tables as read-only.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Parameters:
row - the row number counting from zero.
col - the column number counting from zero.
Returns:
DOCUMENT ME!