X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=ff3b0cddd72c6de52c372992de30cd726c084525;hb=23304093bd85722ad85393516357e565616cbf0b;hp=6626016d27fede4ca6bac582a22d1f0de233fb45;hpb=66616c7a1c2e1d72e98573258b14cd23b5e45ea7;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 6626016..ff3b0cd 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -18,6 +18,7 @@ package jalview.gui; import java.util.*; +import java.util.regex.Pattern; import java.awt.*; import java.awt.datatransfer.*; @@ -404,22 +405,43 @@ public class AnnotationLabels extends JPanel implements MouseListener, && ap.av.alignment.getAlignmentAnnotation().length > selectedRow) { AlignmentAnnotation aa = ap.av.alignment.getAlignmentAnnotation()[selectedRow]; - - StringBuffer desc = new StringBuffer(""); - + + StringBuffer desc = new StringBuffer(); if (aa.description != null && !aa.description.equals("New description")) { - desc.append(aa.getDescription(true)); - if (aa.hasScore) - desc.append("
"); + // TODO: we could refactor and merge this code with the code in jalview.gui.SeqPanel.mouseMoved(..) that formats sequence feature tooltips + desc.append(aa.getDescription(true).trim()); + // check to see if the description is an html fragment. + if (desc.length()<6 || (desc.substring(0,6).toLowerCase().indexOf("")<0)) + { + // clean the description ready for embedding in html + desc = new StringBuffer(Pattern.compile("<").matcher(desc).replaceAll("<")); + desc.insert(0, ""); + } else { + // remove terminating html if any + int i=desc.substring(desc.length()-7).toLowerCase().lastIndexOf(""); + if (i>-1) { + desc.setLength(desc.length()-7+i); + } + } + if (aa.hasScore()) + { + desc.append("
"); + } + + + } else { + // begin the tooltip's html fragment + desc.append(""); } if (aa.hasScore()) { - desc.append("Score: " + aa.score); + // TODO: limit precision of score to avoid noise from imprecise doubles (64.7 becomes 64.7+/some tiny value). + desc.append(" Score: " + aa.score); } - if (desc.length() != 6) + if (desc.length() > 6) { desc.append(""); this.setToolTipText(desc.toString());