From 6764821c4e729eeb90fea0817ac9964c3b0b7111 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 29 Jan 2007 17:40:50 +0000 Subject: [PATCH] Tooltips for group names, descriptions --- src/jalview/appletgui/SeqPanel.java | 42 +++++--- src/jalview/gui/SeqPanel.java | 188 ++++++++++++++++++----------------- 2 files changed, 124 insertions(+), 106 deletions(-) diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 6b93206..1a2da1e 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -564,13 +564,28 @@ public class SeqPanel ap.alignFrame.statusBar.setText(text.toString()); + StringBuffer tooltipText = new StringBuffer(); + SequenceGroup [] groups = av.alignment.findAllGroups(sequence); + if(groups!=null) + { + for(int g=0; g=res) + { + tooltipText.append(groups[g].getName()+" "); + if(groups[g].getDescription()!=null) + tooltipText.append(groups[g].getDescription()); + tooltipText.append("\n"); + } + } + } // use aa to see if the mouse pointer is on a if (av.showSequenceFeatures && sequence.getSequenceFeatures()!=null && av.featuresDisplayed!=null) { - StringBuffer featureText = new StringBuffer(); + Vector allFeatures = getAllFeaturesAtRes(sequence, sequence.findPosition(res)); int index = 0; @@ -578,35 +593,30 @@ public class SeqPanel { SequenceFeature sf = (SequenceFeature) allFeatures.elementAt(index); - featureText.append(sf.getType()+" "+sf.begin+":"+sf.end); + tooltipText.append(sf.getType()+" "+sf.begin+":"+sf.end); if (sf.getDescription() != null) - featureText.append(" " + sf.getDescription()); + tooltipText.append(" " + sf.getDescription()); if (sf.getValue("status") != null ) { String status = sf.getValue("status").toString(); if(status.length()>0) - featureText.append(" (" + sf.getValue("status") + ")"); + tooltipText.append(" (" + sf.getValue("status") + ")"); } - featureText.append("\n"); + tooltipText.append("\n"); index++; } + } + if (tooltip == null) + tooltip = new Tooltip(tooltipText.toString(), seqCanvas); + else + tooltip.setTip(tooltipText.toString()); - if (tooltip == null) - tooltip = new Tooltip(featureText.toString(), seqCanvas); - else - tooltip.setTip(featureText.toString()); - - tooltip.repaint(); + tooltip.repaint(); - } - else if (tooltip != null) - { - tooltip.setTip(""); - } } Vector getAllFeaturesAtRes(SequenceI seq, int res) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 8de1d01..cd6fe2e 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -570,116 +570,124 @@ public class SeqPanel extends JPanel implements MouseListener, setStatusMessage(sequence, res, seq); + + + tooltipText.setLength(6); // Cuts the buffer back to + + SequenceGroup [] groups = av.alignment.findAllGroups(sequence); + if(groups!=null) + { + for(int g=0; g=res) + { + tooltipText.append(groups[g].getName()+" "); + if(groups[g].getDescription()!=null) + tooltipText.append(groups[g].getDescription()+"
"); + } + } + } + + // use aa to see if the mouse pointer is on a if (av.showSequenceFeatures) { - tooltipText.setLength(6); // Cuts the buffer back to + SequenceFeature[] features = findFeaturesAtRes( + sequence.getDatasetSequence(), sequence.findPosition(res)); - SequenceFeature[] features = findFeaturesAtRes( - sequence.getDatasetSequence(), sequence.findPosition(res)); - - if(features!=null) + if (features != null) + { + for (int i = 0; i < features.length; i++) { - for (int i = 0; i < features.length; i++) + if (features[i].getType().equals("disulfide bond")) { - if (features[i].getType().equals("disulfide bond")) - { - if (features[i].getBegin() == sequence.findPosition(res) - || features[i].getEnd() == sequence.findPosition(res)) - { - if (tooltipText.length() > 6) - tooltipText.append("
"); - tooltipText.append("disulfide bond " + features[i].getBegin() + ":" + + if (features[i].getBegin() == sequence.findPosition(res) + || features[i].getEnd() == sequence.findPosition(res)) + { + if (tooltipText.length() > 6) + tooltipText.append("
"); + tooltipText.append("disulfide bond " + features[i].getBegin() + ":" + features[i].getEnd()); - if (features[i].links != null) - tooltipText.append(" "); - } - } - else - { - if (tooltipText.length() > 6) - tooltipText.append("
"); + if (features[i].links != null) + tooltipText.append(" "); + } + } + else + { + if (tooltipText.length() > 6) + tooltipText.append("
"); - tooltipText.append(features[i].getType() + " " + + tooltipText.append(features[i].getType() + " " + features[i].begin); - if (features[i].begin != features[i].end) - tooltipText.append(" " + features[i].end); + if (features[i].begin != features[i].end) + tooltipText.append(" " + features[i].end); - if (features[i].getDescription() != null - && !features[i].description.equals(features[i].getType())) - { - 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 ) + if (features[i].getDescription() != null + && !features[i].description.equals(features[i].getType())) + { + 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) { - String status = features[i].getValue("status").toString(); - if(status.length()>0) - tooltipText.append("; (" + features[i].getValue("status") + ")"); - } + //The description does not specify html is to + //be used, so we must remove < > symbols + tmpString = tmpString.replaceAll("<", "<"); + tmpString = tmpString.replaceAll(">", ">"); - if (features[i].links != null) - tooltipText.append(" "); + tooltipText.append("; "); + tooltipText.append(tmpString); + } + else + tooltipText.append("; " + tmpString); } - - // else if(features[i].begin==0 && features[i].end==0) + } + if (features[i].getValue("status") != null) { - // seqSpecific.append(features[i].featureGroup+": " - // + features[i].getType()+" " - // +features[i].getDescription()+"
"); - + String status = features[i].getValue("status").toString(); + if (status.length() > 0) + tooltipText.append("; (" + features[i].getValue("status") + ")"); } - } - if(tooltipText.length()==6) // - { - setToolTipText(null); - } - else - { - tooltipText.append(""); - setToolTipText(tooltipText.toString()); + if (features[i].links != null) + tooltipText.append(" "); + } } - else - setToolTipText(null); + } + } + if (tooltipText.length() == 6) // + { + setToolTipText(null); + } + else + { + tooltipText.append(""); + setToolTipText(tooltipText.toString()); } + // else + // setToolTipText(null); } void setStatusMessage(SequenceI sequence, int res, int seq) -- 1.7.10.2