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

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

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

revision 1215 by alfonx, Wed Nov 3 11:06:22 2010 UTC revision 1228 by alfonx, Wed Nov 3 20:44:16 2010 UTC
# Line 91  import schmitzm.geotools.feature.Feature Line 91  import schmitzm.geotools.feature.Feature
91  import schmitzm.geotools.styling.StylingUtil;  import schmitzm.geotools.styling.StylingUtil;
92  import schmitzm.io.IOUtil;  import schmitzm.io.IOUtil;
93  import schmitzm.lang.LangUtil;  import schmitzm.lang.LangUtil;
94    import schmitzm.swing.ExceptionDialog;
95  import schmitzm.swing.JPanel;  import schmitzm.swing.JPanel;
96  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
97  import skrueger.AttributeMetadataImpl;  import skrueger.AttributeMetadataImpl;
# Line 98  import skrueger.AttributeMetadataInterfa Line 99  import skrueger.AttributeMetadataInterfa
99  import skrueger.RasterLegendData;  import skrueger.RasterLegendData;
100  import skrueger.i8n.Translation;  import skrueger.i8n.Translation;
101    
102    import com.vividsolutions.jts.geom.Geometry;
103    
104  /**  /**
105   * This class provides static helper methods for dealing with   * This class provides static helper methods for dealing with
106   * {@link StyledLayerInterface} stuff.   * {@link StyledLayerInterface} stuff.
# Line 942  public class StyledLayerUtil { Line 945  public class StyledLayerUtil {
945                          final SimpleFeatureType featureType, final int iconWidth,                          final SimpleFeatureType featureType, final int iconWidth,
946                          final int iconHeight) {                          final int iconHeight) {
947    
948                    if (featureType == null) {
949                            ExceptionDialog.show(new IllegalStateException(
950                                            "featureType is null!"));
951                            return new JPanel();
952                    }
953    
954                  final List<FeatureTypeStyle> list = style.featureTypeStyles();                  final List<FeatureTypeStyle> list = style.featureTypeStyles();
955    
956                  final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]"));                  final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]"));
# Line 1356  public class StyledLayerUtil { Line 1365  public class StyledLayerUtil {
1365                  }                  }
1366                  return nicelyFormatted;                  return nicelyFormatted;
1367          }          }
1368    
1369            /**
1370             * Creates a new {@link AttributeMetadataMap} with instances of
1371             * {@link AttributeMetadataInterface} for every non-geometry attribute.
1372             * Default NODATA values (like "" for String) are set.
1373             */
1374            public static AttributeMetadataMap<AttributeMetadataImpl> createDefaultAttributeMetadataMap(
1375                            SimpleFeatureType schema) {
1376                    AttributeMetadataImplMap attMap = new AttributeMetadataImplMap();
1377    
1378                    for (int i = 0; i < schema.getAttributeCount(); i++) {
1379                            AttributeDescriptor attDesc = schema.getDescriptor(i);
1380    
1381                            if (Geometry.class.isAssignableFrom(attDesc.getType().getBinding())) {
1382                                    // Ignore the Geometry column
1383                                    continue;
1384                            }
1385    
1386                            // TODO AttributeMetadataAS would be nicer, which would not work
1387                            // with Translations ;-)
1388                            AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
1389                                            new NameImpl(attDesc.getName().getNamespaceURI(), attDesc
1390                                                            .getName().getLocalPart()), attMap.getLanguages());
1391    
1392                            if (String.class.isAssignableFrom(attDesc.getType().getBinding())) {
1393                                    // For Strings we add the "" as NODATA values
1394                                    attMetaData.addNodataValue("");
1395                            }
1396    
1397                            attMap.put(attDesc.getName(), attMetaData);
1398                    }
1399                    return attMap;
1400            }
1401  }  }

Legend:
Removed from v.1215  
changed lines
  Added in v.1228

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26