com.michaelbaranov.microba.marker

Class DefaultMarkerModel

Implemented Interfaces:
MarkerMutationModel

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:
MarkerBar

Constructor Summary

DefaultMarkerModel()
Constructs a DefaultMarkerModel.

Method Summary

int
addMarkAtPosition(int position)
Adds a marker with specified position.
Class
getColumnClass(int columnIndex)
This implementation returns Integer.class for columnIndex=0.
int
getColumnCount()
Returns the numbar of columns in the TableModel.This implementation always returns 1.
String
getColumnName(int columnIndex)
This implementation returns "Position" for columnIndex=0.
int
getLowerBound()
int
getRowCount()
Returns the count of markers.
int
getUpperBound()
Object
getValueAt(int rowIndex, int columnIndex)
Returns the position of a marker, specified by index.
boolean
isCellEditable(int rowIndex, int columnIndex)
This implementation always returns true, 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(Object aValue, int rowIndex, int columnIndex)
Assigns a new position to a marker, specified by index (moves the marker).

Constructor Details

DefaultMarkerModel

public DefaultMarkerModel()
Constructs a DefaultMarkerModel.

Method Details

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.

Returns:
index of added mark.

getColumnClass

public Class getColumnClass(int columnIndex)
This implementation returns Integer.class for columnIndex=0.
Parameters:
columnIndex - should be 0.
Returns:
column data class.

getColumnCount

public int getColumnCount()
Returns the numbar of columns in the TableModel.This implementation always returns 1.
Returns:
always 1.

getColumnName

public String getColumnName(int columnIndex)
This implementation returns "Position" for columnIndex=0.
Parameters:
columnIndex - should be 0.
Returns:
column name.

getLowerBound

public int getLowerBound()

getRowCount

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

getUpperBound

public int getUpperBound()

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Returns the position of a marker, specified by index.
Parameters:
rowIndex - marker index.
columnIndex - should be 0.
Returns:
an Integer position of the marker.

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
This implementation always returns true, indicating that all markers are movable. Override to change behaviour.
Returns:
always true.

removeMarkerAtIndex

public void removeMarkerAtIndex(int index)
Removes a marker, specified by index. Actually removes a row from the TableModel.
Parameters:
index - marker index.

setLowerBound

public void setLowerBound(int lowerBound)
Sets current lower bound.
Parameters:
lowerBound - new lower bound value.

setUpperBound

public void setUpperBound(int upperBound)
Sets current upper bound.
Parameters:
upperBound - new upper bound value.

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.

Parameters:
aValue - an Integer new position.
rowIndex - marker index.
columnIndex - should be 0.