1 |
alfonx |
244 |
/******************************************************************************* |
2 |
|
|
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
|
|
* |
4 |
|
|
* This file is part of the SCHMITZM library - a collection of utility |
5 |
alfonx |
256 |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
alfonx |
244 |
* 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 |
alfonx |
139 |
package skrueger.geotools.labelsearch; |
31 |
|
|
|
32 |
|
|
import javax.swing.SwingUtilities; |
33 |
|
|
|
34 |
|
|
import org.apache.log4j.Logger; |
35 |
alfonx |
322 |
import org.opengis.feature.simple.SimpleFeature; |
36 |
alfonx |
153 |
import org.geotools.map.MapLayer; |
37 |
alfonx |
139 |
|
38 |
alfonx |
153 |
public class SearchResultFeature implements SearchResult { |
39 |
|
|
final static private Logger LOGGER = Logger |
40 |
|
|
.getLogger(SearchResultFeature.class); |
41 |
alfonx |
139 |
|
42 |
alfonx |
318 |
private final SimpleFeature feature; |
43 |
alfonx |
139 |
private final String title; |
44 |
|
|
private final schmitzm.geotools.gui.JMapPane mapPane; |
45 |
|
|
private final String inTitle; |
46 |
|
|
|
47 |
alfonx |
153 |
private final MapLayer mapLayer; |
48 |
|
|
|
49 |
alfonx |
318 |
public SearchResultFeature(SimpleFeature feature, String title, String inTitle, |
50 |
alfonx |
153 |
schmitzm.geotools.gui.JMapPane mapPane, MapLayer mapLayer) { |
51 |
alfonx |
139 |
this.feature = feature; |
52 |
|
|
this.title = title; |
53 |
|
|
this.inTitle = inTitle; |
54 |
|
|
this.mapPane = mapPane; |
55 |
alfonx |
153 |
this.mapLayer = mapLayer; |
56 |
alfonx |
139 |
} |
57 |
alfonx |
153 |
|
58 |
alfonx |
139 |
@Override |
59 |
|
|
public String toString() { |
60 |
|
|
return feature.toString(); |
61 |
|
|
} |
62 |
|
|
|
63 |
alfonx |
318 |
public SimpleFeature getFeature() { |
64 |
alfonx |
139 |
return feature; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
@Override |
68 |
|
|
public String getTitle() { |
69 |
|
|
return title; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
@Override |
73 |
|
|
public void open() { |
74 |
alfonx |
153 |
|
75 |
alfonx |
139 |
// 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 |
alfonx |
153 |
|
84 |
|
|
// TODO |
85 |
alfonx |
318 |
// Mark the selected SimpleFeature using a spacial style.. similar to the |
86 |
alfonx |
153 |
// selection stuff. |
87 |
|
|
// mapLayer.getStyle().addFeatureTypeStyle( new FeatureTypeStyle()); |
88 |
|
|
|
89 |
alfonx |
139 |
} |
90 |
|
|
|
91 |
|
|
@Override |
92 |
|
|
public String getInTitle() { |
93 |
|
|
return inTitle; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
} |