Class 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:
  • Constructor Details

    • DefaultMarkerModel

      public DefaultMarkerModel()
      Constructs a DefaultMarkerModel.
  • Method Details

    • getRowCount

      public int getRowCount()
      Returns the count of markers. Actually returns the cound of rows in the TableModel.
      Specified by:
      getRowCount in interface TableModel
      Returns:
      current marker count.
    • getColumnCount

      public int getColumnCount()
      Returns the numbar of columns in the TableModel.This implementation always returns 1.
      Specified by:
      getColumnCount in interface TableModel
      Returns:
      always 1.
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Returns the position of a marker, specified by index.
      Specified by:
      getValueAt in interface TableModel
      Parameters:
      rowIndex - marker index.
      columnIndex - should be 0.
      Returns:
      an Integer position of the marker.
      See Also:
    • setValueAt

      public void setValueAt(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 interface TableModel
      Overrides:
      setValueAt in class AbstractTableModel
      Parameters:
      aValue - an Integer new position.
      rowIndex - marker index.
      columnIndex - should be 0.
      See Also:
    • getColumnClass

      public Class getColumnClass(int columnIndex)
      This implementation returns Integer.class for columnIndex=0.
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
      Parameters:
      columnIndex - should be 0.
      Returns:
      column data class.
    • getColumnName

      public String getColumnName(int columnIndex)
      This implementation returns "Position" for columnIndex=0.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
      Parameters:
      columnIndex - should be 0.
      Returns:
      column name.
    • isCellEditable

      public boolean isCellEditable(int rowIndex, int columnIndex)
      This implementation always returns true, indicating that all markers are movable. Override to change behaviour.
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
      Returns:
      always true.
    • removeMarkerAtIndex

      public void removeMarkerAtIndex(int index)
      Removes a marker, specified by index. Actually removes a row from the TableModel.
      Specified by:
      removeMarkerAtIndex in interface MarkerMutationModel
      Parameters:
      index - marker index.
      See Also:
    • addMarkAtPosition

      public int addMarkAtPosition(int position)
      Adds a marker with specified position. Actually appends a row to TableModel 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 interface MarkerMutationModel
      Parameters:
      position - position at which to insert the mark.
      Returns:
      index of added mark.
      See Also:
    • getLowerBound

      public int getLowerBound()
      Description copied from interface: BoundedTableModel
      Returns some lower bound, further describing the data.
      Specified by:
      getLowerBound in interface BoundedTableModel
      Returns:
      lower bound.
    • getUpperBound

      public int getUpperBound()
      Description copied from interface: BoundedTableModel
      Returns some upper bound, further describing the data.
      Specified by:
      getUpperBound in interface BoundedTableModel
      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: