X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FSequenceAnnotationReport.java;h=df28ea3757f9e76e58d5064a71ec689014cc9a47;hb=586b87fca07c53c935ffe67827e498eb80fad4bf;hp=5a55b5b41e7a5c4e2cccc5317fdf5f2e7c2dacaf;hpb=74f21ca6ca8fa17d53708e457d191e15904f8310;p=jalview.git diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 5a55b5b..df28ea3 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -46,6 +46,8 @@ import java.util.Map; */ public class SequenceAnnotationReport { + private static final int MAX_DESCRIPTION_LENGTH = 40; + private static final String COMMA = ","; private static final String ELLIPSIS = "..."; @@ -64,7 +66,7 @@ public class SequenceAnnotationReport * Comparator to order DBRefEntry by Source + accession id (case-insensitive), * with 'Primary' sources placed before others, and 'chromosome' first of all */ - private static Comparator comparator = new Comparator() + private static Comparator comparator = new Comparator<>() { @Override @@ -206,6 +208,17 @@ public class SequenceAnnotationReport if (description != null && !description.equals(feature.getType())) { description = StringUtils.stripHtmlTags(description); + + /* + * truncate overlong descriptions unless they contain an href + * (as truncation could leave corrupted html) + */ + boolean hasLink = description.indexOf("a href") > -1; + if (description.length() > MAX_DESCRIPTION_LENGTH && !hasLink) + { + description = description.substring(0, MAX_DESCRIPTION_LENGTH) + + ELLIPSIS; + } sb.append("; ").append(description); } @@ -376,7 +389,7 @@ public class SequenceAnnotationReport if (sequence.getDescription() != null) { tmp = sequence.getDescription(); - sb.append("
").append(tmp); + sb.append(tmp); maxWidth = Math.max(maxWidth, tmp.length()); } SequenceI ds = sequence;