/[schmitzm]/trunk/src/skrueger/geotools/StyledFeatureCollection.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/StyledFeatureCollection.java

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

revision 325 by mojays, Wed Aug 26 15:32:54 2009 UTC revision 331 by mojays, Wed Aug 26 16:22:38 2009 UTC
# Line 38  import javax.swing.ImageIcon; Line 38  import javax.swing.ImageIcon;
38    
39  import org.geotools.data.FeatureSource;  import org.geotools.data.FeatureSource;
40  import org.geotools.data.collection.CollectionDataStore;  import org.geotools.data.collection.CollectionDataStore;
 import org.geotools.feature.AttributeType;  
41  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
42  import org.geotools.styling.Style;  import org.geotools.styling.Style;
43  import org.opengis.feature.simple.SimpleFeature;  import org.opengis.feature.simple.SimpleFeature;
44  import org.opengis.feature.simple.SimpleFeatureType;  import org.opengis.feature.simple.SimpleFeatureType;
45    import org.opengis.feature.type.AttributeDescriptor;
46    
47  import schmitzm.geotools.feature.FeatureUtil;  import schmitzm.geotools.feature.FeatureUtil;
48  import skrueger.AttributeMetaData;  import skrueger.AttributeMetaData;
# Line 93  public class StyledFeatureCollection ext Line 93  public class StyledFeatureCollection ext
93           * @exception IllegalArgumentException           * @exception IllegalArgumentException
94           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
95           */           */
96          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
97                          Translation title, Translation desc, Translation keywords,                          Translation title, Translation desc, Translation keywords,
98                          Style style, Map<Integer, AttributeMetaData> attrMetaData,                          Style style, Map<Integer, AttributeMetaData> attrMetaData,
99                          ImageIcon icon) {                          ImageIcon icon) {
100                  super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry()                  super(fc, fc.getBounds(), fc.getSchema().getGeometryDescriptor()
101                                  .getCoordinateSystem(), id, title, desc, keywords, style, icon);                                  .getCoordinateReferenceSystem(), id, title, desc, keywords, style, icon);
102                  setAttributeMetaData(attrMetaData);                  setAttributeMetaData(attrMetaData);
103          }          }
104    
# Line 123  public class StyledFeatureCollection ext Line 123  public class StyledFeatureCollection ext
123           * @exception IllegalArgumentException           * @exception IllegalArgumentException
124           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
125           */           */
126          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
127                          Translation title, Translation desc, Translation keywords,                          Translation title, Translation desc, Translation keywords,
128                          StyledLayerStyle<Map<Integer, AttributeMetaData>> style,                          StyledLayerStyle<Map<Integer, AttributeMetaData>> style,
129                          ImageIcon icon) {                          ImageIcon icon) {
130                  super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry()                  super(fc, fc.getBounds(), fc.getSchema().getGeometryDescriptor()
131                                  .getCoordinateSystem(), id, title, desc, keywords,                                  .getCoordinateReferenceSystem(), id, title, desc, keywords,
132                                  style != null ? style.getGeoObjectStyle() : null, icon);                                  style != null ? style.getGeoObjectStyle() : null, icon);
133                  setAttributeMetaData(style != null ? style.getMetaData() : null);                  setAttributeMetaData(style != null ? style.getMetaData() : null);
134          }          }
# Line 150  public class StyledFeatureCollection ext Line 150  public class StyledFeatureCollection ext
150           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
151           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
152           */           */
153          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
154                          Translation title, Style style) {                          Translation title, Style style) {
155                  this(fc, id, title, null, null, style, null, null);                  this(fc, id, title, null, null, style, null, null);
156          }          }
# Line 178  public class StyledFeatureCollection ext Line 178  public class StyledFeatureCollection ext
178           * @exception IllegalArgumentException           * @exception IllegalArgumentException
179           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
180           */           */
181          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
182                          String title, String desc, String keywords, Style style,                          String title, String desc, String keywords, Style style,
183                          Map<Integer, AttributeMetaData> attrMetaData, ImageIcon icon) {                          Map<Integer, AttributeMetaData> attrMetaData, ImageIcon icon) {
184                  this(fc, id, (Translation) null, null, null, style, attrMetaData, icon);                  this(fc, id, (Translation) null, null, null, style, attrMetaData, icon);
# Line 208  public class StyledFeatureCollection ext Line 208  public class StyledFeatureCollection ext
208           * @exception IllegalArgumentException           * @exception IllegalArgumentException
209           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
210           */           */
211          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
212                          String title, String desc, String keywords,                          String title, String desc, String keywords,
213                          StyledLayerStyle<Map<Integer, AttributeMetaData>> style,                          StyledLayerStyle<Map<Integer, AttributeMetaData>> style,
214                          ImageIcon icon) {                          ImageIcon icon) {
# Line 234  public class StyledFeatureCollection ext Line 234  public class StyledFeatureCollection ext
234           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
235           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
236           */           */
237          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
238                          String title, Style style) {                          String title, Style style) {
239                  this(fc, id, title, null, null, style, null, null);                  this(fc, id, title, null, null, style, null, null);
240          }          }
# Line 256  public class StyledFeatureCollection ext Line 256  public class StyledFeatureCollection ext
256           *                if {@code null} is given as ID or geo object           *                if {@code null} is given as ID or geo object
257           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
258           */           */
259          public StyledFeatureCollection(FeatureCollection fc, String id,          public StyledFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc, String id,
260                          String title, StyledLayerStyle<Map<Integer, AttributeMetaData>> style) {                          String title, StyledLayerStyle<Map<Integer, AttributeMetaData>> style) {
261                  this(fc, id, title, null, null, style != null ? style                  this(fc, id, title, null, null, style != null ? style
262                                  .getGeoObjectStyle() : null, style != null ? style                                  .getGeoObjectStyle() : null, style != null ? style
# Line 301  public class StyledFeatureCollection ext Line 301  public class StyledFeatureCollection ext
301           *            a {@link FeatureCollection}           *            a {@link FeatureCollection}
302           */           */
303          public static Map<Integer, AttributeMetaData> createDefaultAttributeMetaDataMap(          public static Map<Integer, AttributeMetaData> createDefaultAttributeMetaDataMap(
304                          FeatureCollection fc) {                          FeatureCollection<SimpleFeatureType,SimpleFeature> fc) {
305                  HashMap<Integer, AttributeMetaData> metaDataMap = new HashMap<Integer, AttributeMetaData>();                  HashMap<Integer, AttributeMetaData> metaDataMap = new HashMap<Integer, AttributeMetaData>();
306                  SimpleFeatureType ftype = fc.getSchema();                  SimpleFeatureType ftype = fc.getSchema();
307                  for (int i = 0; i < ftype.getAttributeCount(); i++) {                  for (int i = 0; i < ftype.getAttributeCount(); i++) {
308                          AttributeType aType = ftype.getAttributeType(i);                          AttributeDescriptor aType = ftype.getAttributeDescriptors().get(i);
309                          if (aType != ftype.getDefaultGeometry())                          if (aType != ftype.getGeometryDescriptor())
310                                  metaDataMap.put(i, new AttributeMetaData(i, // Column no.                                  metaDataMap.put(i, new AttributeMetaData(i, // Column no.
311                                                  true, // visible                                                  true, // visible
312                                                  new Translation(aType.getName()), // Column name                                                  new Translation(aType.getLocalName()), // Column name
313                                                  new Translation(), // description                                                  new Translation(), // description
314                                                  "" // Unit                                                  "" // Unit
315                                  ));                                  ));
# Line 362  public class StyledFeatureCollection ext Line 362  public class StyledFeatureCollection ext
362           * @see {@link StyledFeaturesInterface}           * @see {@link StyledFeaturesInterface}
363           */           */
364          @Override          @Override
365          public FeatureCollection getFeatureCollection() {          public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatureCollection() {
366                  return getGeoObject();                  return getGeoObject();
367          }          }
368    
# Line 373  public class StyledFeatureCollection ext Line 373  public class StyledFeatureCollection ext
373           * @see {@link StyledFeaturesInterface}           * @see {@link StyledFeaturesInterface}
374           */           */
375          @Override          @Override
376          public FeatureSource getFeatureSource() {          public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource() {
377                  if (featureSource == null) {                  if (featureSource == null) {
378                          CollectionDataStore store = new CollectionDataStore(getGeoObject());                          CollectionDataStore store = new CollectionDataStore(getGeoObject());
379                          try {                          try {

Legend:
Removed from v.325  
changed lines
  Added in v.331

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26