org.protege.editor.owl.ui.frame.individual.OWLDataPropertyAssertionAxiomFrameSection Maven / Gradle / Ivy
The newest version!
package org.protege.editor.owl.ui.frame.individual;
import org.protege.editor.owl.OWLEditorKit;
import org.protege.editor.owl.model.inference.ReasonerPreferences.OptionalInferenceTask;
import org.protege.editor.owl.ui.editor.OWLDataPropertyRelationshipEditor;
import org.protege.editor.owl.ui.editor.OWLObjectEditor;
import org.protege.editor.owl.ui.frame.AbstractOWLFrameSection;
import org.protege.editor.owl.ui.frame.OWLDataPropertyConstantPair;
import org.protege.editor.owl.ui.frame.OWLFrame;
import org.protege.editor.owl.ui.frame.OWLFrameSectionRow;
import org.semanticweb.owlapi.model.*;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
/**
* Author: Matthew Horridge
* The University Of Manchester
* Bio-Health Informatics Group
* Date: 30-Jan-2007
*/
public class OWLDataPropertyAssertionAxiomFrameSection extends AbstractOWLFrameSection {
public static final String LABEL = "Data property assertions";
private OWLDataPropertyRelationshipEditor editor;
private Set added = new HashSet<>();
protected void clear() {
if (editor != null) {
editor.clear();
}
}
public OWLDataPropertyAssertionAxiomFrameSection(OWLEditorKit editorKit, OWLFrame frame) {
super(editorKit, LABEL, "Data property assertion", frame);
}
/**
* Refills the section with rows. This method will be called
* by the system and should be directly called.
*/
protected void refill(OWLOntology ontology) {
added.clear();
for (OWLDataPropertyAssertionAxiom ax : ontology.getDataPropertyAssertionAxioms(getRootObject())) {
addRow(new OWLDataPropertyAssertionAxiomFrameSectionRow(getOWLEditorKit(),
this,
ontology,
getRootObject(),
ax));
added.add(ax);
}
}
protected void refillInferred() {
getOWLModelManager().getReasonerPreferences().executeTask(OptionalInferenceTask.SHOW_INFERRED_DATA_PROPERTY_ASSERTIONS, () -> {
if (!getOWLModelManager().getReasoner().isConsistent()) {
return;
}
if (!getRootObject().isAnonymous()){
for (OWLDataProperty dp : getReasoner().getRootOntology().getDataPropertiesInSignature(true)) {
Set values = getReasoner().getDataPropertyValues(getRootObject().asOWLNamedIndividual(), dp);
for (OWLLiteral constant : values) {
OWLDataPropertyAssertionAxiom ax = getOWLDataFactory().getOWLDataPropertyAssertionAxiom(dp,
getRootObject(),
constant);
if (!added.contains(ax)) {
addRow(new OWLDataPropertyAssertionAxiomFrameSectionRow(getOWLEditorKit(),
OWLDataPropertyAssertionAxiomFrameSection.this,
null,
getRootObject(),
ax));
}
}
}
}
});
}
protected OWLDataPropertyAssertionAxiom createAxiom(OWLDataPropertyConstantPair object) {
return getOWLDataFactory().getOWLDataPropertyAssertionAxiom(object.getProperty(),
getRootObject(),
object.getConstant());
}
public OWLObjectEditor getObjectEditor() {
if (editor == null) {
editor = new OWLDataPropertyRelationshipEditor(getOWLEditorKit());
}
return editor;
}
/**
* Obtains a comparator which can be used to sort the rows
* in this section.
* @return A comparator if to sort the rows in this section,
* or null
if the rows shouldn't be sorted.
*/
public Comparator> getRowComparator() {
return null;
}
@Override
protected boolean isResettingChange(OWLOntologyChange change) {
return change.isAxiomChange() &&
change.getAxiom() instanceof OWLDataPropertyAssertionAxiom &&
((OWLDataPropertyAssertionAxiom) change.getAxiom()).getSubject().equals(getRootObject());
}
}