Package adams.gui.core
Class TagTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.TagTableModel
-
- All Implemented Interfaces:
Serializable,TableModel
public class TagTableModel extends AbstractTableModel
Table model for tags.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Tag>m_Tagsthe underlying tags.-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description TagTableModel()Default constructor.TagTableModel(Tag[] tags)Initializes the model with the provided tags.TagTableModel(List<Tag> tags)Initializes the model with the provided tags.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Tag tag)Adds the tag.voidaddAll(Tag[] tags)Adds all the tags.voidaddAll(List<Tag> tags)Adds all the tags.voidclear()Removes all tags.Tagget(int rowIndex)Returns the tag at the specified location.Class<?>getColumnClass(int columnIndex)Returns the type of the column.intgetColumnCount()Returns the number of columns in the model.StringgetColumnName(int column)Returns the name for the column.intgetRowCount()Returns the number of rows in the model.ObjectgetValueAt(int rowIndex, int columnIndex)Returns the value for the cell atcolumnIndexandrowIndex.booleanisEmpty()Returns whether there are no tags present.Tagremove(int rowIndex)Removes the tag at the specified index.voidset(int rowIndex, Tag tag)Updates the tag.Tag[]toArray()Returns the underlying tags as array.-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Constructor Detail
-
TagTableModel
public TagTableModel()
Default constructor.
-
TagTableModel
public TagTableModel(Tag[] tags)
Initializes the model with the provided tags.- Parameters:
tags- the tags to use
-
-
Method Detail
-
clear
public void clear()
Removes all tags.
-
add
public void add(Tag tag)
Adds the tag.- Parameters:
tag- the tag to add
-
addAll
public void addAll(Tag[] tags)
Adds all the tags.- Parameters:
tags- the tags to add
-
remove
public Tag remove(int rowIndex)
Removes the tag at the specified index.- Parameters:
rowIndex- the index to remove- Returns:
- the removed tag
-
get
public Tag get(int rowIndex)
Returns the tag at the specified location.- Parameters:
rowIndex- the index of the tag- Returns:
- the associated tag
-
set
public void set(int rowIndex, Tag tag)Updates the tag.- Parameters:
rowIndex- the index of the tagtag- the new tag
-
isEmpty
public boolean isEmpty()
Returns whether there are no tags present.- Returns:
- true if empty
-
getRowCount
public int getRowCount()
Returns the number of rows in the model. AJTableuses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.- Returns:
- the number of rows in the model
- See Also:
getColumnCount()
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the model. AJTableuses this method to determine how many columns it should create and display by default.- Returns:
- the number of columns in the model
- See Also:
getRowCount()
-
getColumnClass
public Class<?> getColumnClass(int columnIndex)
Returns the type of the column.- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel- Parameters:
columnIndex- the column being queried- Returns:
- the type
-
getColumnName
public String getColumnName(int column)
Returns the name for the column.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
column- the column being queried- Returns:
- a string containing the name of
column
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the value for the cell atcolumnIndexandrowIndex.- Parameters:
rowIndex- the row whose value is to be queriedcolumnIndex- the column whose value is to be queried- Returns:
- the value Object at the specified cell
-
toArray
public Tag[] toArray()
Returns the underlying tags as array.- Returns:
- the array
-
-