[Schmitzm-commits] r409 - in branches/1.0-gt2-2.6/src: org/geotools/feature/collection schmitzm/geotools/feature schmitzm/geotools/gui skrueger/geotools skrueger/geotools/selection skrueger/i8n
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 18 17:00:30 CEST 2009
Author: alfonx
Date: 2009-09-18 17:00:29 +0200 (Fri, 18 Sep 2009)
New Revision: 409
Removed:
branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/PipedFeatureIterator.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
branches/1.0-gt2-2.6/src/skrueger/i8n/Translation.java
Log:
* First start of rewriting of AtlasStyler GUI for GT2.6 and Miglayout.
* Fix for Schmitzm so that the FeatureMapLayerSelectionSynchronizer works correctly again.
Deleted: branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java
===================================================================
--- branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -1,236 +0,0 @@
-/*
- * GeoTools - The Open Source Java GIS Toolkit
- * http://geotools.org
- *
- * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- */
-package org.geotools.feature.collection;
-
-/*******************
- * This copied from 2.6-m2. Added by SK on 2009-09-03 because the 2.6-M2
- * SubFeatureCollection had forgotten to overwrite getBounds() and
- * threw an UnsupportedOperationException.
- * It has been reported as http://jira.codehaus.org/browse/GEOT-2693
- *******************/
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.geotools.data.DataUtilities;
-import org.geotools.data.FeatureReader;
-import org.geotools.data.collection.DelegateFeatureReader;
-import org.geotools.factory.CommonFactoryFinder;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureIterator;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.sort.SortBy;
-
-/**
- * Used as a reasonable default implementation for subCollection.
- * <p>
- * Note: to implementors, this is not optimal, please do your own thing - your
- * users will thank you.
- * </p>
- *
- * @author Jody Garnett, Refractions Research, Inc.
- *
- * @source $URL:
- * http://svn.osgeo.org/geotools/tags/2.6-M2/modules/library/main/src
- * /main/java/org/geotools/feature/collection/SubFeatureCollection.java
- * $
- */
-public class SubFeatureCollection extends AbstractFeatureCollection {
-
- /** Filter */
- protected Filter filter;
-
- /** Original Collection */
- protected FeatureCollection<SimpleFeatureType, SimpleFeature> collection;
-
- protected FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
-
- public SubFeatureCollection(
- FeatureCollection<SimpleFeatureType, SimpleFeature> collection) {
- this(collection, Filter.INCLUDE);
- }
-
- public SubFeatureCollection(
- FeatureCollection<SimpleFeatureType, SimpleFeature> collection,
- Filter subfilter) {
- super(collection.getSchema());
- if (subfilter == null)
- subfilter = Filter.INCLUDE;
- if (subfilter.equals(Filter.EXCLUDE)) {
- throw new IllegalArgumentException(
- "A subcollection with Filter.EXCLUDE would be empty");
- }
- if (collection instanceof SubFeatureCollection) {
- SubFeatureCollection filtered = (SubFeatureCollection) collection;
- if (subfilter.equals(Filter.INCLUDE)) {
- this.collection = filtered.collection;
- this.filter = filtered.filter();
- } else {
- this.collection = filtered.collection;
- this.filter = ff.and(filtered.filter(), subfilter);
- }
- } else {
- this.collection = collection;
- this.filter = subfilter;
- }
- }
-
- public Iterator openIterator() {
- return new FilteredIterator<SimpleFeature>(collection, filter());
- }
-
- public void closeIterator(Iterator iterator) {
- if (iterator == null)
- return;
-
- if (iterator instanceof FilteredIterator) {
- FilteredIterator filtered = (FilteredIterator) iterator;
- filtered.close();
- }
- }
-
- public int size() {
- int count = 0;
- Iterator i = null;
- try {
- for (i = iterator(); i.hasNext(); count++)
- i.next();
- } finally {
- close(i);
- }
- return count;
- }
-
- protected Filter filter() {
- if (filter == null) {
- filter = createFilter();
- }
- return filter;
- }
-
- /** Override to implement subsetting */
- protected Filter createFilter() {
- return Filter.INCLUDE;
- }
-
- public FeatureIterator<SimpleFeature> features() {
- return new DelegateFeatureIterator<SimpleFeature>(this, iterator());
- }
-
- public void close(FeatureIterator<SimpleFeature> close) {
- if (close != null)
- close.close();
- }
-
- //
- //
- //
- public FeatureCollection<SimpleFeatureType, SimpleFeature> subCollection(
- Filter filter) {
- if (filter.equals(Filter.INCLUDE)) {
- return this;
- }
- if (filter.equals(Filter.EXCLUDE)) {
- // TODO implement EmptyFeatureCollection( schema )
- }
- return new SubFeatureCollection(this, filter);
- }
-
- public boolean isEmpty() {
- Iterator iterator = iterator();
- try {
- return !iterator.hasNext();
- } finally {
- close(iterator);
- }
- }
-
- public void accepts(org.opengis.feature.FeatureVisitor visitor,
- org.opengis.util.ProgressListener progress) {
- Iterator iterator = null;
- // if( progress == null ) progress = new NullProgressListener();
- try {
- float size = size();
- float position = 0;
- progress.started();
- for (iterator = iterator(); !progress.isCanceled()
- && iterator.hasNext(); progress.progress(position++ / size)) {
- try {
- SimpleFeature feature = (SimpleFeature) iterator.next();
- visitor.visit(feature);
- } catch (Exception erp) {
- progress.exceptionOccurred(erp);
- }
- }
- } finally {
- progress.complete();
- close(iterator);
- }
- }
-
- public FeatureCollection<SimpleFeatureType, SimpleFeature> sort(SortBy order) {
- return new SubFeatureList(collection, filter, order);
- }
-
- public boolean add(SimpleFeature o) {
- return collection.add(o);
- }
-
- public void clear() {
- List toDelete = DataUtilities.list(this);
- removeAll(toDelete);
- }
-
- public boolean remove(Object o) {
- return collection.remove(o);
- }
-
- public String getID() {
- return collection.getID();
- }
-
- // extra methods
- public FeatureReader<SimpleFeatureType, SimpleFeature> reader()
- throws IOException {
- return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(
- getSchema(), features());
- }
-
- public int getCount() throws IOException {
- return size();
- }
-
- public FeatureCollection<SimpleFeatureType, SimpleFeature> collection()
- throws IOException {
- return this;
- }
-
- /**
- * TODO THIS IS NOT VErY SMART.. THE Bounds of the sub-collection might be
- * different from the original collection.
- */
- @Override
- public ReferencedEnvelope getBounds() {
- return collection.getBounds();
- }
-
-}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/PipedFeatureIterator.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/PipedFeatureIterator.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/PipedFeatureIterator.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -46,14 +46,14 @@
*/
public class PipedFeatureIterator implements Iterator<SimpleFeature> {
/** Holds the {@link FeatureIterator} which is piped. */
- protected FeatureIterator<SimpleFeature> filter = null;
+ protected FeatureIterator<SimpleFeature> iterator = null;
/**
* Creates a new iterator.
- * @param filter {@link FeatureIterator} which is piped
+ * @param iterator {@link FeatureIterator} which is piped
*/
- public PipedFeatureIterator(FeatureIterator<SimpleFeature> filter) {
- this.filter = filter;
+ public PipedFeatureIterator(FeatureIterator<SimpleFeature> iterator) {
+ this.iterator = iterator;
}
/**
@@ -61,7 +61,7 @@
*/
@Override
public boolean hasNext() {
- return filter.hasNext();
+ return iterator.hasNext();
}
/**
@@ -69,7 +69,7 @@
*/
@Override
public SimpleFeature next() {
- return filter.next();
+ return iterator.next();
}
/**
@@ -82,6 +82,5 @@
throw new UnsupportedOperationException("PipedFeatureIterator.remove() not supported!");
}
-
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -212,10 +212,10 @@
mapCRS = mapPane.getContext().getCoordinateReferenceSystem();
gridCRS = formatter.getCRS();// lat/lon
- LOGGER.debug("mapCRS = "+LangUtil.getSimpleClassName(mapCRS));
- LOGGER.debug("gridCRS = "+LangUtil.getSimpleClassName(gridCRS));
- LOGGER.debug("mapCRS: "+mapCRS);
- LOGGER.debug("gridCRS: "+gridCRS);
+// LOGGER.debug("mapCRS = "+LangUtil.getSimpleClassName(mapCRS));
+// LOGGER.debug("gridCRS = "+LangUtil.getSimpleClassName(gridCRS));
+// LOGGER.debug("mapCRS: "+mapCRS);
+// LOGGER.debug("gridCRS: "+gridCRS);
double minX = mapPane.getMapArea().getMinX();
double minY = mapPane.getMapArea().getMinY();
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -1665,7 +1665,7 @@
*
* 17.4.08, Stefan
*
- * @param filter
+ * @param iterator
* Filter
* @param mode
* Suchmodus
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -980,17 +980,8 @@
hbox.add(iconLabel);
hbox.add(Box.createHorizontalStrut(3));
- // ****************************************************************************
- // The labeltext is read from the SLD. Its either the title
- // directly, or interpreted as OneLine Code
- // ****************************************************************************
- // final String rawText =
- // rule.getDescription().getTitle().toString();
- final String rawText = rule.getDescription().getTitle()
- .toString();
-
Translation labelT = new Translation();
- labelT.fromOneLine(rawText);
+ labelT.fromOneLine(rule.getDescription().getTitle());
final JLabel classTitleLabel = new JLabel(labelT.toString());
hbox.add(classTitleLabel);
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -29,7 +29,7 @@
******************************************************************************/
/**
Copyright 2008 Stefan Alfons Krüger
-
+
atlas-framework - This file is part of the Atlas Framework
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
@@ -45,8 +45,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
@@ -54,6 +54,7 @@
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionListener;
+import org.geotools.feature.FeatureIterator;
import org.geotools.map.MapLayer;
import org.geotools.styling.FeatureTypeStyle;
import org.geotools.styling.Style;
@@ -61,6 +62,7 @@
import org.opengis.filter.identity.FeatureId;
import schmitzm.geotools.FilterUtil;
+import schmitzm.geotools.feature.PipedFeatureIterator;
import schmitzm.geotools.gui.JMapPane;
import schmitzm.geotools.map.event.FeatureSelectedEvent;
import schmitzm.geotools.map.event.JMapPaneEvent;
@@ -204,12 +206,13 @@
* used on objects that are selected. <br/>
*
* Note 1:<br/>
- * It is NEVER allowed to GeoTools extend Filter () { .. } (and write
- * tests into the evaluate block). Especially for the
+ * It is NEVER allowed to GeoTools extend Filter () { .. } (and
+ * write tests into the evaluate block). Especially for the
* ShapeFileRenderer, we may only use a geotools Filter.<br/>
*
* Note 2:<br/>
- * The FilterUtil.FILTER_FAC2.id(fids) wants a set of FeatureId-Objects!
+ * The FilterUtil.FILTER_FAC2.id(fids) wants a set of
+ * FeatureId-Objects!
*/
Set<FeatureId> fids = new HashSet<FeatureId>();
@@ -299,15 +302,16 @@
// Avoid event circles in propertyChange(..)
selectionChangeCausedByMe = true;
- Collection<SimpleFeature> selectionResult = (Collection<SimpleFeature>) fse
- .getSelectionResult();
+ Iterator<SimpleFeature> fi = fse.getSelectionResult().iterator();
// reset the selection of the DpLayerSelectionModel
// layerSelModel.setValueIsAdjusting(true);
if (selectedTool == MapPaneToolBar.TOOL_SELECTION_ADD) {
layerSelModel.setValueIsAdjusting(true);
- for (SimpleFeature f : selectionResult) {
+
+ for (int fIdx = 0; fi.hasNext(); fIdx++) {
+ SimpleFeature f = fi.next();
layerSelModel.addSelection(f.getID());
}
layerSelModel.setValueIsAdjusting(false);
@@ -315,15 +319,18 @@
layerSelModel.setValueIsAdjusting(true);
layerSelModel.clearSelection();
- for (SimpleFeature f : selectionResult) {
+ for (int fIdx = 0; fi.hasNext(); fIdx++) {
+ SimpleFeature f = fi.next();
layerSelModel.addSelection(f.getID());
}
- LOGGER.debug("Setting selection to " + selectionResult.size());
+ // LOGGER.debug("Setting selection to " + fi.());
+
layerSelModel.setValueIsAdjusting(false);
} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_REMOVE) {
layerSelModel.setValueIsAdjusting(true);
- for (SimpleFeature f : selectionResult) {
+ for (int fIdx = 0; fi.hasNext(); fIdx++) {
+ SimpleFeature f = fi.next();
layerSelModel.removeSelection(f.getID());
}
layerSelModel.setValueIsAdjusting(false);
Modified: branches/1.0-gt2-2.6/src/skrueger/i8n/Translation.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/i8n/Translation.java 2009-09-14 18:39:29 UTC (rev 408)
+++ branches/1.0-gt2-2.6/src/skrueger/i8n/Translation.java 2009-09-18 15:00:29 UTC (rev 409)
@@ -42,6 +42,7 @@
import javax.swing.JComponent;
import org.apache.log4j.Logger;
+import org.opengis.util.InternationalString;
/**
* Represents a {@link HashMap} of translations. toString() returns the
@@ -192,6 +193,7 @@
*/
public void fromOneLine(final String oneLineCoded) {
clear();
+
if ((oneLineCoded == null) || (oneLineCoded.equals(""))) {
put(DEFAULT_KEY, "");
return;
@@ -329,6 +331,13 @@
fireTranslationChangedEvents(lang);
return result;
}
+
+ public void fromOneLine(InternationalString iString) {
+ if (iString != null)
+ fromOneLine(iString.toString());
+ else
+ fromOneLine((String)null);
+ }
}
More information about the Schmitzm-commits
mailing list