Package versusSNP.gui.widgets

Source Code of versusSNP.gui.widgets.SNPTableModel

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();
  }

}
TOP

Related Classes of versusSNP.gui.widgets.SNPTableModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.