1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.fts.core; |
23 |
|
|
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
import jalview.fts.api.FTSData; |
26 |
|
import jalview.fts.api.FTSDataColumnI; |
27 |
|
|
28 |
|
import java.util.Collection; |
29 |
|
import java.util.Map; |
30 |
|
|
31 |
|
import javax.swing.JTable; |
32 |
|
import javax.swing.table.DefaultTableModel; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@author |
39 |
|
|
40 |
|
|
|
|
| 52.7% |
Uncovered Elements: 26 (55) |
Complexity: 18 |
Complexity Density: 0.55 |
|
41 |
|
public class FTSRestResponse |
42 |
|
{ |
43 |
|
private int numberOfItemsFound; |
44 |
|
|
45 |
|
private String responseTime; |
46 |
|
|
47 |
|
private Collection<FTSData> searchSummary; |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
58 |
public int getNumberOfItemsFound()... |
50 |
|
{ |
51 |
58 |
return numberOfItemsFound; |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
51 |
public void setNumberOfItemsFound(int itemFound)... |
55 |
|
{ |
56 |
51 |
this.numberOfItemsFound = itemFound; |
57 |
|
} |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
public String getResponseTime()... |
60 |
|
{ |
61 |
0 |
return responseTime; |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
32 |
public void setResponseTime(String responseTime)... |
65 |
|
{ |
66 |
32 |
this.responseTime = responseTime; |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
29113 |
public Collection<FTSData> getSearchSummary()... |
70 |
|
{ |
71 |
29113 |
return searchSummary; |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
51 |
public void setSearchSummary(Collection<FTSData> searchSummary)... |
75 |
|
{ |
76 |
51 |
this.searchSummary = searchSummary; |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
|
85 |
|
|
86 |
|
@param |
87 |
|
|
88 |
|
|
89 |
|
@return |
90 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
91 |
2 |
public static DefaultTableModel getTableModel(FTSRestRequest request,... |
92 |
|
Collection<FTSData> summariesList) |
93 |
|
{ |
94 |
2 |
final FTSDataColumnI[] cols = request.getWantedFields() |
95 |
|
.toArray(new FTSDataColumnI[0]); |
96 |
2 |
final int colOffset = request.getAssociatedSequence() == null ? 0 : 1; |
97 |
2 |
DefaultTableModel tableModel = new DefaultTableModel() |
98 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
0 |
@Override... |
100 |
|
public boolean isCellEditable(int row, int column) |
101 |
|
{ |
102 |
0 |
return false; |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
105 |
16 |
@Override... |
106 |
|
public Class<?> getColumnClass(int columnIndex) |
107 |
|
{ |
108 |
16 |
if (colOffset == 1 && columnIndex == 0) |
109 |
|
{ |
110 |
1 |
return SequenceI.class; |
111 |
|
} |
112 |
15 |
return cols[columnIndex - colOffset].getDataType() |
113 |
|
.getDataTypeClass(); |
114 |
|
} |
115 |
|
|
116 |
|
}; |
117 |
2 |
if (request.getAssociatedSequence() != null) |
118 |
|
{ |
119 |
2 |
tableModel.addColumn("Ref Sequence"); |
120 |
|
|
121 |
|
} |
122 |
2 |
for (FTSDataColumnI field : request.getWantedFields()) |
123 |
|
{ |
124 |
30 |
tableModel.addColumn(field.getName()); |
125 |
|
|
126 |
|
} |
127 |
|
|
128 |
2 |
for (FTSData res : summariesList) |
129 |
|
{ |
130 |
126 |
tableModel.addRow(res.getSummaryData()); |
131 |
|
|
132 |
|
} |
133 |
|
|
134 |
2 |
return tableModel; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
137 |
0 |
public static void configureTableColumn(JTable tbl_summary,... |
138 |
|
Collection<FTSDataColumnI> wantedFields, |
139 |
|
Map<String, Integer> columnPrefs) |
140 |
|
{ |
141 |
0 |
for (FTSDataColumnI wantedField : wantedFields) |
142 |
|
{ |
143 |
0 |
try |
144 |
|
{ |
145 |
0 |
tbl_summary.getColumn(wantedField.getName()) |
146 |
|
.setMinWidth(wantedField.getMinWidth()); |
147 |
0 |
tbl_summary.getColumn(wantedField.getName()) |
148 |
|
.setMaxWidth(wantedField.getMaxWidth()); |
149 |
0 |
int prefedWidth = columnPrefs.get(wantedField.getName()) == null |
150 |
|
? wantedField.getPreferredWidth() |
151 |
|
: columnPrefs.get(wantedField.getName()); |
152 |
0 |
tbl_summary.getColumn(wantedField.getName()) |
153 |
|
.setPreferredWidth(prefedWidth); |
154 |
|
} catch (Exception e) |
155 |
|
{ |
156 |
0 |
e.printStackTrace(); |
157 |
|
} |
158 |
0 |
if (wantedField.getDataType().getDataTypeClass() == Double.class) |
159 |
|
{ |
160 |
0 |
DecimalFormatTableCellRenderer dfr = new DecimalFormatTableCellRenderer( |
161 |
|
wantedField.getDataType().isFormtted(), |
162 |
|
wantedField.getDataType().getSignificantFigures()); |
163 |
0 |
tbl_summary.getColumn(wantedField.getName()).setCellRenderer(dfr); |
164 |
|
} |
165 |
0 |
else if (wantedField.getDataType() |
166 |
|
.getDataTypeClass() == Integer.class) |
167 |
|
{ |
168 |
0 |
DecimalFormatTableCellRenderer dfr = new DecimalFormatTableCellRenderer( |
169 |
|
wantedField.getDataType().isFormtted(), |
170 |
|
wantedField.getDataType().getSignificantFigures()); |
171 |
0 |
tbl_summary.getColumn(wantedField.getName()).setCellRenderer(dfr); |
172 |
|
} |
173 |
|
} |
174 |
|
} |
175 |
|
|
176 |
|
} |