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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/SearchResultFeature.java revision 315 by mojays, Wed Aug 26 11:03:27 2009 UTC trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java revision 862 by alfonx, Sat May 22 01:24:46 2010 UTC
# Line 25  Line 25 
25   *   *
26   * Contributors:   * Contributors:
27   *     Martin O. J. Schmitz - initial API and implementation   *     Martin O. J. Schmitz - initial API and implementation
28   *     Stefan A. Krüger - additional utility classes   *     Stefan A. Tzeggai - additional utility classes
29   ******************************************************************************/   ******************************************************************************/
30  package skrueger.geotools.labelsearch;  package skrueger.geotools.labelsearch;
31    
32  import javax.swing.SwingUtilities;  import javax.swing.SwingUtilities;
33    
34  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
 import org.geotools.feature.Feature;  
35  import org.geotools.map.MapLayer;  import org.geotools.map.MapLayer;
36    import org.opengis.display.canvas.RenderingState;
37    import org.opengis.feature.simple.SimpleFeature;
38    
39    import schmitzm.geotools.gui.MapRenderingStateEvent;
40    import schmitzm.geotools.gui.XMapPaneEvent;
41    import schmitzm.geotools.map.event.JMapPaneListener;
42    
43  public class SearchResultFeature implements SearchResult {  public class SearchResultFeature implements SearchResult {
44          final static private Logger LOGGER = Logger          final static private Logger LOGGER = Logger
45                          .getLogger(SearchResultFeature.class);                          .getLogger(SearchResultFeature.class);
46    
47          private final Feature feature;          private final SimpleFeature feature;
48          private final String title;          private final String title;
49          private final schmitzm.geotools.gui.JMapPane mapPane;          private final schmitzm.geotools.gui.SelectableXMapPane mapPane;
50          private final String inTitle;          private final String inTitle;
51    
52          private final MapLayer mapLayer;          private final MapLayer mapLayer;
53    
54          public SearchResultFeature(Feature feature, String title, String inTitle,          public SearchResultFeature(SimpleFeature feature, String title,
55                          schmitzm.geotools.gui.JMapPane mapPane, MapLayer mapLayer) {                          String inTitle, schmitzm.geotools.gui.SelectableXMapPane mapPane,
56                            MapLayer mapLayer) {
57                  this.feature = feature;                  this.feature = feature;
58                  this.title = title;                  this.title = title;
59                  this.inTitle = inTitle;                  this.inTitle = inTitle;
# Line 60  public class SearchResultFeature impleme Line 66  public class SearchResultFeature impleme
66                  return feature.toString();                  return feature.toString();
67          }          }
68    
69          public Feature getFeature() {          public SimpleFeature getFeature() {
70                  return feature;                  return feature;
71          }          }
72    
# Line 78  public class SearchResultFeature impleme Line 84  public class SearchResultFeature impleme
84                          throw new RuntimeException("Not on EDT!");                          throw new RuntimeException("Not on EDT!");
85                  }                  }
86    
87                  mapPane.zoomTo(feature);                  // ZOmming will take some time, until the new map is correctly rendered
88                  mapPane.refresh();                  if (mapPane.zoomTo(feature)) {
89                            mapPane.addMapPaneListener(new JMapPaneListener() {
90                  // TODO  
91                  // Mark the selected Feature using a spacial style.. similar to the                                  boolean virgin = true;
92                  // selection stuff.  
93                  // mapLayer.getStyle().addFeatureTypeStyle( new FeatureTypeStyle());                                  @Override
94                                    public void performMapPaneEvent(XMapPaneEvent e) {
95                                            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          }          }
113    
114          @Override          @Override

Legend:
Removed from v.315  
changed lines
  Added in v.862

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26