public Set<OWLAnnotationAssertionAxiom> writeAnnotations(OWLAnnotationSubject subject) {
   Set<OWLAnnotationAssertionAxiom> axioms = new HashSet<OWLAnnotationAssertionAxiom>();
   if (!isFiltered(AxiomType.ANNOTATION_ASSERTION)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap sectionMap = new SectionMap();
       // Set<OWLAnnotation> annos = new TreeSet<OWLAnnotation>();
       for (OWLAnnotationAssertionAxiom ax : ontology.getAnnotationAssertionAxioms(subject)) {
         if (isDisplayed(ax)) {
           axioms.add(ax);
           sectionMap.add(ax.getAnnotation(), ax);
         }
       }
       writeSection(ANNOTATIONS, sectionMap, ",", true, ontology);
     }
   }
   return axioms;
 }
  public Set<OWLAxiom> write(OWLIndividual individual) {
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    axioms.addAll(writeEntityStart(INDIVIDUAL, individual));
    if (!isFiltered(AxiomType.CLASS_ASSERTION)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap expressions = new SectionMap();
        for (OWLClassAssertionAxiom ax : ontology.getClassAssertionAxioms(individual)) {
          if (isDisplayed(ax)) {
            expressions.add(ax.getClassExpression(), ax);
            axioms.add(ax);
          }
        }
        writeSection(TYPES, expressions, ",", true, ontology);
      }
    }
    for (OWLOntology ontology : getOntologies()) {

      List<OWLPropertyAssertionAxiom<?, ?>> assertions =
          new ArrayList<OWLPropertyAssertionAxiom<?, ?>>();
      assertions.addAll(ontology.getObjectPropertyAssertionAxioms(individual));
      assertions.addAll(ontology.getNegativeObjectPropertyAssertionAxioms(individual));
      assertions.addAll(ontology.getDataPropertyAssertionAxioms(individual));
      assertions.addAll(ontology.getNegativeDataPropertyAssertionAxioms(individual));

      if (!assertions.isEmpty()) {
        fireSectionRenderingPrepared(FACTS.toString());
        writeSection(FACTS);
        writeSpace();
        writeOntologiesList(ontology);
        incrementTab(1);
        writeNewLine();
        fireSectionRenderingStarted(FACTS.toString());

        for (Iterator<OWLPropertyAssertionAxiom<?, ?>> it = assertions.iterator(); it.hasNext(); ) {
          OWLPropertyAssertionAxiom<?, ?> ax = it.next();
          fireSectionItemPrepared(FACTS.toString());
          Set<OWLAnnotation> annos = ax.getAnnotations();
          if (!annos.isEmpty()) {
            writeAnnotations(annos);
            pushTab(getIndent() + 1);
          }

          if (ax instanceof OWLNegativeDataPropertyAssertionAxiom
              || ax instanceof OWLNegativeObjectPropertyAssertionAxiom) {
            write(NOT);
            writeSpace();
          }
          ax.getProperty().accept(this);
          writeSpace();
          writeSpace();
          ax.getObject().accept(this);
          if (!annos.isEmpty()) {
            popTab();
          }
          fireSectionItemFinished(FACTS.toString());
          if (it.hasNext()) {
            write(",");
            writeNewLine();
          }
        }
        popTab();
        writeNewLine();
        writeNewLine();
      }
    }

    if (!isFiltered(AxiomType.SAME_INDIVIDUAL)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLIndividual> inds = new TreeSet<OWLIndividual>();
        for (OWLSameIndividualAxiom ax : ontology.getSameIndividualAxioms(individual)) {
          if (isDisplayed(ax)) {
            inds.addAll(ax.getIndividuals());
            axioms.add(ax);
          }
        }
        inds.remove(individual);
        writeSection(SAME_AS, inds, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.DIFFERENT_INDIVIDUALS)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLIndividual> inds = new TreeSet<OWLIndividual>();
        Set<OWLDifferentIndividualsAxiom> nary = new TreeSet<OWLDifferentIndividualsAxiom>();
        for (OWLDifferentIndividualsAxiom ax : ontology.getDifferentIndividualAxioms(individual)) {
          if (ax.getIndividuals().size() == 2 && isDisplayed(ax)) {
            inds.addAll(ax.getIndividuals());
            axioms.add(ax);
          } else {
            nary.add(ax);
          }
        }
        inds.remove(individual);
        writeSection(DIFFERENT_FROM, inds, ",", true, ontology);
        if (renderExtensions) {
          for (OWLDifferentIndividualsAxiom ax : nary) {
            writeSection(DIFFERENT_INDIVIDUALS, ax.getIndividuals(), ", ", false, ontology);
          }
        }
      }
    }
    writeEntitySectionEnd(INDIVIDUAL.toString());
    return axioms;
  }
 public Set<OWLAxiom> write(OWLDataProperty property) {
   Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
   axioms.addAll(writeEntityStart(DATA_PROPERTY, property));
   if (!isFiltered(AxiomType.FUNCTIONAL_DATA_PROPERTY)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap characteristics = new SectionMap();
       for (OWLAxiom ax : ontology.getFunctionalDataPropertyAxioms(property)) {
         if (isDisplayed(ax)) {
           characteristics.add(FUNCTIONAL.toString(), ax);
           axioms.add(ax);
         }
       }
       writeSection(CHARACTERISTICS, characteristics, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.DATA_PROPERTY_DOMAIN)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap domains = new SectionMap();
       for (OWLDataPropertyDomainAxiom ax : ontology.getDataPropertyDomainAxioms(property)) {
         if (isDisplayed(ax)) {
           domains.add(ax.getDomain(), ax);
           axioms.add(ax);
         }
       }
       writeSection(DOMAIN, domains, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.DATA_PROPERTY_RANGE)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap ranges = new SectionMap();
       for (OWLDataPropertyRangeAxiom ax : ontology.getDataPropertyRangeAxioms(property)) {
         if (isDisplayed(ax)) {
           ranges.add(ax.getRange(), ax);
           axioms.add(ax);
         }
       }
       writeSection(RANGE, ranges, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.SUB_DATA_PROPERTY)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap supers = new SectionMap();
       for (OWLSubDataPropertyOfAxiom ax :
           ontology.getDataSubPropertyAxiomsForSubProperty(property)) {
         if (isDisplayed(ax)) {
           supers.add(ax.getSuperProperty(), ax);
           axioms.add(ax);
         }
       }
       writeSection(SUB_PROPERTY_OF, supers, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.EQUIVALENT_DATA_PROPERTIES)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap props = new SectionMap();
       for (OWLEquivalentDataPropertiesAxiom ax :
           ontology.getEquivalentDataPropertiesAxioms(property)) {
         if (isDisplayed(ax) && ax.getProperties().size() == 2) {
           props.add(ax.getPropertiesMinus(property).iterator().next(), ax);
           axioms.add(ax);
         }
       }
       writeSection(EQUIVALENT_TO, props, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.DISJOINT_DATA_PROPERTIES)) {
     for (OWLOntology ontology : getOntologies()) {
       SectionMap props = new SectionMap();
       for (OWLDisjointDataPropertiesAxiom ax :
           ontology.getDisjointDataPropertiesAxioms(property)) {
         if (ax.getProperties().size() == 2 && isDisplayed(ax)) {
           props.add(ax.getPropertiesMinus(property).iterator().next(), ax);
           axioms.add(ax);
         }
       }
       props.remove(property);
       writeSection(DISJOINT_WITH, props, ",", true, ontology);
     }
   }
   if (!isFiltered(AxiomType.SWRL_RULE)) {
     for (OWLOntology ontology : getOntologies()) {
       Set<OWLAxiom> rules = new HashSet<OWLAxiom>();
       for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) {
         if (isDisplayed(rule)) {
           for (SWRLAtom atom : rule.getHead()) {
             if (atom.getPredicate().equals(property)) {
               writeSection(RULE, rules, "", true, ontology);
               break;
             }
           }
         }
       }
     }
   }
   writeEntitySectionEnd(DATA_PROPERTY.toString());
   return axioms;
 }
  public Set<OWLAxiom> write(OWLObjectPropertyExpression property) {
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    axioms.addAll(writeEntityStart(OBJECT_PROPERTY, property));
    if (!isFiltered(AxiomType.SUB_OBJECT_PROPERTY)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap properties = new SectionMap();
        for (OWLSubObjectPropertyOfAxiom ax :
            ontology.getObjectSubPropertyAxiomsForSubProperty(property)) {
          if (isDisplayed(ax)) {
            properties.add(ax.getSuperProperty(), ax);
            axioms.add(ax);
          }
        }
        writeSection(SUB_PROPERTY_OF, properties, ",", true, ontology);
      }
      if (renderExtensions) {
        for (OWLOntology ontology : getOntologies()) {
          SectionMap properties = new SectionMap();
          for (OWLSubObjectPropertyOfAxiom ax :
              ontology.getObjectSubPropertyAxiomsForSuperProperty(property)) {
            if (isDisplayed(ax)) {
              properties.add(ax.getSubProperty(), ax);
              axioms.add(ax);
            }
          }
          writeSection(SUPER_PROPERTY_OF, properties, ",", true, ontology);
        }
      }
    }
    if (!isFiltered(AxiomType.EQUIVALENT_OBJECT_PROPERTIES)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap properties = new SectionMap();
        for (OWLEquivalentObjectPropertiesAxiom ax :
            ontology.getEquivalentObjectPropertiesAxioms(property)) {
          if (isDisplayed(ax) && ax.getProperties().size() == 2) {
            Set<OWLObjectPropertyExpression> props = ax.getPropertiesMinus(property);
            properties.add(props.iterator().next(), ax);
            axioms.add(ax);
          }
        }
        writeSection(EQUIVALENT_TO, properties, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.DISJOINT_OBJECT_PROPERTIES)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap properties = new SectionMap();
        for (OWLDisjointObjectPropertiesAxiom ax :
            ontology.getDisjointObjectPropertiesAxioms(property)) {
          if (ax.getProperties().size() == 2 && isDisplayed(ax)) {
            Set<OWLObjectPropertyExpression> props = ax.getPropertiesMinus(property);
            properties.add(props.iterator().next(), ax);
            axioms.add(ax);
          }
        }
        writeSection(DISJOINT_WITH, properties, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
      for (OWLOntology ontology : getOntologies()) {
        for (OWLSubPropertyChainOfAxiom ax : ontology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
          if (ax.getSuperProperty().equals(property)) {
            if (isDisplayed(ax)) {
              SectionMap map = new SectionMap();
              map.add(ax.getPropertyChain(), ax);
              writeSection(SUB_PROPERTY_CHAIN, map, " o ", false, ontology);
              axioms.add(ax);
            }
          }
        }
      }
    }

    for (OWLOntology ontology : getOntologies()) {
      SectionMap characteristics = new SectionMap();
      if (!isFiltered(AxiomType.FUNCTIONAL_OBJECT_PROPERTY)) {
        for (OWLFunctionalObjectPropertyAxiom ax :
            ontology.getFunctionalObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(FUNCTIONAL.toString(), ax);
            axioms.add(ax);
          }
        }
      }

      if (!isFiltered(AxiomType.INVERSE_FUNCTIONAL_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getInverseFunctionalObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(INVERSE_FUNCTIONAL.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      if (!isFiltered(AxiomType.SYMMETRIC_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getSymmetricObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(SYMMETRIC.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      if (!isFiltered(AxiomType.TRANSITIVE_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getTransitiveObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(TRANSITIVE.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      if (!isFiltered(AxiomType.REFLEXIVE_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getReflexiveObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(REFLEXIVE.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      if (!isFiltered(AxiomType.IRREFLEXIVE_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getIrreflexiveObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(IRREFLEXIVE.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      if (!isFiltered(AxiomType.ASYMMETRIC_OBJECT_PROPERTY)) {
        for (OWLAxiom ax : ontology.getAsymmetricObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            characteristics.add(ASYMMETRIC.toString(), ax);
            axioms.add(ax);
          }
        }
      }
      writeSection(CHARACTERISTICS, characteristics, ",", true, ontology);
    }

    if (!isFiltered(AxiomType.OBJECT_PROPERTY_DOMAIN)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap expressions = new SectionMap();
        for (OWLObjectPropertyDomainAxiom ax : ontology.getObjectPropertyDomainAxioms(property)) {
          if (isDisplayed(ax)) {
            expressions.add(ax.getDomain(), ax);
            axioms.add(ax);
          }
        }
        writeSection(DOMAIN, expressions, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.OBJECT_PROPERTY_RANGE)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap expressions = new SectionMap();
        for (OWLObjectPropertyRangeAxiom ax : ontology.getObjectPropertyRangeAxioms(property)) {
          if (isDisplayed(ax)) {
            expressions.add(ax.getRange(), ax);
            axioms.add(ax);
          }
        }
        writeSection(RANGE, expressions, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.INVERSE_OBJECT_PROPERTIES)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLObjectPropertyExpression> properties = new TreeSet<OWLObjectPropertyExpression>();
        for (OWLInverseObjectPropertiesAxiom ax :
            ontology.getInverseObjectPropertyAxioms(property)) {
          if (isDisplayed(ax)) {
            if (ax.getFirstProperty().equals(property)) {
              properties.add(ax.getSecondProperty());
            } else {
              properties.add(ax.getFirstProperty());
            }
            axioms.add(ax);
          }
        }
        writeSection(INVERSE_OF, properties, ",", true, ontology);
      }
    }

    if (!isFiltered(AxiomType.SWRL_RULE)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLAxiom> rules = new HashSet<OWLAxiom>();
        for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) {
          if (isDisplayed(rule)) {
            for (SWRLAtom atom : rule.getHead()) {
              if (atom.getPredicate().equals(property)) {
                rules.add(rule);
                // XXX attempted patching
                writeSection(RULE, rules, ",", true, ontology);
                break;
              }
            }
          }
        }
      }
    }
    writeEntitySectionEnd(OBJECT_PROPERTY.toString());
    return axioms;
  }
  public Set<OWLAxiom> write(OWLClass cls) {
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    axioms.addAll(writeEntityStart(CLASS, cls));

    if (!isFiltered(AxiomType.EQUIVALENT_CLASSES)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap equivalentClasses = new SectionMap();
        for (OWLEquivalentClassesAxiom ax : ontology.getEquivalentClassesAxioms(cls)) {
          if (ax.getClassExpressions().size() == 2) {
            if (isDisplayed(ax)) {
              for (OWLClassExpression equivCls : ax.getClassExpressionsMinus(cls)) {
                equivalentClasses.add(equivCls, ax);
              }
              axioms.add(ax);
            }
          }
        }
        equivalentClasses.remove(cls);
        writeSection(EQUIVALENT_TO, equivalentClasses, ",", true, ontology);
      }
    }

    if (!isFiltered(AxiomType.SUBCLASS_OF)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap superclasses = new SectionMap();
        for (OWLSubClassOfAxiom ax : ontology.getSubClassAxiomsForSubClass(cls)) {
          if (isDisplayed(ax)) {
            superclasses.add(ax.getSuperClass(), ax);
            axioms.add(ax);
          }
        }
        writeSection(SUBCLASS_OF, superclasses, ",", true, ontology);
      }
      if (renderExtensions) {
        for (OWLOntology ont : getOntologies()) {
          SectionMap subClasses = new SectionMap();
          for (OWLSubClassOfAxiom ax : ont.getSubClassAxiomsForSuperClass(cls)) {
            if (isDisplayed(ax)) {
              subClasses.add(ax.getSubClass(), ax);
              axioms.add(ax);
            }
          }
          writeSection(SUPERCLASS_OF, subClasses, ",", true, ont);
        }
      }
    }
    if (!isFiltered(AxiomType.DISJOINT_CLASSES)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLAxiom> pairwiseDisjointClassesAxioms = new HashSet<OWLAxiom>();
        SectionMap disjointClasses = new SectionMap();
        for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(cls)) {
          if (isDisplayed(ax)) {
            if (ax.getClassExpressions().size() == 2) {
              pairwiseDisjointClassesAxioms.add(ax);
              OWLClassExpression disjointWith = ax.getClassExpressionsMinus(cls).iterator().next();
              disjointClasses.add(disjointWith, ax);
            }
            axioms.add(ax);
          }
        }
        writeSection(DISJOINT_WITH, disjointClasses, ", ", false, ontology);
        if (renderExtensions) {
          // Handling of nary in frame style
          for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(cls)) {
            if (isDisplayed(ax)) {
              if (ax.getClassExpressions().size() > 2) {
                Set<OWLClassExpression> allDisjointClasses =
                    new TreeSet<OWLClassExpression>(ax.getClassExpressions());
                allDisjointClasses.remove(cls);
                axioms.add(ax);
                writeSection(DISJOINT_CLASSES, allDisjointClasses, ", ", false, ontology);
              }
            }
          }
        }
      }
    }
    if (!isFiltered(AxiomType.HAS_KEY)) {
      for (OWLOntology ontology : getOntologies()) {
        for (OWLHasKeyAxiom ax : ontology.getHasKeyAxioms(cls)) {
          if (isDisplayed(ax)) {
            SectionMap map = new SectionMap();
            map.add(ax.getPropertyExpressions(), ax);
            writeSection(HAS_KEY, map, ", ", true, ontology);
          }
        }
      }
    }
    if (!isFiltered(AxiomType.CLASS_ASSERTION)) {
      for (OWLOntology ontology : getOntologies()) {
        SectionMap individuals = new SectionMap();
        for (OWLClassAssertionAxiom ax : ontology.getClassAssertionAxioms(cls)) {
          if (isDisplayed(ax)) {
            if (renderExtensions || ax.getIndividual().isAnonymous()) {
              individuals.add(ax.getIndividual(), ax);
              axioms.add(ax);
            }
          }
        }
        writeSection(INDIVIDUALS, individuals, ",", true, ontology);
      }
    }
    if (!isFiltered(AxiomType.SWRL_RULE)) {
      for (OWLOntology ontology : getOntologies()) {
        Set<OWLAxiom> rules = new HashSet<OWLAxiom>();
        for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) {
          if (isDisplayed(rule)) {
            for (SWRLAtom atom : rule.getHead()) {
              if (atom.getPredicate().equals(cls)) {
                writeSection(RULE, rules, ", ", true, ontology);
                break;
              }
            }
          }
        }
      }
    }
    writeEntitySectionEnd(CLASS.toString());
    return axioms;
  }
  public void writeOntology() throws OWLRendererException {
    if (ontologies.size() != 1) {
      throw new OWLRuntimeException("Can only render one ontology");
    }
    OWLOntology ontology = getOntologies().iterator().next();
    writePrefixMap();
    writeNewLine();
    writeOntologyHeader(ontology);

    for (OWLAnnotationProperty prop : ontology.getAnnotationPropertiesInSignature()) {
      write(prop);
    }
    for (OWLDatatype datatype : ontology.getDatatypesInSignature()) {
      write(datatype);
    }
    for (OWLObjectProperty prop : ontology.getObjectPropertiesInSignature()) {
      write(prop);
      OWLObjectPropertyExpression invProp = prop.getInverseProperty();
      if (!ontology.getAxioms(invProp).isEmpty()) {
        write(invProp);
      }
    }
    for (OWLDataProperty prop : ontology.getDataPropertiesInSignature()) {
      write(prop);
    }
    for (OWLClass cls : ontology.getClassesInSignature()) {
      write(cls);
    }
    for (OWLNamedIndividual ind : ontology.getIndividualsInSignature()) {
      write(ind);
    }
    for (OWLAnonymousIndividual ind : ontology.getReferencedAnonymousIndividuals()) {
      write(ind);
    }
    // Nary disjoint classes axioms
    event = new RendererEvent(this, ontology);
    for (OWLDisjointClassesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_CLASSES)) {
      if (ax.getClassExpressions().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getClassExpressions(), ax);
        writeSection(DISJOINT_CLASSES, map, ",", false, ontology);
      }
    }
    // Nary equivalent classes axioms
    for (OWLEquivalentClassesAxiom ax : ontology.getAxioms(AxiomType.EQUIVALENT_CLASSES)) {
      if (ax.getClassExpressions().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getClassExpressions(), ax);
        writeSection(EQUIVALENT_CLASSES, map, ",", false, ontology);
      }
    }
    // Nary disjoint properties
    for (OWLDisjointObjectPropertiesAxiom ax :
        ontology.getAxioms(AxiomType.DISJOINT_OBJECT_PROPERTIES)) {
      if (ax.getProperties().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getProperties(), ax);
        writeSection(DISJOINT_PROPERTIES, map, ",", false, ontology);
      }
    }
    // Nary equivlant properties
    for (OWLEquivalentObjectPropertiesAxiom ax :
        ontology.getAxioms(AxiomType.EQUIVALENT_OBJECT_PROPERTIES)) {
      if (ax.getProperties().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getProperties(), ax);
        writeSection(EQUIVALENT_PROPERTIES, map, ",", false, ontology);
      }
    }
    // Nary disjoint properties
    for (OWLDisjointDataPropertiesAxiom ax :
        ontology.getAxioms(AxiomType.DISJOINT_DATA_PROPERTIES)) {
      if (ax.getProperties().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getProperties(), ax);
        writeSection(DISJOINT_PROPERTIES, map, ",", false, ontology);
      }
    }
    // Nary equivalent properties
    for (OWLEquivalentDataPropertiesAxiom ax :
        ontology.getAxioms(AxiomType.EQUIVALENT_DATA_PROPERTIES)) {
      if (ax.getProperties().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getProperties(), ax);
        writeSection(EQUIVALENT_PROPERTIES, map, ",", false, ontology);
      }
    }
    // Nary different individuals
    for (OWLDifferentIndividualsAxiom ax : ontology.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS)) {
      if (ax.getIndividuals().size() > 2) {
        SectionMap map = new SectionMap();
        map.add(ax.getIndividuals(), ax);
        writeSection(DIFFERENT_INDIVIDUALS, map, ",", false, ontology);
      }
    }
    for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) {
      writeSection(RULE, Collections.singleton(rule), ", ", false);
    }
    flush();
  }
  public void writeSection(
      ManchesterOWLSyntax keyword,
      SectionMap content,
      String delimeter,
      boolean newline,
      OWLOntology... ontologiesList) {
    String sec = keyword.toString();
    if (!content.isEmpty() || renderingDirector.renderEmptyFrameSection(keyword, ontologiesList)) {
      fireSectionRenderingPrepared(sec);
      writeSection(keyword);
      writeOntologiesList(ontologiesList);
      incrementTab(4);
      writeNewLine();
      fireSectionRenderingStarted(sec);
      for (Iterator<?> it = content.getSectionObjects().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        Set<Set<OWLAnnotation>> annotationSets = content.getAnnotationsForSectionObject(obj);
        for (Iterator<Set<OWLAnnotation>> annosSetIt = annotationSets.iterator();
            annosSetIt.hasNext(); ) {
          Set<OWLAnnotation> annos = annosSetIt.next();
          fireSectionItemPrepared(sec);
          if (!annos.isEmpty()) {
            incrementTab(4);
            writeNewLine();
            write(ManchesterOWLSyntax.ANNOTATIONS.toString());
            write(": ");
            pushTab(getIndent() + 1);
            for (Iterator<OWLAnnotation> annoIt = annos.iterator(); annoIt.hasNext(); ) {
              annoIt.next().accept(this);
              if (annoIt.hasNext()) {
                write(", ");
                writeNewLine();
              }
            }
            popTab();
            popTab();
            writeNewLine();
          }
          // Write actual object
          if (obj instanceof OWLObject) {
            ((OWLObject) obj).accept(this);
          } else if (obj instanceof Collection) {
            for (Iterator<?> listIt = ((Collection<?>) obj).iterator(); listIt.hasNext(); ) {
              Object o = listIt.next();
              if (o instanceof OWLObject) {
                ((OWLObject) o).accept(this);
              } else {
                write(o.toString());
              }
              if (listIt.hasNext()) {
                write(delimeter);
                if (newline) {
                  writeNewLine();
                }
              }
            }

          } else {
            write(obj.toString());
          }
          if (it.hasNext()) {
            write(delimeter);
            fireSectionItemFinished(sec);
            if (newline) {
              writeNewLine();
            }
          } else {
            fireSectionItemFinished(sec);
          }

          if (annosSetIt.hasNext()) {
            write(",");
            writeNewLine();
          }
        }
      }
      fireSectionRenderingFinished(sec);
      popTab();
      writeNewLine();
      writeNewLine();
    }
  }