/[schmitzm]/branches/2.2.x/src/skrueger/geotools/labelsearch/SearchResultFeature.java
ViewVC logotype

Annotation of /branches/2.2.x/src/skrueger/geotools/labelsearch/SearchResultFeature.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 740 - (hide annotations)
Wed Mar 3 10:32:14 2010 UTC (15 years ago) by alfonx
Original Path: trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java
File MIME type: text/plain
File size: 3679 byte(s)
Moved XMapPane and it's listeners/actions/tools to schmitzm.geotools.swing
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 mojays 325 import org.geotools.map.MapLayer;
36 alfonx 725 import org.opengis.display.canvas.RenderingState;
37 alfonx 322 import org.opengis.feature.simple.SimpleFeature;
38 alfonx 139
39 alfonx 740 import schmitzm.geotools.gui.MapRenderingStateEvent;
40     import schmitzm.geotools.gui.XMapPaneEvent;
41 alfonx 725 import schmitzm.geotools.map.event.JMapPaneListener;
42    
43 alfonx 153 public class SearchResultFeature implements SearchResult {
44     final static private Logger LOGGER = Logger
45     .getLogger(SearchResultFeature.class);
46 alfonx 139
47 alfonx 318 private final SimpleFeature feature;
48 alfonx 139 private final String title;
49 alfonx 509 private final schmitzm.geotools.gui.SelectableXMapPane mapPane;
50 alfonx 139 private final String inTitle;
51    
52 alfonx 153 private final MapLayer mapLayer;
53    
54 alfonx 725 public SearchResultFeature(SimpleFeature feature, String title,
55     String inTitle, schmitzm.geotools.gui.SelectableXMapPane mapPane,
56     MapLayer mapLayer) {
57 alfonx 139 this.feature = feature;
58     this.title = title;
59     this.inTitle = inTitle;
60     this.mapPane = mapPane;
61 alfonx 153 this.mapLayer = mapLayer;
62 alfonx 139 }
63 alfonx 153
64 alfonx 139 @Override
65     public String toString() {
66     return feature.toString();
67     }
68    
69 alfonx 318 public SimpleFeature getFeature() {
70 alfonx 139 return feature;
71     }
72    
73     @Override
74     public String getTitle() {
75     return title;
76     }
77    
78     @Override
79     public void open() {
80 alfonx 153
81 alfonx 139 // GuiAndTools.checkThatWeAreOnEDT();
82     if (!SwingUtilities.isEventDispatchThread()) {
83     LOGGER.error("Not on EDT");
84     throw new RuntimeException("Not on EDT!");
85     }
86    
87 alfonx 725 // ZOmming will take some time, until the new map is correctly rendered
88     if (mapPane.zoomTo(feature)) {
89     mapPane.addMapPaneListener(new JMapPaneListener() {
90 alfonx 153
91 alfonx 725 boolean virgin = true;
92 alfonx 153
93 alfonx 725 @Override
94 alfonx 740 public void performMapPaneEvent(XMapPaneEvent e) {
95 alfonx 725 if (virgin && e instanceof MapRenderingStateEvent) {
96     MapRenderingStateEvent mre = (MapRenderingStateEvent) e;
97     if (mre.getState() == RenderingState.ON_HOLD) {
98     // Remove this listener, and blink!
99     mapPane.blink(feature);
100     virgin = false;
101     // mapPane.removeMapPaneListener(this);
102     }
103     }
104     }
105     });
106     // TODO Remove the listener and the virgin flag again! otherwise the
107     // listener is never removed!
108     } else {
109     // Just blink
110     mapPane.blink(feature);
111     }
112 alfonx 139 }
113    
114     @Override
115     public String getInTitle() {
116     return inTitle;
117     }
118    
119     }

Properties

Name Value
svn:eol-style native
svn:keywords Id
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26