1 |
alfonx |
139 |
package skrueger.geotools.labelsearch; |
2 |
|
|
|
3 |
|
|
import java.util.List; |
4 |
|
|
|
5 |
|
|
import javax.swing.table.TableModel; |
6 |
|
|
|
7 |
|
|
import schmitzm.swing.table.AbstractTableModel; |
8 |
|
|
import skrueger.geotools.labelsearch.SearchResult; |
9 |
|
|
import skrueger.geotools.labelsearch.SearchResultFeature; |
10 |
|
|
|
11 |
|
|
/** |
12 |
|
|
* A {@link TableModel} which presents a {@link List} of {@link SearchResult}s. |
13 |
|
|
* by the time of writing, {@link SearchResult}'s only concrete class is |
14 |
|
|
* {@link SearchResultFeature}, but others might follow that reference to a Map or a DpEntry.<br/> |
15 |
|
|
* The three columns of this {@link TableModel} are: result number, full name, |
16 |
|
|
* name of layer containing the result |
17 |
|
|
* |
18 |
|
|
* @author Stefan A. Krueger |
19 |
|
|
* |
20 |
|
|
*/ |
21 |
|
|
public class SearchResultTableModel extends AbstractTableModel implements |
22 |
|
|
TableModel { |
23 |
|
|
|
24 |
|
|
private final List<SearchResult> searchResultsList; |
25 |
|
|
|
26 |
|
|
public SearchResultTableModel(List<SearchResult> searchResultsList) { |
27 |
|
|
this.searchResultsList = searchResultsList; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
@Override |
31 |
|
|
/* |
32 |
|
|
* The three columns of this {@link TableModel} are: full |
33 |
|
|
* name, name of layer containing the result |
34 |
|
|
*/ |
35 |
|
|
public int getColumnCount() { |
36 |
|
|
return 2; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
@Override |
40 |
|
|
public int getRowCount() { |
41 |
|
|
return searchResultsList.size(); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
@Override |
45 |
|
|
public Object getValueAt(int row, int column) { |
46 |
|
|
// if (column == 0) { |
47 |
|
|
// return row + 1; |
48 |
|
|
// } else |
49 |
|
|
if (column == 0) { |
50 |
|
|
return searchResultsList.get(row).getTitle(); |
51 |
|
|
|
52 |
|
|
} else if (column == 1) { |
53 |
|
|
return searchResultsList.get(row).getInTitle(); |
54 |
|
|
|
55 |
|
|
} else return null; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
@Override |
59 |
|
|
public String[] createColumnNames() { |
60 |
|
|
return new String[] {LabelSearch.R("SearchMapDialog.Results.Column.Name"), LabelSearch.R("SearchMapDialog.Results.Column.Layer")}; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
} |