1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "jalview.structure.SelectionListener", "$.SequenceListener", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread"], "jalview.appletgui.SeqPanel", ["jalview.api.AlignViewportI", "jalview.appletgui.APopupMenu", "$.AlignViewport", "$.PaintRefresher", "$.SeqCanvas", "$.SliderPanel", "$.Tooltip", "jalview.commands.EditCommand", "jalview.datamodel.ColumnSelection", "$.SearchResults", "$.SequenceGroup", "jalview.schemes.ResidueProperties", "jalview.structure.StructureSelectionManager", "jalview.util.Comparison", "$.MappingUtils", "$.MessageManager", "java.awt.BorderLayout", "$.Font", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
9 this.seqEditOccurred = false;
10 this.scrollThread = null;
11 this.mouseDragging = false;
12 this.editingSeqs = false;
13 this.groupEditing = false;
15 this.changeEndSeq = false;
16 this.changeStartSeq = false;
17 this.changeEndRes = false;
18 this.changeStartRes = false;
19 this.stretchGroup = null;
20 this.keyboardNo1 = null;
21 this.keyboardNo2 = null;
22 this.mouseWheelPressed = false;
23 this.lastMousePress = null;
24 this.editCommand = null;
26 this.startWrapBlock = -1;
27 this.wrappedBlock = -1;
28 this.lastMessage = null;
30 if (!Clazz.isClassDefined ("jalview.appletgui.SeqPanel.ScrollThread")) {
31 jalview.appletgui.SeqPanel.$SeqPanel$ScrollThread$ ();
33 Clazz.instantialize (this, arguments);
34 }, jalview.appletgui, "SeqPanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener, jalview.structure.SequenceListener, jalview.structure.SelectionListener]);
35 Clazz.makeConstructor (c$,
37 Clazz.superConstructor (this, jalview.appletgui.SeqPanel, []);
39 this.setName ("seqPanel");
40 this.seqCanvas = new jalview.appletgui.SeqCanvas (avp);
41 this.setLayout ( new java.awt.BorderLayout ());
42 this.add (this.seqCanvas);
44 this.seqCanvas.addMouseMotionListener (this);
45 this.seqCanvas.addMouseListener (this);
46 this.ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet);
47 this.ssm.addStructureViewerListener (this);
48 this.ssm.addSelectionListener (this);
49 this.seqCanvas.repaint ();
50 }, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel");
51 Clazz.defineMethod (c$, "endEditing",
53 if (this.editCommand != null && this.editCommand.getSize () > 0) {
54 this.ap.alignFrame.addHistoryItem (this.editCommand);
55 this.av.firePropertyChange ("alignment", null, this.av.getAlignment ().getSequences ());
58 this.editingSeqs = false;
59 this.groupEditing = false;
60 this.keyboardNo1 = null;
61 this.keyboardNo2 = null;
62 this.editCommand = null;
64 Clazz.defineMethod (c$, "setCursorRow",
66 this.seqCanvas.cursorY = this.getKeyboardNo1 () - 1;
67 this.scrollToVisible ();
69 Clazz.defineMethod (c$, "setCursorColumn",
71 this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1;
72 this.scrollToVisible ();
74 Clazz.defineMethod (c$, "setCursorRowAndColumn",
76 if (this.keyboardNo2 == null) {
77 this.keyboardNo2 = new StringBuffer ();
79 this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1;
80 this.seqCanvas.cursorY = this.getKeyboardNo2 () - 1;
81 this.scrollToVisible ();
83 Clazz.defineMethod (c$, "setCursorPosition",
85 var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY);
86 this.seqCanvas.cursorX = sequence.findIndex (this.getKeyboardNo1 ()) - 1;
87 this.scrollToVisible ();
89 Clazz.defineMethod (c$, "moveCursor",
91 this.seqCanvas.cursorX += dx;
92 this.seqCanvas.cursorY += dy;
93 if (this.av.hasHiddenColumns () && !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) {
94 var original = this.seqCanvas.cursorX - dx;
95 var maxWidth = this.av.getAlignment ().getWidth ();
96 while (!this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX) && this.seqCanvas.cursorX < maxWidth && this.seqCanvas.cursorX > 0) {
97 this.seqCanvas.cursorX += dx;
99 if (this.seqCanvas.cursorX >= maxWidth || !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) {
100 this.seqCanvas.cursorX = original;
101 }}this.scrollToVisible ();
103 Clazz.defineMethod (c$, "scrollToVisible",
105 if (this.seqCanvas.cursorX < 0) {
106 this.seqCanvas.cursorX = 0;
107 } else if (this.seqCanvas.cursorX > this.av.getAlignment ().getWidth () - 1) {
108 this.seqCanvas.cursorX = this.av.getAlignment ().getWidth () - 1;
109 }if (this.seqCanvas.cursorY < 0) {
110 this.seqCanvas.cursorY = 0;
111 } else if (this.seqCanvas.cursorY > this.av.getAlignment ().getHeight () - 1) {
112 this.seqCanvas.cursorY = this.av.getAlignment ().getHeight () - 1;
114 if (this.av.getWrapAlignment ()) {
115 this.ap.scrollToWrappedVisible (this.seqCanvas.cursorX);
117 while (this.seqCanvas.cursorY < this.av.startSeq) {
118 this.ap.scrollUp (true);
120 while (this.seqCanvas.cursorY + 1 > this.av.endSeq) {
121 this.ap.scrollUp (false);
123 while (this.seqCanvas.cursorX < this.av.getColumnSelection ().adjustForHiddenColumns (this.av.startRes)) {
124 if (!this.ap.scrollRight (false)) {
127 while (this.seqCanvas.cursorX > this.av.getColumnSelection ().adjustForHiddenColumns (this.av.endRes)) {
128 if (!this.ap.scrollRight (true)) {
131 }this.setStatusMessage (this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY), this.seqCanvas.cursorX, this.seqCanvas.cursorY);
132 this.seqCanvas.repaint ();
134 Clazz.defineMethod (c$, "setSelectionAreaAtCursor",
136 var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY);
137 if (this.av.getSelectionGroup () != null) {
138 var sg = this.av.getSelectionGroup ();
139 var min = this.av.getAlignment ().getHeight ();
141 for (var i = 0; i < sg.getSize (); i++) {
142 var index = this.av.getAlignment ().findIndex (sg.getSequenceAt (i));
150 sg.setStartRes (this.seqCanvas.cursorX);
151 if (sg.getEndRes () < this.seqCanvas.cursorX) {
152 sg.setEndRes (this.seqCanvas.cursorX);
153 }min = this.seqCanvas.cursorY;
155 sg.setEndRes (this.seqCanvas.cursorX);
156 if (sg.getStartRes () > this.seqCanvas.cursorX) {
157 sg.setStartRes (this.seqCanvas.cursorX);
158 }max = this.seqCanvas.cursorY + 1;
160 this.av.setSelectionGroup (null);
163 for (var i = min; i < max; i++) {
164 sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false);
166 }}if (this.av.getSelectionGroup () == null) {
167 var sg = new jalview.datamodel.SequenceGroup ();
168 sg.setStartRes (this.seqCanvas.cursorX);
169 sg.setEndRes (this.seqCanvas.cursorX);
170 sg.addSequence (sequence, false);
171 this.av.setSelectionGroup (sg);
172 }this.ap.paintAlignment (false);
173 this.av.sendSelection ();
175 Clazz.defineMethod (c$, "insertGapAtCursor",
177 this.groupEditing = group;
178 this.startseq = this.seqCanvas.cursorY;
179 this.lastres = this.seqCanvas.cursorX;
180 this.editSequence (true, this.seqCanvas.cursorX + this.getKeyboardNo1 ());
183 Clazz.defineMethod (c$, "deleteGapAtCursor",
185 this.groupEditing = group;
186 this.startseq = this.seqCanvas.cursorY;
187 this.lastres = this.seqCanvas.cursorX + this.getKeyboardNo1 ();
188 this.editSequence (false, this.seqCanvas.cursorX);
191 Clazz.defineMethod (c$, "numberPressed",
193 if (this.keyboardNo1 == null) {
194 this.keyboardNo1 = new StringBuffer ();
195 }if (this.keyboardNo2 != null) {
196 this.keyboardNo2.append (value);
198 this.keyboardNo1.append (value);
200 Clazz.defineMethod (c$, "getKeyboardNo1",
203 if (this.keyboardNo1 != null) {
204 var value = Integer.parseInt (this.keyboardNo1.toString ());
205 this.keyboardNo1 = null;
208 if (Clazz.exceptionOf (x, Exception)) {
213 this.keyboardNo1 = null;
216 Clazz.defineMethod (c$, "getKeyboardNo2",
219 if (this.keyboardNo2 != null) {
220 var value = Integer.parseInt (this.keyboardNo2.toString ());
221 this.keyboardNo2 = null;
224 if (Clazz.exceptionOf (x, Exception)) {
229 this.keyboardNo2 = null;
232 Clazz.defineMethod (c$, "setStatusMessage",
233 function (sequence, res, seq) {
234 var text = new StringBuilder (32);
235 var seqno = seq == -1 ? "" : " " + (seq + 1);
236 text.append ("Sequence" + seqno + " ID: " + sequence.getName ());
238 var displayChar = String.valueOf (sequence.getCharAt (res));
239 if (this.av.getAlignment ().isNucleotide ()) {
240 residue = jalview.schemes.ResidueProperties.nucleotideName.get (displayChar);
241 if (residue != null) {
242 text.append (" Nucleotide: ").append (residue);
244 residue = "X".equalsIgnoreCase (displayChar) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (displayChar);
245 if (residue != null) {
246 text.append (" Residue: ").append (residue);
248 if (residue != null) {
249 pos = sequence.findPosition (res);
250 text.append (" (").append (Integer.toString (pos)).append (")");
251 }this.ap.alignFrame.setStatus (text.toString ());
252 }, "jalview.datamodel.SequenceI,~N,~N");
253 Clazz.defineMethod (c$, "setStatusMessage",
254 ($fz = function (results) {
255 var matches = results.getResults ();
256 if (!matches.isEmpty ()) {
257 var m = matches.get (0);
258 var seq = m.getSequence ();
259 var sequenceIndex = this.av.getAlignment ().findIndex (seq);
260 var start = m.getStart () - 1;
261 this.setStatusMessage (seq, start, sequenceIndex);
262 }}, $fz.isPrivate = true, $fz), "jalview.datamodel.SearchResults");
263 Clazz.overrideMethod (c$, "mousePressed",
265 this.lastMousePress = evt.getPoint ();
266 if ((evt.getModifiers () & 8) == 8 && !this.av.MAC) {
267 this.mouseWheelPressed = true;
269 }if (evt.isShiftDown () || evt.isControlDown () || evt.isAltDown ()) {
270 if (evt.isControlDown () || evt.isAltDown ()) {
271 this.groupEditing = true;
272 }this.editingSeqs = true;
274 this.doMousePressedDefineMode (evt);
276 }var seq = this.findSeq (evt);
277 var res = this.findRes (evt);
278 if (seq < 0 || res < 0) {
280 }if ((seq < this.av.getAlignment ().getHeight ()) && (res < this.av.getAlignment ().getSequenceAt (seq).getLength ())) {
287 }, "java.awt.event.MouseEvent");
288 Clazz.overrideMethod (c$, "mouseClicked",
290 var sequence = this.av.getAlignment ().getSequenceAt (this.findSeq (evt));
291 if (evt.getClickCount () > 1) {
292 if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSize () == 1 && this.av.getSelectionGroup ().getEndRes () - this.av.getSelectionGroup ().getStartRes () < 2) {
293 this.av.setSelectionGroup (null);
294 }var features = this.findFeaturesAtRes (sequence, sequence.findPosition (this.findRes (evt)));
295 if (features != null && features.length > 0) {
296 var highlight = new jalview.datamodel.SearchResults ();
297 highlight.addResult (sequence, features[0].getBegin (), features[0].getEnd ());
298 this.seqCanvas.highlightSearchResults (highlight);
299 }if (features != null && features.length > 0) {
300 this.seqCanvas.getFeatureRenderer ().amendFeatures ( Clazz.newArray (-1, [sequence]), features, false, this.ap);
301 this.seqCanvas.highlightSearchResults (null);
302 }}}, "java.awt.event.MouseEvent");
303 Clazz.overrideMethod (c$, "mouseReleased",
305 this.mouseDragging = false;
306 this.mouseWheelPressed = false;
307 this.ap.paintAlignment (true);
308 if (!this.editingSeqs) {
309 this.doMouseReleasedDefineMode (evt);
312 }, "java.awt.event.MouseEvent");
313 Clazz.defineMethod (c$, "findRes",
317 if (this.av.getWrapAlignment ()) {
318 var hgap = this.av.getCharHeight ();
319 if (this.av.getScaleAboveWrapped ()) {
320 hgap += this.av.getCharHeight ();
321 }var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight ();
324 x -= this.seqCanvas.LABEL_WEST;
325 var cwidth = this.seqCanvas.getWrappedCanvasWidth (this.getSize ().width);
328 }this.wrappedBlock = Clazz.doubleToInt (y / cHeight);
329 this.wrappedBlock += Clazz.doubleToInt (this.av.getStartRes () / cwidth);
330 res = this.wrappedBlock * cwidth + Clazz.doubleToInt (x / this.av.getCharWidth ());
332 res = (Clazz.doubleToInt (x / this.av.getCharWidth ())) + this.av.getStartRes ();
333 }if (this.av.hasHiddenColumns ()) {
334 res = this.av.getColumnSelection ().adjustForHiddenColumns (res);
336 }, "java.awt.event.MouseEvent");
337 Clazz.defineMethod (c$, "findSeq",
339 var sqnum = this.findAlRow (evt);
340 return (sqnum < 0) ? 0 : sqnum;
341 }, "java.awt.event.MouseEvent");
342 Clazz.defineMethod (c$, "findAlRow",
343 ($fz = function (evt) {
346 if (this.av.getWrapAlignment ()) {
347 var hgap = this.av.getCharHeight ();
348 if (this.av.getScaleAboveWrapped ()) {
349 hgap += this.av.getCharHeight ();
350 }var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight ();
352 seq = Math.min (Clazz.doubleToInt ((y % cHeight) / this.av.getCharHeight ()), this.av.getAlignment ().getHeight () - 1);
356 seq = Math.min ((Clazz.doubleToInt (y / this.av.getCharHeight ())) + this.av.getStartSeq (), this.av.getAlignment ().getHeight () - 1);
360 }, $fz.isPrivate = true, $fz), "java.awt.event.MouseEvent");
361 Clazz.defineMethod (c$, "doMousePressed",
363 var seq = this.findSeq (evt);
364 var res = this.findRes (evt);
365 if (seq < this.av.getAlignment ().getHeight () && res < this.av.getAlignment ().getSequenceAt (seq).getLength ()) {
372 }, "java.awt.event.MouseEvent");
373 Clazz.overrideMethod (c$, "mouseOverSequence",
374 function (sequence, index, pos) {
375 var tmp = sequence.hashCode () + index + "";
376 if (this.lastMessage == null || !this.lastMessage.equals (tmp)) {
377 this.ssm.mouseOverSequence (sequence, index, pos, this.av);
378 }this.lastMessage = tmp;
379 }, "jalview.datamodel.SequenceI,~N,~N");
380 Clazz.overrideMethod (c$, "highlightSequence",
382 if (this.av.isFollowHighlight ()) {
383 if (this.ap.scrollToPosition (results, true)) {
384 this.ap.alignFrame.repaint ();
385 }}this.setStatusMessage (results);
386 this.seqCanvas.highlightSearchResults (results);
387 }, "jalview.datamodel.SearchResults");
388 Clazz.overrideMethod (c$, "getVamsasSource",
390 return this.ap == null ? null : this.ap.av;
392 Clazz.overrideMethod (c$, "updateColours",
393 function (seq, index) {
394 System.out.println ("update the seqPanel colours");
395 }, "jalview.datamodel.SequenceI,~N");
396 Clazz.overrideMethod (c$, "mouseMoved",
398 var res = this.findRes (evt);
399 var seq = this.findSeq (evt);
400 if (seq >= this.av.getAlignment ().getHeight () || seq < 0 || res < 0) {
401 if (this.tooltip != null) {
402 this.tooltip.setTip ("");
404 }var sequence = this.av.getAlignment ().getSequenceAt (seq);
405 if (res > sequence.getLength ()) {
406 if (this.tooltip != null) {
407 this.tooltip.setTip ("");
409 }var respos = sequence.findPosition (res);
410 if (this.ssm != null) {
411 this.mouseOverSequence (sequence, res, respos);
412 }var text = new StringBuilder ();
413 text.append ("Sequence ").append (Integer.toString (seq + 1)).append (" ID: ").append (sequence.getName ());
415 var ch = String.valueOf (sequence.getCharAt (res));
416 if (this.av.getAlignment ().isNucleotide ()) {
417 obj = jalview.schemes.ResidueProperties.nucleotideName.get (ch);
419 text.append (" Nucleotide: ").append (obj);
421 obj = "X".equalsIgnoreCase (ch) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (ch);
423 text.append (" Residue: ").append (obj);
425 text.append (" (").append (Integer.toString (respos)).append (")");
426 }this.ap.alignFrame.setStatus (text.toString ());
427 var tooltipText = new StringBuilder ();
428 var groups = this.av.getAlignment ().findAllGroups (sequence);
429 if (groups != null) {
430 for (var g = 0; g < groups.length; g++) {
431 if (groups[g].getStartRes () <= res && groups[g].getEndRes () >= res) {
432 if (!groups[g].getName ().startsWith ("JTreeGroup") && !groups[g].getName ().startsWith ("JGroup")) {
433 tooltipText.append (groups[g].getName ()).append (" ");
434 }if (groups[g].getDescription () != null) {
435 tooltipText.append (groups[g].getDescription ());
436 }tooltipText.append ("\n");
438 }var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res));
440 while (index < allFeatures.length) {
441 var sf = allFeatures[index];
442 tooltipText.append (sf.getType () + " " + sf.begin + ":" + sf.end);
443 if (sf.getDescription () != null) {
444 tooltipText.append (" " + sf.getDescription ());
445 }if (sf.getValue ("status") != null) {
446 var status = sf.getValue ("status").toString ();
447 if (status.length > 0) {
448 tooltipText.append (" (" + sf.getValue ("status") + ")");
449 }}tooltipText.append ("\n");
452 if (this.tooltip == null) {
453 this.tooltip = new jalview.appletgui.Tooltip (tooltipText.toString (), this.seqCanvas);
455 this.tooltip.setTip (tooltipText.toString ());
456 }}, "java.awt.event.MouseEvent");
457 Clazz.defineMethod (c$, "findFeaturesAtRes",
458 function (sequence, res) {
459 var tmp = new java.util.Vector ();
460 var features = sequence.getSequenceFeatures ();
461 if (features != null) {
462 for (var i = 0; i < features.length; i++) {
463 if (this.av.getFeaturesDisplayed () == null || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) {
465 }if (features[i].featureGroup != null && !this.seqCanvas.fr.checkGroupVisibility (features[i].featureGroup, false)) {
467 }if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) {
468 tmp.addElement (features[i]);
470 }features = new Array (tmp.size ());
471 tmp.copyInto (features);
473 }, "jalview.datamodel.SequenceI,~N");
474 Clazz.overrideMethod (c$, "mouseDragged",
476 if (this.mouseWheelPressed) {
477 var oldWidth = this.av.getCharWidth ();
478 if (Math.abs (evt.getY () - this.lastMousePress.y) > Math.abs (evt.getX () - this.lastMousePress.x)) {
479 var fontSize = this.av.font.getSize ();
480 if (evt.getY () < this.lastMousePress.y && this.av.getCharHeight () > 1) {
482 } else if (evt.getY () > this.lastMousePress.y) {
486 }this.av.setFont ( new java.awt.Font (this.av.font.getName (), this.av.font.getStyle (), fontSize));
487 this.av.setCharWidth (oldWidth);
489 if (evt.getX () < this.lastMousePress.x && this.av.getCharWidth () > 1) {
490 this.av.setCharWidth (this.av.getCharWidth () - 1);
491 } else if (evt.getX () > this.lastMousePress.x) {
492 this.av.setCharWidth (this.av.getCharWidth () + 1);
493 }if (this.av.getCharWidth () < 1) {
494 this.av.setCharWidth (1);
495 }}this.ap.fontChanged ();
496 var fm = this.getFontMetrics (this.av.getFont ());
497 this.av.validCharWidth = fm.charWidth ('M') <= this.av.getCharWidth ();
498 this.lastMousePress = evt.getPoint ();
499 this.ap.paintAlignment (false);
500 this.ap.annotationPanel.image = null;
502 }if (!this.editingSeqs) {
503 this.doMouseDraggedDefineMode (evt);
505 }var res = this.findRes (evt);
508 }if ((this.lastres == -1) || (this.lastres == res)) {
510 }if ((res < this.av.getAlignment ().getWidth ()) && (res < this.lastres)) {
511 this.editSequence (false, res);
513 this.editSequence (true, res);
514 }this.mouseDragging = true;
515 if (this.scrollThread != null) {
516 this.scrollThread.setEvent (evt);
517 }}, "java.awt.event.MouseEvent");
518 Clazz.defineMethod (c$, "editSequence",
519 function (insertGap, startres) {
522 var fixedColumns = false;
523 var sg = this.av.getSelectionGroup ();
524 var seq = this.av.getAlignment ().getSequenceAt (this.startseq);
525 if (!this.groupEditing && this.av.hasHiddenRows ()) {
526 if (this.av.isHiddenRepSequence (seq)) {
527 sg = this.av.getRepresentedSequences (seq);
528 this.groupEditing = true;
529 }}var message = new StringBuffer ();
530 if (this.groupEditing) {
531 message.append (jalview.util.MessageManager.getString ("action.edit_group")).append (":");
532 if (this.editCommand == null) {
533 this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.edit_group"));
535 message.append (jalview.util.MessageManager.getString ("label.edit_sequence")).append (" " + seq.getName ());
536 var label = seq.getName ();
537 if (label.length > 10) {
538 label = label.substring (0, 10);
539 }if (this.editCommand == null) {
540 this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.formatMessage ("label.edit_params", Clazz.newArray (-1, [label])));
542 message.append (" insert ");
544 message.append (" delete ");
545 }message.append (Math.abs (startres - this.lastres) + " gaps.");
546 this.ap.alignFrame.setStatus (message.toString ());
547 if (this.groupEditing || (sg != null && sg.getSequences (this.av.getHiddenRepSequences ()).contains (seq))) {
550 if (!this.av.isHiddenRepSequence (seq)) {
553 }sg = this.av.getRepresentedSequences (seq);
554 }fixedLeft = sg.getStartRes ();
555 fixedRight = sg.getEndRes ();
556 if ((startres < fixedLeft && this.lastres >= fixedLeft) || (startres >= fixedLeft && this.lastres < fixedLeft) || (startres > fixedRight && this.lastres <= fixedRight) || (startres <= fixedRight && this.lastres > fixedRight)) {
559 }if (fixedLeft > startres) {
560 fixedRight = fixedLeft - 1;
562 } else if (fixedRight < startres) {
563 fixedLeft = fixedRight;
565 }}if (this.av.hasHiddenColumns ()) {
567 var y1 = this.av.getColumnSelection ().getHiddenBoundaryLeft (startres);
568 var y2 = this.av.getColumnSelection ().getHiddenBoundaryRight (startres);
569 if ((insertGap && startres > y1 && this.lastres < y1) || (!insertGap && startres < y2 && this.lastres > y2)) {
572 }if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) {
573 if (startres >= y2) {
577 }}}if (this.groupEditing) {
578 var groupSeqs = sg.getSequences (this.av.getHiddenRepSequences ()).toArray ( new Array (0));
580 if (sg.getStartRes () == 0 && sg.getEndRes () == fixedRight && sg.getEndRes () == this.av.getAlignment ().getWidth () - 1) {
581 sg.setEndRes (this.av.getAlignment ().getWidth () + startres - this.lastres);
582 fixedRight = sg.getEndRes ();
584 for (fixedRight = fixedRight; fixedRight > this.lastres; fixedRight--) {
586 for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) {
587 for (var j = 0; j < startres - this.lastres; j++) {
588 if (!jalview.util.Comparison.isGap (gs.getCharAt (fixedRight - j))) {
597 if (sg.getSize () == this.av.getAlignment ().getHeight ()) {
598 if ((this.av.hasHiddenColumns () && startres < this.av.getColumnSelection ().getHiddenBoundaryRight (startres))) {
601 }var alWidth = this.av.getAlignment ().getWidth ();
602 if (this.av.hasHiddenRows ()) {
603 var hwidth = this.av.getAlignment ().getHiddenSequences ().getWidth ();
604 if (hwidth > alWidth) {
606 }}sg.setEndRes (sg.getEndRes () + startres - this.lastres);
607 fixedRight = alWidth + startres - this.lastres;
611 }}} else if (!insertGap) {
612 for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) {
613 for (var j = startres; j < this.lastres; j++) {
614 if (gs.getLength () <= j) {
616 }if (!jalview.util.Comparison.isGap (gs.getCharAt (j))) {
622 if (fixedColumns && fixedRight != -1) {
623 for (var j = this.lastres; j < startres; j++) {
624 this.insertChar (j, groupSeqs, fixedRight);
627 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, groupSeqs, startres, startres - this.lastres, this.av.getAlignment (), true);
629 if (fixedColumns && fixedRight != -1) {
630 for (var j = this.lastres; j > startres; j--) {
631 this.deleteChar (startres, groupSeqs, fixedRight);
634 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, groupSeqs, startres, this.lastres - startres, this.av.getAlignment (), true);
637 if (fixedColumns && fixedRight != -1) {
638 for (var j = this.lastres; j < startres; j++) {
639 this.insertChar (j, Clazz.newArray (-1, [seq]), fixedRight);
642 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, Clazz.newArray (-1, [seq]), this.lastres, startres - this.lastres, this.av.getAlignment (), true);
644 if (fixedColumns && fixedRight != -1) {
645 for (var j = this.lastres; j > startres; j--) {
646 if (!jalview.util.Comparison.isGap (seq.getCharAt (startres))) {
649 }this.deleteChar (startres, Clazz.newArray (-1, [seq]), fixedRight);
653 for (var m = startres; m < this.lastres; m++) {
654 if (!jalview.util.Comparison.isGap (seq.getCharAt (m))) {
659 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seq]), startres, max, this.av.getAlignment (), true);
660 }}}}this.lastres = startres;
661 this.seqCanvas.repaint ();
663 Clazz.defineMethod (c$, "insertChar",
664 function (j, seq, fixedColumn) {
665 var blankColumn = fixedColumn;
666 for (var s = 0; s < seq.length; s++) {
667 for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) {
668 if (jalview.util.Comparison.isGap (seq[s].getCharAt (blankColumn))) {
671 if (blankColumn <= j) {
672 blankColumn = fixedColumn;
676 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, blankColumn, 1, this.av.getAlignment (), true);
677 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, j, 1, this.av.getAlignment (), true);
679 Clazz.defineMethod (c$, "deleteChar",
680 function (j, seq, fixedColumn) {
681 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, j, 1, this.av.getAlignment (), true);
682 this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, fixedColumn, 1, this.av.getAlignment (), true);
684 Clazz.defineMethod (c$, "doMousePressedDefineMode",
686 if (this.scrollThread != null) {
687 this.scrollThread.running = false;
688 this.scrollThread = null;
689 }var res = this.findRes (evt);
690 var seq = this.findSeq (evt);
692 this.startWrapBlock = this.wrappedBlock;
695 }var sequence = this.av.getAlignment ().getSequenceAt (seq);
696 if (sequence == null || res > sequence.getLength ()) {
698 }this.stretchGroup = this.av.getSelectionGroup ();
699 if (this.stretchGroup == null) {
700 this.stretchGroup = this.av.getAlignment ().findGroup (sequence);
701 if (this.stretchGroup != null && res > this.stretchGroup.getStartRes () && res < this.stretchGroup.getEndRes ()) {
702 this.av.setSelectionGroup (this.stretchGroup);
704 this.stretchGroup = null;
705 }} else if (!this.stretchGroup.getSequences (null).contains (sequence) || this.stretchGroup.getStartRes () > res || this.stretchGroup.getEndRes () < res) {
706 this.stretchGroup = null;
707 var allGroups = this.av.getAlignment ().findAllGroups (sequence);
708 if (allGroups != null) {
709 for (var i = 0; i < allGroups.length; i++) {
710 if (allGroups[i].getStartRes () <= res && allGroups[i].getEndRes () >= res) {
711 this.stretchGroup = allGroups[i];
714 }this.av.setSelectionGroup (this.stretchGroup);
715 }if ((evt.getModifiers () & 4) == 4) {
716 var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res));
718 if (allFeatures != null) {
719 for (var i = 0; i < allFeatures.length; i++) {
720 if (allFeatures[i].links != null) {
722 links = new java.util.Vector ();
723 }for (var j = 0; j < allFeatures[i].links.size (); j++) {
724 links.addElement (allFeatures[i].links.elementAt (j));
727 }var popup = new jalview.appletgui.APopupMenu (this.ap, null, links);
729 popup.show (this, evt.getX (), evt.getY ());
731 }if (this.av.cursorMode) {
732 this.seqCanvas.cursorX = this.findRes (evt);
733 this.seqCanvas.cursorY = this.findSeq (evt);
734 this.seqCanvas.repaint ();
736 }if (this.stretchGroup == null) {
737 var sg = new jalview.datamodel.SequenceGroup ();
738 sg.setStartRes (res);
740 sg.addSequence (sequence, false);
741 this.av.setSelectionGroup (sg);
742 this.stretchGroup = sg;
743 if (this.av.getConservationSelected ()) {
744 jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.av.getGlobalColourScheme (), "Background");
745 }if (this.av.getAbovePIDThreshold ()) {
746 jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.av.getGlobalColourScheme (), "Background");
747 }}}, "java.awt.event.MouseEvent");
748 Clazz.defineMethod (c$, "doMouseReleasedDefineMode",
750 if (this.stretchGroup == null) {
752 }this.stretchGroup.recalcConservation ();
753 if (this.stretchGroup.cs != null) {
754 this.stretchGroup.cs.alignmentChanged (this.stretchGroup, this.av.getHiddenRepSequences ());
755 if (this.stretchGroup.cs.conservationApplied ()) {
756 jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ());
758 jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ());
759 }}this.changeEndRes = false;
760 this.changeStartRes = false;
761 this.stretchGroup = null;
762 jalview.appletgui.PaintRefresher.Refresh (this.ap, this.av.getSequenceSetId ());
763 this.ap.paintAlignment (true);
764 this.av.sendSelection ();
765 }, "java.awt.event.MouseEvent");
766 Clazz.defineMethod (c$, "doMouseDraggedDefineMode",
768 var res = this.findRes (evt);
769 var y = this.findSeq (evt);
770 if (this.wrappedBlock != this.startWrapBlock) {
772 }if (this.stretchGroup == null) {
774 }this.mouseDragging = true;
775 if (y > this.av.getAlignment ().getHeight ()) {
776 y = this.av.getAlignment ().getHeight () - 1;
777 }if (res >= this.av.getAlignment ().getWidth ()) {
778 res = this.av.getAlignment ().getWidth () - 1;
779 }if (this.stretchGroup.getEndRes () == res) {
780 this.changeEndRes = true;
781 } else if (this.stretchGroup.getStartRes () == res) {
782 this.changeStartRes = true;
785 }if (this.changeEndRes) {
786 if (res > (this.stretchGroup.getStartRes () - 1)) {
787 this.stretchGroup.setEndRes (res);
788 }} else if (this.changeStartRes) {
789 if (res < (this.stretchGroup.getEndRes () + 1)) {
790 this.stretchGroup.setStartRes (res);
791 }}var dragDirection = 0;
792 if (y > this.oldSeq) {
794 } else if (y < this.oldSeq) {
796 }while ((y != this.oldSeq) && (this.oldSeq > -1) && (y < this.av.getAlignment ().getHeight ())) {
797 var seq = this.av.getAlignment ().getSequenceAt (this.oldSeq);
798 this.oldSeq += dragDirection;
799 if (this.oldSeq < 0) {
801 }var nextSeq = this.av.getAlignment ().getSequenceAt (this.oldSeq);
802 if (this.stretchGroup.getSequences (null).contains (nextSeq)) {
803 this.stretchGroup.deleteSequence (seq, false);
806 this.stretchGroup.addSequence (seq, false);
807 }this.stretchGroup.addSequence (nextSeq, false);
809 if (this.oldSeq < 0) {
811 }if (res > this.av.endRes || res < this.av.startRes || y < this.av.startSeq || y > this.av.endSeq) {
812 this.mouseExited (evt);
813 }if (this.scrollThread != null) {
814 this.scrollThread.setEvent (evt);
815 }this.seqCanvas.repaint ();
816 }, "java.awt.event.MouseEvent");
817 Clazz.overrideMethod (c$, "mouseEntered",
819 if (this.oldSeq < 0) {
821 }if (this.scrollThread != null) {
822 this.scrollThread.running = false;
823 this.scrollThread = null;
824 }}, "java.awt.event.MouseEvent");
825 Clazz.overrideMethod (c$, "mouseExited",
827 if (this.av.getWrapAlignment ()) {
829 }if (this.mouseDragging && this.scrollThread == null) {
830 this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null);
831 }}, "java.awt.event.MouseEvent");
832 Clazz.defineMethod (c$, "scrollCanvas",
835 if (this.scrollThread != null) {
836 this.scrollThread.running = false;
837 this.scrollThread = null;
838 }this.mouseDragging = false;
840 if (this.scrollThread == null) {
841 this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null);
842 }this.mouseDragging = true;
843 this.scrollThread.setEvent (evt);
844 }}, "java.awt.event.MouseEvent");
845 Clazz.overrideMethod (c$, "selection",
846 function (seqsel, colsel, source) {
847 if (this.av != null && (this.av === source || !this.av.followSelection || (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).getSequenceSetId ().equals (this.av.getSequenceSetId ())))) {
849 }if (this.selectionFromTranslation (seqsel, colsel, source)) {
851 }var repaint = false;
852 var copycolsel = true;
853 if (this.av.getSelectionGroup () == null || !this.av.isSelectionGroupChanged (true)) {
855 if (seqsel != null && seqsel.getSize () > 0) {
856 if (this.av.getAlignment () == null) {
857 System.out.println ("Selection message: alignviewport av SeqSetId=" + this.av.getSequenceSetId () + " ViewId=" + this.av.getViewId () + " 's alignment is NULL! returning immediatly.");
859 }sgroup = seqsel.intersect (this.av.getAlignment (), (this.av.hasHiddenRows ()) ? this.av.getHiddenRepSequences () : null);
860 if ((sgroup == null || sgroup.getSize () == 0) && (colsel == null || colsel.size () == 0)) {
862 }}if (sgroup != null && sgroup.getSize () > 0) {
863 this.av.setSelectionGroup (sgroup);
865 this.av.setSelectionGroup (null);
866 }repaint = this.av.isSelectionGroupChanged (true);
867 }if (copycolsel && (this.av.getColumnSelection () == null || !this.av.isColSelChanged (true))) {
868 if (colsel == null || colsel.size () == 0) {
869 if (this.av.getColumnSelection () != null) {
870 this.av.getColumnSelection ().clear ();
872 if (this.av.getColumnSelection () == null) {
873 this.av.setColumnSelection ( new jalview.datamodel.ColumnSelection (colsel));
875 this.av.getColumnSelection ().setElementsFrom (colsel);
876 }}repaint = new Boolean (repaint | this.av.isColSelChanged (true)).valueOf ();
877 }if (copycolsel && this.av.hasHiddenColumns () && (this.av.getColumnSelection () == null || this.av.getColumnSelection ().getHiddenColumns () == null)) {
878 System.err.println ("Bad things");
880 this.ap.scalePanelHolder.repaint ();
882 }}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource");
883 Clazz.defineMethod (c$, "scrollTo",
884 function (row, column) {
885 row = row < 0 ? this.ap.av.startSeq : row;
886 column = column < 0 ? this.ap.av.startRes : column;
887 this.ap.scrollTo (column, column, row, true, true);
889 Clazz.defineMethod (c$, "scrollToRow",
891 row = row < 0 ? this.ap.av.startSeq : row;
892 this.ap.scrollTo (this.ap.av.startRes, this.ap.av.startRes, row, true, true);
894 Clazz.defineMethod (c$, "scrollToColumn",
896 column = column < 0 ? this.ap.av.startRes : column;
897 this.ap.scrollTo (column, column, this.ap.av.startSeq, true, true);
899 Clazz.defineMethod (c$, "selectionFromTranslation",
900 function (seqsel, colsel, source) {
901 if (!(Clazz.instanceOf (source, jalview.api.AlignViewportI))) {
903 }var sourceAv = source;
904 if (sourceAv.getCodingComplement () !== this.av && this.av.getCodingComplement () !== sourceAv) {
906 }var sg = jalview.util.MappingUtils.mapSequenceGroup (seqsel, sourceAv, this.av);
907 this.av.setSelectionGroup (sg);
908 this.av.isSelectionGroupChanged (true);
909 var cs = jalview.util.MappingUtils.mapColumnSelection (colsel, sourceAv, this.av);
910 this.av.setColumnSelection (cs);
911 this.av.isColSelChanged (true);
912 this.ap.scalePanelHolder.repaint ();
915 }, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource");
916 c$.$SeqPanel$ScrollThread$ = function () {
918 c$ = Clazz.decorateAsClass (function () {
919 Clazz.prepareCallback (this, arguments);
921 this.running = false;
922 Clazz.instantialize (this, arguments);
923 }, jalview.appletgui.SeqPanel, "ScrollThread", Thread);
924 Clazz.makeConstructor (c$,
926 Clazz.superConstructor (this, jalview.appletgui.SeqPanel.ScrollThread, []);
929 Clazz.defineMethod (c$, "setEvent",
932 }, "java.awt.event.MouseEvent");
933 Clazz.defineMethod (c$, "stopScrolling",
935 this.running = false;
937 Clazz.overrideMethod (c$, "run",
940 while (this.running) {
941 if (this.evt != null) {
942 if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () < 0 && this.b$["jalview.appletgui.SeqPanel"].av.getStartSeq () > 0) {
943 this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (true);
944 }if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().height && this.b$["jalview.appletgui.SeqPanel"].av.getAlignment ().getHeight () > this.b$["jalview.appletgui.SeqPanel"].av.getEndSeq ()) {
945 this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (false);
946 }if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () < 0) {
947 this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (false);
948 } else if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().width) {
949 this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (true);
953 if (Clazz.exceptionOf (ex, Exception)) {