use of javax.swing.table.DefaultTableModel in project MassBank-web by MassBank.
the class SearchPage method createWindow.
/**
* �E�C���h�E����
*/
private void createWindow() {
// �c�[���`�b�v�}�l�[�W���[�ݒ�
ToolTipManager ttm = ToolTipManager.sharedInstance();
ttm.setInitialDelay(50);
ttm.setDismissDelay(8000);
// Search�p�l��
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), new EmptyBorder(1, 1, 1, 1));
mainPanel.setBorder(border);
// *********************************************************************
// User File Query�^�u
// *********************************************************************
DefaultTableModel fileDm = new DefaultTableModel();
fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
queryFileTable = new JTable(fileSorter) {
@Override
public boolean isCellEditable(int row, int column) {
// �I�[�o�[���C�h�ŃZ���ҏW��s�Ƃ���
return false;
}
};
queryFileTable.addMouseListener(new TblMouseListener());
fileSorter.setTableHeader(queryFileTable.getTableHeader());
queryFileTable.setRowSelectionAllowed(true);
queryFileTable.setColumnSelectionAllowed(false);
queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
(queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
(queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
(queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);
ListSelectionModel lm = queryFileTable.getSelectionModel();
lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
lm.addListSelectionListener(new LmFileListener());
queryFilePane = new JScrollPane(queryFileTable);
queryFilePane.addMouseListener(new PaneMouseListener());
queryFilePane.setPreferredSize(new Dimension(300, 300));
// *********************************************************************
// Result�^�u
// *********************************************************************
DefaultTableModel resultDm = new DefaultTableModel();
resultSorter = new TableSorter(resultDm, TABLE_RESULT);
resultTable = new JTable(resultSorter) {
@Override
public String getToolTipText(MouseEvent me) {
// super.getToolTipText(me);
// �I�[�o�[���C�h�Ńc�[���`�b�v�̕������Ԃ�
Point pt = me.getPoint();
int row = rowAtPoint(pt);
if (row < 0) {
return null;
} else {
int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
return " " + getValueAt(row, nameCol) + " ";
}
}
@Override
public boolean isCellEditable(int row, int column) {
// �I�[�o�[���C�h�ŃZ���ҏW��s�Ƃ���
return false;
}
};
resultTable.addMouseListener(new TblMouseListener());
resultSorter.setTableHeader(resultTable.getTableHeader());
JPanel dbPanel = new JPanel();
dbPanel.setLayout(new BorderLayout());
resultPane = new JScrollPane(resultTable);
resultPane.addMouseListener(new PaneMouseListener());
resultTable.setRowSelectionAllowed(true);
resultTable.setColumnSelectionAllowed(false);
resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
resultDm.setColumnIdentifiers(col2);
(resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
(resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
(resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
(resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
(resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
(resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
(resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);
ListSelectionModel lm2 = resultTable.getSelectionModel();
lm2.addListSelectionListener(new LmResultListener());
resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
dbPanel.add(resultPane, BorderLayout.CENTER);
// *********************************************************************
// DB Query�^�u
// *********************************************************************
DefaultTableModel dbDm = new DefaultTableModel();
querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
queryDbTable = new JTable(querySorter) {
@Override
public boolean isCellEditable(int row, int column) {
// �I�[�o�[���C�h�ŃZ���ҏW��s�Ƃ���
return false;
}
};
queryDbTable.addMouseListener(new TblMouseListener());
querySorter.setTableHeader(queryDbTable.getTableHeader());
queryDbPane = new JScrollPane(queryDbTable);
queryDbPane.addMouseListener(new PaneMouseListener());
int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
queryDbTable.setRowSelectionAllowed(true);
queryDbTable.setColumnSelectionAllowed(false);
queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
model.setColumnIdentifiers(col3);
// �Z�b�g
queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);
ListSelectionModel lm3 = queryDbTable.getSelectionModel();
lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
lm3.addListSelectionListener(new LmQueryDbListener());
// �{�^���p�l��
JPanel btnPanel = new JPanel();
btnName.addActionListener(new BtnSearchNameListener());
btnAll.addActionListener(new BtnAllListener());
btnPanel.add(btnName);
btnPanel.add(btnAll);
parentPanel2 = new JPanel();
parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
parentPanel2.add(btnPanel);
parentPanel2.add(queryDbPane);
// �I�v�V�����p�l��
JPanel dispModePanel = new JPanel();
isDispSelected = dispSelected.isSelected();
isDispRelated = dispRelated.isSelected();
if (isDispSelected) {
resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else if (isDispRelated) {
resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
Object[] retRadio = new Object[] { dispSelected, dispRelated };
for (int i = 0; i < retRadio.length; i++) {
((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {
isDispSelected = dispSelected.isSelected();
isDispRelated = dispRelated.isSelected();
// ���ʃ��R�[�h�I����Ԃ�����
resultTable.clearSelection();
resultPlot.clear();
compPlot.setPeaks(null, 1);
resultPlot.setPeaks(null, 0);
setAllPlotAreaRange();
pkgView.initResultRecInfo();
if (isDispSelected) {
resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else if (isDispRelated) {
resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
}
}
});
}
ButtonGroup disGroup = new ButtonGroup();
disGroup.add(dispSelected);
disGroup.add(dispRelated);
dispModePanel.add(lbl2);
dispModePanel.add(dispSelected);
dispModePanel.add(dispRelated);
JPanel paramPanel = new JPanel();
paramPanel.add(etcPropertyButton);
etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
etcPropertyButton.addActionListener(new ActionListener() {
private ParameterSetWindow ps = null;
public void actionPerformed(ActionEvent e) {
// �q��ʂ��J���Ă��Ȃ���ΐ���
if (!isSubWindow) {
ps = new ParameterSetWindow();
} else {
ps.requestFocus();
}
}
});
JPanel optionPanel = new JPanel();
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
optionPanel.add(dispModePanel);
optionPanel.add(paramPanel);
// PackageView�����y�сA������
pkgView = new PackageViewPanel();
pkgView.initAllRecInfo();
queryTabPane.addTab("DB", parentPanel2);
queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
queryTabPane.addTab("File", queryFilePane);
queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
queryTabPane.setSelectedIndex(TAB_ORDER_DB);
queryTabPane.setFocusable(false);
queryTabPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
// �v���b�g�y�C��������
queryPlot.clear();
compPlot.clear();
resultPlot.clear();
queryPlot.setPeaks(null, 0);
compPlot.setPeaks(null, 1);
resultPlot.setPeaks(null, 0);
// PackageView������
pkgView.initAllRecInfo();
// DB Hit�^�u�֘A������
if (resultTabPane.getTabCount() > 0) {
resultTabPane.setSelectedIndex(0);
}
DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
dataModel.setRowCount(0);
hitLabel.setText(" ");
// DB�^�u�AUser File�^�u�̑I���ς݃��R�[�h���f����
queryTabPane.update(queryTabPane.getGraphics());
if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
parentPanel2.update(parentPanel2.getGraphics());
updateSelectQueryTable(queryDbTable);
} else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
queryFilePane.update(queryFilePane.getGraphics());
updateSelectQueryTable(queryFileTable);
}
}
});
// ���C�A�E�g
JPanel queryPanel = new JPanel();
queryPanel.setLayout(new BorderLayout());
queryPanel.add(queryTabPane, BorderLayout.CENTER);
queryPanel.add(optionPanel, BorderLayout.SOUTH);
queryPanel.setMinimumSize(new Dimension(0, 170));
JPanel jtp2Panel = new JPanel();
jtp2Panel.setLayout(new BorderLayout());
jtp2Panel.add(dbPanel, BorderLayout.CENTER);
jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
jtp2Panel.setMinimumSize(new Dimension(0, 70));
Color colorGreen = new Color(0, 128, 0);
hitLabel.setForeground(colorGreen);
resultTabPane.addTab("Result", jtp2Panel);
resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
resultTabPane.setFocusable(false);
queryPlot.setMinimumSize(new Dimension(0, 100));
compPlot.setMinimumSize(new Dimension(0, 120));
resultPlot.setMinimumSize(new Dimension(0, 100));
int height = initAppletHight / 3;
JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
jsp_cmp2db.setDividerLocation(height);
jsp_qry2cmp.setDividerLocation(height - 25);
jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));
viewTabPane.addTab("Compare View", jsp_qry2cmp);
viewTabPane.addTab("Package View", pkgView);
viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
viewTabPane.setFocusable(false);
JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
jsp.setDividerLocation(310);
jsp.setMinimumSize(new Dimension(180, 0));
jsp.setOneTouchExpandable(true);
JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
int divideSize = (int) (initAppletWidth * 0.4);
divideSize = (divideSize >= 180) ? divideSize : 180;
jsp2.setDividerLocation(divideSize);
jsp2.setOneTouchExpandable(true);
mainPanel.add(jsp2, BorderLayout.CENTER);
add(mainPanel);
queryPlot.setSearchPage(this);
compPlot.setSearchPage(this);
resultPlot.setSearchPage(this);
}
use of javax.swing.table.DefaultTableModel in project MassBank-web by MassBank.
the class SearchPage method loadFile.
/**
* �t�@�C���ǂݍ��ݏ���
* @param fileName �t�@�C����
*/
private void loadFile(String fileName) {
seaqCompound = 0;
seaqId = 0;
String reqUrl = baseUrl + "jsp/SearchPage.jsp?file=" + fileName;
ArrayList<String> lineList = new ArrayList<String>();
try {
URL url = new URL(reqUrl);
URLConnection con = url.openConnection();
// ���X�|���X�擾
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line = "";
while ((line = in.readLine()) != null) {
lineList.add(line);
}
in.close();
// 1�s���ǂݍ��߂Ȃ������ꍇ
if (lineList.size() == 0) {
// ERROR�F�t�@�C��������܂���
JOptionPane.showMessageDialog(null, "No file.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
} catch (MalformedURLException mue) {
// URL��������
mue.printStackTrace();
// ERROR�F�T�[�o�[�G���[
JOptionPane.showMessageDialog(null, "Server error.", "Error", JOptionPane.ERROR_MESSAGE);
return;
} catch (IOException ie) {
// ���o�͗�O
ie.printStackTrace();
// ERROR�F�T�[�o�[�G���[
JOptionPane.showMessageDialog(null, "Server error.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
DefaultTableModel dataModel = (DefaultTableModel) fileSorter.getTableModel();
dataModel.setRowCount(0);
Object[] row;
String line = "";
String peaksLine = "";
UserFileData usrData = null;
Vector<UserFileData> tmpUserDataList = new Vector<UserFileData>();
int dataNum = 0;
try {
for (int i = 0; i < lineList.size(); i++) {
line = lineList.get(i);
// �R�����g�s�ǂݔ��
if (line.trim().startsWith("//")) {
continue;
}
// ���R�[�h���擾����
if (line.trim().indexOf(":") == -1 && line.trim().length() != 0) {
if (usrData == null) {
usrData = new UserFileData();
}
if (line.lastIndexOf(";") != -1) {
peaksLine += line.trim();
} else {
peaksLine += line.trim() + ";";
}
} else if (line.trim().startsWith("Name:")) {
if (usrData == null) {
usrData = new UserFileData();
}
usrData.setName(line.substring(5).trim());
} else if (line.trim().startsWith("ID:")) {
if (usrData == null) {
usrData = new UserFileData();
}
usrData.setId(line.substring(3).trim());
}
// ���R�[�h���lj�����
if (line.trim().length() == 0 || i == lineList.size() - 1) {
if (usrData != null) {
dataNum++;
// === ID ===
if (usrData.getId().equals("")) {
usrData.setId(createId());
}
// === �������� ===
if (usrData.getName().equals("")) {
usrData.setName(createName());
}
if (peaksLine.length() != 0) {
// �s�[�N�����H(m/z������m/z�Ƌ��x�̑g�ݍ��킹)
double max = 0d;
ArrayList<String> peakList = new ArrayList<String>(Arrays.asList(peaksLine.split(";")));
for (int j = 0; j < peakList.size(); j++) {
peakList.set(j, peakList.get(j).replaceAll("^ +", ""));
peakList.set(j, peakList.get(j).replaceAll(" +", "\t"));
// �ő勭�x�ێ�
if (max < Double.parseDouble(peakList.get(j).split("\t")[1])) {
max = Double.parseDouble(peakList.get(j).split("\t")[1]);
}
}
Collections.sort(peakList, new PeakComparator());
// �����I�ɋ��x�𑊑��x�ɕϊ�
for (int j = 0; j < peakList.size(); j++) {
// m/z�ޔ�
String tmpMz = peakList.get(j).split("\t")[0];
// ���̋��x
String beforeVal = peakList.get(j).split("\t")[1];
// �����x
long tmpVal = Math.round(Double.parseDouble(beforeVal) / max * 999d);
if (tmpVal > 999) {
tmpVal = 999;
}
if (tmpVal < 1) {
tmpVal = 1;
}
String afterVal = String.valueOf(tmpVal);
peakList.set(j, tmpMz + "\t" + afterVal);
}
usrData.setPeaks((String[]) peakList.toArray(new String[peakList.size()]));
}
// ���[�U�f�[�^���lj�
tmpUserDataList.add(usrData);
// �e�[�u�����lj�
row = new Object[3];
row[0] = String.valueOf(dataNum);
row[1] = usrData.getName();
row[2] = usrData.getId();
dataModel.addRow(row);
}
usrData = null;
peaksLine = "";
}
}
} catch (Exception e) {
System.out.println("Illegal file format.");
e.printStackTrace();
// WARNING�F�t�@�C���t�H�[�}�b�g���s���ł�
JOptionPane.showMessageDialog(null, "Illegal file format.", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
userDataList = (UserFileData[]) tmpUserDataList.toArray(new UserFileData[tmpUserDataList.size()]);
queryTabPane.setSelectedIndex(TAB_ORDER_FILE);
}
use of javax.swing.table.DefaultTableModel in project MassBank-web by MassBank.
the class SearchPage method searchDb.
/**
* DB����
* �N�G���[�Ƀq�b�g����s�[�N�̃X�y�N�g����DB���猟������B
* @param ps �s�[�N���
* @param precursor �v���J�[�T�[
* @param queryName �N�G���[��������
* @param queryKey �N�G���[���R�[�h�L�[
*/
private void searchDb(String[] ps, String precursor, String queryName, String queryKey) {
queryPlot.clear();
compPlot.clear();
resultPlot.clear();
queryPlot.setPeaks(null, 0);
compPlot.setPeaks(null, 1);
resultPlot.setPeaks(null, 0);
DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
dataModel.setRowCount(0);
hitLabel.setText("");
if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
queryPlot.setSpectrumInfo(queryName, queryKey, precursor, PeakPanel.SP_TYPE_QUERY, false);
} else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
queryPlot.setSpectrumInfo(queryName, queryKey, precursor, PeakPanel.SP_TYPE_QUERY, true);
}
// �N�G�����X�y�N�g���̃s�[�N���Ȃ��ꍇ
if (ps.length == 0 || (ps.length == 1 && ps[0].split("\t")[0].equals("0") && ps[0].split("\t")[1].equals("0"))) {
queryPlot.setNoPeak(true);
hitLabel.setText(" 0 Hit. (" + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ") + "Tolerance : " + TOLERANCE + " " + ((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText()) + ", Cutoff threshold : " + CUTOFF_THRESHOLD + ")");
// �}�E�X�J�[�\�����f�t�H���g�J�[�\����
this.setCursor(Cursor.getDefaultCursor());
return;
}
// POST�f�[�^���쐬
StringBuffer post = new StringBuffer();
if (isRecInteg)
post.append("INTEG=true&");
else if (isRecActu)
post.append("INTEG=false&");
if (PRECURSOR > 0) {
post.append("PRE=" + PRECURSOR + "&");
}
post.append("CUTOFF=" + CUTOFF_THRESHOLD + "&");
post.append("TOLERANCE=" + TOLERANCE + "&");
if (tolUnit2.isSelected())
post.append("TOLUNIT=ppm&");
else
post.append("TOLUNIT=unit&");
post.append("INST=");
StringBuffer instTmp = new StringBuffer();
boolean isInstAll = true;
for (Iterator i = isInstCheck.keySet().iterator(); i.hasNext(); ) {
String key = (String) i.next();
if ((isInstCheck.get(key))) {
if (instTmp.length() > 0) {
instTmp.append(",");
}
instTmp.append(key);
} else {
isInstAll = false;
}
}
if (isInstAll) {
if (instTmp.length() > 0) {
instTmp.append(",");
}
instTmp.append("ALL");
}
post.append(instTmp.toString() + "&");
post.append("MS=");
StringBuffer msTmp = new StringBuffer();
boolean isMsAll = true;
for (Iterator i = isMsCheck.keySet().iterator(); i.hasNext(); ) {
String key = (String) i.next();
if ((isMsCheck.get(key))) {
if (msTmp.length() > 0) {
msTmp.append(",");
}
msTmp.append(key);
} else {
isMsAll = false;
}
}
if (isMsAll) {
if (msTmp.length() > 0) {
msTmp.append(",");
}
msTmp.append("ALL");
}
post.append(msTmp.toString() + "&");
if (isIonRadio.get("Posi")) {
post.append("ION=1&");
} else if (isIonRadio.get("Nega")) {
post.append("ION=-1&");
} else {
post.append("ION=0&");
}
post.append("VAL=");
for (int i = 0; i < ps.length; i++) {
post.append(ps[i].replace("\t", ",") + "@");
}
// ��ʑ��������
setOperationEnbled(false);
// �������_�C�A���O�\������
dlg.setVisible(true);
this.param = post.toString();
this.ps = ps;
SwingWorker worker = new SwingWorker() {
private ArrayList<String> result = null;
public Object construct() {
// �T�[�u���b�g�Ăяo��-�}���`�X���b�h��CGI���N��
String cgiType = MassBankCommon.CGI_TBL[MassBankCommon.CGI_TBL_NUM_TYPE][MassBankCommon.CGI_TBL_TYPE_SEARCH];
result = mbcommon.execMultiDispatcher(baseUrl, cgiType, SearchPage.this.param);
return null;
}
public void finished() {
// ��ʑ��얳������������
setOperationEnbled(true);
// �������_�C�A���O���\���ɂ���
dlg.setVisible(false);
int total = 0;
if (result != null && result.size() > 0) {
total = result.size();
DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
// �������ʂ�DBTable�ɃZ�b�g
siteList = new String[total];
for (int i = 0; i < total; i++) {
String line = (String) result.get(i);
String[] item = line.split("\t");
String id = item[0];
String name = item[1];
// Score, Hit
String score = "";
String hit = "";
String hitScore = item[2];
int pos = hitScore.indexOf(".");
if (pos > 0) {
score = "0" + hitScore.substring(pos);
hit = hitScore.substring(0, pos);
} else {
score = "0";
hit = hitScore;
}
Double dblScore = Double.parseDouble(score);
Integer ihit = Integer.parseInt(hit);
// Ion
int iIon = Integer.parseInt(item[3]);
String ion = "";
if (iIon > 0) {
ion = "P";
} else if (iIon < 0) {
ion = "N";
} else {
ion = "-";
}
// SiteName
String siteName = siteNameList[Integer.parseInt(item[4])];
siteList[i] = item[4];
// Name, Score, Hit, ID, Ion, SiteName, No.
Object[] rowData = { name, dblScore, ihit, id, ion, siteName, (i + 1) };
dataModel.addRow(rowData);
}
}
PeakData peak = new PeakData(SearchPage.this.ps);
queryPlot.setPeaks(peak, 0);
compPlot.setPeaks(peak, 0);
resultTabPane.setSelectedIndex(0);
setAllPlotAreaRange(queryPlot);
SearchPage.this.setCursor(Cursor.getDefaultCursor());
hitLabel.setText(" " + total + " Hit. (" + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ") + "Tolerance : " + TOLERANCE + " " + ((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText()) + ", Cutoff threshold : " + CUTOFF_THRESHOLD + ")");
hitLabel.setToolTipText(" " + total + " Hit. (" + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ") + "Tolerance : " + TOLERANCE + " " + ((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText()) + ", Cutoff threshold : " + CUTOFF_THRESHOLD + ")");
}
};
worker.start();
}
use of javax.swing.table.DefaultTableModel in project knime-core by knime.
the class ShapeManagerNodeDialogPane method columnChanged.
private void columnChanged(final String column) {
final LinkedHashMap<DataCell, Shape> domMap = m_map.get(column);
TableModel tableModel = new DefaultTableModel() {
private final DataCell[] m_valueNames = new DataCell[domMap.size()];
{
int row = 0;
for (DataCell cell : domMap.keySet()) {
m_valueNames[row] = cell;
row++;
}
}
@Override
public String getColumnName(final int columnIdx) {
if (columnIdx == 1) {
return "Shapes";
} else {
return "Values of " + column;
}
}
@Override
public boolean isCellEditable(final int row, final int columnIdx) {
return (columnIdx == 1);
}
@Override
public int getRowCount() {
return domMap.size();
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public Class<?> getColumnClass(final int columnIndex) {
if (columnIndex == 1) {
return Shape.class;
} else {
return DataCell.class;
}
}
@Override
public Object getValueAt(final int row, final int columnIndex) {
if (columnIndex == 1) {
return domMap.get(m_valueNames[row]);
} else {
return m_valueNames[row];
}
}
@Override
public void setValueAt(final Object aValue, final int row, final int columnIdx) {
assert aValue instanceof Shape;
assert columnIdx == 1;
domMap.put(m_valueNames[row], (Shape) aValue);
}
};
m_valueTable.setModel(tableModel);
m_valueTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(new ShapeSelectionComboBox()));
m_valueTable.getColumnModel().getColumn(1).setCellRenderer(new ShapeSelectionComboBoxRenderer());
}
use of javax.swing.table.DefaultTableModel in project knime-core by knime.
the class AbstractAccuracyScorerNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
public void modelChanged() {
ScorerViewData viewData = getScorerViewData();
if (viewData == null) {
// model is not executed yet, or was reset.
// m_precision.setText(" n/a ");
String na = " n/a ";
setLabels(na, na, na, null, na, null, na, null);
setTableViewModel(new DefaultTableModel());
if (m_hiLite) {
setCellHilited(new boolean[0][0]);
}
return;
}
String rowHeaderDescription = viewData.getFirstCompareColumn();
String columnHeaderDescription = viewData.getSecondCompareColumn();
if (m_hiLite) {
// init the boolean array determining which cell is selected
setCellHilited(new boolean[viewData.getScorerCount().length][viewData.getScorerCount().length]);
updateHilitedCells();
}
ConfusionTableModel dataModel = new ConfusionTableModel(viewData.getScorerCount(), viewData.getTargetValues(), rowHeaderDescription, columnHeaderDescription);
setTableViewModel(dataModel);
double error = 100.0 * viewData.getError();
double accuracy = 100.0 * viewData.getAccuracy();
double cohenKappa = viewData.getCohenKappa();
setLabels(viewData.getCorrectCount(), viewData.getFalseCount(), error, accuracy, cohenKappa);
}
Aggregations