HiRISE

HiRISE.HiPlan.PTF
Class PTF_Record_Table_Model

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by HiRISE.HiPlan.PTF.PTF_Record_Table_Model
All Implemented Interfaces:
Serializable, TableModel

public class PTF_Record_Table_Model
extends AbstractTableModel

A table model for displaying PTF records. The model extends the base PTF_Record by including a line number to display. It also maintains non-displayed data indicating whether a particular row should be hidden by a viewer and data indicating whether a particular row is a duplicate of another row. It is up to the viewer to take action on these attributes, however.

This model is designed primarily for PTF_Viewer's table, which does handle the aforementioned extended attributes.

Note that all row and col (column) indexes are model indexes, not view indexes.

Version:
1.24
Author:
Christian Schaller - UA/PIRL
See Also:
PTF_Record_Table_Model.ExtendedPtfRecord, isDuplicateRow(int), isHiddenRow(int), Serialized Form

Nested Class Summary
static class PTF_Record_Table_Model.Column
           
static class PTF_Record_Table_Model.ColumnType
          An enumeration of the types of data that may be contained in columns of the PTF record table model.
static class PTF_Record_Table_Model.ExtendedPtfRecord
          A PTF record with extended attributes.
static class PTF_Record_Table_Model.TransferFormat
           
static class PTF_Record_Table_Model.Uniqueness
          A measure of uniqueness for a PTF record.
 
Field Summary
static String ID
          Class identification name with source code version and date.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PTF_Record_Table_Model()
          Creates an empty table model.
