1 |
alfonx |
139 |
package skrueger.geotools.labelsearch; |
2 |
|
|
|
3 |
|
|
import javax.swing.SwingUtilities; |
4 |
|
|
|
5 |
|
|
import org.apache.log4j.Logger; |
6 |
|
|
import org.geotools.feature.Feature; |
7 |
alfonx |
153 |
import org.geotools.map.MapLayer; |
8 |
alfonx |
139 |
|
9 |
alfonx |
153 |
public class SearchResultFeature implements SearchResult { |
10 |
|
|
final static private Logger LOGGER = Logger |
11 |
|
|
.getLogger(SearchResultFeature.class); |
12 |
alfonx |
139 |
|
13 |
|
|
private final Feature feature; |
14 |
|
|
private final String title; |
15 |
|
|
private final schmitzm.geotools.gui.JMapPane mapPane; |
16 |
|
|
private final String inTitle; |
17 |
|
|
|
18 |
alfonx |
153 |
private final MapLayer mapLayer; |
19 |
|
|
|
20 |
|
|
public SearchResultFeature(Feature feature, String title, String inTitle, |
21 |
|
|
schmitzm.geotools.gui.JMapPane mapPane, MapLayer mapLayer) { |
22 |
alfonx |
139 |
this.feature = feature; |
23 |
|
|
this.title = title; |
24 |
|
|
this.inTitle = inTitle; |
25 |
|
|
this.mapPane = mapPane; |
26 |
alfonx |
153 |
this.mapLayer = mapLayer; |
27 |
alfonx |
139 |
} |
28 |
alfonx |
153 |
|
29 |
alfonx |
139 |
@Override |
30 |
|
|
public String toString() { |
31 |
|
|
return feature.toString(); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
public Feature getFeature() { |
35 |
|
|
return feature; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
@Override |
39 |
|
|
public String getTitle() { |
40 |
|
|
return title; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
@Override |
44 |
|
|
public void open() { |
45 |
alfonx |
153 |
|
46 |
alfonx |
139 |
// GuiAndTools.checkThatWeAreOnEDT(); |
47 |
|
|
if (!SwingUtilities.isEventDispatchThread()) { |
48 |
|
|
LOGGER.error("Not on EDT"); |
49 |
|
|
throw new RuntimeException("Not on EDT!"); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
mapPane.zoomTo(feature); |
53 |
|
|
mapPane.refresh(); |
54 |
alfonx |
153 |
|
55 |
|
|
// TODO |
56 |
|
|
// Mark the selected Feature using a spacial style.. similar to the |
57 |
|
|
// selection stuff. |
58 |
|
|
// mapLayer.getStyle().addFeatureTypeStyle( new FeatureTypeStyle()); |
59 |
|
|
|
60 |
alfonx |
139 |
} |
61 |
|
|
|
62 |
|
|
@Override |
63 |
|
|
public String getInTitle() { |
64 |
|
|
return inTitle; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
} |