Java 类org.semanticweb.owlapi.model.OWLEntity 实例源码

项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getPrefLabels(OWLEntity cpt) {
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLAnnotationProperty prop = annot.getProperty();
            // The DOE prefLabel, if they exist
            if(prop.getIRI().equals(prefLabelIRI) ||
                prop.getIRI().equals(SKOSVocabulary.PREFLABEL.getIRI()) ||
                prop.getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI())) {

                OWLLiteral literal = (OWLLiteral)annot.getValue();
                finalLabels.add(literal.getLiteral());
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getPrefLabels(OWLEntity cpt, String lang) {
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLAnnotationProperty prop = annot.getProperty();
            // The DOE prefLabel, if they exist
            if(prop.getIRI().equals(prefLabelIRI) ||
                prop.getIRI().equals(SKOSVocabulary.PREFLABEL.getIRI()) ||
                prop.getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI())) {

                OWLLiteral literal = (OWLLiteral)annot.getValue();
                if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
                        // ou si il n'y en a pas et que c'est voulu
                        || (!literal.hasLang() && lang.equals(""))) { 

                    finalLabels.add(literal.getLiteral());
                }
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLAnnotationProperty prop = annot.getProperty();
            // The DOE prefLabel, if they exist
            if(prop.getIRI().equals(altLabelIRI) ||
                prop.getIRI().equals(hiddenLabelIRI) ||
                prop.getIRI().equals(SKOSVocabulary.ALTLABEL.getIRI()) ||
                prop.getIRI().equals(SKOSVocabulary.HIDDENLABEL.getIRI())) {

                OWLLiteral literal = (OWLLiteral)annot.getValue();
                finalLabels.add(literal.getLiteral());
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLAnnotationProperty prop = annot.getProperty();
            // The DOE prefLabel, if they exist
            if(prop.getIRI().equals(altLabelIRI) ||
                prop.getIRI().equals(hiddenLabelIRI) ||
                prop.getIRI().equals(SKOSVocabulary.ALTLABEL.getIRI()) ||
                prop.getIRI().equals(SKOSVocabulary.HIDDENLABEL.getIRI())) {

                OWLLiteral literal = (OWLLiteral)annot.getValue();
                if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
                        // ou si il n'y en a pas et que c'est voulu
                        || (!literal.hasLang() && lang.equals(""))) { 

                    finalLabels.add(literal.getLiteral());
                }
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");

    // The rdfs:label, if it exists
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(
            ontology,
            df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            finalLabels.add(((OWLLiteral)annot.getValue()).getLiteral());
        }
    }
    return finalLabels;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");

    // The rdfs:label, if it exists
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(
            ontology,
            df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLLiteral literal = (OWLLiteral)annot.getValue();
            // Si il y a une langue et que c'est celle en parametre
            if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
                    // ou si il n'y en a pas et que c'est voulu
                    || (!literal.hasLang() && lang.equals(""))) { 

                String label = literal.getLiteral();
                finalLabels.add(label);
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<OWLEntity> getChildren(OWLEntity cpt) {
    if(!cpt.isOWLClass()) return new HashSet<OWLEntity>();

    Set<OWLEntity> entities = new HashSet<OWLEntity>();
    Set<OWLEntity> result = new HashSet<OWLEntity>();
    OWLClass localRootClass = cpt.asOWLClass();
    entities.addAll(reasoner.getSubClasses(localRootClass, true).getFlattened());
    entities.addAll(reasoner.getInstances(localRootClass, true).getFlattened());        
    for(OWLEntity child : entities) {
        // Only Class or Named individual
        if(!child.isOWLClass() && !child.isOWLNamedIndividual())
        {
            continue;
        }
        // Not Nothing
        if(child.isOWLClass() && child.asOWLClass().isOWLNothing())
        {
            continue;
        }
        result.add(child);
    }
    return result;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<OWLEntity> getParents(OWLEntity cpt) {
    if(!cpt.isOWLClass()) return new HashSet<OWLEntity>();

    Set<OWLEntity> entities = new HashSet<OWLEntity>();
    Set<OWLEntity> result = new HashSet<OWLEntity>();
    OWLClass localRootClass = cpt.asOWLClass();
    entities.addAll(reasoner.getSuperClasses(localRootClass, true).getFlattened());
    for(OWLEntity parentClass : entities) {
        // Only Class
        if(!parentClass.isOWLClass())
        {
            continue;
        }
        // Not Nothing
        if(parentClass.isOWLClass() && parentClass.asOWLClass().isOWLNothing())
        {
            continue;
        }
        result.add(parentClass);
    }
    return result;
}
项目:OWLAx    文件:OWLCellRenderer.java   
private void highlightPropertyIfUnsatisfiable(final OWLEntity entity, final StyledDocument doc,
        final int tokenStartIndex, final int tokenLength) {
    try {
        getOWLModelManager().getReasonerPreferences()
                .executeTask(OptionalInferenceTask.SHOW_OBJECT_PROPERTY_UNSATISFIABILITY, () -> {
                    OWLObjectProperty prop = (OWLObjectProperty) entity;
                    OWLReasoner reasoner = getOWLModelManager().getReasoner();
                    boolean consistent = reasoner.isConsistent();
                    if (!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
                        doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
                    }
                });
    } catch (Exception e) {
        logger.warn("An error occurred whilst highlighting an unsatisfiable property: {}", e);
    }
}
项目:minerva    文件:GafToLegoTranslator.java   
/**
 * Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
 * Additionally minimize the lego model and imports into one ontology module.
 * 
 * @param gaf
 * @return minimized lego ontology
 */
public OWLOntology minimizedTranslate(GafDocument gaf) {
    OWLOntology all = translate(gaf);
    final OWLOntologyManager m = all.getOWLOntologyManager();

    SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
    Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
    Set<OWLAxiom> moduleAxioms = sme.extract(sig);

    try {
        OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
        m.addAxioms(module, moduleAxioms);
        return module;
    } catch (OWLException e) {
        throw new RuntimeException("Could not create minimized lego model.", e);
    }
}
项目:DL-Learner-Protege-Plugin    文件:ProtegePlugin.java   
@Override
public void initialise() throws Exception {
    System.out.println("Initializing DL-Learner plugin for " + getAxiomType().getName() + " axioms...");

    // initialize the manager
    Manager manager = Manager.getInstance(getOWLEditorKit());
    manager.setAxiomType(getAxiomType());

    // create the view
    view = new DLLearnerView(getOWLEditorKit(),
            getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().getSelectedEntity(), 
            getAxiomType());

    manager.setProgressMonitor(view.getStatusBar());
    manager.addProgressMonitor(view);

    OWLEntity entity = getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().getSelectedEntity();
    manager.setEntity(entity);

    // add listeners
    addListeners();

    ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer());
}
项目:logmap-matcher    文件:BasicMultiplePartitioning.java   
private void createOverlappingEstimation(OWLOntology ontology, Set<OWLEntity> entities, Set<OWLAxiom> overlapping){

    //Module: overlapping overestimation
    OntologyModuleExtractor module_extractor =
            new OntologyModuleExtractor(
                    SynchronizedOWLManager.createOWLOntologyManager(),
                    ontology.getAxioms(),
                    true,
                    false,
                    true);
    //OWLOntology module_source = module_extractor_source.extractAsOntology(
    //      entities_source, 
    //      IRI.create(source.getOntologyID().getOntologyIRI().toString()));
    overlapping = module_extractor.extract(entities);

    module_extractor.clearStrutures();

    //Remove original ontology
    ontology.getOWLOntologyManager().removeOntology(ontology);
    ontology=null;

    entities.clear();

}
项目:jopa    文件:SelectResultSet.java   
private <T> T owlObjectToType(OWLObject owlValue, Class<T> cls) throws OntoDriverException {
    if (cls.isAssignableFrom(owlValue.getClass())) {
        return cls.cast(owlValue);
    }
    if (owlValue instanceof OWLLiteral) {
        final Object ob = OwlapiUtils.owlLiteralToValue((OWLLiteral) owlValue);
        if (cls.isAssignableFrom(ob.getClass())) {
            return cls.cast(ob);
        }
    } else {
        final Set<OWLEntity> sig = owlValue.getSignature();
        if (!sig.isEmpty()) {
            final URI uri = URI.create(sig.iterator().next().toStringID());
            if (cls.isAssignableFrom(uri.getClass())) {
                return cls.cast(uri);
            }
            return tryInstantiatingClassUsingConstructor(cls, uri);
        }
    }
    throw new OwlapiDriverException("Conversion to type " + cls + " is not supported.");
}
项目:jcel    文件:AxiomTranslator.java   
@Override
public Set<ComplexIntegerAxiom> visit(OWLDeclarationAxiom axiom) {
    Objects.requireNonNull(axiom);
    OWLEntity entity = axiom.getEntity();
    if (entity.isOWLClass()) {
        return declare(entity.asOWLClass(), axiom.getAnnotations());

    } else if (entity.isOWLObjectProperty()) {
        return declare(entity.asOWLObjectProperty(), axiom.getAnnotations());

    } else if (entity.isOWLNamedIndividual()) {
        return declare(entity.asOWLNamedIndividual(), axiom.getAnnotations());

    } else if (entity.isOWLDataProperty()) {
        return declare(entity.asOWLDataProperty(), axiom.getAnnotations());

    } else if (entity.isOWLAnnotationProperty()) {
        // FIXME add annotation property
        return Collections.emptySet();

    } else {
        throw TranslationException.newUnsupportedAxiomException(axiom);

    }
}
项目:owltools    文件:OldSimpleOwlSim.java   
/**
 * @param populationClass
 * @param sampleSetClass
 * @param enrichedClass
 * @return enrichment
 * @throws MathException
 */
public EnrichmentResult calculatePairwiseEnrichment(OWLClass populationClass,
        OWLClass sampleSetClass, OWLClass enrichedClass) throws MathException {
    HypergeometricDistributionImpl hg = 
        new HypergeometricDistributionImpl(
                getNumElementsForAttribute(populationClass),
                getNumElementsForAttribute(sampleSetClass),
                getNumElementsForAttribute(enrichedClass)
        );
    /*
    LOG.info("popsize="+getNumElementsForAttribute(populationClass));
    LOG.info("sampleSetSize="+getNumElementsForAttribute(sampleSetClass));
    LOG.info("enrichedClass="+getNumElementsForAttribute(enrichedClass));
    */
    Set<OWLEntity> eiSet = getElementsForAttribute(sampleSetClass);
    eiSet.retainAll(this.getElementsForAttribute(enrichedClass));
    //LOG.info("both="+eiSet.size());
    double p = hg.cumulativeProbability(eiSet.size(), 
            Math.min(getNumElementsForAttribute(sampleSetClass),
                    getNumElementsForAttribute(enrichedClass)));
    double pCorrected = p * getCorrectionFactor(populationClass);
    return new EnrichmentResult(sampleSetClass, enrichedClass, p, pCorrected);      
}
项目:owltools    文件:OldSimpleOwlSim.java   
private Set<OWLClass> addElement(OWLEntity e, Set<OWLClass> atts) {
    // TODO - fully fold TBox so that expressions of form (inh (part_of x))
    // generate a class "part_of x", to ensure that a SEP grouping class is created
    Set<OWLClass> attClasses = new HashSet<OWLClass>();
    for (OWLClass attClass : atts) {

        // filtering, e.g. Type :human. This is a somewhat unsatisfactory way to do this;
        // better to filter at the outset
        if (attClass instanceof OWLClass && ignoreSubClassesOf != null && ignoreSubClassesOf.size() > 0) {
            if (this.getReasoner().getSuperClasses(attClass, false).getFlattened().retainAll(ignoreSubClassesOf)) {
                continue;
            }
        }
        if (!this.attributeToElementsMap.containsKey(attClass))
            attributeToElementsMap.put(attClass, new HashSet<OWLEntity>());
        attributeToElementsMap.get(attClass).add(e);
        attClasses.add(attClass);
    }

    // note this only caches direct associations
    this.elementToAttributesMap.put(e, attClasses);
    return attClasses;
}
项目:owltools    文件:OldSimpleOwlSim.java   
public void precomputeAttributeElementCount() {
    if (attributeElementCount != null)
        return;
    attributeElementCount = new HashMap<OWLClass, Integer>();
    for (OWLEntity e : this.getAllElements()) {
        LOG.info("Adding 1 to all attributes of "+e);
        for (OWLClass dc : getAttributesForElement(e)) {
            for (Node<OWLClass> n : this.getNamedReflexiveSubsumers(dc)) {
                for (OWLClass c : n.getEntities()) {
                    if (!attributeElementCount.containsKey(c))
                        attributeElementCount.put(c, 1);
                    else
                        attributeElementCount.put(c, attributeElementCount.get(c)+1);
                }
            }

        }
    }
}
项目:owltools    文件:Mooncat.java   
/**
 * 
 * returns set of entities that belong to a referenced ontology that are referenced in the source ontology.
 * 
 * If the source ontology is not explicitly declared, then all entities that are referenced in the source
 * ontology and declared in a reference ontology are returned.
 * 
 * Example: if the source ontology is cl, and cl contains axioms that reference go:1, go:2, ...
 * and go is in the set of referenced ontologies, then {go:1,go:2,...} will be in the returned set.
 * It is irrelevant whether go:1, ... is declared in the source (e.g. MIREOTed)
 * 
 * Note this only returns direct references. See
 * {@link #getClosureOfExternalReferencedEntities()} for closure of references
 * 
 * @return all objects referenced by source ontology
 */
public Set<OWLEntity> getExternalReferencedEntities() {
    OWLOntology ont = graph.getSourceOntology();
    Set<OWLEntity> objs = ont.getSignature(Imports.EXCLUDED);
    Set<OWLEntity> refObjs = new HashSet<OWLEntity>();
    LOG.info("testing "+objs.size()+" objs to see if they are contained in: "+getReferencedOntologies());
    for (OWLEntity obj : objs) {
        //LOG.info("considering: "+obj);
        // a reference ontology may have entities from the source ontology MIREOTed in..
        // allow a configuration with the URI prefix specified
        if (isInExternalOntology(obj)) {
            refObjs.add(obj);

        }
    }
    LOG.info("#refObjs: "+refObjs.size());

    return refObjs;
}
项目:owltools    文件:OWLConverter.java   
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
        OWLOntology ontology, OWLEntity subject, 
        OWLAnnotationValue type,
        OWLAnnotationProperty property, 
        OWLAnnotationValue value) {
    OWLOntologyManager manager = ontology.getOWLOntologyManager();
    OWLDataFactory dataFactory = manager.getOWLDataFactory();
    OWLAnnotationProperty hasSynonymType =
        dataFactory.getOWLAnnotationProperty(
            format.getIRI("oio:hasSynonymType"));
    OWLAnnotation annotation = 
        dataFactory.getOWLAnnotation(hasSynonymType, type);
    Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
    annotations.add(annotation);
    OWLAnnotationAssertionAxiom axiom =
        dataFactory.getOWLAnnotationAssertionAxiom(
            property, subject.getIRI(), value,
            annotations);
    manager.addAxiom(ontology, axiom);
    return axiom;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * fetches the value of a single-valued annotation property for an OWLObject
 * <p>
 * TODO: provide a flag that determines behavior in the case of >1 value
 * 
 * @param c
 * @param lap
 * @return value
 */
public String getAnnotationValue(OWLObject c, OWLAnnotationProperty lap) {
    Set<OWLAnnotation>anns = new HashSet<OWLAnnotation>();
    if (c instanceof OWLEntity) {
        for (OWLOntology ont : getAllOntologies()) {
            anns.addAll(OwlHelper.getAnnotations((OWLEntity) c, lap, ont));
        }
    }
    else {
        return null;
    }
    for (OWLAnnotation a : anns) {
        if (a.getValue() instanceof OWLLiteral) {
            OWLLiteral val = (OWLLiteral) a.getValue();
            return val.getLiteral(); // return first - TODO - check zero or one
        }
    }
    return null;
}
项目:owltools    文件:OWLGraphWrapper.java   
/**
 * It returns array of synonyms (is encoded as synonym in obo format and IAO_0000118 annotation property in OWL format) of a class
 * @param c
 * @return array of strings or null
 */
@Deprecated
public String[] getSynonymStrings(OWLObject c) {
    OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(IRI.create(DEFAULT_IRI_PREFIX + "IAO_0000118")); 
    Set<OWLAnnotation>anns = null;
    if (c instanceof OWLEntity) {
        anns = OwlHelper.getAnnotations((OWLEntity) c, lap, sourceOntology);
    }
    else {
        return null;
    }

    List<String> list = new ArrayList<String>();
    for (OWLAnnotation a : anns) {
        if (a.getValue() instanceof OWLLiteral) {
            OWLLiteral val = (OWLLiteral) a.getValue();
            list.add(val.getLiteral()); // return first - todo - check zero or one
        }
    }
    return list.toArray(new String[list.size()]);
}
项目:neo4j-sparql-extension-yars    文件:PredicateVariableExtractor.java   
/**
 * Extracts {@link PredicateVariableExtractor} rules.
 * 
 * @param ot ontology
 * @return extracted rules
 */
@Override
public List<Rule> extract(OWLOntology ot) {
    List<Rule> list = new ArrayList<>();
    // list of predicates in ontology
    List<String> ps = new ArrayList<>();
    ps.add(TOPOBJ);
    ps.add(TOPDATA);
    OWLEntity e;
    String op;
    // check all declarations
    for (OWLDeclarationAxiom a : ot.getAxioms(AxiomType.DECLARATION)) {
        e = a.getEntity();
        if (e.isOWLObjectProperty()) {
            // if it is a object property declaration, add it to the list
            // and also add it as subproperty of owl:topObjectProperty
            op = getString(e.asOWLObjectProperty());
            ps.add(op);
            list.add(new SubPropertyOf(op, TOPOBJ));
        } else if (e.isOWLDataProperty()) {
            // if it is a data property declaration, add it to the list
            // and also add it as subproperty of owl:topDataProperty
            op = getString(e.asOWLDataProperty());
            ps.add(op);
            list.add(new SubPropertyOf(op, TOPDATA));
        }
    }
    list.add(new PredicateVariable(ps));
    return list;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public OWLEntity visit(OWLClass desc) {
    if(!desc.isOWLNothing()) {
        visitor.visit(desc);
    }
    return super.visit(desc);
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<OWLEntity> getAllConcepts() {
    // Only class and properties
    Set<OWLEntity> result = new HashSet<OWLEntity>();
    result.addAll(ontology.getClassesInSignature());
    result.addAll(ontology.getIndividualsInSignature());
    return result;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<OWLEntity> getAllProperties() {
    // Only class and properties
    Set<OWLEntity> result = new HashSet<OWLEntity>();
    result.addAll(ontology.getObjectPropertiesInSignature());
    return result;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getPrefLabels(OWLEntity cpt) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");
    // No pref label in pure OWL...
    return Collections.emptySet();
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getPrefLabels(OWLEntity cpt, String lang) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");
    // No pref label in pure OWL...
    return Collections.emptySet();
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public OWLEntity getConceptFromURI(URI uri) {
    OWLClass res = df.getOWLClass(IRI.create(uri));
    if(ontology.isDeclared(res))
        return res;
    return null;
}
项目:OWLAx    文件:OWLCellRenderer.java   
protected Component prepareRenderer(Object value, boolean isSelected, boolean hasFocus) {
    renderingComponent.setOpaque(isSelected || opaque);

    if (value instanceof OWLEntity) {
        OWLEntity entity = (OWLEntity) value;
        OWLDeclarationAxiom declAx = getOWLModelManager().getOWLDataFactory().getOWLDeclarationAxiom(entity);
        if (getOWLModelManager().getActiveOntology().containsAxiom(declAx)) {
            ontology = getOWLModelManager().getActiveOntology();
        }
        entity.accept(activeEntityVisitor);
        if (OWLUtilities.isDeprecated(getOWLModelManager(), entity)) {
            setStrikeThrough(true);
        } else {
            setStrikeThrough(false);
        }
    }

    prepareTextPane(getRendering(value), isSelected);

    if (isSelected) {
        renderingComponent.setBackground(SELECTION_BACKGROUND);
        textPane.setForeground(SELECTION_FOREGROUND);
    } else {
        renderingComponent.setBackground(componentBeingRendered.getBackground());
        textPane.setForeground(componentBeingRendered.getForeground());
    }

    final Icon icon = getIcon(value);
    iconLabel.setIcon(icon);
    if (icon != null) {
        iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), plainFontHeight));
    }
    renderingComponent.revalidate();
    return renderingComponent;
}
项目:OWLAx    文件:OWLCellRenderer.java   
protected Color getColor(OWLEntity entity, Color defaultColor) {
    for (OWLEntityColorProvider prov : entityColorProviders) {
        Color c = prov.getColor(entity);
        if (c != null) {
            return c;
        }
    }
    return defaultColor;
}
项目:OWLAx    文件:OWLCellRenderer.java   
private void renderHyperlink(OWLEntity curEntity, int tokenStartIndex, int tokenLength, StyledDocument doc) {
    try {
        Rectangle startRect = textPane.modelToView(tokenStartIndex);
        Rectangle endRect = textPane.modelToView(tokenStartIndex + tokenLength);
        if (startRect != null && endRect != null) {
            int width = endRect.x - startRect.x;
            int heght = startRect.height;

            Rectangle tokenRect = new Rectangle(startRect.x, startRect.y, width, heght);
            tokenRect.grow(0, -2);
            if (linkedObjectComponent.getMouseCellLocation() != null) {
                Point mouseCellLocation = linkedObjectComponent.getMouseCellLocation();
                if (mouseCellLocation != null) {
                    mouseCellLocation = SwingUtilities.convertPoint(renderingComponent, mouseCellLocation,
                            textPane);
                    if (tokenRect.contains(mouseCellLocation)) {
                        doc.setCharacterAttributes(tokenStartIndex, tokenLength, linkStyle, false);
                        linkedObjectComponent.setLinkedObject(curEntity);
                        linkRendered = true;
                    }
                }
            }
        }
    } catch (BadLocationException e) {
        //e.printStackTrace();
    }
}
项目:owltools    文件:OWLConverter.java   
/**
 * Convenience method for adding an annotation assertion to the
 * ontology.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param property the annotation property
 * @param value the annotation value
 * @return the annotation axiom
 */
protected static OWLAnnotationAssertionAxiom annotate(
        OWLOntology ontology, 
        OWLEntity subject,
        OWLAnnotationProperty property, 
        OWLAnnotationValue value) {
    OWLOntologyManager manager = ontology.getOWLOntologyManager();
    OWLDataFactory dataFactory = manager.getOWLDataFactory();
    OWLAnnotationAssertionAxiom axiom =
        dataFactory.getOWLAnnotationAssertionAxiom(
            property, subject.getIRI(), value);
    manager.addAxiom(ontology, axiom);
    return axiom;
}
项目:minerva    文件:InferenceProviderCreatorImpl.java   
@Override
public InferenceProvider create(ModelContainer model) throws OWLOntologyCreationException, InterruptedException {
    OWLOntology ont = model.getAboxOntology();
    final OWLOntologyManager m = ont.getOWLOntologyManager();
    OWLOntology module = null;
    OWLReasoner reasoner = null;
    try {
        InferenceProvider provider;
        synchronized (ont) {
            concurrentLock.acquire();
            try {
                if (useSLME) {
                    LOG.info("Creating for module: "+model.getModelId());
                    ModuleType mtype = ModuleType.BOT;
                    SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, ont, mtype);
                    Set<OWLEntity> seeds = new HashSet<OWLEntity>(ont.getIndividualsInSignature());
                    module = ont = sme.extractAsOntology(seeds, IRI.generateDocumentIRI());
                    LOG.info("Done creating module: "+model.getModelId());
                }
                reasoner = rf.createReasoner(ont);
                provider = MapInferenceProvider.create(reasoner, ont);
            }
            finally {
                concurrentLock.release();
            }
        }
        return provider;
    }
    finally {
        if (reasoner != null) {
            reasoner.dispose();
        }
        if (module != null) {
            m.removeOntology(module);
        }
    }

}
项目:minerva    文件:MolecularModelManager.java   
@Deprecated
public Set<IRI> searchModels(Collection<String> ids) throws IOException {
    final Set<IRI> resultSet = new HashSet<>();
    // create IRIs
    Set<IRI> searchIRIs = new HashSet<IRI>();
    for(String id : ids) {
        searchIRIs.add(graph.getIRIByIdentifier(id));
    }

    if (!searchIRIs.isEmpty()) {
        // search for IRI usage in models
        final Set<IRI> allModelIds = getAvailableModelIds();
        for (IRI modelId : allModelIds) {
            final ModelContainer model = getModel(modelId);
            final OWLOntology aboxOntology = model.getAboxOntology();
            Set<OWLEntity> signature = aboxOntology.getSignature();
            for (OWLEntity entity : signature) {
                if (searchIRIs.contains(entity.getIRI())) {
                    resultSet.add(modelId);
                    break;
                }
            }
        }
    }
    // return results
    return resultSet;
}
项目:pronto    文件:ProntoLoaderUtils.java   
/**
 * Loads conditional constraints from an ontology with annotated axioms
 * 
 * @param ontology
 * @param signature 
 * @param declAxioms Used to return declaration axioms for auto-generated class names
 * @param iriPrefix IRI prefix for auto-generated class names
 * @param raxList
 * @return
 */
public static Set<ConditionalConstraint> loadDefaultConstraintsFromOWL(
        OWLOntology ontology,
        Map<String, OWLClassExpression> nameMap,
        Set<OWLEntity> signature,
        List<RemoveAxiom> raxList, String iriPrefix,
        OWLOntologyManager manager) {

    Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
    //Begin with generic (default) subclass-of axioms
    for( OWLAxiom axiom : ontology.getAxioms( AxiomType.SUBCLASS_OF ) ) {
        for( OWLAnnotation annotation : axiom.getAnnotations() ) {

            if( Constants.CERTAINTY_ANNOTATION_URI.equals(annotation.getProperty().getIRI().toURI() ) ) {

                OWLSubClassOfAxiom sbAxiom = (OWLSubClassOfAxiom) axiom;
                String subClassIRI = generateClassName(sbAxiom.getSubClass(), nameMap, iriPrefix);
                String superClassIRI = generateClassName(sbAxiom.getSuperClass(), nameMap, iriPrefix);
                ConditionalConstraint cc = newConstraint(subClassIRI, superClassIRI, annotation.getValue().toString());

                signature.addAll( sbAxiom.getSubClass().getClassesInSignature() );
                signature.addAll( sbAxiom.getSuperClass().getClassesInSignature() );

                if( null != cc ) {

                    ccSet.add( cc );

                    if( null != raxList ) {
                        raxList.add( new RemoveAxiom( ontology, axiom ) );
                    }
                }
            }
        }
    }

    return ccSet;
}
项目:owltools    文件:OWLConverter.java   
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param typeCURIE a CURIE string for the type of synonym
 * @param propertyCURIE a CURIE string for the property
 * @param value the string value of the synonym
 * @return the axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
        OWLOntology ontology, OWLEntity subject,
        String typeCURIE, String propertyCURIE, String value) {
    OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
        getOWLDataFactory();
    IRI type = format.getIRI(typeCURIE);
    OWLAnnotationProperty property =
        dataFactory.getOWLAnnotationProperty(
            format.getIRI(propertyCURIE));
    OWLLiteral literal = dataFactory.getOWLLiteral(value);
    return synonym(ontology, subject, type, property, literal);
}
项目:logmap-matcher    文件:OntologyModuleExtractor.java   
private void indexEntities() {

    for (OWLAxiom ax : ontologyAxioms) {
        for (OWLEntity ent : ax.getSignature()){
            if (!entity2Axioms.containsKey(ent)){
                entity2Axioms.put(ent, new HashSet<OWLAxiom>());
            }
            entity2Axioms.get(ent).add(ax);
        }
    }
}
项目:owltools    文件:OboOntologyReleaseRunner.java   
private void createEquivModule(String ontologyId, List<OWLEquivalentClassesAxiom> equivalentNamedClassPairs)
        throws OWLOntologyCreationException, IOException, OWLOntologyStorageException
{
    Set<OWLEntity> signature = new HashSet<OWLEntity>();
    for(OWLEquivalentClassesAxiom ax : equivalentNamedClassPairs) {
        signature.addAll(ax.getClassesInSignature());
    }
    final String moduleName = "equivalent-classes";
    createModule(ontologyId, moduleName, signature);
}
项目:logmap-matcher    文件:OntologyModuleExtractor.java   
/**
 *  Interface from OWLAPI OntologySegmenter. 
 *  We extract by the type of module defined in constructor or Bottom module by default
 */
public OWLOntology extractAsOntology(Set<OWLEntity> signature, IRI iri)
        throws OWLOntologyCreationException {

    OWLOntologyManager manager;
    if (ontologyManager!=null)
        manager=ontologyManager;
    else 
        manager = OWLManager.createOWLOntologyManager();

    return manager.createOntology(extractModule4Entities(signature, typeModule, manager), iri);             
}
项目:logmap-matcher    文件:OntologyModuleExtractor.java   
/**
 * Not implemented
 */
public OWLOntology extractAsOntology(Set<OWLEntity> signature, IRI arg1,
        int arg2, int arg3, OWLReasoner arg4)
        throws OWLOntologyCreationException {
    // TODO Auto-generated method stub
    //Not Implemented       
    return null;
}