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
,java.io.Serializable
,javax.swing.ListSelectionModel
,javax.swing.table.TableModel
public class DefaultMarkerModel extends AbstractBoundedTableModelWithSelection implements MarkerMutationModel
A basic implementation ofBoundedRangeModel
,ListSelectionModel
andMutationModel
all in one. Used by default byJMarkerBar
as data model, selection model and mutation model.- Author:
- Michael Baranov
- See Also:
MarkerBar
, Serialized Form
-
-
Field Summary
-
Fields inherited from interface com.michaelbaranov.microba.common.BoundedTableModel
PROPERTY_LOWER_BOUND, PROPERTY_UPPER_BOUND
-
-
Constructor Summary
Constructors Constructor Description DefaultMarkerModel()
Constructs aDefaultMarkerModel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addMarkAtPosition(int position)
Adds a marker with specified position.java.lang.Class
getColumnClass(int columnIndex)
This implementation returnsInteger.class
for columnIndex=0.int
getColumnCount()
Returns the numbar of columns in theTableModel
.This implementation always returns 1.java.lang.String
getColumnName(int columnIndex)
This implementation returns"Position"
for columnIndex=0.int
getLowerBound()
Returns some lower bound, further describing the data.int
getRowCount()
Returns the count of markers.int
getUpperBound()
Returns some upper bound, further describing the data.java.lang.Object
getValueAt(int rowIndex, int columnIndex)
Returns the position of a marker, specified by index.boolean
isCellEditable(int rowIndex, int columnIndex)
This implementation always returnstrue
, indicating that all markers are movable.void
removeMarkerAtIndex(int index)
Removes a marker, specified by index.void
setLowerBound(int lowerBound)
Sets current lower bound.void
setUpperBound(int upperBound)
Sets current upper bound.void
setValueAt(java.lang.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, setValueIsAdjusting
-
Methods inherited from class com.michaelbaranov.microba.common.AbstractBoundedTableModel
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getTableModelListeners, removeTableModelListener
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
getRowCount
public int getRowCount()
Returns the count of markers. Actually returns the cound of rows in theTableModel
.- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
- Returns:
- current marker count.
-
getColumnCount
public int getColumnCount()
Returns the numbar of columns in theTableModel
.This implementation always returns 1.- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
- Returns:
- always 1.
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
Returns the position of a marker, specified by index.- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
- Parameters:
rowIndex
- marker index.columnIndex
- should be 0.- Returns:
- an Integer position of the marker.
- See Also:
setValueAt(Object, int, int)
-
setValueAt
public void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
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:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classjavax.swing.table.AbstractTableModel
- Parameters:
aValue
- an Integer new position.rowIndex
- marker index.columnIndex
- should be 0.- See Also:
getValueAt(int, int)
-
getColumnClass
public java.lang.Class getColumnClass(int columnIndex)
This implementation returnsInteger.class
for columnIndex=0.- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
- Parameters:
columnIndex
- should be 0.- Returns:
- column data class.
-
getColumnName
public java.lang.String getColumnName(int columnIndex)
This implementation returns"Position"
for columnIndex=0.- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
- 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:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.AbstractTableModel
- Returns:
- always
true
.
-
removeMarkerAtIndex
public void removeMarkerAtIndex(int index)
Removes a marker, specified by index. Actually removes a row from theTableModel
.- Specified by:
removeMarkerAtIndex
in interfaceMarkerMutationModel
- Parameters:
index
- marker index.- See Also:
addMarkAtPosition(int)
-
addMarkAtPosition
public int addMarkAtPosition(int position)
Adds a marker with specified position. Actually appends a row toTableModel
with 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:
addMarkAtPosition
in interfaceMarkerMutationModel
- Parameters:
position
- position at which to insert the mark.- Returns:
- index of added mark.
- See Also:
removeMarkerAtIndex(int)
-
getLowerBound
public int getLowerBound()
Description copied from interface:BoundedTableModel
Returns some lower bound, further describing the data.- Specified by:
getLowerBound
in interfaceBoundedTableModel
- Returns:
- lower bound.
-
getUpperBound
public int getUpperBound()
Description copied from interface:BoundedTableModel
Returns some upper bound, further describing the data.- Specified by:
getUpperBound
in interfaceBoundedTableModel
- Returns:
- upper bound.
-
setLowerBound
public void setLowerBound(int lowerBound)
Sets current lower bound.- Parameters:
lowerBound
- new lower bound value.- See Also:
setLowerBound(int)
-
setUpperBound
public void setUpperBound(int upperBound)
Sets current upper bound.- Parameters:
upperBound
- new upper bound value.- See Also:
getUpperBound()
-
-