non-positional features are displayed with additional score/evidence if necessary...
authorjprocter <Jim Procter>
Tue, 9 Sep 2008 10:10:48 +0000 (10:10 +0000)
committerjprocter <Jim Procter>
Tue, 9 Sep 2008 10:10:48 +0000 (10:10 +0000)
src/jalview/gui/IdPanel.java

index 222cf8d..a325618 100755 (executable)
@@ -20,6 +20,8 @@ package jalview.gui;
 
 import java.awt.*;
 import java.awt.event.*;
+import java.util.Vector;
+
 import javax.swing.*;
 
 import jalview.datamodel.*;
@@ -115,10 +117,19 @@ public class IdPanel extends JPanel implements MouseListener,
         {
           if (features[i].begin == 0 && features[i].end == 0)
           {
-            tmp = features[i].featureGroup + " " + features[i].getType()
-                    + " " + features[i].description;
-            tip.append("<br>" + tmp);
-            maxWidth = Math.max(maxWidth, tmp.length());
+            tip.append("<br>");
+            int sz = -tip.length();
+            boolean nl=false;
+            if (features[i].getFeatureGroup()!=null) { tip.append(features[i].getFeatureGroup()); nl=true;};
+            if (features[i].getType()!=null) { tip.append(" "); tip.append(features[i].getType()); nl=true;};
+            if (features[i].getDescription()!=null) { tip.append(" "); tip.append(features[i].getDescription()); nl=true;};
+            if (features[i].getScore()!=Float.NaN && features[i].getScore()!=0f) { tip.append(" Score = "); tip.append(features[i].getScore()); nl=true;};
+            if (features[i].getStatus()!=null && features[i].getStatus().length()>0) { tip.append(" ("); tip.append(features[i].getStatus()); tip.append(")");nl=true;};
+            if (nl) {
+              sz+=tip.length();
+              tip.append("<br>");
+              maxWidth = Math.max(maxWidth, sz);
+            }
           }
         }
       }
@@ -302,9 +313,28 @@ public class IdPanel extends JPanel implements MouseListener,
 
     if (javax.swing.SwingUtilities.isRightMouseButton(e))
     {
+      Sequence sq = (Sequence) av
+      .getAlignment().getSequenceAt(seq);
+      // build a new links menu based on the current links + any non-positional features
+      Vector nlinks = new Vector(Preferences.sequenceURLLinks);
+      SequenceFeature sf[] = sq.getDatasetSequence().getSequenceFeatures();
+      for (int sl=0;sf!=null && sl<sf.length;sl++)
+      {
+        if (sf[sl].begin==sf[sl].end && sf[sl].begin==0)
+        {
+          if (sf[sl].links!=null && sf[sl].links.size()>0)
+          {
+            for (int l=0, lSize=sf[sl].links.size(); l<lSize; l++)
+            { 
+              nlinks.addElement(sf[sl].links.elementAt(l));
+            }
+          }
+        }
+      }
+      
       jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel,
-              (Sequence) av.getAlignment().getSequenceAt(seq),
-              Preferences.sequenceURLLinks);
+              sq,
+              nlinks);
       pop.show(this, e.getX(), e.getY());
 
       return;