*/
public void writeOntology() throws OWLRendererException {
if (ontologies.size() != 1) {
throw new OWLRuntimeException("Can only render one ontology");
}
OWLOntology ontology = ontologies.iterator().next();
assert ontology != null;
writePrefixMap();
writeNewLine();
writeOntologyHeader(ontology);
for (OWLAnnotationProperty prop : ontology
.getAnnotationPropertiesInSignature(EXCLUDED)) {
assert prop != null;
write(prop);
}
for (OWLDatatype datatype : ontology.getDatatypesInSignature()) {
assert datatype != null;
write(datatype);
}
for (OWLObjectProperty prop : ontology.getObjectPropertiesInSignature()) {
assert prop != null;
write(prop);
OWLObjectPropertyExpression invProp = prop.getInverseProperty();
if (!ontology.getAxioms(invProp, EXCLUDED).isEmpty()) {
write(invProp);
}
}
for (OWLDataProperty prop : ontology.getDataPropertiesInSignature()) {
assert prop != null;
write(prop);
}
for (OWLClass cls : ontology.getClassesInSignature()) {
assert cls != null;
write(cls);
}
for (OWLNamedIndividual ind : ontology.getIndividualsInSignature()) {
assert ind != null;
write(ind);
}
for (OWLAnonymousIndividual ind : ontology
.getReferencedAnonymousIndividuals(EXCLUDED)) {
assert ind != null;
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<Object, OWLAxiom> map = new SectionMap<>();
map.put(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<Object, OWLAxiom> map = new SectionMap<>();
map.put(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<Object, OWLAxiom> map = new SectionMap<>();
map.put(ax.getProperties(), ax);
writeSection(DISJOINT_PROPERTIES, map, ",", false, ontology);
}
}
// Nary equivalent properties
for (OWLEquivalentObjectPropertiesAxiom ax : ontology
.getAxioms(AxiomType.EQUIVALENT_OBJECT_PROPERTIES)) {
if (ax.getProperties().size() > 2) {
SectionMap<Object, OWLAxiom> map = new SectionMap<>();
map.put(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<Object, OWLAxiom> map = new SectionMap<>();
map.put(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<Object, OWLAxiom> map = new SectionMap<>();
map.put(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<Object, OWLAxiom> map = new SectionMap<>();
map.put(ax.getIndividuals(), ax);
writeSection(DIFFERENT_INDIVIDUALS, map, ",", false, ontology);
}
}
for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) {
@SuppressWarnings("null")
@Nonnull
Set<SWRLRule> singleton = Collections.singleton(rule);
writeSection(RULE, singleton, ", ", false);
}