Ejemplo n.º 1
0
 @Override
 CompoundSpiderDiagram createSD(
     Map<String, Entry<Object, CommonTree>> attributes, CommonTree mainNode)
     throws ReadingException {
   String operator = (String) attributes.remove(SDTextOperatorAttribute).getKey();
   ArrayList<SpiderDiagram> operands = new ArrayList<>();
   int i = 1;
   Entry<Object, CommonTree> curSD, lastSD = null;
   while ((curSD = attributes.remove(CompoundSpiderDiagram.SDTextArgAttribute + i++)) != null
       && curSD.getKey() instanceof SpiderDiagram) {
     operands.add((SpiderDiagram) curSD.getKey());
     lastSD = curSD;
   }
   if (curSD != null) {
     throw new ReadingException(
         i18n("GERR_ILLEGAL_STATE"), (CommonTree) curSD.getValue().getChild(0));
   }
   if (!attributes.isEmpty()) {
     throw new ReadingException(
         i18n("ERR_TRANSLATE_UNKNOWN_ATTRIBUTES", attributes.keySet()),
         (CommonTree) attributes.values().iterator().next().getValue().getChild(0));
   }
   try {
     return SpiderDiagrams.createCompoundSD(operator, operands, false);
   } catch (Exception e) {
     throw new ReadingException(
         e.getLocalizedMessage(),
         lastSD == null ? mainNode : (CommonTree) lastSD.getValue().getChild(0));
   }
 }
Ejemplo n.º 2
0
 @Override
 @SuppressWarnings("unchecked")
 PrimarySpiderDiagram createSD(
     Map<String, Entry<Object, CommonTree>> attributes, CommonTree mainNode)
     throws ReadingException {
   Entry<Object, CommonTree> presentZonesAttribute = attributes.get(SDTextPresentZonesAttribute);
   return SpiderDiagrams.createPrimarySDNoCopy(
       (Collection<String>) attributes.get(SDTextSpidersAttribute).getKey(),
       (Map<String, Region>) attributes.get(SDTextHabitatsAttribute).getKey(),
       (Collection<Zone>) attributes.get(SDTextShadedZonesAttribute).getKey(),
       presentZonesAttribute == null ? null : (Collection<Zone>) presentZonesAttribute.getKey());
 }