/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
\r
import jalview.datamodel.*;\r
\r
+/**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @author $author$\r
+ * @version $Revision$\r
+ */\r
public class IdPanel\r
extends JPanel implements MouseListener,\r
- MouseMotionListener\r
+ MouseMotionListener, MouseWheelListener\r
{\r
protected IdCanvas idCanvas;\r
protected AlignViewport av;\r
int lastid = -1;\r
boolean mouseDragging = false;\r
\r
+ /**\r
+ * Creates a new IdPanel object.\r
+ *\r
+ * @param av DOCUMENT ME!\r
+ * @param parent DOCUMENT ME!\r
+ */\r
public IdPanel(AlignViewport av, AlignmentPanel parent)\r
{\r
this.av = av;\r
add(idCanvas, BorderLayout.CENTER);\r
addMouseListener(this);\r
addMouseMotionListener(this);\r
+ addMouseWheelListener(this);\r
+ ToolTipManager.sharedInstance().registerComponent(this);\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mouseMoved(MouseEvent e)\r
{\r
- }\r
+ int seq = Math.max(0, alignPanel.seqPanel.findSeq(e));\r
+ if (seq > -1 && seq < av.alignment.getHeight())\r
+ {\r
+ SequenceI sequence = av.alignment.getSequenceAt(seq);\r
+ StringBuffer tip = new StringBuffer("<html>");\r
+ tip.append(sequence.getDisplayId(true));\r
+ if (sequence.getDescription() != null)\r
+ {\r
+ tip.append("<table width=250 border=0><tr><td><i>");\r
+ tip.append(sequence.getDescription());\r
\r
- public void mouseDragged(MouseEvent e)\r
- {\r
- mouseDragging = true;\r
+ //ADD NON POSITIONAL SEQUENCE INFO\r
+ SequenceFeature[] features = sequence.getDatasetSequence().\r
+ getSequenceFeatures();\r
+ if (features != null)\r
+ {\r
+ for (int i = 0; i < features.length; i++)\r
+ {\r
+ if (features[i].begin == 0 && features[i].end == 0)\r
+ {\r
+ tip.append("<br>" + features[i].featureGroup\r
+ + " " + features[i].getType() + " " +\r
+ features[i].description);\r
+ }\r
+ }\r
+ }\r
+ tip.append("</i></td></tr></table>");\r
+ }\r
\r
- int y = e.getY();\r
+ DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef();\r
+ if (dbrefs != null)\r
+ {\r
+ tip.append("<i>");\r
+ for (int i = 0; i < dbrefs.length; i++)\r
+ {\r
+ tip.append("<br>");\r
+ tip.append(dbrefs[i].getSource() + " "\r
+ + dbrefs[i].getAccessionId());\r
+ }\r
+ tip.append("</i>");\r
+ }\r
\r
- if (av.getWrapAlignment())\r
- {\r
- y -= (2 * av.charHeight);\r
+ tip.append("</html>");\r
+ setToolTipText(tip.toString());\r
}\r
+ }\r
\r
- int seq = av.getIndex(y);\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
+ public void mouseDragged(MouseEvent e)\r
+ {\r
+ mouseDragging = true;\r
\r
- if (seq < 0)\r
- {\r
- return;\r
- }\r
+ int seq = Math.max(0, alignPanel.seqPanel.findSeq(e));\r
\r
if (seq < lastid)\r
{\r
}\r
\r
lastid = seq;\r
- alignPanel.repaint();\r
+ alignPanel.paintAlignment(true);\r
+ }\r
+\r
+ public void mouseWheelMoved(MouseWheelEvent e)\r
+ {\r
+ e.consume();\r
+ if (e.getWheelRotation() > 0)\r
+ {\r
+ alignPanel.scrollUp(false);\r
+ }\r
+ else\r
+ {\r
+ alignPanel.scrollUp(true);\r
+ }\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mouseClicked(MouseEvent e)\r
{\r
- if (e.getClickCount() == 2)\r
+ if (e.getClickCount() < 2)\r
{\r
- int y = e.getY();\r
+ return;\r
+ }\r
\r
- if (av.getWrapAlignment())\r
- {\r
- y -= (2 * av.charHeight);\r
- }\r
+ java.util.Vector links = Preferences.sequenceURLLinks;\r
+ if (links == null || links.size() < 1)\r
+ {\r
+ return;\r
+ }\r
\r
- int seq = av.getIndex(y);\r
- String id = av.getAlignment().getSequenceAt(seq).getName();\r
+ int seq = alignPanel.seqPanel.findSeq(e);\r
\r
- try\r
- {\r
- jalview.util.BrowserLauncher.openURL(\r
- "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[swall-id:" +\r
- id + "]+-vn+2");\r
- }\r
- catch (Exception ex)\r
- {\r
- // TODO: JBPNote : state dependent error message for real browserLaunch problems rather than unix misconfiguration.\r
- System.err.println(ex.getMessage() +\r
- "\nUnixers: Try adding this jalview.browser property line \n" +\r
- "in your jalview.properties file (/usr/local/bin/firefox is an exanmple browser path):\n" +\r
- "jalview.browser=/usr/local/bin/firefox\n");\r
+ //DEFAULT LINK IS FIRST IN THE LINK LIST\r
\r
- //ex.printStackTrace();\r
- }\r
+ String id = av.getAlignment().getSequenceAt(seq).getName();\r
+ if (id.indexOf("|") > -1)\r
+ {\r
+ id = id.substring(id.lastIndexOf("|") + 1);\r
+ }\r
+\r
+ String url = links.elementAt(0).toString();\r
+ url = url.substring(url.indexOf("|") + 1);\r
+\r
+ int index = url.indexOf("$SEQUENCE_ID$");\r
+ url = url.substring(0, index) + id + url.substring(index + 13);\r
+\r
+ try\r
+ {\r
+ jalview.util.BrowserLauncher.openURL(url);\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "Unixers: Couldn't find default web browser."\r
+ +\r
+ "\nAdd the full path to your browser in Preferences.",\r
+ "Web browser not found",\r
+ JOptionPane.WARNING_MESSAGE);\r
+ ex.printStackTrace();\r
}\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mouseEntered(MouseEvent e)\r
{\r
if (scrollThread != null)\r
}\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mouseExited(MouseEvent e)\r
{\r
if (av.getWrapAlignment())\r
}\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mousePressed(MouseEvent e)\r
{\r
if (e.getClickCount() == 2)\r
return;\r
}\r
\r
- int y = e.getY();\r
-\r
- if (av.getWrapAlignment())\r
- {\r
- y -= (2 * av.charHeight);\r
- }\r
-\r
- int seq = av.getIndex(y);\r
-\r
- if (seq == -1)\r
- {\r
- return;\r
- }\r
+ int seq = alignPanel.seqPanel.findSeq(e);\r
\r
if (javax.swing.SwingUtilities.isRightMouseButton(e))\r
{\r
jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel,\r
- (Sequence) av.getAlignment().getSequenceAt(seq));\r
- pop.show(this, e.getX(), y);\r
-\r
- return;\r
- }\r
-\r
- if (!e.isControlDown() && !e.isShiftDown() &&\r
- (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null))\r
- {\r
- SequenceGroup selection = new SequenceGroup();\r
- SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt(\r
- seq));\r
- selection.setStartRes(0);\r
- selection.setEndRes(av.alignment.getWidth() - 1);\r
-\r
- for (int i = 0; i < sg.getSize(); i++)\r
- {\r
- selection.addSequence(sg.getSequenceAt(i), true);\r
- }\r
-\r
- av.setSelectionGroup(selection);\r
+ (Sequence) av.getAlignment().getSequenceAt(seq),\r
+ Preferences.sequenceURLLinks);\r
+ pop.show(this, e.getX(), e.getY());\r
\r
return;\r
}\r
\r
if ( (av.getSelectionGroup() == null) ||\r
- (!e.isControlDown() && (av.getSelectionGroup() != null)))\r
+ ( (!e.isControlDown() && !e.isShiftDown()) && av.getSelectionGroup() != null))\r
{\r
av.setSelectionGroup(new SequenceGroup());\r
+ av.getSelectionGroup().setStartRes(0);\r
+ av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);\r
}\r
\r
- av.getSelectionGroup().setStartRes(0);\r
- av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);\r
-\r
if (e.isShiftDown() && (lastid != -1))\r
{\r
selectSeqs(lastid, seq);\r
selectSeq(seq);\r
}\r
\r
- alignPanel.repaint();\r
+ alignPanel.paintAlignment(true);\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param seq DOCUMENT ME!\r
+ */\r
void selectSeq(int seq)\r
{\r
lastid = seq;\r
av.getSelectionGroup().addOrRemove(pickedSeq, true);\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param start DOCUMENT ME!\r
+ * @param end DOCUMENT ME!\r
+ */\r
void selectSeqs(int start, int end)\r
{\r
+ if (av.getSelectionGroup() == null)\r
+ {\r
+ return;\r
+ }\r
+\r
+ if (end >= av.getAlignment().getHeight())\r
+ {\r
+ end = av.getAlignment().getHeight() - 1;\r
+ }\r
+\r
lastid = start;\r
\r
if (end < start)\r
\r
for (int i = start; i <= end; i++)\r
{\r
- av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i), true);\r
+ av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),\r
+ true);\r
}\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
public void mouseReleased(MouseEvent e)\r
{\r
if (scrollThread != null)\r
}\r
\r
mouseDragging = false;\r
- PaintRefresher.Refresh(av.alignment);\r
+ PaintRefresher.Refresh(this, av.getSequenceSetId());\r
}\r
\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param found DOCUMENT ME!\r
+ */\r
public void highlightSearchResults(java.util.Vector found)\r
{\r
idCanvas.setHighlighted(found);\r
running = false;\r
}\r
\r
- alignPanel.repaint();\r
+ alignPanel.paintAlignment(true);\r
\r
try\r
{\r