HiRISE

HiRISE.HiPlan.HiTemp
Class Observation_Timeline_Table_Model

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by HiRISE.HiPlan.HiTemp.Observation_Timeline_Table_Model
All Implemented Interfaces:
Serializable, TableModel

public class Observation_Timeline_Table_Model
extends AbstractTableModel

A table model for managing an Observation_Timeline. The model allows an observation's start time and duration to be editable.

Version:
1.12
Author:
Christian Schaller - UA/PIRL
See Also:
Serialized Form

Nested Class Summary
static class Observation_Timeline_Table_Model.DateRenderer
          A date cell render suitable for the predict time.
 
Field Summary
static String[] COLUMN_NAMES
           
static String ID
          Class identification name with source code version and date.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
Observation_Timeline_Table_Model()
          Creates an empty table model.
Observation_Timeline_Table_Model(Observation_Timeline timeline)
          Creates a table model for the specified Observation_Timeline.
 
Method Summary
 void addObservation(Observation_Event event)
          Adds an observation event to the underlying timeline.
 void addObservation(String identifier, double startTime, double duration)
          Adds an observation event to the underlying timeline.
 double getAutoDuration()
          Gets a nice duration for the underlying timeline.
 Class getColumnClass(int column)
          Gets the specific superclass for all the cell values in the column.
 int getColumnCount()
          Gets the number of columns in the table model.
 String getColumnName(int column)
          Gets the name of the column at column.
 double getDuration()
          Gets the duration of the underlying timeline.
 int getIndexForDate(Date date)
          Gets the row index of the the observation whose start time is nearest to, but not greater than, the indicated date.
 Observation_Event getObservationEvent(int row)
          Gets the observation event at the indicated row.
 Observation_Event getObservationEvent(String id)
          Gets the observation event with the indicated ID.
 List<String> getObservationIds(boolean includeArbitrary)
          Gets the set of observation IDs in the underlying observation timeline.
 Observation_Timeline getObservationTimeline()
          Gets the Observation_Timeline data from the table model.
 int getRowCount()
          Gets the number of rows in the table model.
 double getStartTime()
          Gets the start time of the underlying timeline.
 double getStopTime()
          Gets the stop time of the underlying timeline.
 Object getValueAt(int row, int column)
          Returns the value for the cell at column and row.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 void removeObservation(String identifier)
          Removes an observation from the timeline.
 void setObservationTimeline(Observation_Timeline timeline)
          Sets the Observation_Timeline data for the table model.
 void setValueAt(Object value, int row, int column)
          Sets the value in the cell at column and row to value.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

COLUMN_NAMES

public static final String[] COLUMN_NAMES
Constructor Detail

Observation_Timeline_Table_Model

public Observation_Timeline_Table_Model()
Creates an empty table model.


Observation_Timeline_Table_Model

public Observation_Timeline_Table_Model(Observation_Timeline timeline)
Creates a table model for the specified Observation_Timeline.

Parameters:
timeline - the timeline from which to create the table model.
Method Detail

getObservationTimeline

public Observation_Timeline getObservationTimeline()
Gets the Observation_Timeline data from the table model.

Returns:
the timeline data.

setObservationTimeline

public void setObservationTimeline(Observation_Timeline timeline)
Sets the Observation_Timeline data for the table model. This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

Parameters:
timeline - the new timeline data.
See Also:
AbstractTableModel.fireTableDataChanged()

getObservationIds

public List<String> getObservationIds(boolean includeArbitrary)
Gets the set of observation IDs in the underlying observation timeline. If includeArbitrary is true, all observation IDs will be returned, including those for so-called arbitrary observations, i.e., those that are presumed not to be represented in the database. If false, the arbitrary observations will not be included.

Parameters:
includeArbitrary - if true, all arbitrary observations are included; otherwise they are not.
Returns:
the observation IDs.
See Also:
Observation_Event.isArbitrary()

getStartTime

public double getStartTime()
Gets the start time of the underlying timeline.

