10 |
**/ |
**/ |
11 |
package skrueger.geotools; |
package skrueger.geotools; |
12 |
|
|
13 |
|
|
14 |
import java.util.Iterator; |
import java.util.Iterator; |
15 |
import java.util.Map; |
import java.util.Map; |
|
import java.util.TreeMap; |
|
16 |
import java.util.Vector; |
import java.util.Vector; |
17 |
|
|
18 |
|
import org.apache.log4j.Logger; |
19 |
import org.geotools.data.DefaultQuery; |
import org.geotools.data.DefaultQuery; |
20 |
import org.geotools.data.FeatureSource; |
import org.geotools.data.FeatureSource; |
21 |
import org.geotools.data.Query; |
import org.geotools.data.Query; |
23 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
24 |
import org.opengis.filter.Filter; |
import org.opengis.filter.Filter; |
25 |
|
|
|
import com.vividsolutions.jts.geom.Envelope; |
|
|
|
|
26 |
import schmitzm.geotools.gui.FeatureCollectionTableModel; |
import schmitzm.geotools.gui.FeatureCollectionTableModel; |
27 |
import skrueger.AttributeMetaData; |
import skrueger.AttributeMetaData; |
28 |
import skrueger.i8n.I8NUtil; |
import skrueger.i8n.I8NUtil; |
29 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
30 |
|
|
31 |
|
import com.vividsolutions.jts.geom.Envelope; |
32 |
|
|
33 |
/** |
/** |
34 |
* This class extends the the {@link FeatureCollectionTableModel} with the |
* This class extends the the {@link FeatureCollectionTableModel} with the |
35 |
* functionalities of the {@link AttributeMetaData} of |
* functionalities of the {@link AttributeMetaData} of |
41 |
* @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany) |
* @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany) |
42 |
*/ |
*/ |
43 |
public class StyledFeatureCollectionTableModel extends FeatureCollectionTableModel { |
public class StyledFeatureCollectionTableModel extends FeatureCollectionTableModel { |
44 |
|
final static private Logger LOGGER = Logger.getLogger(StyledFeatureCollectionTableModel.class); |
45 |
/** Holds the data source as styled map. */ |
/** Holds the data source as styled map. */ |
46 |
protected StyledMapInterface map = null; |
protected StyledMapInterface<?> map = null; |
47 |
/** Contains only the visible elements of the {@link AttributeMetaData}-Map */ |
/** Contains only the visible elements of the {@link AttributeMetaData}-Map */ |
48 |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
49 |
/** Holds the data source for the table as {@code FeatureSource}. */ |
/** Holds the data source for the table as {@code FeatureSource}. */ |
124 |
// create a query for the visible attributes |
// create a query for the visible attributes |
125 |
String[] properties = visibleAttrNames.toArray(new String[0]); |
String[] properties = visibleAttrNames.toArray(new String[0]); |
126 |
|
|
127 |
|
LOGGER.debug("Query contains the following attributes: " + visibleAttrNames); |
128 |
|
|
129 |
query = new DefaultQuery(fs.getSchema().getTypeName(), filter, properties); |
query = new DefaultQuery(fs.getSchema().getTypeName(), filter, properties); |
130 |
} |
} |
131 |
fc = fs.getFeatures(query); |
fc = fs.getFeatures(query); |
159 |
setFeatureSource(null, null, null); |
setFeatureSource(null, null, null); |
160 |
else { |
else { |
161 |
FeatureCollection fc = map.getGeoObject(); |
FeatureCollection fc = map.getGeoObject(); |
162 |
String fcName = fc.getFeatureType().getTypeName(); |
String fcName = fc.getSchema().getTypeName(); |
163 |
FeatureSource fs = new MemoryDataStore(fc).getFeatureSource(fcName); |
FeatureSource fs = new MemoryDataStore(fc).getFeatureSource(fcName); |
164 |
setFeatureSource(fs, map.getAttributeMetaDataMap(), filter); |
setFeatureSource(fs, map.getAttributeMetaDataMap(), filter); |
165 |
} |
} |
194 |
try{ |
try{ |
195 |
setFeatureSource(this.featureSource, this.origAMD, filter); |
setFeatureSource(this.featureSource, this.origAMD, filter); |
196 |
} catch (Exception err) { |
} catch (Exception err) { |
197 |
|
LOGGER.error("Setting the filter of the table model", err); |
198 |
throw new RuntimeException(err); |
throw new RuntimeException(err); |
199 |
} |
} |
200 |
} |
} |
231 |
} |
} |
232 |
|
|
233 |
/** |
/** |
234 |
* @returns Cached bounds for the whole dataset (without applying the |
* @return Cached bounds for the whole dataset (without applying the |
235 |
* filter) or <code>null</code> |
* filter) or <code>null</code> |
236 |
*/ |
*/ |
237 |
public Envelope getBounds() { |
public Envelope getBounds() { |