package versusSNP.gui.widgets;
import java.util.Iterator;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import versusSNP.blast.util.SNPList;
import versusSNP.genome.SNP;
import versusSNP.gui.SNPContainer;
public class SNPTableModel extends DefaultTableModel implements ListSelectionListener {
private static final long serialVersionUID = 5135460413423214490L;
private SNPContainer snpContainer;
public SNPTableModel(Object[] columnNames, int rowCount) {
super(columnNames, rowCount);
// TODO Auto-generated constructor stub
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
public void accept(SNPList snpList, SNPContainer snpContainer) {
this.snpContainer = snpContainer;
setRowCount(0); // clear previous table things
int record = -1;
for (Iterator<SNP> iter = snpList.iterator(); iter.hasNext();) {
// if (getRowCount() > SNPTableControl.PAGE_RECORD_LIMIT) return;
SNP snp = iter.next();
record++;
if (record < snpContainer.getRecord())
continue;
else if (record >= snpContainer.getRecord() + SNPTableControl.PAGE_RECORD_LIMIT)
break;
snpContainer.add(snp);
}
}
@Override
public void valueChanged(ListSelectionEvent e) {
snpContainer.updateInfo();
}
}