From: amwaterhouse Date: Wed, 18 Oct 2006 13:05:05 +0000 (+0000) Subject: remove html and body from tooltip X-Git-Tag: Release_2_2~262 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b91371a3cd132a220927f7e1bac6433eeb51b75d;p=jalview.git remove html and body from tooltip --- diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 5782797..5c96e79 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -74,6 +74,9 @@ public class SeqPanel extends JPanel implements MouseListener, java.net.URL linkImageURL; + StringBuffer tooltipText = new StringBuffer(""); + String tmpString; + /** * Creates a new SeqPanel object. * @@ -527,12 +530,11 @@ public class SeqPanel extends JPanel implements MouseListener, // use aa to see if the mouse pointer is on a if (av.showSequenceFeatures) { + tooltipText.setLength(6); // Cuts the buffer back to + SequenceFeature [] features = sequence.getDatasetSequence().getSequenceFeatures(); if(features!=null) { - StringBuffer sbuffer = new StringBuffer(""); - StringBuffer seqSpecific = new StringBuffer(); - for (int i = 0; i < features.length; i++) { @@ -549,34 +551,74 @@ public class SeqPanel extends JPanel implements MouseListener, if (features[i].getBegin() == sequence.findPosition(res) || features[i].getEnd() == sequence.findPosition(res)) { - if (sbuffer.length() > 6) - sbuffer.append("
"); - sbuffer.append("disulfide bond " + features[i].getBegin() + ":" + + if (tooltipText.length() > 6) + tooltipText.append("
"); + tooltipText.append("disulfide bond " + features[i].getBegin() + ":" + features[i].getEnd()); if (features[i].links != null) - sbuffer.append(" "); + tooltipText.append(" "); } } else { - if (sbuffer.length() > 6) - sbuffer.append("
"); + if (tooltipText.length() > 6) + tooltipText.append("
"); - sbuffer.append(features[i].getType() + " " + + tooltipText.append(features[i].getType() + " " + features[i].begin); if (features[i].begin != features[i].end) - sbuffer.append(" " + features[i].end); + tooltipText.append(" " + features[i].end); if (features[i].getDescription() != null && !features[i].description.equals(features[i].getType())) - sbuffer.append("; " + features[i].getDescription()); - - if (features[i].getValue("status") != null) { - sbuffer.append("; (" + features[i].getValue("status") + ")"); + tmpString = features[i].getDescription(); + int startTag=tmpString.toUpperCase().indexOf(""); + if(startTag>-1) + { + tmpString = tmpString.substring(startTag + 6); + } + int endTag=tmpString.toUpperCase().indexOf(""); + if(endTag>-1) + { + tmpString = tmpString.substring(0, endTag); + } + endTag = tmpString.toUpperCase().indexOf(""); + if(endTag>-1) + { + tmpString = tmpString.substring(0, endTag); + } + + if(startTag>-1) + { + tooltipText.append("; " + tmpString); + } + else + { + if (tmpString.indexOf("<") > -1 || tmpString.indexOf(">") > -1) + { + //The description does not specify html is to + //be used, so we must remove < > symbols + tmpString = tmpString.replaceAll("<", "<"); + tmpString = tmpString.replaceAll(">", ">"); + + tooltipText.append("; "); + tooltipText.append(tmpString); + + } + else + tooltipText.append("; "+tmpString); + } } + if (features[i].getValue("status") != null ) + { + String status = features[i].getValue("status").toString(); + if(status.length()>0) + tooltipText.append("; (" + features[i].getValue("status") + ")"); + } + if (features[i].links != null) - sbuffer.append(" "); + tooltipText.append(" "); } } @@ -589,15 +631,18 @@ public class SeqPanel extends JPanel implements MouseListener, } } - if(seqSpecific.length()>0) - seqSpecific.setLength(seqSpecific.length()-4); - sbuffer.append(seqSpecific); - sbuffer.append(""); - if(sbuffer.length()==13) // + + if(tooltipText.length()==6) // + { + setToolTipText(""); + } else - setToolTipText(sbuffer.toString()); + { + tooltipText.append(""); + setToolTipText(tooltipText.toString()); + } } else setToolTipText("");