X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=d1dc11de476c5f625a93841ea5d7a5aee3ee8b87;hb=621a628afc1f6ee7a2778b9d0ae2729b88fe5bfd;hp=310276c5ee63b832f0de1820b8f4ed5bfb67e101;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 310276c..d1dc11d 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,56 @@ 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) + { + SequenceI sequence = av.alignment.getSequenceAt(seq); + StringBuffer tip = new StringBuffer(""); + tip.append(sequence.getDisplayId(true)); + if (av.alignment.getSequenceAt(seq).getDescription() != null) + { + tip.append("
"); + tip.append(av.alignment.getSequenceAt(seq).getDescription()); + + //ADD NON POSITIONAL SEQUENCE INFO + SequenceFeature [] features = sequence.getDatasetSequence().getSequenceFeatures(); + if(features!=null) + { + for(int i=0; i"+features[i].featureGroup + +" "+ features[i].getType()+" "+features[i].description); + } + } + } + + 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 +132,7 @@ public class IdPanel extends JPanel implements MouseListener, if (av.getWrapAlignment()) { - y -= (2 * av.charHeight); + y = getWrappedY(y); } int seq = av.getIndex(y); @@ -106,6 +155,7 @@ public class IdPanel extends JPanel implements MouseListener, alignPanel.repaint(); } + /** * DOCUMENT ME! * @@ -113,35 +163,48 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) - { - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y -= (2 * av.charHeight); - } - - int seq = av.getIndex(y); - String id = av.getAlignment().getSequenceAt(seq).getName(); - - try - { - jalview.util.BrowserLauncher.openURL( - "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:" + - id + "]+-vn+2"); - } - catch (Exception ex) - { - // TODO: JBPNote : state dependent error message for real browserLaunch problems rather than unix misconfiguration. - System.err.println(ex.getMessage() + - "\nUnixers: Try adding this jalview.browser property line \n" + - "in your jalview.properties file (/usr/local/bin/firefox is an exanmple browser path):\n" + - "jalview.browser=/usr/local/bin/firefox\n"); - - //ex.printStackTrace(); - } - } + if (e.getClickCount() < 2) + return; + + java.util.Vector links = Preferences.sequenceURLLinks; + if (links == null || links.size() < 1) + return; + + int y = e.getY(); + + if (av.getWrapAlignment()) + { + 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); + + int index = url.indexOf("$SEQUENCE_ID$"); + url = url.substring(0, index)+ id + url.substring(index+13); + + try + { + jalview.util.BrowserLauncher.openURL(url); + } + catch (Exception ex) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Unixers: Couldn't find default web browser." + +"\nAdd the full path to your browser in Preferences.", + "Web browser not found", JOptionPane.WARNING_MESSAGE ); + ex.printStackTrace(); + } } /** @@ -197,7 +260,7 @@ public class IdPanel extends JPanel implements MouseListener, if (av.getWrapAlignment()) { - y -= (2 * av.charHeight); + y = getWrappedY(y); } int seq = av.getIndex(y); @@ -210,15 +273,17 @@ public class IdPanel extends JPanel implements MouseListener, if (javax.swing.SwingUtilities.isRightMouseButton(e)) { jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, - (Sequence) av.getAlignment().getSequenceAt(seq)); + (Sequence) av.getAlignment().getSequenceAt(seq), + Preferences.sequenceURLLinks); pop.show(this, e.getX(), y); return; } - if (!e.isControlDown() && !e.isShiftDown() && + /* if (!e.isControlDown() && !e.isShiftDown() && (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null)) { + System.out.println("no modifiers"); SequenceGroup selection = new SequenceGroup(); SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( seq)); @@ -233,16 +298,17 @@ public class IdPanel extends JPanel implements MouseListener, av.setSelectionGroup(selection); return; - } + }*/ if ((av.getSelectionGroup() == null) || - (!e.isControlDown() && (av.getSelectionGroup() != null))) + ((!e.isControlDown() && !e.isShiftDown()) && av.getSelectionGroup() != null)) { - av.setSelectionGroup(new SequenceGroup()); + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().setStartRes(0); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); } - av.getSelectionGroup().setStartRes(0); - av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); + if (e.isShiftDown() && (lastid != -1)) { @@ -277,6 +343,9 @@ public class IdPanel extends JPanel implements MouseListener, */ void selectSeqs(int start, int end) { + if(av.getSelectionGroup()==null) + return; + lastid = start; if (end < start) @@ -289,7 +358,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); } }