[Schmitzm-commits] r139 - in trunk/src/skrueger/geotools: . labelsearch
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jun 11 14:52:59 CEST 2009
Author: alfonx
Date: 2009-06-11 14:52:58 +0200 (Thu, 11 Jun 2009)
New Revision: 139
Added:
trunk/src/skrueger/geotools/labelsearch/
trunk/src/skrueger/geotools/labelsearch/LabelSearch.java
trunk/src/skrueger/geotools/labelsearch/SearchMapDialog.java
trunk/src/skrueger/geotools/labelsearch/SearchResult.java
trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java
trunk/src/skrueger/geotools/labelsearch/SearchResultTableModel.java
trunk/src/skrueger/geotools/labelsearch/Snippet.java
trunk/src/skrueger/geotools/labelsearch/labelsearch.properties
trunk/src/skrueger/geotools/labelsearch/labelsearch_de.properties
trunk/src/skrueger/geotools/labelsearch/labelsearch_fr.properties
Removed:
trunk/src/skrueger/geotools/LabelSearch.java
trunk/src/skrueger/geotools/SearchResult.java
trunk/src/skrueger/geotools/SearchResultFeature.java
Modified:
trunk/src/skrueger/geotools/MapPaneToolBar.java
trunk/src/skrueger/geotools/MapView.java
Log:
* Fixed a bug when creating more than 3 additional styles at once... A NPE occurred because none has been set as the selected additional style.
* Moved the i8n and Localisation for LabelSearch to schmitzm
Deleted: trunk/src/skrueger/geotools/LabelSearch.java
===================================================================
--- trunk/src/skrueger/geotools/LabelSearch.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/LabelSearch.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -1,169 +0,0 @@
-package skrueger.geotools;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.geotools.data.DefaultQuery;
-import org.geotools.feature.AttributeType;
-import org.geotools.feature.Feature;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureType;
-import org.geotools.map.MapLayer;
-import org.geotools.styling.Style;
-import org.geotools.styling.TextSymbolizer;
-import org.opengis.filter.Filter;
-import org.opengis.filter.expression.Expression;
-import org.opengis.filter.expression.PropertyName;
-
-import schmitzm.geotools.styling.StylingUtil;
-
-/**
- * This class allows to search for a {@link String} in a map. The algorithm will
- * analyze the {@link Style} of every visible(?) layer and determine the label
- * attribute. This field is then searched for every feature.
- *
- * @author Stefan A. Krüger
- *
- */
-public class LabelSearch {
- final static private Logger LOGGER = Logger.getLogger(LabelSearch.class);
-
- protected final schmitzm.geotools.gui.JMapPane mapPane;
-
- public LabelSearch(final schmitzm.geotools.gui.JMapPane mapPane) {
- this.mapPane = mapPane;
- }
-
- private AttributeType getLabelAttribute(final TextSymbolizer ts,
- final FeatureType schema) {
- if (ts == null) {
- // This layer has no labels
- return null;
- }
- final Expression labelExp = ts.getLabel();
- if (labelExp instanceof PropertyName) {
- final PropertyName pn = (PropertyName) labelExp;
- final String propertyName = pn.getPropertyName();
- return schema.getAttributeType(propertyName);
- } else {
- // When does this happen
- }
-
- return null;
- }
-
- public List<SearchResult> search(final String string) {
-
- final String searchMe = string.toLowerCase();
-
- final ArrayList<SearchResult> hits = new ArrayList<SearchResult>();
-
- for (final MapLayer ml : mapPane.getContext().getLayers()) {
- try {
-
- // System.out.println("layer = "+ml.getTitle());
-
- if (!ml.isVisible())
- continue;
-
- final List<TextSymbolizer> allTS = StylingUtil.getTextSymbolizers(ml
- .getStyle());
- if (allTS.size() == 0) {
- // A layer without any TextSymbolizer doesn't have to be
- // searched any more.
- continue;
- }
-
- final String typeName = ml.getFeatureSource().getSchema()
- .getTypeName();
-
- // Expression labelExp = ts.getLabel();
- // ff.like(labelExp, "*"+searchMe+"*");
- // FeatureCollection features =
- // ml.getFeatureSource().getFeatures(
- // new DefaultQuery(typeName, ff.like(labelExp,
- // "*"+searchMe+"*"), properties));
-
- final FeatureCollection features = ml.getFeatureSource().getFeatures(
- new DefaultQuery(typeName, Filter.INCLUDE));
-
- // new MemoryDataStore().getFeatureSource(typeName)
-
- /**
- * We do the comparison NOT with a ff.like, because that doesn't
- * support case insensitivity and i don't find a lower or UPPER
- * function.
- */
- final Iterator<Feature> fi = features.iterator();
- while (fi.hasNext()) {
- final Feature f = fi.next();
-
- final TextSymbolizer ts = StylingUtil.getTextSymbolizer(ml
- .getStyle(), f);
- if (ts == null)
- continue;
-
- final AttributeType labelAttribute = getLabelAttribute(ts, ml
- .getFeatureSource().getSchema());
-
- if (labelAttribute == null) {
- continue;
- }
-
- // System.out.println("labelAttrib local name" +
- // labelAttribute.getLocalName());
-
- final Object value = f
- .getAttribute(labelAttribute.getLocalName());
-
- // System.out.println("labelAttrib value " + value);
-
- if (value == null) {
- LOGGER.info("Skipping f: getLocalName() is null for feature="+f);
- continue;
- }
-
- /**
- * LabelString ist z.B. "IMPETUS pluviograph". Suchwort
- * "plu" soll treffen. Also wird nach spaces zerlegt und
- * dann gesucht
- */
- final String labelString = value.toString().toLowerCase();
- if (labelString.startsWith(searchMe)) {
- hits.add(createSearchResult(f, value.toString(), ml
- .getTitle()));
- } else {
- final String[] parts = labelString.trim().split(" ");
- for (final String part : parts) {
- if (part.startsWith(searchMe)) {
- hits.add(createSearchResult(f, value.toString(), ml
- .getTitle()));
- break;
- }
- }
- }
-
- }
-
- } catch (final IOException e) {
- // Searching this layer failed
- LOGGER.error(e);
- }
- } // next layer
-
- // Hits from the top-most layer should appear first.
- Collections.reverse(hits);
-
- return hits;
- }
-
- protected SearchResult createSearchResult(final Feature f, final String title,
- final String inTitle) {
- return new SearchResultFeature(f, title, inTitle, mapPane);
- }
-
-}
Modified: trunk/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- trunk/src/skrueger/geotools/MapPaneToolBar.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/MapPaneToolBar.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -631,21 +631,7 @@
public int getMinToolID() {
return toolAndActionButtons.firstKey();
}
-//
-// /**
-// * Returns the maximum ID of actions.
-// */
-// public int getMaxActionID() {
-// return actionButtons.lastKey();
-// }
-//
-// /**
-// * Returns the minimum ID of actions.
-// */
-// public int getMinActionID() {
-// return actionButtons.firstKey();
-// }
-
+
/**
* Extends the {@link AbstractAction} with maintaining an ID and
* the {@link MapPaneToolBar} the actions controls.
Modified: trunk/src/skrueger/geotools/MapView.java
===================================================================
--- trunk/src/skrueger/geotools/MapView.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/MapView.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -93,6 +93,8 @@
newRight.add(getToolBar(), BorderLayout.NORTH);
newRight.add(getGeoMapPane(), BorderLayout.CENTER);
splitPane.add(newRight);
+
+
this.add(splitPane, BorderLayout.CENTER);
}
Deleted: trunk/src/skrueger/geotools/SearchResult.java
===================================================================
--- trunk/src/skrueger/geotools/SearchResult.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/SearchResult.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -1,26 +0,0 @@
-package skrueger.geotools;
-
-import org.geotools.feature.Feature;
-
-public interface SearchResult {
-
- /**
- * @returns a {@link String} that represents the Title/Name of this search
- * result.
- *
- */
- String getTitle();
-
- /**
- * "Open" the result. For a {@link Feature} that mean to zoom to the
- * location. For a {@link Map} if means to open the {@link Map}.
- */
- void open();
-
- /**
- * @returns a {@link String} that represents the Title/Name of "something" that contains the search
- * result. This may return "" if it makes no sense.
- */
- String getInTitle();
-
-}
Deleted: trunk/src/skrueger/geotools/SearchResultFeature.java
===================================================================
--- trunk/src/skrueger/geotools/SearchResultFeature.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/SearchResultFeature.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -1,58 +0,0 @@
-package skrueger.geotools;
-
-import javax.swing.SwingUtilities;
-
-import org.apache.log4j.Logger;
-import org.geotools.feature.Feature;
-
-import skrueger.geotools.LabelSearch;
-
-public class SearchResultFeature implements SearchResult {
- final static private Logger LOGGER = Logger.getLogger(SearchResultFeature.class);
-
- private final Feature feature;
- private final String title;
- private final schmitzm.geotools.gui.JMapPane mapPane;
- private final String inTitle;
-
- public SearchResultFeature(Feature feature, String title, String inTitle, schmitzm.geotools.gui.JMapPane mapPane) {
- this.feature = feature;
- this.title = title;
- this.inTitle = inTitle;
- this.mapPane = mapPane;
- }
-
- @Override
- public String toString() {
- return feature.toString();
- }
-
- public Feature getFeature() {
- return feature;
- }
-
- @Override
- public String getTitle() {
- return title;
- }
-
- @Override
- public void open() {
-
- // GuiAndTools.checkThatWeAreOnEDT();
- if (!SwingUtilities.isEventDispatchThread()) {
- LOGGER.error("Not on EDT");
- throw new RuntimeException("Not on EDT!");
- }
-
-
- mapPane.zoomTo(feature);
- mapPane.refresh();
- }
-
- @Override
- public String getInTitle() {
- return inTitle;
- }
-
-}
Added: trunk/src/skrueger/geotools/labelsearch/LabelSearch.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/LabelSearch.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/LabelSearch.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,183 @@
+package skrueger.geotools.labelsearch;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.log4j.Logger;
+import org.geotools.data.DefaultQuery;
+import org.geotools.feature.AttributeType;
+import org.geotools.feature.Feature;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureType;
+import org.geotools.map.MapLayer;
+import org.geotools.styling.Style;
+import org.geotools.styling.TextSymbolizer;
+import org.opengis.filter.Filter;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.PropertyName;
+
+import schmitzm.geotools.styling.StylingUtil;
+import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+
+/**
+ * This class allows to search for a {@link String} in a map. The algorithm will
+ * analyze the {@link Style} of every visible(?) layer and determine the label
+ * attribute. This field is then searched for every feature.
+ *
+ * @author Stefan A. Krüger
+ *
+ */
+public class LabelSearch {
+ final static private Logger LOGGER = Logger.getLogger(LabelSearch.class);
+
+ public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
+ .extendPackagePath(LabelSearch.class,
+ "labelsearch"), Locale.ENGLISH);
+
+
+
+
+ public static String R(String key, Object... values) {
+ return RESOURCE.getString(key, values);
+ }
+
+ protected final schmitzm.geotools.gui.JMapPane mapPane;
+
+ public LabelSearch(final schmitzm.geotools.gui.JMapPane mapPane) {
+ this.mapPane = mapPane;
+ }
+
+ private AttributeType getLabelAttribute(final TextSymbolizer ts,
+ final FeatureType schema) {
+ if (ts == null) {
+ // This layer has no labels
+ return null;
+ }
+ final Expression labelExp = ts.getLabel();
+ if (labelExp instanceof PropertyName) {
+ final PropertyName pn = (PropertyName) labelExp;
+ final String propertyName = pn.getPropertyName();
+ return schema.getAttributeType(propertyName);
+ } else {
+ // When does this happen
+ }
+
+ return null;
+ }
+
+ public List<SearchResult> search(final String string) {
+
+ final String searchMe = string.toLowerCase();
+
+ final ArrayList<SearchResult> hits = new ArrayList<SearchResult>();
+
+ for (final MapLayer ml : mapPane.getContext().getLayers()) {
+ try {
+
+ // System.out.println("layer = "+ml.getTitle());
+
+ if (!ml.isVisible())
+ continue;
+
+ final List<TextSymbolizer> allTS = StylingUtil.getTextSymbolizers(ml
+ .getStyle());
+ if (allTS.size() == 0) {
+ // A layer without any TextSymbolizer doesn't have to be
+ // searched any more.
+ continue;
+ }
+
+ final String typeName = ml.getFeatureSource().getSchema()
+ .getTypeName();
+
+ // Expression labelExp = ts.getLabel();
+ // ff.like(labelExp, "*"+searchMe+"*");
+ // FeatureCollection features =
+ // ml.getFeatureSource().getFeatures(
+ // new DefaultQuery(typeName, ff.like(labelExp,
+ // "*"+searchMe+"*"), properties));
+
+ final FeatureCollection features = ml.getFeatureSource().getFeatures(
+ new DefaultQuery(typeName, Filter.INCLUDE));
+
+ // new MemoryDataStore().getFeatureSource(typeName)
+
+ /**
+ * We do the comparison NOT with a ff.like, because that doesn't
+ * support case insensitivity and i don't find a lower or UPPER
+ * function.
+ */
+ final Iterator<Feature> fi = features.iterator();
+ while (fi.hasNext()) {
+ final Feature f = fi.next();
+
+ final TextSymbolizer ts = StylingUtil.getTextSymbolizer(ml
+ .getStyle(), f);
+ if (ts == null)
+ continue;
+
+ final AttributeType labelAttribute = getLabelAttribute(ts, ml
+ .getFeatureSource().getSchema());
+
+ if (labelAttribute == null) {
+ continue;
+ }
+
+ // System.out.println("labelAttrib local name" +
+ // labelAttribute.getLocalName());
+
+ final Object value = f
+ .getAttribute(labelAttribute.getLocalName());
+
+ // System.out.println("labelAttrib value " + value);
+
+ if (value == null) {
+ LOGGER.info("Skipping f: getLocalName() is null for feature="+f);
+ continue;
+ }
+
+ /**
+ * LabelString ist z.B. "IMPETUS pluviograph". Suchwort
+ * "plu" soll treffen. Also wird nach spaces zerlegt und
+ * dann gesucht
+ */
+ final String labelString = value.toString().toLowerCase();
+ if (labelString.startsWith(searchMe)) {
+ hits.add(createSearchResult(f, value.toString(), ml
+ .getTitle()));
+ } else {
+ final String[] parts = labelString.trim().split(" ");
+ for (final String part : parts) {
+ if (part.startsWith(searchMe)) {
+ hits.add(createSearchResult(f, value.toString(), ml
+ .getTitle()));
+ break;
+ }
+ }
+ }
+
+ }
+
+ } catch (final IOException e) {
+ // Searching this layer failed
+ LOGGER.error(e);
+ }
+ } // next layer
+
+ // Hits from the top-most layer should appear first.
+ Collections.reverse(hits);
+
+ return hits;
+ }
+
+ protected SearchResult createSearchResult(final Feature f, final String title,
+ final String inTitle) {
+ return new SearchResultFeature(f, title, inTitle, mapPane);
+ }
+
+}
Property changes on: trunk/src/skrueger/geotools/labelsearch/LabelSearch.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/SearchMapDialog.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/SearchMapDialog.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/SearchMapDialog.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,214 @@
+/*
+ * SearchMapDialog.java
+ *
+ * Created on __DATE__, __TIME__
+ */
+
+package skrueger.geotools.labelsearch;
+
+import java.awt.BorderLayout;
+import java.awt.Cursor;
+import java.awt.FlowLayout;
+import java.awt.Point;
+import java.awt.Window;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingWorker;
+
+import org.apache.log4j.Logger;
+import org.geotools.gui.swing.ExceptionMonitor;
+import org.geotools.gui.swing.JMapPane;
+
+import schmitzm.swing.SortableJTable;
+import schmitzm.swing.SwingUtil;
+import skrueger.geotools.labelsearch.LabelSearch;
+import skrueger.geotools.labelsearch.SearchResult;
+
+/**
+ * @author Stefan A. Krueger
+ */
+public class SearchMapDialog extends javax.swing.JDialog {
+ final static private Logger LOGGER = Logger
+ .getLogger(SearchMapDialog.class);
+
+ private final LabelSearch labelSearch;
+ /** This JPanel shows the results to the user if there is more than one **/
+ final private JTextField searchTextField = new JTextField(25);
+ final private JScrollPane scrollPane = new JScrollPane();
+
+ public String getSearchText() {
+ return searchTextField.getText();
+ }
+
+ public void setSearchText(String text) {
+ searchTextField.setText(text);
+ }
+
+ private final JMapPane mapPane;
+
+ /**
+ * The dialog will be relative to the {@link JMapPane}s parent
+ * {@link Window}.
+ *
+ * @param parent
+ * @param labelSearch
+ * @param mapPane
+ * @param windowTitle
+ * A title to be used for the dialog.
+ */
+ public SearchMapDialog(LabelSearch labelSearch, JMapPane mapPane,
+ final String windowTitle) {
+ super(SwingUtil.getParentWindow(mapPane), windowTitle);
+ this.labelSearch = labelSearch;
+ this.mapPane = mapPane;
+ initialize();
+ }
+
+ // Pressing ESC disposes the Dialog
+ KeyAdapter keyEscDispose = new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ int key = e.getKeyCode();
+ if (key == KeyEvent.VK_ESCAPE) {
+ dispose();
+ }
+ }
+ };
+
+ // Pressing ENTER in the JTextfield automatically starts the search
+ KeyAdapter keyListenerStartSearch = new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ int key = e.getKeyCode();
+ if (key == KeyEvent.VK_ENTER) {
+ if (searchTextField.getText().trim().length() > 0)
+ search(searchTextField.getText());
+ }
+ }
+ };
+
+ private void initialize() {
+
+ JPanel cp = new JPanel(new BorderLayout());
+
+ JLabel label = new JLabel(LabelSearch.R("SearchMapDialog.searchString.Label"));
+ label.setLabelFor(searchTextField);
+ searchTextField.setToolTipText(LabelSearch.R("SearchMapDialog.searchString.tt"));
+
+ searchTextField.addKeyListener(keyListenerStartSearch);
+
+ // Pressing ESC disposes the Dialog
+ searchTextField.addKeyListener(keyEscDispose);
+
+ JPanel upper = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ upper.add(label);
+ upper.add(searchTextField);
+
+ cp.add(upper, BorderLayout.NORTH);
+
+ SwingUtil.setPreferredHeight(scrollPane, 0);
+ SwingUtil.setMaximumHeight(scrollPane, 0);
+ cp.add(scrollPane, BorderLayout.SOUTH);
+
+ cp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ setContentPane(cp);
+ pack();
+
+ Point mapPanelocationOnScreen = mapPane.getLocationOnScreen();
+ mapPanelocationOnScreen.x -= mapPane.getLocation().x;
+ mapPanelocationOnScreen.y -= mapPane.getLocation().y;
+ setLocation(mapPanelocationOnScreen);
+
+ // SwingUtil.centerFrameOnScreenRandom(this);
+ }
+
+ /**
+ * Performes a search on the {@link JMapPane}'s labels and outputs the
+ * possible numerouse results.
+ *
+ * @param text
+ * Text to search
+ */
+ public void search(final String text) {
+
+ final Cursor backupCursor = getContentPane().getCursor();
+ getContentPane().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ searchTextField.setEnabled(false);
+
+ SwingWorker<List<SearchResult>, String> swingWorker = new SwingWorker<List<SearchResult>, String>() {
+ @Override
+ protected List<SearchResult> doInBackground() throws Exception {
+ return labelSearch.search(text);
+ }
+
+ @Override
+ protected void done() {
+ getContentPane().setCursor(backupCursor);
+ searchTextField.setEnabled(true);
+ super.done();
+ try {
+ showMultipleResults(get());
+ } catch (InterruptedException e) {
+ LOGGER.error(e);
+ ExceptionMonitor.show(SearchMapDialog.this, e);
+ } catch (ExecutionException e) {
+ LOGGER.error(e);
+ ExceptionMonitor.show(SearchMapDialog.this, e);
+ }
+ }
+ };
+ swingWorker.execute();
+
+ }
+
+ private void showMultipleResults(final List<SearchResult> searchResultsList) {
+
+ final SortableJTable resultsTable = new SortableJTable();
+ resultsTable.setModel(new SearchResultTableModel(searchResultsList));
+
+ resultsTable.addKeyListener(keyEscDispose);
+
+ // set up the table
+ resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+// resultsTable.setRowSorter( new TableRowSorter<SearchResultTableModel>((SearchResultTableModel)resultsTable.getModel()));
+//
+ resultsTable.setToolTipText(LabelSearch.R("SearchMapDialog.resultsTable.tt"));
+
+// // The first column should be small
+// resultsTable.getColumnModel().getColumn(0).setMinWidth(20);
+// resultsTable.getColumnModel().getColumn(0).setMaxWidth(25);
+
+ resultsTable.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ int index = resultsTable.getSelectedModelRow();
+ SearchResult searchResult = searchResultsList.get(index);
+ Cursor backupCursor = scrollPane.getCursor();
+ scrollPane.setCursor(Cursor
+ .getPredefinedCursor(Cursor.WAIT_CURSOR));
+ searchResult.open();
+ scrollPane.setCursor(backupCursor);
+ }
+ });
+
+ scrollPane.setViewportView(resultsTable);
+ SwingUtil.setPreferredHeight(scrollPane, 140);
+ SwingUtil.setMaximumHeight(scrollPane, 140);
+
+ pack();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/src/skrueger/geotools/labelsearch/SearchMapDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/SearchResult.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/SearchResult.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/SearchResult.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,26 @@
+package skrueger.geotools.labelsearch;
+
+import org.geotools.feature.Feature;
+
+public interface SearchResult {
+
+ /**
+ * @returns a {@link String} that represents the Title/Name of this search
+ * result.
+ *
+ */
+ String getTitle();
+
+ /**
+ * "Open" the result. For a {@link Feature} that mean to zoom to the
+ * location. For a {@link Map} if means to open the {@link Map}.
+ */
+ void open();
+
+ /**
+ * @returns a {@link String} that represents the Title/Name of "something" that contains the search
+ * result. This may return "" if it makes no sense.
+ */
+ String getInTitle();
+
+}
Property changes on: trunk/src/skrueger/geotools/labelsearch/SearchResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,57 @@
+package skrueger.geotools.labelsearch;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.Logger;
+import org.geotools.feature.Feature;
+
+
+public class SearchResultFeature implements SearchResult {
+ final static private Logger LOGGER = Logger.getLogger(SearchResultFeature.class);
+
+ private final Feature feature;
+ private final String title;
+ private final schmitzm.geotools.gui.JMapPane mapPane;
+ private final String inTitle;
+
+ public SearchResultFeature(Feature feature, String title, String inTitle, schmitzm.geotools.gui.JMapPane mapPane) {
+ this.feature = feature;
+ this.title = title;
+ this.inTitle = inTitle;
+ this.mapPane = mapPane;
+ }
+
+ @Override
+ public String toString() {
+ return feature.toString();
+ }
+
+ public Feature getFeature() {
+ return feature;
+ }
+
+ @Override
+ public String getTitle() {
+ return title;
+ }
+
+ @Override
+ public void open() {
+
+ // GuiAndTools.checkThatWeAreOnEDT();
+ if (!SwingUtilities.isEventDispatchThread()) {
+ LOGGER.error("Not on EDT");
+ throw new RuntimeException("Not on EDT!");
+ }
+
+
+ mapPane.zoomTo(feature);
+ mapPane.refresh();
+ }
+
+ @Override
+ public String getInTitle() {
+ return inTitle;
+ }
+
+}
Property changes on: trunk/src/skrueger/geotools/labelsearch/SearchResultFeature.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/SearchResultTableModel.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/SearchResultTableModel.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/SearchResultTableModel.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,63 @@
+package skrueger.geotools.labelsearch;
+
+import java.util.List;
+
+import javax.swing.table.TableModel;
+
+import schmitzm.swing.table.AbstractTableModel;
+import skrueger.geotools.labelsearch.SearchResult;
+import skrueger.geotools.labelsearch.SearchResultFeature;
+
+/**
+ * A {@link TableModel} which presents a {@link List} of {@link SearchResult}s.
+ * by the time of writing, {@link SearchResult}'s only concrete class is
+ * {@link SearchResultFeature}, but others might follow that reference to a Map or a DpEntry.<br/>
+ * The three columns of this {@link TableModel} are: result number, full name,
+ * name of layer containing the result
+ *
+ * @author Stefan A. Krueger
+ *
+ */
+public class SearchResultTableModel extends AbstractTableModel implements
+ TableModel {
+
+ private final List<SearchResult> searchResultsList;
+
+ public SearchResultTableModel(List<SearchResult> searchResultsList) {
+ this.searchResultsList = searchResultsList;
+ }
+
+ @Override
+ /*
+ * The three columns of this {@link TableModel} are: full
+ * name, name of layer containing the result
+ */
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public int getRowCount() {
+ return searchResultsList.size();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+// if (column == 0) {
+// return row + 1;
+// } else
+ if (column == 0) {
+ return searchResultsList.get(row).getTitle();
+
+ } else if (column == 1) {
+ return searchResultsList.get(row).getInTitle();
+
+ } else return null;
+ }
+
+ @Override
+ public String[] createColumnNames() {
+ return new String[] {LabelSearch.R("SearchMapDialog.Results.Column.Name"), LabelSearch.R("SearchMapDialog.Results.Column.Layer")};
+ }
+
+}
Property changes on: trunk/src/skrueger/geotools/labelsearch/SearchResultTableModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/Snippet.java
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/Snippet.java 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/Snippet.java 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,13 @@
+package skrueger.geotools.labelsearch;
+
+import java.util.Locale;
+
+import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+import skrueger.swing.TranslationAskJDialog;
+
+public class Snippet {
+ public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
+ .extendPackagePath(TranslationAskJDialog.class,
+ "resource.locales.SwingResourceBundle"), Locale.ENGLISH);
+}
Property changes on: trunk/src/skrueger/geotools/labelsearch/Snippet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/labelsearch.properties
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/labelsearch.properties 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/labelsearch.properties 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,6 @@
+SearSearchMapDialog.Results.Column.Layer=found in
+SearchMapDialog.Results.Column.Name=name
+SearchMapDialog.resultsTable.tt=Click on a result to show it.
+SearchMapDialog.searchString.Label=Enter search string:
+SearchMapDialog.searchString.tt=Enter text and press [Enter or Return].
+SearchMapDialog.title=Search map: ${0}
\ No newline at end of file
Property changes on: trunk/src/skrueger/geotools/labelsearch/labelsearch.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/labelsearch_de.properties
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/labelsearch_de.properties 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/labelsearch_de.properties 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,6 @@
+SearchMapDialog.Results.Column.Layer=Gefunden in
+SearchMapDialog.Results.Column.Name=Name
+SearchMapDialog.resultsTable.tt=Klicken Sie auf ein Ergebnis um es anzuzeigen.
+SearchMapDialog.searchString.Label=Suchbegriff eingeben:
+SearchMapDialog.searchString.tt=Geben Sie den Suchbegriff ein und drücken Sie [Enter]
+SearchMapDialog.title=Durchsuche Karte: ${0}
\ No newline at end of file
Property changes on: trunk/src/skrueger/geotools/labelsearch/labelsearch_de.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/src/skrueger/geotools/labelsearch/labelsearch_fr.properties
===================================================================
--- trunk/src/skrueger/geotools/labelsearch/labelsearch_fr.properties 2009-06-10 15:23:33 UTC (rev 138)
+++ trunk/src/skrueger/geotools/labelsearch/labelsearch_fr.properties 2009-06-11 12:52:58 UTC (rev 139)
@@ -0,0 +1,6 @@
+SearchMapDialog.Results.Column.Layer=Retrouvés dans
+SearchMapDialog.Results.Column.Name=Nom
+SearchMapDialog.resultsTable.tt=Cliquer sur un résultat pour l`afficher.
+SearchMapDialog.searchString.Label=Entrer le domaine de recherche:
+SearchMapDialog.searchString.tt=Saisir le domaine de recherche et appuyer sur [Enter]
+SearchMapDialog.title=Rechercher dans la carte: ${0}
\ No newline at end of file
Property changes on: trunk/src/skrueger/geotools/labelsearch/labelsearch_fr.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Schmitzm-commits
mailing list