X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=cb13692444af52aca625250adeec02b2353caa56;hb=6fc9aca27f606f6e3a0121597896e1a5dae35c36;hp=201516f228e0d3b9892bbde71e42ab12754d1dba;hpb=d5e29f5d017383d53173b0577f12867bbe9c46d4;p=jalview.git
diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java
index 201516f..cb13692 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,62 @@ public class IdPanel extends JPanel implements MouseListener,
*/
public void mouseMoved(MouseEvent e)
{
+ int y = e.getY();
+
+ if (av.getWrapAlignment())
+ {
+ y = getWrappedY(y);
+ }
+
+ final 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());
+ }
+
+ if(av.hasHiddenRows)
+ {
+ if(av.adjustForHiddenSeqs(seq) -
+ av.adjustForHiddenSeqs(seq-1)>1)
+ {
+ JPopupMenu pop = new JPopupMenu();
+ JMenuItem item = new JMenuItem("Reveal");
+ item.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ av.showSequence(seq);
+ alignPanel.repaint();
+ if(alignPanel.overviewPanel!=null)
+ alignPanel.overviewPanel.updateOverviewImage();
+ }
+ });
+ pop.add(item);
+ pop.show(this, e.getX(), e.getY());
+ }
+ }
+ }
+
+
+ int getWrappedY(int y)
+ {
+ int hgap = av.charHeight;
+ if (av.scaleAboveWrapped)
+ hgap += av.charHeight;
+
+ return y - hgap;
}
+
/**
* DOCUMENT ME!
*
@@ -83,7 +138,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 +169,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 +180,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 +266,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 +346,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 +361,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);
}
}