From: amwaterhouse Date: Mon, 7 May 2007 13:58:46 +0000 (+0000) Subject: Max width for tooltip X-Git-Tag: Release_2_3~49 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b39bccea66aeb6a34d49649e9215a59dd5be4e27;p=jalview.git Max width for tooltip --- 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()); } }