PTF_Record_Table_Model(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
          Creates a new table model from a set of extended attribute PTF records.
 
Method Summary
 void addPtfRecords(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
          Adds to the set of extended PTF records currently held by the table model.
static String getColHeader(List<PTF_Record_Table_Model.Column> columns, PTF_Record_Table_Model.TransferFormat format)
           
 Class getColumnClass(int col)
          Gets the specific class for all the cell values in the column.
 int getColumnCount()
          Gets the number of columns in the table model.
 String getColumnName(int col)
          Gets the name of the column at the indicated column index.
 PTF_Record_Table_Model.ExtendedPtfRecord getPtfRecord(int row)
          Gets the extended attribute PTF record at the indicated row.
 List<PTF_Record_Table_Model.ExtendedPtfRecord> getPtfRecords()
          Gets the set of extended PTF records currently held by the table model.
 String getReport(PTF_Record_Table_Model.ExtendedPtfRecord ptfRecord, List<PTF_Record_Table_Model.Column> columns, PTF_Record_Table_Model.TransferFormat format)
           
 int getRowCount()
          Gets the number of rows in the table model.
 Object getValueAt(int row, int col)
          Returns the value for the cell at the indicated row and column.
 boolean hasNonHiriseRecords()
          Indicates whether the model contains non-HiRISE records.
 void hideRow(int row)
          Sets the 'hidden' attribute of the PTF record at the indicated model row.
 boolean isDuplicateRow(int row)
          Identifies whether the indicated model row contains a duplicate record.
 boolean isHiddenRow(int row)
          Determines whether the PTF record at the indicated row is marked as hidden.
 boolean isHiriseRow(int row)
          Determines whether the PTF record at the indicated row is a HiRISE record.
 void recomputeUniqueness(boolean usePointingModeInUniqueness)
          Recomputes the uniqueness measure for each record in the model.
 void setPtfRecords(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
          Sets the set of extended PTF records currently held by the table model.
 void showRow(int row)
          Unsets the 'hidden' attribute of the PTF record at the indicated model row.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

PTF_Record_Table_Model

public PTF_Record_Table_Model()
Creates an empty table model.


PTF_Record_Table_Model

public PTF_Record_Table_Model(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
Creates a new table model from a set of extended attribute PTF records. The records are scanned for duplicates, identified by their uniqueness measure, and those found to be duplicates are so marked.

Parameters:
ptfRecords - the collection of PTF records for the new model.
See Also:
setPtfRecords(List)
Method Detail

getPtfRecords

public List<PTF_Record_Table_Model.ExtendedPtfRecord> getPtfRecords()
Gets the set of extended PTF records currently held by the table model.

Returns:
the extended PTF records.

setPtfRecords

public void setPtfRecords(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
Sets the set of extended PTF records currently held by the table model. The records are scanned for duplicates, identified by their uniqueness measure, and those found to be duplicates are so marked.

This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
ptfRecords - the new set of extended PTF records; may be null.
See Also:
AbstractTableModel.fireTableDataChanged()

addPtfRecords

public void addPtfRecords(List<PTF_Record_Table_Model.ExtendedPtfRecord> ptfRecords)
Adds to the set of extended PTF records currently held by the table model. The records are scanned for duplicates, identified by their uniqueness measure, and those found to be duplicates are so marked.

This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
ptfRecords - the set of extended PTF records to be added; may be null.
See Also:
AbstractTableModel.fireTableDataChanged()

getRowCount

public int getRowCount()
Gets the number of rows in the table model. The number of rows corresponds to the number of PTF records in the model's data set.

Returns:
the number of rows in the model.

getColumnCount

public int getColumnCount()
Gets the number of columns in the table model. There are 32 columns in the model: The 31 PTF record columns and an additional column that represents line number of the record in the original PTF.

Returns:
the number of columns in the model: 32.
See Also:
PTF_Record_Table_Model.Column

getValueAt

public Object getValueAt(int row,
                         int col)
Returns the value for the cell at the indicated row and column.

For the instrument spare 1, 2, and 3 columns, the returned object's class is either as defined in the PTF SIS (Double, Double, and Integer, respectively) or String. The returned object's class is String if any PTF record in the model contains a non-number in that column.

Parameters:
row - the model row whose value is to be queried.
col - the model column whose value is to be queried.
Returns:
the value Object at the specified cell; null if the indices are not valid.

getColumnClass

public Class getColumnClass(int col)
Gets the specific class for all the cell values in the column.

For the instrument spare 1, 2, and 3 columns, the column class is either as defined in the PTF SIS (Double, Double, and Integer, respectively) or String. The column class is String if any PTF record contains a non-number in that column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
col - the model index of the column in question.
Returns:
the common ancestor class of the object values in the model.

getColumnName

public String getColumnName(int col)
Gets the name of the column at the indicated column index.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
col - the model index of the column.
Returns:
the name of the column.
See Also:
PTF_Record_Table_Model.Column

getPtfRecord

public PTF_Record_Table_Model.ExtendedPtfRecord getPtfRecord(int row)
Gets the extended attribute PTF record at the indicated row.

Parameters:
row - the model row number in question.
Returns:
the record or null if the row number is out of range.

recomputeUniqueness

public void recomputeUniqueness(boolean usePointingModeInUniqueness)
Recomputes the uniqueness measure for each record in the model.

This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
usePointingModeInUniqueness - if true, the uniqueness measure will include whether the observation is nadir or off-nadir pointed; if false, it will not.
See Also:
PTF_Record_Table_Model.Uniqueness, AbstractTableModel.fireTableDataChanged()

isDuplicateRow

public boolean isDuplicateRow(int row)
Identifies whether the indicated model row contains a duplicate record.

This method identifies a row in this model as being a duplicate of another row in this model via the uniqueness values of the rows. It is distinct from the isDuplicate() property of the individual extended attribute PTF records that comprise those rows, which is simply a hint. Although the two properties are related, as a row is hidden and shown, its isDuplicate() property is toggled false (when hidden) and true (when shown)—as is the isDuplicate() property of its counterparts.

Parameters:
row - the model row index of the record in question.
Returns:
true if the record is a duplicate of another, false if it is not or if the row is out of range.

hideRow

public void hideRow(int row)
Sets the 'hidden' attribute of the PTF record at the indicated model row.

If the record is identified in this model as a duplicate row and its isDuplicate() extended property is true, it is set to false. If there is only one other non-hidden member of this record's duplicate set (with the same uniqueness) whose isDuplicate() property is also true, it too is set to false. This check ensures that tables that mark records as duplicates correctly stop marking such records when only one record of a set is still visible.

It is up to a table with this model to handle the actual hiding of a record and the decorating of any duplicate records.

This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
row - the model row index of the record to be marked as hidden.
See Also:
PTF_Record_Table_Model.ExtendedPtfRecord.isHidden(), AbstractTableModel.fireTableDataChanged()

showRow

public void showRow(int row)
Unsets the 'hidden' attribute of the PTF record at the indicated model row.

If the record is identified in this model as a duplicate row and its isDuplicate() extended property is false, it is set to true. Furthermore, any other non-hidden member of this record's duplicate set (with the same uniqueness) whose isDuplicate() property is false is set to true.

It is up to a table with this model to handle the actual unhiding of a record and the decorating of any duplicate records.

This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
row - the model row index of the record to be marked as unhidden.
See Also:
PTF_Record_Table_Model.ExtendedPtfRecord.isHidden(), AbstractTableModel.fireTableDataChanged()

isHiddenRow

public boolean isHiddenRow(int row)
Determines whether the PTF record at the indicated row is marked as hidden.

Parameters:
row - the model row index of the record in question.
Returns:
true if the record's 'hidden' property is true, false if it is not or if the row is out of range.
See Also:
PTF_Record_Table_Model.ExtendedPtfRecord.isHidden()

isHiriseRow

public boolean isHiriseRow(int row)
Determines whether the PTF record at the indicated row is a HiRISE record. A PTF record is a HiRISE record if and only if the instrument set field starts with a capital "H."

Parameters:
row - the model row index of the record in question.
Returns:
true if the record is a HiRISE record, false if it is not or if the row is out of range.

hasNonHiriseRecords

public boolean hasNonHiriseRecords()
Indicates whether the model contains non-HiRISE records. A PTF record is a non-HiRISE record if and only if the instrument set field does not start with a capital "H."

Returns:
true if there is at least one non-HiRISE record in the model, false otherwise.

getColHeader

public static String getColHeader(List<PTF_Record_Table_Model.Column> columns,
                                  PTF_Record_Table_Model.TransferFormat format)

getReport

public String getReport(PTF_Record_Table_Model.ExtendedPtfRecord ptfRecord,
                        List<PTF_Record_Table_Model.Column> columns,
                        PTF_Record_Table_Model.TransferFormat format)

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona