-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closes this issue for the Entities Tab. Some other more general mechanism is needed really. - Also displays OBO style Ids for IRIs that seem to be OBO style Ids.
- Loading branch information
1 parent
0362e6b
commit 4b013ba
Showing
3 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
protege-editor-owl/src/main/java/org/protege/editor/owl/ui/view/EntityBannerFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.protege.editor.owl.ui.view; | ||
|
||
import org.protege.editor.owl.OWLEditorKit; | ||
import org.semanticweb.owlapi.model.OWLEntity; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Matthew Horridge | ||
* Stanford Center for Biomedical Informatics Research | ||
* 7 Sep 16 | ||
*/ | ||
public interface EntityBannerFormatter { | ||
|
||
/** | ||
* Formats a banner for the specified entity under the context of the specified editor kit. | ||
* @param entity The entity. | ||
* @param editorKit The editor kit. | ||
* @return A string representing the banner. May be empty. | ||
*/ | ||
@Nonnull | ||
String formatBanner(@Nonnull OWLEntity entity, @Nonnull OWLEditorKit editorKit); | ||
} |
35 changes: 35 additions & 0 deletions
35
...ge-editor-owl/src/main/java/org/protege/editor/owl/ui/view/EntityBannerFormatterImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.protege.editor.owl.ui.view; | ||
|
||
import org.protege.editor.owl.OWLEditorKit; | ||
import org.semanticweb.owlapi.model.OWLEntity; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Matthew Horridge | ||
* Stanford Center for Biomedical Informatics Research | ||
* 7 Sep 16 | ||
*/ | ||
public class EntityBannerFormatterImpl implements EntityBannerFormatter { | ||
|
||
private static final Pattern OBO_STYLE_ID_PATTERN = Pattern.compile("/(\\w+)_(\\d+)$"); | ||
|
||
@Nonnull | ||
@Override | ||
public String formatBanner(@Nonnull OWLEntity entity, @Nonnull OWLEditorKit editorKit) { | ||
String rendering = editorKit.getOWLModelManager().getRendering(entity); | ||
String iri = entity.getIRI().toString(); | ||
String oboStyleId = ""; | ||
Matcher oboIdMatcher = OBO_STYLE_ID_PATTERN.matcher(iri); | ||
if(oboIdMatcher.find()) { | ||
oboStyleId = " \u2014 " + oboIdMatcher.group(1) + ":" + oboIdMatcher.group(2); | ||
} | ||
return String.format( | ||
"<html><body><nobr>%s <span style='color: #808080;'>%s \u2014 %s</span><nobr></body></html>", | ||
rendering, | ||
oboStyleId, | ||
iri); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters