Class TMWeather

All Implemented Interfaces:
Serializable, TableModel, HealthMonitorGui.MonitoredStationGettingModel, MonitoredStationListener

TableModel reporting the most recent weather information reported by configured weather stations.
Author:
Andrew Pavlin, KA2DDO
See Also:
  • Field Details

  • Constructor Details

    • TMWeather

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

    • generateWeatherValue

      public static 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 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 TableModel
      Returns:
      column count
    • getColumnClass

      public Class<?> getColumnClass(int columnIndex)
      Get the data type of the values for the specified column,
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
      Parameters:
      columnIndex - zero-based number of the column to query
      Returns:
      Class defining the column's data type
    • getColumnName

      public String getColumnName(int column)
      Get the title to be displayed for the specified column.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
      Parameters:
      column - zero-based number of the column
      Returns:
      column header localized String
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Get the display value for the specified table cell.
      Specified by:
      getValueAt in interface 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 Color[] getTableCellColoring(JTable table, boolean isSelected, int modelRow, int column)
      Get the foreground and background colors for rendering the values in the specified cell.
      Parameters:
      table - JTable being rendered
      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 TMWeather.StringCellRenderer createStringCellRenderer()
      Create a StringCellRenderer for the weather data.
      Returns:
      StringCellRenderer