/[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

branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java revision 658 by alfonx, Wed Feb 3 15:32:21 2010 UTC trunk/src/skrueger/geotools/StyledLayerUtil.java revision 714 by alfonx, Sun Feb 21 19:17:34 2010 UTC
# Line 307  public class StyledLayerUtil { Line 307  public class StyledLayerUtil {
307           *           *
308           * @param element           * @param element
309           *            {@link Element} to parse           *            {@link Element} to parse
310           *                       *
311           *            TODO Since GP 1.3 the {@link AttributeMetadata} class has more           *            TODO Since GP 1.3 the {@link AttributeMetadata} class has more
312           *            attributes which are not used by Xulu/ISDSS. GP           *            attributes which are not used by Xulu/ISDSS. GP
313           *            exports/imports the AMD via AMLExporter and AMLImporter           *            exports/imports the AMD via AMLExporter and AMLImporter
314           *            classes. (SK, 3.2.2010)    *                       *            classes. (SK, 3.2.2010) *
315           */           */
316          public static AttributeMetadataMap parseAttributeMetaDataMap(          public static AttributeMetadataMap parseAttributeMetaDataMap(
317                          final Element element) {                          final Element element) {
# Line 914  public class StyledLayerUtil { Line 914  public class StyledLayerUtil {
914          }          }
915    
916          /**          /**
917             * *If appended to the name of a rule, this rule shall not be shown in the
918             * legend
919             */
920            public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND";
921    
922            /**
923           * Creates a {@link JPanel} that shows a legend for a list of           * Creates a {@link JPanel} that shows a legend for a list of
924           * {@link FeatureTypeStyle}s and a targeted featureType           * {@link FeatureTypeStyle}s and a targeted featureType
925           *           *
# Line 944  public class StyledLayerUtil { Line 950  public class StyledLayerUtil {
950                          final List<Rule> rules = ftStyle.rules();                          final List<Rule> rules = ftStyle.rules();
951                          for (final Rule rule : rules) {                          for (final Rule rule : rules) {
952    
953                                    // Check if this RULE shall actually appear in the legend
954                                    if (rule.getName() != null && rule.getName().endsWith(HIDE_IN_LAYER_LEGEND_HINT))
955                                            continue;
956    
957                                  /**                                  /**
958                                   * Let's not create a hbox for Rules that only contain                                   * Let's not create a hbox for Rules that only contain
959                                   * TextSymbolizers                                   * TextSymbolizers
# Line 1229  public class StyledLayerUtil { Line 1239  public class StyledLayerUtil {
1239           * After loading an atlas, the AttribteMetaData contains whatever is written           * After loading an atlas, the AttribteMetaData contains whatever is written
1240           * in the XML. But the DBF may have changed!           * in the XML. But the DBF may have changed!
1241           */           */
1242          public static void checkAttribMetaData(AttributeMetadataMap attributeMetaDataMap,          public static void checkAttribMetaData(
1243                          SimpleFeatureType schema) {                          AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema) {
1244                    
1245                    if (schema == null) throw new IllegalArgumentException("schmema may not be null!");
1246    
1247                  ArrayList<Name> willRemove = new ArrayList<Name>();                  ArrayList<Name> willRemove = new ArrayList<Name>();
1248    
# Line 1256  public class StyledLayerUtil { Line 1268  public class StyledLayerUtil {
1268    
1269                  // Remove the ones that were not findable in the schema                  // Remove the ones that were not findable in the schema
1270                  for (Name removeName : willRemove) {                  for (Name removeName : willRemove) {
1271                          if (attributeMetaDataMap.remove(removeName) == null){                          if (attributeMetaDataMap.remove(removeName) == null) {
1272                                  LOGGER.warn("removing the AMData didn't work");                                  LOGGER.warn("removing the AMData didn't work");
1273                          }                          }
1274                  }                  }
# Line 1267  public class StyledLayerUtil { Line 1279  public class StyledLayerUtil {
1279                                  continue;                                  continue;
1280                          if (!attributeMetaDataMap.containsKey(ad.getName())) {                          if (!attributeMetaDataMap.containsKey(ad.getName())) {
1281                                  attributeMetaDataMap.put(ad.getName(), new AttributeMetadata(                                  attributeMetaDataMap.put(ad.getName(), new AttributeMetadata(
1282                                                  ad, schema.getAttributeDescriptors().indexOf(ad), attributeMetaDataMap                                                  ad, schema.getAttributeDescriptors().indexOf(ad),
1283                                                                  .getLanguages()));                                                  attributeMetaDataMap.getLanguages()));
1284                          }                          }
1285                  }                  }
   
1286          }          }
1287    
1288            /**
1289             * Checks every attribute name in the {@link AttributeMetadataMap} for its
1290             * binding type. It the type is textual, add the mrpty string as a NODATA
1291             * value.
1292             *
1293             * @param attributeMetaDataMap
1294             * @param schema
1295             */
1296            public static void addEmptyStringToAllTextualAttributes(
1297                            AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema) {
1298    
1299                    for (Name name : attributeMetaDataMap.keySet()) {
1300                            if (String.class.isAssignableFrom(schema.getDescriptor(name)
1301                                            .getType().getBinding())) {
1302                                    attributeMetaDataMap.get(name).getNodataValues().add("");
1303                            }
1304                    }
1305            }
1306  }  }

Legend:
Removed from v.658  
changed lines
  Added in v.714

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26