/** * Renderes a list or table cell value if the value contains an OWLAnnotation. * * @param page The page that the value will be rendered into. * @param value The value that may or may not contain an OWLAnnotation. The annotation will be * extracted from this value. * @param foreground The default foreground color. * @param background The default background color. * @param isSelected Whether or not the cell containing the value is selected. */ private void renderCellValue( Page page, Object value, Color foreground, Color background, boolean isSelected) { OWLAnnotation annotation = extractOWLAnnotationFromCellValue(value); if (annotation != null) { renderAnnotationProperty(page, annotation, foreground, background, isSelected); renderAnnotationValue(page, annotation, foreground, background, isSelected); if (inlineAnnotationRendering == RENDER_COMPOUND_ANNOTATIONS_INLINE && value instanceof HasAnnotations) { Page subAnnotationPage = new Page(); for (OWLAnnotation anno : ((HasAnnotations) value).getAnnotations()) { renderCellValue(subAnnotationPage, anno, foreground, background, isSelected); } subAnnotationPage.setMarginLeft(40); subAnnotationPage.setOpacity(0.6); page.add(subAnnotationPage); } } switch (annotationRenderingStyle) { case COMFORTABLE: page.setMargin(2); page.setMarginBottom(6); break; case COSY: page.setMargin(1); page.setMarginBottom(3); break; case COMPACT: page.setMargin(0); page.setMarginBottom(1); } }
/** * Renders an annotation value that is an OWLLiteral. * * @param page The page that the value will be rendered into. * @param literal The literal to be rendered. * @param foreground The default foreground. * @param background The default background. * @param isSelected Whether or not the cell containing the annotation value is selected. * @return A list of paragraphs that represent the rendering of the literal. */ private List<Paragraph> renderLiteral( Page page, OWLLiteral literal, Color foreground, Color background, boolean isSelected) { String rendering = EscapeUtils.unescapeString(literal.getLiteral()).trim(); List<Paragraph> result = new ArrayList<Paragraph>(); if (rendering.length() > 0) { List<LinkSpan> linkSpans = extractLinks(rendering); Paragraph literalParagraph = new Paragraph(rendering, linkSpans); literalParagraph.setForeground(foreground); page.add(literalParagraph); result.add(literalParagraph); Paragraph tagParagraph = literalParagraph; // new Paragraph(""); tagParagraph.append(" ", foreground); page.add(tagParagraph); result.add(tagParagraph); tagParagraph.setMarginTop(2); tagParagraph.setTabCount(2); // appendTag(tagParagraph, literal, foreground, isSelected); } return result; }
/** * Renderes a set of entities as an annotation value. The idea is that the annotation value is an * IRI that corresponds to the IRI of entities in the imports closure of the active ontology. * * @param page The page that the entities will be rendered into. * @param entities The entities. * @return A list of paragraphs that represents the rendering of the entities. */ private List<Paragraph> renderEntities(Page page, Set<OWLEntity> entities) { List<Paragraph> paragraphs = new ArrayList<Paragraph>(); for (OWLEntity entity : entities) { Icon icon = getIcon(entity); OWLModelManager modelManager = editorKit.getOWLModelManager(); Paragraph paragraph = new Paragraph(modelManager.getRendering(entity), new OWLEntityLink(editorKit, entity)); paragraph.setIcon(icon); page.add(paragraph); paragraphs.add(paragraph); } return paragraphs; }