package versusSNP.gui;
import java.awt.GridLayout;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import versusSNP.Size;
import versusSNP.blast.util.SNPList;
import versusSNP.genome.SNP;
import versusSNP.gui.widgets.SNPTable;
import versusSNP.gui.widgets.SNPTableModel;
public class SNPPanel extends JPanel implements Observer, SNPContainer {
private static final long serialVersionUID = 3967876191241650100L;
private SNPTable table;
private SNPTableModel tableModel;
private int record;
public SNPPanel() {
super();
setLayout(new GridLayout(1,1));
setPreferredSize(Size.main_frame_west);
tableModel = new SNPTableModel(headerTexts(), 20);
table = new SNPTable(tableModel);
table.getSelectionModel().addListSelectionListener(tableModel);
add(new JScrollPane(table));
}
private Object[] headerTexts() {
return new Object[] {
UICaption.table_column_query_position,
UICaption.table_column_subject_position,
UICaption.table_column_query_position_in_genome,
UICaption.table_column_subject_position_in_genome,
UICaption.table_column_query_position_in_codon,
UICaption.table_column_subject_position_in_codon,
UICaption.table_column_query_base,
UICaption.table_column_subject_base,
UICaption.table_column_query_amino_acid,
UICaption.table_column_subject_amino_acid,
UICaption.table_column_query_codon,
UICaption.table_column_subject_codon,
UICaption.table_column_snp_type
};
}
public void setHeaderTexts() {
Object[] headerTexts = headerTexts();
for (int i = 0; i < headerTexts.length; i++) {
table.getColumnModel().getColumn(i).setHeaderValue(headerTexts[i]);
}
}
@Override
public void update(Observable o, Object arg) {
// TODO Auto-generated method stub
}
@Override
public void accept(SNPList snpList) {
tableModel.accept(snpList, this);
table.autoResizeColumns();
}
@Override
public void add(SNP snp) {
tableModel.addRow(new Object[]{snp.getQPos(), snp.getSPos(),
snp.getQPosInGenome(), snp.getSPosInGenome(),
snp.getQPosInCodon(), snp.getSPosInCodon(),
snp.getQBase(), snp.getSBase(),
snp.getQAA(), snp.getSAA(),
snp.getQCodon(), snp.getEquivalentSCodon(), snp.getType()});
}
public SNPTable getTable() {
return table;
}
@Override
public int getRecord() {
return record;
}
@Override
public void setRecord(int record) {
this.record = record;
}
@Override
public void addRecord() {
// TODO Auto-generated method stub
}
@Override
public void setMaxRecord() {
// TODO Auto-generated method stub
}
@Override
public void subRecord() {
// TODO Auto-generated method stub
}
@Override
public void reload() {
// TODO Auto-generated method stub
}
@Override
public void updateInfo() {
// TODO Auto-generated method stub
}
@Override
public void clear() {
tableModel.setRowCount(0);
}
}