org.ka2ddo.yaac.gui
Class MessageModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ka2ddo.yaac.gui.MessageModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, TrackerListener, AprsMessageContainingModel, ColumnSizingTableModel, FastComparableTableModel, ClearableTableModel

public class MessageModel
extends javax.swing.table.AbstractTableModel
implements TrackerListener, ColumnSizingTableModel, AprsMessageContainingModel, FastComparableTableModel, ClearableTableModel

This class implements a TableModel for monitoring received APRS messages (actual directed or broadcast text messages, code ':').

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ka2ddo.yaac.util.ClearableTableModel
ClearableTableModel.ClearType
 
Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Method Summary
 int compareRows(int rowIndex1, int rowIndex2, int columnIndex)
          Compare the selected column of the two rows.
 int deleteAllRows(ClearableTableModel.ClearType clearType)
          Delete all rows from this table.
 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 the localized name for the column.
 int getColumnWidth(int columnIndex)
          Specifies the default initial width of a column from this model.
 MessageMessage getMessage(int row)
          Get a message at the specified index from the appropriate (filtered or unfiltered) list.
 AX25Message getMessageAt(int rowIndex)
          Get a message at the specified index.
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isShowEveryonesMessages()
          Report if all Messages are to be shown, or only those addressed to this station.
 boolean isSizeToFit(int columnIndex)
          Specifies whether setWidthToFit() should be enabled on this column.
 void messageAdded(StationState ss, int index, AX25Message msg)
          Called when a AX25Message is added to the history for a station in the tracker.
 void messageDeleted(StationState ss, int index, AX25Message msg)
          Called when a AX25Message is deleted from the history for a station in the tracker.
 void messageRemoved(MessageMessage mm)
           
 void setMode(RawPacketDisplayMode mode)
          Specify what display mode should be used to present the message body of the specified message when the body's column is requested with the getValueAt() method.
 void setShowEveryonesMessages(boolean showEveryonesMessages)
          Specify if all Messages are to be shown, or only those addressed to this station.
 void stationAdded(StationState ss, int index)
          Called when a new station is initially added to the tracker.
 void stationDeleted(StationState ss, int index)
          Called when an existing station is deleted from the tracker.
 void stationUpdated(StationState ss)
          Called when an existing station is updated with new information in the tracker.
 
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
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener, setValueAt
 

Method Detail

isShowEveryonesMessages

public boolean isShowEveryonesMessages()
Report if all Messages are to be shown, or only those addressed to this station.

Returns:
boolean true if all messages are to be shown, or false for only messages addressed to this station

setShowEveryonesMessages

public void setShowEveryonesMessages(boolean showEveryonesMessages)
Specify if all Messages are to be shown, or only those addressed to this station.

Parameters:
showEveryonesMessages - boolean true if all messages are to be shown, or false for only messages addressed to this station

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 the localized name for the column.

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 name of column

getColumnWidth

public int getColumnWidth(int columnIndex)
Description copied from interface: ColumnSizingTableModel
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)
Description copied from interface: ColumnSizingTableModel
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

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

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()

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()

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

getMessageAt

public AX25Message getMessageAt(int rowIndex)
                         throws java.lang.IndexOutOfBoundsException
Get a message at the specified index.

Specified by:
getMessageAt in interface AprsMessageContainingModel
Parameters:
rowIndex - zero-based index to the specified Message
Returns:
AX25Message stored in this table
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range for stored messages

getMessage

public MessageMessage getMessage(int row)
Get a message at the specified index from the appropriate (filtered or unfiltered) list.

Parameters:
row - zero-based index to the specified Message
Returns:
AX25Message stored in this table
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range for stored messages

compareRows

public int compareRows(int rowIndex1,
                       int rowIndex2,
                       int columnIndex)
Compare the selected column of the two rows.

Specified by:
compareRows in interface FastComparableTableModel
Parameters:
rowIndex1 - zero-based model row index of first row to compare
rowIndex2 - zero-based model row index of second row to compare
columnIndex - zero-based model column index of column to compare
Returns:
+1 if the 1st row's column is after the 2nd row's column, -1 if before, or 0 if equal precedence

setMode

public void setMode(RawPacketDisplayMode mode)
Description copied from interface: AprsMessageContainingModel
Specify what display mode should be used to present the message body of the specified message when the body's column is requested with the getValueAt() method.

Specified by:
setMode in interface AprsMessageContainingModel
Parameters:
mode - SnifferPacketDisplayMode enum specifying the display mode
See Also:
TableModel.getValueAt(int, int)

messageAdded

public void messageAdded(StationState ss,
                         int index,
                         AX25Message msg)
Called when a AX25Message is added to the history for a station in the tracker.

Specified by:
messageAdded in interface TrackerListener
Parameters:
ss - StationState containing the station's information
index - zero-based index of the message added to the StationState object
msg - APRS Message object being added to the tracker; note that non-APRS packets that can still be decoded (such as OpenTRAC) will also be passed here; AX25Frames that cannot be decoded will pass null here

messageDeleted

public void messageDeleted(StationState ss,
                           int index,
                           AX25Message msg)
Called when a AX25Message is deleted from the history for a station in the tracker.

Specified by:
messageDeleted in interface TrackerListener
Parameters:
ss - StationState containing the station's information; the AX25Message will already be removed from the StationState object
index - zero-based index of the message removed from the StationState object
msg - APRS Message object being removed from the tracker; note that non-APRS packets that can still be decoded (such as OpenTRAC) will also be passed here; AX25Frames that cannot be decoded will pass null here

stationAdded

public void stationAdded(StationState ss,
                         int index)
Called when a new station is initially added to the tracker.

Specified by:
stationAdded in interface TrackerListener
Parameters:
ss - StationState containing the station's information; the initial AX25Message will not yet be stored within the StationState object
index - zero-based integer sequence number for this station in the StationTracker

stationUpdated

public void stationUpdated(StationState ss)
Called when an existing station is updated with new information in the tracker.

Specified by:
stationUpdated in interface TrackerListener
Parameters:
ss - StationState containing the station's information; the new AX25Message will not yet be stored within the StationState object

stationDeleted

public void stationDeleted(StationState ss,
                           int index)
Called when an existing station is deleted from the tracker.

Specified by:
stationDeleted in interface TrackerListener
Parameters:
ss - StationState containing the station's information
index - zero-based integer sequence number for this station in the StationTracker

messageRemoved

public void messageRemoved(MessageMessage mm)

deleteAllRows

public int deleteAllRows(ClearableTableModel.ClearType clearType)
Delete all rows from this table.

Specified by:
deleteAllRows in interface ClearableTableModel
Parameters:
clearType - type of records to delete
Returns:
number of rows deleted