コード例 #1
0
 /**
  * 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;
 }
 public void visit(OWLAnnotation annotation) {
   annotation.getProperty().accept(this);
   annotation.getValue().accept(this);
   for (OWLAnnotation anno : annotation.getAnnotations()) {
     anno.accept(this);
   }
 }
 private void checkOccurrence(Collection<OWLAnnotation> c) {
   for (OWLAnnotation a : c) {
     if (a.getValue() instanceof OWLAnonymousIndividual) {
       checkAppearance((OWLAnonymousIndividual) a.getValue());
     }
   }
 }
コード例 #4
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);
 }
コード例 #5
0
 private Set<OWLAnnotation> duplicateAxiomAnnotations(OWLAxiom axiom) {
   Set<OWLAnnotation> duplicatedAnnos = new HashSet<OWLAnnotation>();
   for (OWLAnnotation anno : axiom.getAnnotations()) {
     anno.accept(this);
     duplicatedAnnos.add((OWLAnnotation) obj);
   }
   return duplicatedAnnos;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 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();
 }
コード例 #8
0
ファイル: CoffeeOntology.java プロジェクト: mary92/psz
 /**
  * @param entity
  * @return
  */
 public String render(OWLEntity entity) {
   for (OWLOntology ont : manager.getOntologies()) {
     for (OWLAnnotation annot : entity.getAnnotations(ont)) {
       if (annot.getAnnotationURI().equals(OWLRDFVocabulary.RDFS_LABEL.getURI())) {
         if (annot instanceof OWLConstantAnnotation) {
           return ((OWLConstantAnnotation) annot).getAnnotationValue().getLiteral();
         }
       }
     }
   }
   return entity.getURI().getFragment();
 }
コード例 #9
0
  /**
   * 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;
  }
コード例 #10
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;
 }
コード例 #11
0
  // 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);
        }
      }
    }
  }
 // ////////////////////////////////////////////////////////////////////////////////////////////
 //
 // Axiom Visitor stuff
 //
 // ////////////////////////////////////////////////////////////////////////////////////////////
 protected void processAxiomAnnotations(OWLAxiom ax) {
   // default behavior: iterate over the annotations outside the axiom
   for (OWLAnnotation anno : ax.getAnnotations()) {
     anno.accept(this);
   }
 }
コード例 #13
0
 @Override
 public void visit(OWLAnnotation annotation) {
   write("Annotation");
   annotation.getProperty().getIRI().accept(this);
   annotation.getValue().accept(this);
 }