From b39bccea66aeb6a34d49649e9215a59dd5be4e27 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 7 May 2007 13:58:46 +0000 Subject: [PATCH] Max width for tooltip --- src/jalview/gui/IdPanel.java | 66 +++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index aa91354..4ca622d 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -70,50 +70,62 @@ public class IdPanel public void mouseMoved(MouseEvent e) { int seq = Math.max(0, alignPanel.seqPanel.findSeq(e)); + String tmp; if (seq > -1 && seq < av.alignment.getHeight()) { SequenceI sequence = av.alignment.getSequenceAt(seq); - StringBuffer tip = new StringBuffer(""); - tip.append(sequence.getDisplayId(true)); + StringBuffer tip = new StringBuffer(); + + int maxWidth = 0; if (sequence.getDescription() != null) { - tip.append("
"); - tip.append(sequence.getDescription()); + tmp = sequence.getDescription(); + tip.append(tmp); + maxWidth = Math.max(maxWidth, tmp.length()); + } - DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef(); - if (dbrefs != null) + DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef(); + if (dbrefs != null) + { + tip.append(""); + for (int i = 0; i < dbrefs.length; i++) { - tip.append(""); - for (int i = 0; i < dbrefs.length; i++) - { - tip.append("
"); - tip.append(dbrefs[i].getSource() + " " - + dbrefs[i].getAccessionId()); - } - tip.append("
"); + tip.append("
"); + tmp = dbrefs[i].getSource() + " " + dbrefs[i].getAccessionId(); + tip.append(tmp); + maxWidth = Math.max(maxWidth, tmp.length()); } + tip.append("
"); + } - //ADD NON POSITIONAL SEQUENCE INFO - SequenceFeature[] features = sequence.getDatasetSequence(). - getSequenceFeatures(); - if (features != null) + + //ADD NON POSITIONAL SEQUENCE INFO + SequenceFeature[] features = sequence.getDatasetSequence(). + getSequenceFeatures(); + if (features != null) + { + for (int i = 0; i < features.length; i++) { - for (int i = 0; i < features.length; i++) + if (features[i].begin == 0 && features[i].end == 0) { - if (features[i].begin == 0 && features[i].end == 0) - { - tip.append("
" + features[i].featureGroup - + " " + features[i].getType() + " " + - features[i].description); - } + tmp = features[i].featureGroup + + " " + features[i].getType() + " " + + features[i].description; + tip.append("
" + tmp); + maxWidth = Math.max(maxWidth, tmp.length()); } } - tip.append("
"); } + if(maxWidth > 60) + { + tip.insert(0, "
"); + tip.append("
"); + } tip.append(""); - setToolTipText(tip.toString()); + + setToolTipText(""+sequence.getDisplayId(true)+tip.toString()); } } -- 1.7.10.2