1 |
/******************************************************************************* |
2 |
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
* |
4 |
* This file is part of the SCHMITZM library - a collection of utility |
5 |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
* and the Geotools library. |
7 |
* |
8 |
* The SCHMITZM project is hosted at: |
9 |
* http://wald.intevation.org/projects/schmitzm/ |
10 |
* |
11 |
* This program is free software; you can redistribute it and/or |
12 |
* modify it under the terms of the GNU Lesser General Public License |
13 |
* as published by the Free Software Foundation; either version 3 |
14 |
* of the License, or (at your option) any later version. |
15 |
* |
16 |
* This program is distributed in the hope that it will be useful, |
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
* GNU General Public License for more details. |
20 |
* |
21 |
* You should have received a copy of the GNU Lesser General Public License (license.txt) |
22 |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
* or try this link: http://www.gnu.org/licenses/lgpl.html |
25 |
* |
26 |
* Contributors: |
27 |
* Martin O. J. Schmitz - initial API and implementation |
28 |
* Stefan A. Krüger - additional utility classes |
29 |
******************************************************************************/ |
30 |
package skrueger.geotools.labelsearch; |
31 |
|
32 |
import javax.swing.SwingUtilities; |
33 |
|
34 |
import org.apache.log4j.Logger; |
35 |
import org.geotools.map.MapLayer; |
36 |
import org.opengis.feature.simple.SimpleFeature; |
37 |
|
38 |
public class SearchResultFeature implements SearchResult { |
39 |
final static private Logger LOGGER = Logger |
40 |
.getLogger(SearchResultFeature.class); |
41 |
|
42 |
private final SimpleFeature feature; |
43 |
private final String title; |
44 |
private final schmitzm.geotools.gui.SelectableXMapPane mapPane; |
45 |
private final String inTitle; |
46 |
|
47 |
private final MapLayer mapLayer; |
48 |
|
49 |
public SearchResultFeature(SimpleFeature feature, String title, String inTitle, |
50 |
schmitzm.geotools.gui.SelectableXMapPane mapPane, MapLayer mapLayer) { |
51 |
this.feature = feature; |
52 |
this.title = title; |
53 |
this.inTitle = inTitle; |
54 |
this.mapPane = mapPane; |
55 |
this.mapLayer = mapLayer; |
56 |
} |
57 |
|
58 |
@Override |
59 |
public String toString() { |
60 |
return feature.toString(); |
61 |
} |
62 |
|
63 |
public SimpleFeature getFeature() { |
64 |
return feature; |
65 |
} |
66 |
|
67 |
@Override |
68 |
public String getTitle() { |
69 |
return title; |
70 |
} |
71 |
|
72 |
@Override |
73 |
public void open() { |
74 |
|
75 |
// GuiAndTools.checkThatWeAreOnEDT(); |
76 |
if (!SwingUtilities.isEventDispatchThread()) { |
77 |
LOGGER.error("Not on EDT"); |
78 |
throw new RuntimeException("Not on EDT!"); |
79 |
} |
80 |
|
81 |
mapPane.zoomTo(feature); |
82 |
mapPane.refresh(); |
83 |
|
84 |
// TODO |
85 |
// Mark the selected SimpleFeature using a spacial style.. similar to the |
86 |
// selection stuff. |
87 |
// mapLayer.getStyle().addFeatureTypeStyle( new FeatureTypeStyle()); |
88 |
|
89 |
} |
90 |
|
91 |
@Override |
92 |
public String getInTitle() { |
93 |
return inTitle; |
94 |
} |
95 |
|
96 |
} |