org.ka2ddo.yaac.gui
Class KenwoodMessageListTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ka2ddo.yaac.gui.KenwoodMessageListTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, DuplicateCheckedAX25Listener, ColumnSizingTableModel

public class KenwoodMessageListTableModel
extends javax.swing.table.AbstractTableModel
implements ColumnSizingTableModel, DuplicateCheckedAX25Listener

This provides a sortable, filterable situational status display, attempting to emulate the Kenwood D710 control head's LIST view, as a backing TableModel for a JTable view.

See Also:
Serialized Form

Field Summary
protected static java.text.DecimalFormat fmtMonitorFreq
          Format string for APRS-standard frequency format.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
KenwoodMessageListTableModel()
          Create a KenwoodMessageListTableModel.
 
Method Summary
 void consumeAX25Frame(AX25Message msg, AX25Frame frame, Connector connector, boolean isDuplicate)
          Called when a AX.25 frame is received.
 java.lang.Class<?> getColumnClass(int columnIndex)
          Returns the data Class for the specified column.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String getColumnName(int column)
          Returns an empty name for the column (because the Kenwood D710 control head doesn't display column headers).
 int getColumnWidth(int columnIndex)
          Specifies the default initial width of a column from this model.
 int getRowCount()
          Returns the number of rows in the model.
 AX25Message getSortedRow(int rowIndex)
          Return the object state record for the specified index into the sorted list of objects that is backing the table model.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 boolean isSizeToFit(int columnIndex)
          Specifies whether setWidthToFit() should be enabled on this column
 
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
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, isCellEditable, removeTableModelListener, setValueAt
 

Field Detail

fmtMonitorFreq

protected static final java.text.DecimalFormat fmtMonitorFreq
Format string for APRS-standard frequency format.

Constructor Detail

KenwoodMessageListTableModel

public KenwoodMessageListTableModel()
Create a KenwoodMessageListTableModel.

Method Detail

getRowCount

public int getRowCount()
Returns the number of rows in the model.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
the number of rows in the model
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns the number of columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of columns in the model
See Also:
getRowCount()

getSortedRow

public AX25Message getSortedRow(int rowIndex)
Return the object state record for the specified index into the sorted list of objects that is backing the table model.

Parameters:
rowIndex - zero-based row index
Returns:
StationState record describing the Object or Item

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the value Object at the specified cell

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Returns the data Class for the specified column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the column being queried
Returns:
the Class object for the column's data

getColumnName

public java.lang.String getColumnName(int column)
Returns an empty name for the column (because the Kenwood D710 control head doesn't display column headers).

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - the column being queried
Returns:
a string containing the default name of column

getColumnWidth

public int getColumnWidth(int columnIndex)
Specifies the default initial width of a column from this model. Should only be queried at table creation time.

Specified by:
getColumnWidth in interface ColumnSizingTableModel
Parameters:
columnIndex - int index of the model's column whose width should be obtained
Returns:
the width, in the same units used by the TableColumn class's setWidth() method, or -1 to indicate the width should not be forced

isSizeToFit

public boolean isSizeToFit(int columnIndex)
Specifies whether setWidthToFit() should be enabled on this column

Specified by:
isSizeToFit in interface ColumnSizingTableModel
Parameters:
columnIndex - int index of the model's column whose width should be obtained
Returns:
boolean true if sizeWidthToFit() should be called on this column

consumeAX25Frame

public void consumeAX25Frame(AX25Message msg,
                             AX25Frame frame,
                             Connector connector,
                             boolean isDuplicate)
Called when a AX.25 frame is received.

Specified by:
consumeAX25Frame in interface DuplicateCheckedAX25Listener
Parameters:
msg - decoded APRS message if the AX.25 frame contains an APRS packet, or null if the frame is not a recognized protocol
frame - received AX25Frame
connector - the PortConnector over which the frame was received
isDuplicate - boolean true if this is a duplicate message (possibly received over a different digipeater path)