1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread", "java.util.Vector"], "jalview.appletgui.IdPanel", ["jalview.appletgui.APopupMenu", "$.IdCanvas", "$.PaintRefresher", "$.Tooltip", "jalview.datamodel.SequenceGroup", "jalview.util.UrlLink", "java.awt.BorderLayout", "java.lang.Float", "$.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 this.alignPanel = null;
7 this.scrollThread = null;
9 this.mouseDragging = false;
12 if (!Clazz.isClassDefined ("jalview.appletgui.IdPanel.ScrollThread")) {
13 jalview.appletgui.IdPanel.$IdPanel$ScrollThread$ ();
15 Clazz.instantialize (this, arguments);
16 }, jalview.appletgui, "IdPanel", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]);
17 Clazz.prepareFields (c$, function () {
18 this.links = new java.util.Vector ();
20 Clazz.makeConstructor (c$,
21 function (av, parent) {
22 Clazz.superConstructor (this, jalview.appletgui.IdPanel, []);
23 this.setName ("idPanel");
25 this.alignPanel = parent;
26 this.idCanvas = new jalview.appletgui.IdCanvas (av);
27 this.setLayout ( new java.awt.BorderLayout ());
28 this.add (this.idCanvas, "Center");
29 this.idCanvas.addMouseListener (this);
30 this.idCanvas.addMouseMotionListener (this);
31 if (av.applet != null) {
32 av.applet.getLinkParams (this.links);
34 var srsPos = this.links.indexOf ("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
36 this.links.setElementAt ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$", srsPos);
37 }}if (this.links.size () < 1) {
38 this.links = new java.util.Vector ();
39 this.links.addElement ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
40 }}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel");
41 Clazz.overrideMethod (c$, "mouseMoved",
43 var seq = this.alignPanel.seqPanel.findSeq (e);
44 var sequence = this.av.getAlignment ().getSequenceAt (seq);
45 var tooltiptext = new StringBuffer ();
46 if (sequence != null) {
47 if (sequence.getDescription () != null) {
48 tooltiptext.append (sequence.getDescription ());
49 tooltiptext.append ("\n");
50 }var sf = sequence.getSequenceFeatures ();
51 for (var sl = 0; sf != null && sl < sf.length; sl++) {
52 if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) {
54 if (sf[sl].getFeatureGroup () != null) {
55 tooltiptext.append (sf[sl].getFeatureGroup ());
57 };if (sf[sl].getType () != null) {
58 tooltiptext.append (" ");
59 tooltiptext.append (sf[sl].getType ());
61 };if (sf[sl].getDescription () != null) {
62 tooltiptext.append (" ");
63 tooltiptext.append (sf[sl].getDescription ());
65 };if (!Float.isNaN (sf[sl].getScore ()) && sf[sl].getScore () != 0) {
66 tooltiptext.append (" Score = ");
67 tooltiptext.append (sf[sl].getScore ());
69 };if (sf[sl].getStatus () != null && sf[sl].getStatus ().length > 0) {
70 tooltiptext.append (" (");
71 tooltiptext.append (sf[sl].getStatus ());
72 tooltiptext.append (")");
75 tooltiptext.append ("\n");
77 }if (tooltiptext.length () == 0) {
78 if (this.tooltip != null) {
79 this.tooltip.setVisible (false);
83 }if (this.tooltip == null) {
84 this.tooltip = new jalview.appletgui.Tooltip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString (), this.idCanvas);
86 this.tooltip.setTip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString ());
88 }, "java.awt.event.MouseEvent");
89 Clazz.overrideMethod (c$, "mouseDragged",
91 this.mouseDragging = true;
92 var seq = Math.max (0, this.alignPanel.seqPanel.findSeq (e));
93 if (seq < this.lastid) {
94 this.selectSeqs (this.lastid - 1, seq);
95 } else if (seq > this.lastid) {
96 this.selectSeqs (this.lastid + 1, seq);
98 this.alignPanel.paintAlignment (false);
99 }, "java.awt.event.MouseEvent");
100 Clazz.overrideMethod (c$, "mouseClicked",
102 if (e.getClickCount () < 2) {
104 }var seq = this.alignPanel.seqPanel.findSeq (e);
105 var sq = this.av.getAlignment ().getSequenceAt (seq);
108 }var id = sq.getName ();
112 while (url == null && i < this.links.size ()) {
113 url = this.links.elementAt (i++).toString ();
116 urlLink = new jalview.util.UrlLink (url);
117 target = urlLink.getTarget ();
119 if (Clazz.exceptionOf (foo, Exception)) {
120 System.err.println ("Exception for URLLink '" + url + "'");
121 foo.printStackTrace ();
128 ;if (!urlLink.isValid ()) {
129 System.err.println (urlLink.getInvalidMessage ());
132 }var urls = urlLink.makeUrls (id, true);
133 if (urls == null || urls[0] == null || urls[0].length < 1) {
139 this.alignPanel.alignFrame.showURL (url, target);
141 if (Clazz.exceptionOf (ex, Exception)) {
142 ex.printStackTrace ();
147 }, "java.awt.event.MouseEvent");
148 Clazz.overrideMethod (c$, "mouseEntered",
150 if (this.scrollThread != null) {
151 this.scrollThread.running = false;
152 }}, "java.awt.event.MouseEvent");
153 Clazz.overrideMethod (c$, "mouseExited",
155 if (this.av.getWrapAlignment ()) {
157 }if (this.mouseDragging && e.getY () < 0 && this.av.getStartSeq () > 0) {
158 this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, true);
159 }if (this.mouseDragging && e.getY () >= this.getSize ().height && this.av.getAlignment ().getHeight () > this.av.getEndSeq ()) {
160 this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, false);
161 }}, "java.awt.event.MouseEvent");
162 Clazz.overrideMethod (c$, "mousePressed",
164 if (e.getClickCount () > 1) {
167 if (this.av.getWrapAlignment ()) {
168 y -= 2 * this.av.getCharHeight ();
169 }var seq = this.alignPanel.seqPanel.findSeq (e);
170 if ((e.getModifiers () & 4) == 4) {
171 var sq = this.av.getAlignment ().getSequenceAt (seq);
172 var nlinks = new java.util.Vector ();
173 for (var l = 0, lSize = this.links.size (); l < lSize; l++) {
174 nlinks.addElement (this.links.elementAt (l));
176 var sf = sq == null ? null : sq.getSequenceFeatures ();
177 for (var sl = 0; sf != null && sl < sf.length; sl++) {
178 if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) {
179 if (sf[sl].links != null && sf[sl].links.size () > 0) {
180 for (var l = 0, lSize = sf[sl].links.size (); l < lSize; l++) {
181 nlinks.addElement (sf[sl].links.elementAt (l));
184 var popup = new jalview.appletgui.APopupMenu (this.alignPanel, sq, nlinks);
186 popup.show (this, e.getX (), e.getY ());
188 }if ((this.av.getSelectionGroup () == null) || ((!e.isControlDown () && !e.isShiftDown ()) && this.av.getSelectionGroup () != null)) {
189 this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ());
190 this.av.getSelectionGroup ().setStartRes (0);
191 this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1);
192 }if (e.isShiftDown () && this.lastid != -1) {
193 this.selectSeqs (this.lastid, seq);
195 this.selectSeq (seq);
196 }this.alignPanel.paintAlignment (false);
197 }, "java.awt.event.MouseEvent");
198 Clazz.defineMethod (c$, "selectSeq",
201 var pickedSeq = this.av.getAlignment ().getSequenceAt (seq);
202 this.av.getSelectionGroup ().addOrRemove (pickedSeq, true);
204 Clazz.defineMethod (c$, "selectSeqs",
205 function (start, end) {
207 if (end >= this.av.getAlignment ().getHeight ()) {
208 end = this.av.getAlignment ().getHeight () - 1;
214 }if (this.av.getSelectionGroup () == null) {
215 this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ());
216 }for (var i = start; i <= end; i++) {
217 this.av.getSelectionGroup ().addSequence (this.av.getAlignment ().getSequenceAt (i), i == end);
220 Clazz.overrideMethod (c$, "mouseReleased",
222 if (this.scrollThread != null) {
223 this.scrollThread.running = false;
224 }if (this.av.getSelectionGroup () != null) {
225 this.av.getSelectionGroup ().recalcConservation ();
226 }this.mouseDragging = false;
227 jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());
228 this.av.sendSelection ();
229 }, "java.awt.event.MouseEvent");
230 Clazz.defineMethod (c$, "highlightSearchResults",
232 this.idCanvas.setHighlighted (list);
235 }var index = this.av.getAlignment ().findIndex (list.get (0));
236 if (this.av.getStartSeq () > index || this.av.getEndSeq () < index) {
237 this.alignPanel.setScrollValues (this.av.getStartRes (), index);
238 }}, "java.util.List");
239 c$.$IdPanel$ScrollThread$ = function () {
241 c$ = Clazz.decorateAsClass (function () {
242 Clazz.prepareCallback (this, arguments);
243 this.running = false;
245 Clazz.instantialize (this, arguments);
246 }, jalview.appletgui.IdPanel, "ScrollThread", Thread);
247 Clazz.makeConstructor (c$,
249 Clazz.superConstructor (this, jalview.appletgui.IdPanel.ScrollThread, []);
253 Clazz.defineMethod (c$, "stopScrolling",
255 this.running = false;
257 Clazz.overrideMethod (c$, "run",
260 while (this.running) {
261 if (this.b$["jalview.appletgui.IdPanel"].alignPanel.scrollUp (this.up)) {
262 var a = this.b$["jalview.appletgui.IdPanel"].av.getStartSeq ();
264 a = this.b$["jalview.appletgui.IdPanel"].av.getEndSeq ();
265 }if (a < this.b$["jalview.appletgui.IdPanel"].lastid) {
266 this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid - 1, a);
267 } else if (a > this.b$["jalview.appletgui.IdPanel"].lastid && a < this.b$["jalview.appletgui.IdPanel"].av.getAlignment ().getHeight ()) {
268 this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid + 1, a);
269 }this.b$["jalview.appletgui.IdPanel"].lastid = a;
271 this.running = false;
272 }this.b$["jalview.appletgui.IdPanel"].alignPanel.paintAlignment (true);
276 if (Clazz.exceptionOf (ex, Exception)) {