Ejemplo n.º 1
0
 @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);
 }
 protected OWLEquivalentObjectPropertiesAxiom createAxiom(OWLObjectPropertyExpression object) {
   return getOWLDataFactory()
       .getOWLEquivalentObjectPropertiesAxiom(
           CollectionFactory.createSet(getRootObject(), object));
 }