X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=bb6efd799aff8760658425f0a948b88755d6c3e8;hb=df1c58f9669c477db082016aa919d6c6cc9da071;hp=201516f228e0d3b9892bbde71e42ab12754d1dba;hpb=d5e29f5d017383d53173b0577f12867bbe9c46d4;p=jalview.git
diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java
index 201516f..bb6efd7 100755
--- a/src/jalview/gui/IdPanel.java
+++ b/src/jalview/gui/IdPanel.java
@@ -59,6 +59,7 @@ public class IdPanel extends JPanel implements MouseListener,
add(idCanvas, BorderLayout.CENTER);
addMouseListener(this);
addMouseMotionListener(this);
+ ToolTipManager.sharedInstance().registerComponent(this);
}
/**
@@ -68,8 +69,40 @@ public class IdPanel extends JPanel implements MouseListener,
*/
public void mouseMoved(MouseEvent e)
{
+ int y = e.getY();
+
+ if (av.getWrapAlignment())
+ {
+ y = getWrappedY(y);
+ }
+
+ int seq = av.getIndex(y);
+ if(seq!=-1)
+ {
+ StringBuffer tip = new StringBuffer("");
+ tip.append(av.alignment.getSequenceAt(seq).getDisplayId(true));
+ if (av.alignment.getSequenceAt(seq).getDescription() != null)
+ {
+ tip.append("
");
+ tip.append(av.alignment.getSequenceAt(seq).getDescription());
+ tip.append(" |
");
+ }
+ tip.append("");
+ setToolTipText(tip.toString());
+ }
+
+ }
+
+ int getWrappedY(int y)
+ {
+ int hgap = av.charHeight;
+ if (av.scaleAboveWrapped)
+ hgap += av.charHeight;
+
+ return y - hgap;
}
+
/**
* DOCUMENT ME!
*
@@ -83,7 +116,7 @@ public class IdPanel extends JPanel implements MouseListener,
if (av.getWrapAlignment())
{
- y -= (2 * av.charHeight);
+ y = getWrappedY(y);
}
int seq = av.getIndex(y);
@@ -114,7 +147,7 @@ public class IdPanel extends JPanel implements MouseListener,
*/
public void mouseClicked(MouseEvent e)
{
- if (e.getClickCount() < 2)
+ if (e.getClickCount() < 2)
return;
java.util.Vector links = Preferences.sequenceURLLinks;
@@ -125,12 +158,18 @@ public class IdPanel extends JPanel implements MouseListener,
if (av.getWrapAlignment())
{
- y -= (2 * av.charHeight);
+ y = getWrappedY(y);
}
//DEFAULT LINK IS FIRST IN THE LINK LIST
int seq = av.getIndex(y);
+ if(seq==-1)
+ return;
+
String id = av.getAlignment().getSequenceAt(seq).getName();
+ if (id.indexOf("|") > -1)
+ id = id.substring(id.lastIndexOf("|") + 1);
+
String url = links.elementAt(0).toString();
url = url.substring(url.indexOf("|")+1);
@@ -205,7 +244,7 @@ public class IdPanel extends JPanel implements MouseListener,
if (av.getWrapAlignment())
{
- y -= (2 * av.charHeight);
+ y = getWrappedY(y);
}
int seq = av.getIndex(y);
@@ -285,6 +324,9 @@ public class IdPanel extends JPanel implements MouseListener,
*/
void selectSeqs(int start, int end)
{
+ if(av.getSelectionGroup()==null)
+ return;
+
lastid = start;
if (end < start)
@@ -297,7 +339,7 @@ public class IdPanel extends JPanel implements MouseListener,
for (int i = start; i <= end; i++)
{
- av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),
+ av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),
true);
}
}