Returns:
the start time in seconds or 0.0 if the timeline is empty.
See Also:
Observation_Timeline.getStartTime()

getStopTime

public double getStopTime()
Gets the stop time of the underlying timeline.

Returns:
the stop time in seconds or 0.0 if the timeline is empty.
See Also:
Observation_Timeline.getStopTime()

getDuration

public double getDuration()
Gets the duration of the underlying timeline.

Returns:
the duration in seconds or 0.0 if the timeline is empty.
See Also:
Observation_Timeline.getDuration()

getAutoDuration

public double getAutoDuration()
Gets a nice duration for the underlying timeline.

Returns:
the auto-duration for the underlying timeline.
See Also:
Observation_Timeline.getAutoDuration()

getIndexForDate

public int getIndexForDate(Date date)
Gets the row index of the the observation whose start time is nearest to, but not greater than, the indicated date. If the timeline is empty, or if the date is earlier than the earliest observation, this method returns a -1.

Parameters:
date - the date of interest.
Returns:
the row index of the matching observation, or -1 if none is found.

getRowCount

public int getRowCount()
Gets the number of rows in the table model. The number of rows corresponds to the number of Observation_Events in the timeline.

Returns:
the number of rows in the model.
See Also:
Observation_Timeline.getSize()

getColumnCount

public int getColumnCount()
Gets the number of columns in the table model. There are only ever three columns in an Observation_Timeline_Table_Model: an observation identifier, a start time, and a duration.

Returns:
the number of columns in the model: 3.

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the value for the cell at column and row.

Parameters:
row - the row whose value is to be queried.
column - the column whose value is to be queried.
Returns:
the value Object at the specified cell; null if the indices are not valid.

getColumnClass

public Class getColumnClass(int column)
Gets the specific superclass for all the cell values in the column. The first column, the observation identifier, is a String. The remaining columns are Doubles.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
column - the index of the column.
Returns:
the common ancestor class of the object values in the model.

getColumnName

public String getColumnName(int column)
Gets the name of the column at column.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - the index of the column.
Returns:
the name of the column.

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, setValueAt(Object,int,int) will not change the value of that cell.

This implementation returns false for all cells.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
row - the row whose value is to be queried.
column - the column whose value is to be queried.
Returns:
true if the cell is editable.

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Sets the value in the cell at column and row to value.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
value - the new value.
row - the row whose value is to be changed.
column - the column whose value is to be changed.

getObservationEvent

public Observation_Event getObservationEvent(int row)
Gets the observation event at the indicated row.

Parameters:
row - the row number in question.
Returns:
the event or null if the row number is out of range.

getObservationEvent

public Observation_Event getObservationEvent(String id)
Gets the observation event with the indicated ID. If no such observation event exists, or if the ID is null or the empty string, a null is returned instead.

Parameters:
id - the observation ID in question.
Returns:
the event or null if the ID doesn't exist.

addObservation

public void addObservation(Observation_Event event)
Adds an observation event to the underlying timeline. This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

This method invokes Observation_Timeline.addObservation(Observation_Event), which sorts the data according to their natural sort order, which is start time, and which will overwrite a pre-existing observation with the same identifier.

Parameters:
event - the observation event to be added.
See Also:
Observation_Timeline.addObservation(Observation_Event)

addObservation

public void addObservation(String identifier,
                           double startTime,
                           double duration)
Adds an observation event to the underlying timeline. This method notifies all listeners that all cell values in the table's rows may have changed, as may have the number of rows.

This method invokes Observation_Timeline.addObservation(String,double,double), which sorts the data according to their natural sort order, which is start time, and which will overwrite a pre-existing observation with the same identifier.

Parameters:
identifier - the unique identifier of the new observation. Typically this identifier will be the string form of the observation ID associated with this observation, but it is not required to be so.
startTime - the start time of the new observation.
duration - the duration of the new observation.

removeObservation

public void removeObservation(String identifier)
Removes an observation from the timeline.

This method invokes Observation_Timeline.removeObservation(String).

Parameters:
identifier - the unique identifier of the observation to remove.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona