Example #1
0
 // private static Map<String,ComponentInsets> createInsetsMap(Object[][] definitions) {
 private static Map createInsetsMap(Object[][] definitions) {
   Map map = new HashMap();
   for (int i = 0; i < definitions.length; i++) {
     int keys = 0;
     while (keys < definitions[i].length && (definitions[i][keys] instanceof String)) {
       keys++;
     }
     Insets[] values = new Insets[definitions[i].length - keys];
     for (int j = keys; j < definitions[i].length; j++) {
       values[j - keys] = (Insets) definitions[i][j];
     }
     for (int j = 0; j < keys; j++) {
       String key = (String) definitions[i][j];
       int subindex = key.indexOf('.');
       if (subindex == -1) {
         ComponentInsets componentInsets = (ComponentInsets) map.get(key);
         if (componentInsets == null) {
           componentInsets = new ComponentInsets(values);
           map.put(key, new ComponentInsets(values));
         } else {
           assert (componentInsets.getInsets() == null);
           componentInsets.setInsets(values);
         }
       } else {
         String subkey = key.substring(subindex + 1);
         String parentKey = key.substring(0, subindex);
         ComponentInsets componentInsets = (ComponentInsets) map.get(parentKey);
         if (componentInsets == null) {
           componentInsets = new ComponentInsets();
           map.put(parentKey, componentInsets);
         }
         componentInsets.addSubinsets(subkey, new ComponentInsets(values));
       }
     }
   }
   return map;
 }