/**
  * 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;
 }
Beispiel #2
0
 /**
  * @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();
 }
  /**
   * 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;
  }