org.ka2ddo.yaac.gui
Class HeardStationsTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ka2ddo.yaac.gui.HeardStationsTableModel
All Implemented Interfaces:
java.awt.event.WindowListener, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel, TrackerListener, FastComparableTableModel

public class HeardStationsTableModel
extends javax.swing.table.AbstractTableModel
implements TrackerListener, FastComparableTableModel, java.awt.event.WindowListener

This class defines a dynamic table model for reporting traffic rates from different stations seen by this station. The table columns consist of the following fixed columns:

followed by a variable number of columns indicating 15-minute time slices starting with the current quarter hour and going back as far as the oldest message of the oldest station.

The variable column headings will be updated every quarter hour on the quarter hour boundary. The counts will be updated as new messages are received.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
HeardStationsTableModel()
           
 
Method Summary
 int compareRows(int rowIndex1, int rowIndex2, int columnIndex)
          Compare the selected column of the two rows.
 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 a name for the column.
 StationState getRow(int rowIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 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.
 void messageAdded(StationState ss, int msgIndex, AX25Message msg)
          Called when a Message 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 removeTableModelListener(javax.swing.event.TableModelListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 void setUsingTable(javax.swing.JTable usingTable)
           
 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.
 void windowActivated(java.awt.event.WindowEvent e)
          Invoked when the Window is set to be the active Window.
 void windowClosed(java.awt.event.WindowEvent e)
          Invoked when a window has been closed as the result of calling dispose on the window.
 void windowClosing(java.awt.event.WindowEvent e)
          Invoked when the user attempts to close the window from the window's system menu.
 void windowDeactivated(java.awt.event.WindowEvent e)
          Invoked when a Window is no longer the active Window.
 void windowDeiconified(java.awt.event.WindowEvent e)
          Invoked when a window is changed from a minimized to a normal state.
 void windowIconified(java.awt.event.WindowEvent e)
          Invoked when a window is changed from a normal to a minimized state.
 void windowOpened(java.awt.event.WindowEvent e)
          Invoked the first time a window is made visible.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, 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, setValueAt
 

Constructor Detail

HeardStationsTableModel

public HeardStationsTableModel()
Method Detail

setUsingTable

public void setUsingTable(javax.swing.JTable usingTable)

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

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

getColumnName

public java.lang.String getColumnName(int column)
Returns a 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

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. A JTable uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.

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

getRow

public StationState getRow(int rowIndex)
Returns the value for the cell at columnIndex and rowIndex.

Parameters:
rowIndex - the row whose value is to be queried
Returns:
the value Object at the specified row

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

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Overrides:
removeTableModelListener in class javax.swing.table.AbstractTableModel
Parameters:
l - the TableModelListener

messageAdded

public void messageAdded(StationState ss,
                         int msgIndex,
                         AX25Message msg)
Called when a Message 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
msgIndex - 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 Message 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 Message 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

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Invoked when the Window is set to be the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.

Specified by:
windowActivated in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Invoked the first time a window is made visible.

Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Invoked when the user attempts to close the window from the window's system menu.

Specified by:
windowClosing in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Invoked when a window has been closed as the result of calling dispose on the window.

Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Invoked when a window is changed from a normal to a minimized state. For many platforms, a minimized window is displayed as the icon specified in the window's iconImage property.

Specified by:
windowIconified in interface java.awt.event.WindowListener
See Also:
Frame.setIconImage(java.awt.Image)

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Invoked when a window is changed from a minimized to a normal state.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Invoked when a Window is no longer the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener