org.ka2ddo.yaac.gui
Class TMWeather

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ka2ddo.yaac.gui.TMWeather
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, CommonCustomRendererConstants, HealthMonitorGui.MonitoredStationGettingModel, MonitoredStationListener

public class TMWeather
extends javax.swing.table.AbstractTableModel
implements MonitoredStationListener, HealthMonitorGui.MonitoredStationGettingModel, CommonCustomRendererConstants

TableModel reporting the most recent weather information reported by configured weather stations.

See Also:
Serialized Form

Field Summary
static javax.swing.RowFilter<TMWeather,java.lang.Integer> FILTER
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface org.ka2ddo.yaac.gui.CommonCustomRendererConstants
BRIGHTER_RED, BRIGHTER_TEXT_BACKGROUND, DARK_GREEN, DARKER_MAGENTA, DARKER_RED, MINUTES_30
 
Constructor Summary
TMWeather()
          Create a new instance of the weather station monitoring table model.
 
Method Summary
 void close()
          Shut down the asynchronous update listeners in this table model.
 org.ka2ddo.yaac.gui.TMWeather.StringCellRenderer createStringCellRenderer()
           
static java.lang.String generateWeatherValue(AX25Message msg, int columnIndex, boolean showRawValues)
          Produce the displayable text of a weather attribute,
 java.lang.Class<?> getColumnClass(int columnIndex)
          Get the data type of the values for the specified column,
 int getColumnCount()
          Get the number of columns defined in this table model.
 java.lang.String getColumnName(int column)
          Get the title to be displayed for the specified column.
 int getRowCount()
          Get the number of rows in the table model (effectively, the number of monitored stations).
 MonitoredStation getStation(int rowIndex)
          Get the station associated with the specified row.
 java.awt.Color[] getTableCellColoring(boolean isSelected, int modelRow, int column)
          Get the foreground and background colors for rendering the values in the specified cell.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Get the display value for the specified table cell.
 AX25Message getWeatherMessageAt(int rowIndex, int nthCopy)
          Get the Nth historical weather message for the specified table cell.
 void setShowRawValues(boolean showRawValues)
          Specify whether the weather values should be displayed as raw APRS or OpenTRAC values, or formatted into human-expected units.
 void stationAdded(int index, MonitoredStation station)
          Tell the listener that a new station has been added to the MonitoredStationList.
 void stationRemoved(int index, MonitoredStation station)
          Tell the listener that a station is no longer being monitored.
 void stationUpdated(int index, MonitoredStation station)
          Tell the listener that data about a MonitoredStation has changed.
 
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

FILTER

public static final javax.swing.RowFilter<TMWeather,java.lang.Integer> FILTER
Constructor Detail

TMWeather

public TMWeather()
Create a new instance of the weather station monitoring table model.

Method Detail

generateWeatherValue

public static java.lang.String generateWeatherValue(AX25Message msg,
                                                    int columnIndex,
                                                    boolean showRawValues)
Produce the displayable text of a weather attribute,

Parameters:
msg - AX25Message containing the weather data
columnIndex - column index according to the layout in the TMWeather table model
showRawValues - boolean true if the raw numeric values from the APRS or OpenTRAC message should be displayed, false if the appropriately scaled value should be displayed in the user-configured units
Returns:
displayable String, or null if no value for this column in this message

getRowCount

public int getRowCount()
Get the number of rows in the table model (effectively, the number of monitored stations).

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
number of monitored stations

getColumnCount

public int getColumnCount()
Get the number of columns defined in this table model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
column count

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Get the data type of the values for the specified column,

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - zero-based number of the column to query
Returns:
Class defining the column's data type

getColumnName

public java.lang.String getColumnName(int column)
Get the title to be displayed for the specified column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - zero-based number of the column
Returns:
column header localized String

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Get the display value for the specified table cell.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - zero-based row number
columnIndex - zero-based column number
Returns:
value to display

getWeatherMessageAt

public AX25Message getWeatherMessageAt(int rowIndex,
                                       int nthCopy)
Get the Nth historical weather message for the specified table cell.

Parameters:
rowIndex - zero-based row number
nthCopy - how many more-recent weather messages should be skipped to get to the desired record
Returns:
historical weather message

stationAdded

public void stationAdded(int index,
                         MonitoredStation station)
Tell the listener that a new station has been added to the MonitoredStationList.

Specified by:
stationAdded in interface MonitoredStationListener
Parameters:
index - int zero-based position in the list where the station has been added
station - MonitoredStation object to add

stationUpdated

public void stationUpdated(int index,
                           MonitoredStation station)
Tell the listener that data about a MonitoredStation has changed.

Specified by:
stationUpdated in interface MonitoredStationListener
Parameters:
index - zero-based index of the station in the MonitoredStationList
station - MonitoredStation whose data has been updated

stationRemoved

public void stationRemoved(int index,
                           MonitoredStation station)
Tell the listener that a station is no longer being monitored.

Specified by:
stationRemoved in interface MonitoredStationListener
Parameters:
index - int zero-based position in the MonitoredStationList where the station used to be
station - MonitoredStation being removed

getStation

public MonitoredStation getStation(int rowIndex)
Get the station associated with the specified row.

Specified by:
getStation in interface HealthMonitorGui.MonitoredStationGettingModel
Parameters:
rowIndex - the zero-based row index for the desired station
Returns:
MonitoredStation at the specified row

setShowRawValues

public void setShowRawValues(boolean showRawValues)
Specify whether the weather values should be displayed as raw APRS or OpenTRAC values, or formatted into human-expected units.

Parameters:
showRawValues - boolean true if weather values should be reported as-is in the protocol message

close

public void close()
Shut down the asynchronous update listeners in this table model.


getTableCellColoring

public java.awt.Color[] getTableCellColoring(boolean isSelected,
                                             int modelRow,
                                             int column)
Get the foreground and background colors for rendering the values in the specified cell.

Parameters:
isSelected - boolean true if table cell is selected
modelRow - zero-based row number in the table model
column - zero-based column number in the table model
Returns:
array of two Colors (background and foreground)

createStringCellRenderer

public org.ka2ddo.yaac.gui.TMWeather.StringCellRenderer createStringCellRenderer()