private void checkOccurrence(Collection<OWLAnnotation> c) {
   for (OWLAnnotation a : c) {
     if (a.getValue() instanceof OWLAnonymousIndividual) {
       checkAppearance((OWLAnonymousIndividual) a.getValue());
     }
   }
 }
 /**
  * Renders the annotation property into a paragraph in the page.
  *
  * @param page The page to insert the paragraph into.
  * @param annotation The annotation containing the property to be rendered.
  * @param defaultForeground The default foreground color.
  * @param defaultBackground The default background color.
  * @param isSelected Specifies whether the associated cell is selected or not.
  */
 private Paragraph renderAnnotationProperty(
     Page page,
     OWLAnnotation annotation,
     Color defaultForeground,
     Color defaultBackground,
     boolean isSelected) {
   OWLAnnotationProperty property = annotation.getProperty();
   String rendering = editorKit.getOWLModelManager().getRendering(property);
   Paragraph paragraph = page.addParagraph(rendering);
   Color foreground = getAnnotationPropertyForeground(defaultForeground, isSelected);
   paragraph.setForeground(foreground);
   //        if (isReferenceOntologyActive()) {
   //            paragraph.setBold(true);
   //        }
   if (annotation.getValue() instanceof OWLLiteral) {
     OWLLiteral literalValue = (OWLLiteral) annotation.getValue();
     paragraph.append("    ", foreground);
     appendTag(paragraph, literalValue, foreground, isSelected);
   }
   switch (annotationRenderingStyle) {
     case COMFORTABLE:
       paragraph.setMarginBottom(4);
       break;
     case COSY:
       paragraph.setMarginBottom(2);
       break;
     case COMPACT:
       paragraph.setMarginBottom(1);
       break;
   }
   return paragraph;
 }
  /**
   * Renders an annotation value into a {@link Page}.
   *
   * @param page The page that the value should be rendered into.
   * @param annotation The annotation that contains the value to be rendered.
   * @param defaultForeground The default foreground color.
   * @param defaultBackground The default background color.
   * @param isSelected Whether or not the cell containing the annotation is selected.
   * @return A list of paragraphs that represent the rendering of the annotation value. These
   *     paragraphs will have been added to the Page specified by the page argument.
   */
  private List<Paragraph> renderAnnotationValue(
      final Page page,
      OWLAnnotation annotation,
      final Color defaultForeground,
      final Color defaultBackground,
      final boolean isSelected) {
    OWLAnnotationValue annotationValue = annotation.getValue();
    List<Paragraph> paragraphs =
        annotationValue.accept(
            new OWLAnnotationValueVisitorEx<List<Paragraph>>() {
              public List<Paragraph> visit(IRI iri) {
                return renderIRI(
                    page, iri, defaultForeground, defaultBackground, isSelected, hasFocus());
              }

              public List<Paragraph> visit(OWLAnonymousIndividual individual) {
                return renderAnonymousIndividual(page, individual);
              }

              public List<Paragraph> visit(OWLLiteral literal) {
                return renderLiteral(
                    page, literal, defaultForeground, defaultBackground, isSelected);
              }
            });
    applyGlobalFormattingToAnnotationValueParagraphs(paragraphs);
    return paragraphs;
  }
 public void visit(OWLAnnotation annotation) {
   annotation.getProperty().accept(this);
   annotation.getValue().accept(this);
   for (OWLAnnotation anno : annotation.getAnnotations()) {
     anno.accept(this);
   }
 }
예제 #5
0
 @Override
 public void visit(OWLAnnotation node) {
   node.getProperty().accept(this);
   OWLAnnotationProperty prop = (OWLAnnotationProperty) obj;
   node.getValue().accept(this);
   OWLAnnotationValue val = (OWLAnnotationValue) obj;
   obj = dataFactory.getOWLAnnotation(prop, val);
 }
