Class DefaultMarkerModel
java.lang.Object
javax.swing.table.AbstractTableModel
com.michaelbaranov.microba.common.AbstractBoundedTableModel
com.michaelbaranov.microba.common.AbstractBoundedTableModelWithSelection
com.michaelbaranov.microba.marker.DefaultMarkerModel
- All Implemented Interfaces:
BoundedTableModel,MarkerMutationModel,Serializable,ListSelectionModel,TableModel
public class DefaultMarkerModel
extends AbstractBoundedTableModelWithSelection
implements MarkerMutationModel
A basic implementation of
BoundedRangeModel,
ListSelectionModel and MutationModel all in
one. Used by default by JMarkerBar as data model, selection
model and mutation model.
- Author:
- Michael Baranov
- See Also:
-
Field Summary
Fields inherited from interface com.michaelbaranov.microba.common.BoundedTableModel
PROPERTY_LOWER_BOUND, PROPERTY_UPPER_BOUNDFields inherited from interface javax.swing.ListSelectionModel
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddMarkAtPosition(int position) Adds a marker with specified position.getColumnClass(int columnIndex) This implementation returnsInteger.classfor columnIndex=0.intReturns the numbar of columns in theTableModel.This implementation always returns 1.getColumnName(int columnIndex) This implementation returns"Position"for columnIndex=0.intReturns some lower bound, further describing the data.intReturns the count of markers.intReturns some upper bound, further describing the data.getValueAt(int rowIndex, int columnIndex) Returns the position of a marker, specified by index.booleanisCellEditable(int rowIndex, int columnIndex) This implementation always returnstrue, indicating that all markers are movable.voidremoveMarkerAtIndex(int index) Removes a marker, specified by index.voidsetLowerBound(int lowerBound) Sets current lower bound.voidsetUpperBound(int upperBound) Sets current upper bound.voidsetValueAt(Object aValue, int rowIndex, int columnIndex) Assigns a new position to a marker, specified by index (moves the marker).Methods inherited from class com.michaelbaranov.microba.common.AbstractBoundedTableModelWithSelection
addListSelectionListener, addSelectionInterval, clearSelection, getAnchorSelectionIndex, getLeadSelectionIndex, getListeners, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getSelectionMode, getValueIsAdjusting, insertIndexInterval, isLeadAnchorNotificationEnabled, isSelectedIndex, isSelectionEmpty, removeIndexInterval, removeListSelectionListener, removeSelectionInterval, setAnchorSelectionIndex, setLeadAnchorNotificationEnabled, setLeadSelectionIndex, setSelectionInterval, setSelectionMode, setValueIsAdjustingMethods inherited from class com.michaelbaranov.microba.common.AbstractBoundedTableModel
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getTableModelListeners, removeTableModelListenerMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.ListSelectionModel
getSelectedIndices, getSelectedItemsCountMethods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
-
Constructor Details
-
DefaultMarkerModel
public DefaultMarkerModel()Constructs aDefaultMarkerModel.
-
-
Method Details
-
getRowCount
public int getRowCount()Returns the count of markers. Actually returns the cound of rows in theTableModel.- Specified by:
getRowCountin interfaceTableModel- Returns:
- current marker count.
-
getColumnCount
public int getColumnCount()Returns the numbar of columns in theTableModel.This implementation always returns 1.- Specified by:
getColumnCountin interfaceTableModel- Returns:
- always 1.
-
getValueAt
Returns the position of a marker, specified by index.- Specified by:
getValueAtin interfaceTableModel- Parameters:
rowIndex- marker index.columnIndex- should be 0.- Returns:
- an Integer position of the marker.
- See Also:
-
setValueAt
Assigns a new position to a marker, specified by index (moves the marker).This implementation does not check if the specified marker position lies beyond current upper and lower bounds.
- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel- Parameters:
aValue- an Integer new position.rowIndex- marker index.columnIndex- should be 0.- See Also:
-
getColumnClass
This implementation returnsInteger.classfor columnIndex=0.- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel- Parameters:
columnIndex- should be 0.- Returns:
- column data class.
-
getColumnName
This implementation returns"Position"for columnIndex=0.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
columnIndex- should be 0.- Returns:
- column name.
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) This implementation always returnstrue, indicating that all markers are movable. Override to change behaviour.- Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel- Returns:
- always
true.
-
removeMarkerAtIndex
public void removeMarkerAtIndex(int index) Removes a marker, specified by index. Actually removes a row from theTableModel.- Specified by:
removeMarkerAtIndexin interfaceMarkerMutationModel- Parameters:
index- marker index.- See Also:
-
addMarkAtPosition
public int addMarkAtPosition(int position) Adds a marker with specified position. Actually appends a row toTableModelwith specified position value. Returns the index of the added mark.This implementation does not check if the specified marker position lies beyond current upper and lower bounds.
- Specified by:
addMarkAtPositionin interfaceMarkerMutationModel- Parameters:
position- position at which to insert the mark.- Returns:
- index of added mark.
- See Also:
-
getLowerBound
public int getLowerBound()Description copied from interface:BoundedTableModelReturns some lower bound, further describing the data.- Specified by:
getLowerBoundin interfaceBoundedTableModel- Returns:
- lower bound.
-
getUpperBound
public int getUpperBound()Description copied from interface:BoundedTableModelReturns some upper bound, further describing the data.- Specified by:
getUpperBoundin interfaceBoundedTableModel- Returns:
- upper bound.
-
setLowerBound
public void setLowerBound(int lowerBound) Sets current lower bound.- Parameters:
lowerBound- new lower bound value.- See Also:
-
setUpperBound
public void setUpperBound(int upperBound) Sets current upper bound.- Parameters:
upperBound- new upper bound value.- See Also:
-