Debian Codegraph @

src/dr/app/beauti/priorspanel/PriorTableModel.java

raw symbols SCIP
1 /*
2 * PriorTableModel.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.beauti.priorspanel;
27
28 import dr.app.beauti.options.Parameter;
29
30 import javax.swing.table.AbstractTableModel;
31
32 /**
33 * @author Alexei Drummond
34 * @author Andrew Rambaut
35 */
36 class PriorTableModel extends AbstractTableModel {
37
38 private static final long serialVersionUID = -8864178122484971872L;
39
40 String[] columnNames = {"Parameter", "Prior", "Bound", "Description"};
41 private PriorsPanel priorsPanel;
42
43 public PriorTableModel(PriorsPanel priorsPanel) {
44 this.priorsPanel = priorsPanel;
45 }
46
47 public int getColumnCount() {
48 return columnNames.length;
49 }
50
51 public int getRowCount() {
52 return priorsPanel.parameters.size();
53 }
54
55 public Object getValueAt(int row, int col) {
56 Parameter param = priorsPanel.parameters.get(row);
57 switch (col) {
58 case 0:
59 return param.getName();
60 case 1:
61 return (param.isLinked ? "Linked as [" + param.linkedName + "]" : param.priorType.getPriorString(param));
62 case 2:
63 return param.priorType.getPriorBoundString(param);
64 case 3:
65 return param.getDescription();
66 }
67 return null;
68 }
69
70 public String getColumnName(int column) {
71 return columnNames[column];
72 }
73
74 public Class getColumnClass(int c) {
75 return getValueAt(0, c).getClass();
76 }
77
78 public boolean isCellEditable(int row, int col) {
79 Parameter param = priorsPanel.parameters.get(row);
80 return col == 1 && !param.isPriorFixed;
81 }
82
83 public String toString() {
84 StringBuffer buffer = new StringBuffer();
85
86 buffer.append(getColumnName(0));
87 for (int j = 1; j < getColumnCount(); j++) {
88 buffer.append("\t");
89 buffer.append(getColumnName(j));
90 }
91 buffer.append("\n");
92
93 for (int i = 0; i < getRowCount(); i++) {
94 buffer.append(getValueAt(i, 0));
95 for (int j = 1; j < getColumnCount(); j++) {
96 buffer.append("\t");
97 buffer.append(getValueAt(i, j));
98 }
99 buffer.append("\n");
100 }
101
102 return buffer.toString();
103 }
104 }