예제 #6
0
 @Override
 public void handle(String currentId, String value, String qualifierBlock, String comment) {
   if (currentId == null) {
     return;
   }
   OWLAnnotation xrefAnnotation = getConsumer().parseXRef(value);
   IRI subject = getIRIFromOBOId(currentId);
   OWLAnnotationAssertionAxiom ax =
       getDataFactory()
           .getOWLAnnotationAssertionAxiom(
               xrefAnnotation.getProperty(), subject, xrefAnnotation.getValue());
   applyChange(new AddAxiom(getOntology(), ax));
   if (getConsumer().isTypedef() && xrefAnnotation.getValue() instanceof IRI) {
     IRI xrefIRI = (IRI) xrefAnnotation.getValue();
     String typedefId = getConsumer().getCurrentId();
     getConsumer().addSymbolicIdMapping(typedefId, xrefIRI);
   }
 }
 private String getAnnotationValueByUri(OWLOntology o, OWLEntity owlEntity, String uri) {
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().getIRI().toString().equals(uri)) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       return value.getLiteral();
     }
   }
   return null;
 }
 public static String getLabel(OWLOntology o, OWLEntity owlEntity) {
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().isLabel()) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       return value.getLiteral();
     }
   }
   return owlEntity.getIRI().toString();
 }
  // this method retrieves all the geometric properties that have been
  // pre-designated as "house setable" or "room setable",
  // that is, if a geometric property is available for houses, it has been
  // annotated as "houseSetable", for rooms, "roomSetable" and for both it
  // has been designated with both annotations.
  public void retrieveGeometricPropertiesMaps() {
    OWLDataProperty geometricProperty =
        OWLFactory.getOWLDataProperty(":GeometricProperty", topIxPrefixManager);
    OWLAnnotationProperty propertyID =
        OWLFactory.getOWLAnnotationProperty(":propertyID", topIxPrefixManager);
    logger.info(propertyID);
    OWLAnnotationProperty houseSetable =
        OWLFactory.getOWLAnnotationProperty(":houseSetable", topIxPrefixManager);
    OWLAnnotationProperty roomSetable =
        OWLFactory.getOWLAnnotationProperty(":roomSetable", topIxPrefixManager);
    Set<OWLSubDataPropertyOfAxiom> tempGeometricDataPropertiesSet =
        topIxOnt.getDataSubPropertyAxiomsForSuperProperty(geometricProperty);

    for (OWLSubDataPropertyOfAxiom tempGeomPropAxiom : tempGeometricDataPropertiesSet) {
      OWLDataProperty tempDataProperty = tempGeomPropAxiom.getSubProperty().asOWLDataProperty();
      // the following two local vars will become an entry for geometricPropertiesMap
      String tempString = tempDataProperty.getAnnotations(topIxOnt, propertyID).toString();
      tempString = tempString.substring(tempString.indexOf('"') + 1, tempString.indexOf("^") - 1);
      IRI tempIRI = tempGeomPropAxiom.getSubProperty().asOWLDataProperty().getIRI();
      geometricPropertiesMap.put(tempString, tempIRI);

      // the following code decides whether the above entry should also be contained
      // in the houseSetableGeometricPropertiesMap
      Set<OWLAnnotation> tempDataPropAnnotationSet = tempDataProperty.getAnnotations(topIxOnt);
      for (OWLAnnotation tempDataPropAnnotation : tempDataPropAnnotationSet) {
        if (tempDataPropAnnotation.getProperty() == houseSetable
            && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) {
          houseSetableGeometricPropertiesMap.put(tempString, tempIRI);
        }
        if (tempDataPropAnnotation.getProperty() == roomSetable
            && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) {
          roomSetableGeometricPropertiesMap.put(tempString, tempIRI);
        }
      }
    }
  }
예제 #10
0
 private OntologyManager() {
   _manager = OWLManager.createOWLOntologyManager();
   try {
     _ontology = _manager.loadOntology(IRI.create(getClass().getResource(ONTOLOGY_RESOURCE_PATH)));
     for (OWLAnnotation anon : _ontology.getAnnotations()) {
       if (anon.getProperty().getIRI().toString().equals(DomainOntology.taxonomyDefinedBy)) {
         _taxonomyType = anon.getValue().toString().replace("\"", "");
         break;
       }
     }
     _reasoner = new StructuralReasonerFactory().createReasoner(_ontology);
   } catch (OWLOntologyCreationException ex) {
     Log.e(TAG, "Error while loading the domain ontology");
     _taxonomyType = null;
   }
 }
예제 #11
0
 protected ArrayList<PossibleValueType> getAnnotationValuesByUri(
     OWLOntology o, OWLEntity owlEntity, String uri) {
   ArrayList<PossibleValueType> possibleValueTypes = new ArrayList<PossibleValueType>();
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().getIRI().toString().equals(uri)) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       String[] possibleValues = value.getLiteral().split(",");
       for (String possibleValue : possibleValues) {
         String[] parsedValue = possibleValue.split(":");
         checkArgument(
             parsedValue.length == 2, "Possible values must be in the format mapping:value");
         possibleValueTypes.add(new PossibleValueType(parsedValue[0], parsedValue[1]));
       }
     }
   }
   return possibleValueTypes;
 }
예제 #12
0
 @Override
 public void visit(OWLAnnotation annotation) {
   write("Annotation");
   annotation.getProperty().getIRI().accept(this);
   annotation.getValue().accept(this);
 }