@Override public void visit(OWLEquivalentClassesAxiom axiom) { if (axiom.getClassExpressions().size() > 2) { Set<Set<OWLClassExpression>> rendered = new HashSet<Set<OWLClassExpression>>(); for (OWLClassExpression left : axiom.getClassExpressions()) { for (OWLClassExpression right : axiom.getClassExpressions()) { if (left != right) { Set<OWLClassExpression> cur = CollectionFactory.createSet(left, right); if (!rendered.contains(cur)) { rendered.add(cur); left.accept(this); writeSpace(); write(EQUIV); writeSpace(); right.accept(this); } } } } } else if (axiom.getClassExpressions().size() == 2) { Iterator<OWLClassExpression> it = axiom.getClassExpressions().iterator(); OWLClassExpression descA = it.next(); OWLClassExpression descB = it.next(); OWLClassExpression lhs; OWLClassExpression rhs; if (subject.equals(descA)) { lhs = descA; rhs = descB; } else { lhs = descB; rhs = descA; } lhs.accept(this); writeSpace(); write(EQUIV); writeSpace(); rhs.accept(this); } }
public void actionPerformed(ActionEvent e) { OWLClass selClass = getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); Set<OWLClassExpression> operands = new HashSet<OWLClassExpression>(); for (OWLOntology ont : getOWLModelManager().getActiveOntologies()) { for (OWLSubClassOfAxiom ax : ont.getSubClassAxiomsForSubClass(selClass)) { changes.add(new RemoveAxiom(ont, ax)); operands.add(ax.getSuperClass()); } } if (operands.isEmpty()) { return; } OWLDataFactory df = getOWLModelManager().getOWLDataFactory(); OWLClassExpression equCls; if (operands.size() == 1) { equCls = operands.iterator().next(); } else { equCls = df.getOWLObjectIntersectionOf(operands); } OWLAxiom ax = df.getOWLEquivalentClassesAxiom(CollectionFactory.createSet(selClass, equCls)); changes.add(new AddAxiom(getOWLModelManager().getActiveOntology(), ax)); getOWLModelManager().applyChanges(changes); }
@Override public Set<OWLDataRange> getOperands() { return CollectionFactory.getCopyOnRequestSetFromImmutableCollection(operands); }
/** @return the resulting owl objects */ public Set<OWLObject> getResult() { return CollectionFactory.getCopyOnRequestSetFromMutableCollection(result); }
@Override public Set<OWLClassExpression> getClassExpressions() { return CollectionFactory.getCopyOnRequestSetFromImmutableCollection(classExpressions); }
public Set<V> getValues(K key) { return CollectionFactory.getCopyOnRequestSetFromMutableCollection(map.get(key)); }
public Set<K> keySet() { return CollectionFactory.getCopyOnRequestSetFromMutableCollection(map.keySet()); }
@Override public Set<OWLFacetRestriction> getFacetRestrictions() { return CollectionFactory.getCopyOnRequestSetFromImmutableCollection(facetRestrictions); }
protected OWLEquivalentObjectPropertiesAxiom createAxiom(OWLObjectPropertyExpression object) { return getOWLDataFactory() .getOWLEquivalentObjectPropertiesAxiom( CollectionFactory.createSet(getRootObject(), object)); }
@Override public Set<SWRLAtom> getHead() { return CollectionFactory.getCopyOnRequestSetFromImmutableCollection(head); }