From 608b684c6af6d993bf9cd3fbd6c4c134106a429e Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Wed, 15 Jan 2025 17:57:20 +0000 Subject: [PATCH] Display a normal link if we can't display an image. When the value of an annotation is an IRI that seems to point to an image, and we are set to display thumbnails, check if we were able to sucessfully load the remote image; if not, then fallback to display the link, as if the "Display thumbnails for image URLs" option was disabled. --- .../owl/ui/renderer/OWLAnnotationCellRenderer2.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/renderer/OWLAnnotationCellRenderer2.java b/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/renderer/OWLAnnotationCellRenderer2.java index 4ea9287da..d0540d426 100644 --- a/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/renderer/OWLAnnotationCellRenderer2.java +++ b/protege-editor-owl/src/main/java/org/protege/editor/owl/ui/renderer/OWLAnnotationCellRenderer2.java @@ -419,7 +419,11 @@ private List renderExternalIRI(Page page, IRI iri) { try { if (isImageAddress(iri) && isDisplayThumbnails()) { IconBox iconBox = getImageBox(iri); - page.add(iconBox); + if (iconBox != null) { + page.add(iconBox); + } else { + paragraphs.add(page.addParagraph(iriString, new HTTPLink(iri.toURI()))); + } } else { paragraphs.add(page.addParagraph(iriString, new HTTPLink(iri.toURI()))); @@ -469,7 +473,9 @@ public void setThumbnailRendering(InlineThumbnailRendering thumbnailRendering) { */ private IconBox getImageBox(IRI iri) throws MalformedURLException, IllegalArgumentException { ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL()); - imageIcon.getImageLoadStatus(); + if ( imageIcon.getImageLoadStatus() != MediaTracker.COMPLETE ) { + return null; + } IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI())); iconBox.setMaxHeight(50); return iconBox;