X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fappletgui%2FSeqPanel.js;h=d500d0ec48283a7e81148db46f722d36add8da57;hp=7f97353c3ff5917718711d4c63f3ac564c2153ad;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/appletgui/SeqPanel.js b/bin/jalview/appletgui/SeqPanel.js index 7f97353..d500d0e 100644 --- a/bin/jalview/appletgui/SeqPanel.js +++ b/bin/jalview/appletgui/SeqPanel.js @@ -1,962 +1,962 @@ -Clazz.declarePackage ("jalview.appletgui"); -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 () { -c$ = Clazz.decorateAsClass (function () { -this.seqCanvas = null; -this.ap = null; -this.lastres = 0; -this.startseq = 0; -this.av = null; -this.seqEditOccurred = false; -this.scrollThread = null; -this.mouseDragging = false; -this.editingSeqs = false; -this.groupEditing = false; -this.oldSeq = -1; -this.changeEndSeq = false; -this.changeStartSeq = false; -this.changeEndRes = false; -this.changeStartRes = false; -this.stretchGroup = null; -this.keyboardNo1 = null; -this.keyboardNo2 = null; -this.mouseWheelPressed = false; -this.lastMousePress = null; -this.editCommand = null; -this.ssm = null; -this.startWrapBlock = -1; -this.wrappedBlock = -1; -this.lastMessage = null; -this.tooltip = null; -if (!Clazz.isClassDefined ("jalview.appletgui.SeqPanel.ScrollThread")) { -jalview.appletgui.SeqPanel.$SeqPanel$ScrollThread$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SeqPanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener, jalview.structure.SequenceListener, jalview.structure.SelectionListener]); -Clazz.makeConstructor (c$, -function (avp, p) { -Clazz.superConstructor (this, jalview.appletgui.SeqPanel, []); -this.av = avp; -this.setName ("seqPanel"); -this.seqCanvas = new jalview.appletgui.SeqCanvas (avp); -this.setLayout ( new java.awt.BorderLayout ()); -this.add (this.seqCanvas); -this.ap = p; -this.seqCanvas.addMouseMotionListener (this); -this.seqCanvas.addMouseListener (this); -this.ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); -this.ssm.addStructureViewerListener (this); -this.ssm.addSelectionListener (this); -this.seqCanvas.repaint (); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "endEditing", -function () { -if (this.editCommand != null && this.editCommand.getSize () > 0) { -this.ap.alignFrame.addHistoryItem (this.editCommand); -this.av.firePropertyChange ("alignment", null, this.av.getAlignment ().getSequences ()); -}this.startseq = -1; -this.lastres = -1; -this.editingSeqs = false; -this.groupEditing = false; -this.keyboardNo1 = null; -this.keyboardNo2 = null; -this.editCommand = null; -}); -Clazz.defineMethod (c$, "setCursorRow", -function () { -this.seqCanvas.cursorY = this.getKeyboardNo1 () - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "setCursorColumn", -function () { -this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "setCursorRowAndColumn", -function () { -if (this.keyboardNo2 == null) { -this.keyboardNo2 = new StringBuffer (); -} else { -this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; -this.seqCanvas.cursorY = this.getKeyboardNo2 () - 1; -this.scrollToVisible (); -}}); -Clazz.defineMethod (c$, "setCursorPosition", -function () { -var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); -this.seqCanvas.cursorX = sequence.findIndex (this.getKeyboardNo1 ()) - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "moveCursor", -function (dx, dy) { -this.seqCanvas.cursorX += dx; -this.seqCanvas.cursorY += dy; -if (this.av.hasHiddenColumns () && !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { -var original = this.seqCanvas.cursorX - dx; -var maxWidth = this.av.getAlignment ().getWidth (); -while (!this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX) && this.seqCanvas.cursorX < maxWidth && this.seqCanvas.cursorX > 0) { -this.seqCanvas.cursorX += dx; -} -if (this.seqCanvas.cursorX >= maxWidth || !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { -this.seqCanvas.cursorX = original; -}}this.scrollToVisible (); -}, "~N,~N"); -Clazz.defineMethod (c$, "scrollToVisible", -function () { -if (this.seqCanvas.cursorX < 0) { -this.seqCanvas.cursorX = 0; -} else if (this.seqCanvas.cursorX > this.av.getAlignment ().getWidth () - 1) { -this.seqCanvas.cursorX = this.av.getAlignment ().getWidth () - 1; -}if (this.seqCanvas.cursorY < 0) { -this.seqCanvas.cursorY = 0; -} else if (this.seqCanvas.cursorY > this.av.getAlignment ().getHeight () - 1) { -this.seqCanvas.cursorY = this.av.getAlignment ().getHeight () - 1; -}this.endEditing (); -if (this.av.getWrapAlignment ()) { -this.ap.scrollToWrappedVisible (this.seqCanvas.cursorX); -} else { -while (this.seqCanvas.cursorY < this.av.startSeq) { -this.ap.scrollUp (true); -} -while (this.seqCanvas.cursorY + 1 > this.av.endSeq) { -this.ap.scrollUp (false); -} -while (this.seqCanvas.cursorX < this.av.getColumnSelection ().adjustForHiddenColumns (this.av.startRes)) { -if (!this.ap.scrollRight (false)) { -break; -}} -while (this.seqCanvas.cursorX > this.av.getColumnSelection ().adjustForHiddenColumns (this.av.endRes)) { -if (!this.ap.scrollRight (true)) { -break; -}} -}this.setStatusMessage (this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY), this.seqCanvas.cursorX, this.seqCanvas.cursorY); -this.seqCanvas.repaint (); -}); -Clazz.defineMethod (c$, "setSelectionAreaAtCursor", -function (topLeft) { -var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); -if (this.av.getSelectionGroup () != null) { -var sg = this.av.getSelectionGroup (); -var min = this.av.getAlignment ().getHeight (); -var max = 0; -for (var i = 0; i < sg.getSize (); i++) { -var index = this.av.getAlignment ().findIndex (sg.getSequenceAt (i)); -if (index > max) { -max = index; -}if (index < min) { -min = index; -}} -max++; -if (topLeft) { -sg.setStartRes (this.seqCanvas.cursorX); -if (sg.getEndRes () < this.seqCanvas.cursorX) { -sg.setEndRes (this.seqCanvas.cursorX); -}min = this.seqCanvas.cursorY; -} else { -sg.setEndRes (this.seqCanvas.cursorX); -if (sg.getStartRes () > this.seqCanvas.cursorX) { -sg.setStartRes (this.seqCanvas.cursorX); -}max = this.seqCanvas.cursorY + 1; -}if (min > max) { -this.av.setSelectionGroup (null); -} else { -sg.clear (); -for (var i = min; i < max; i++) { -sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); -} -}}if (this.av.getSelectionGroup () == null) { -var sg = new jalview.datamodel.SequenceGroup (); -sg.setStartRes (this.seqCanvas.cursorX); -sg.setEndRes (this.seqCanvas.cursorX); -sg.addSequence (sequence, false); -this.av.setSelectionGroup (sg); -}this.ap.paintAlignment (false); -this.av.sendSelection (); -}, "~B"); -Clazz.defineMethod (c$, "insertGapAtCursor", -function (group) { -this.groupEditing = group; -this.startseq = this.seqCanvas.cursorY; -this.lastres = this.seqCanvas.cursorX; -this.editSequence (true, this.seqCanvas.cursorX + this.getKeyboardNo1 ()); -this.endEditing (); -}, "~B"); -Clazz.defineMethod (c$, "deleteGapAtCursor", -function (group) { -this.groupEditing = group; -this.startseq = this.seqCanvas.cursorY; -this.lastres = this.seqCanvas.cursorX + this.getKeyboardNo1 (); -this.editSequence (false, this.seqCanvas.cursorX); -this.endEditing (); -}, "~B"); -Clazz.defineMethod (c$, "numberPressed", -function (value) { -if (this.keyboardNo1 == null) { -this.keyboardNo1 = new StringBuffer (); -}if (this.keyboardNo2 != null) { -this.keyboardNo2.append (value); -} else { -this.keyboardNo1.append (value); -}}, "~S"); -Clazz.defineMethod (c$, "getKeyboardNo1", -function () { -try { -if (this.keyboardNo1 != null) { -var value = Integer.parseInt (this.keyboardNo1.toString ()); -this.keyboardNo1 = null; -return value; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -this.keyboardNo1 = null; -return 1; -}); -Clazz.defineMethod (c$, "getKeyboardNo2", -function () { -try { -if (this.keyboardNo2 != null) { -var value = Integer.parseInt (this.keyboardNo2.toString ()); -this.keyboardNo2 = null; -return value; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -this.keyboardNo2 = null; -return 1; -}); -Clazz.defineMethod (c$, "setStatusMessage", -function (sequence, res, seq) { -var text = new StringBuilder (32); -var seqno = seq == -1 ? "" : " " + (seq + 1); -text.append ("Sequence" + seqno + " ID: " + sequence.getName ()); -var residue = null; -var displayChar = String.valueOf (sequence.getCharAt (res)); -if (this.av.getAlignment ().isNucleotide ()) { -residue = jalview.schemes.ResidueProperties.nucleotideName.get (displayChar); -if (residue != null) { -text.append (" Nucleotide: ").append (residue); -}} else { -residue = "X".equalsIgnoreCase (displayChar) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (displayChar); -if (residue != null) { -text.append (" Residue: ").append (residue); -}}var pos = -1; -if (residue != null) { -pos = sequence.findPosition (res); -text.append (" (").append (Integer.toString (pos)).append (")"); -}this.ap.alignFrame.setStatus (text.toString ()); -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.defineMethod (c$, "setStatusMessage", -($fz = function (results) { -var matches = results.getResults (); -if (!matches.isEmpty ()) { -var m = matches.get (0); -var seq = m.getSequence (); -var sequenceIndex = this.av.getAlignment ().findIndex (seq); -var start = m.getStart () - 1; -this.setStatusMessage (seq, start, sequenceIndex); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.lastMousePress = evt.getPoint (); -if ((evt.getModifiers () & 8) == 8 && !this.av.MAC) { -this.mouseWheelPressed = true; -return; -}if (evt.isShiftDown () || evt.isControlDown () || evt.isAltDown ()) { -if (evt.isControlDown () || evt.isAltDown ()) { -this.groupEditing = true; -}this.editingSeqs = true; -} else { -this.doMousePressedDefineMode (evt); -return; -}var seq = this.findSeq (evt); -var res = this.findRes (evt); -if (seq < 0 || res < 0) { -return; -}if ((seq < this.av.getAlignment ().getHeight ()) && (res < this.av.getAlignment ().getSequenceAt (seq).getLength ())) { -this.startseq = seq; -this.lastres = res; -} else { -this.startseq = -1; -this.lastres = -1; -}return; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -var sequence = this.av.getAlignment ().getSequenceAt (this.findSeq (evt)); -if (evt.getClickCount () > 1) { -if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSize () == 1 && this.av.getSelectionGroup ().getEndRes () - this.av.getSelectionGroup ().getStartRes () < 2) { -this.av.setSelectionGroup (null); -}var features = this.findFeaturesAtRes (sequence, sequence.findPosition (this.findRes (evt))); -if (features != null && features.length > 0) { -var highlight = new jalview.datamodel.SearchResults (); -highlight.addResult (sequence, features[0].getBegin (), features[0].getEnd ()); -this.seqCanvas.highlightSearchResults (highlight); -}if (features != null && features.length > 0) { -this.seqCanvas.getFeatureRenderer ().amendFeatures ( Clazz.newArray (-1, [sequence]), features, false, this.ap); -this.seqCanvas.highlightSearchResults (null); -}}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.mouseDragging = false; -this.mouseWheelPressed = false; -this.ap.paintAlignment (true); -if (!this.editingSeqs) { -this.doMouseReleasedDefineMode (evt); -return; -}this.endEditing (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findRes", -function (evt) { -var res = 0; -var x = evt.getX (); -if (this.av.getWrapAlignment ()) { -var hgap = this.av.getCharHeight (); -if (this.av.getScaleAboveWrapped ()) { -hgap += this.av.getCharHeight (); -}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); -var y = evt.getY (); -y -= hgap; -x -= this.seqCanvas.LABEL_WEST; -var cwidth = this.seqCanvas.getWrappedCanvasWidth (this.getSize ().width); -if (cwidth < 1) { -return 0; -}this.wrappedBlock = Clazz.doubleToInt (y / cHeight); -this.wrappedBlock += Clazz.doubleToInt (this.av.getStartRes () / cwidth); -res = this.wrappedBlock * cwidth + Clazz.doubleToInt (x / this.av.getCharWidth ()); -} else { -res = (Clazz.doubleToInt (x / this.av.getCharWidth ())) + this.av.getStartRes (); -}if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}return res; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findSeq", -function (evt) { -var sqnum = this.findAlRow (evt); -return (sqnum < 0) ? 0 : sqnum; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findAlRow", -($fz = function (evt) { -var seq = 0; -var y = evt.getY (); -if (this.av.getWrapAlignment ()) { -var hgap = this.av.getCharHeight (); -if (this.av.getScaleAboveWrapped ()) { -hgap += this.av.getCharHeight (); -}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); -y -= hgap; -seq = Math.min (Clazz.doubleToInt ((y % cHeight) / this.av.getCharHeight ()), this.av.getAlignment ().getHeight () - 1); -if (seq < 0) { -seq = -1; -}} else { -seq = Math.min ((Clazz.doubleToInt (y / this.av.getCharHeight ())) + this.av.getStartSeq (), this.av.getAlignment ().getHeight () - 1); -if (seq < 0) { -seq = -1; -}}return seq; -}, $fz.isPrivate = true, $fz), "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMousePressed", -function (evt) { -var seq = this.findSeq (evt); -var res = this.findRes (evt); -if (seq < this.av.getAlignment ().getHeight () && res < this.av.getAlignment ().getSequenceAt (seq).getLength ()) { -this.startseq = seq; -this.lastres = res; -} else { -this.startseq = -1; -this.lastres = -1; -}return; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseOverSequence", -function (sequence, index, pos) { -var tmp = sequence.hashCode () + index + ""; -if (this.lastMessage == null || !this.lastMessage.equals (tmp)) { -this.ssm.mouseOverSequence (sequence, index, pos, this.av); -}this.lastMessage = tmp; -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.overrideMethod (c$, "highlightSequence", -function (results) { -if (this.av.isFollowHighlight ()) { -if (this.ap.scrollToPosition (results, true)) { -this.ap.alignFrame.repaint (); -}}this.setStatusMessage (results); -this.seqCanvas.highlightSearchResults (results); -}, "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "getVamsasSource", -function () { -return this.ap == null ? null : this.ap.av; -}); -Clazz.overrideMethod (c$, "updateColours", -function (seq, index) { -System.out.println ("update the seqPanel colours"); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var res = this.findRes (evt); -var seq = this.findSeq (evt); -if (seq >= this.av.getAlignment ().getHeight () || seq < 0 || res < 0) { -if (this.tooltip != null) { -this.tooltip.setTip (""); -}return; -}var sequence = this.av.getAlignment ().getSequenceAt (seq); -if (res > sequence.getLength ()) { -if (this.tooltip != null) { -this.tooltip.setTip (""); -}return; -}var respos = sequence.findPosition (res); -if (this.ssm != null) { -this.mouseOverSequence (sequence, res, respos); -}var text = new StringBuilder (); -text.append ("Sequence ").append (Integer.toString (seq + 1)).append (" ID: ").append (sequence.getName ()); -var obj = null; -var ch = String.valueOf (sequence.getCharAt (res)); -if (this.av.getAlignment ().isNucleotide ()) { -obj = jalview.schemes.ResidueProperties.nucleotideName.get (ch); -if (obj != null) { -text.append (" Nucleotide: ").append (obj); -}} else { -obj = "X".equalsIgnoreCase (ch) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (ch); -if (obj != null) { -text.append (" Residue: ").append (obj); -}}if (obj != null) { -text.append (" (").append (Integer.toString (respos)).append (")"); -}this.ap.alignFrame.setStatus (text.toString ()); -var tooltipText = new StringBuilder (); -var groups = this.av.getAlignment ().findAllGroups (sequence); -if (groups != null) { -for (var g = 0; g < groups.length; g++) { -if (groups[g].getStartRes () <= res && groups[g].getEndRes () >= res) { -if (!groups[g].getName ().startsWith ("JTreeGroup") && !groups[g].getName ().startsWith ("JGroup")) { -tooltipText.append (groups[g].getName ()).append (" "); -}if (groups[g].getDescription () != null) { -tooltipText.append (groups[g].getDescription ()); -}tooltipText.append ("\n"); -}} -}var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); -var index = 0; -while (index < allFeatures.length) { -var sf = allFeatures[index]; -tooltipText.append (sf.getType () + " " + sf.begin + ":" + sf.end); -if (sf.getDescription () != null) { -tooltipText.append (" " + sf.getDescription ()); -}if (sf.getValue ("status") != null) { -var status = sf.getValue ("status").toString (); -if (status.length > 0) { -tooltipText.append (" (" + sf.getValue ("status") + ")"); -}}tooltipText.append ("\n"); -index++; -} -if (this.tooltip == null) { -this.tooltip = new jalview.appletgui.Tooltip (tooltipText.toString (), this.seqCanvas); -} else { -this.tooltip.setTip (tooltipText.toString ()); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findFeaturesAtRes", -function (sequence, res) { -var tmp = new java.util.Vector (); -var features = sequence.getSequenceFeatures (); -if (features != null) { -for (var i = 0; i < features.length; i++) { -if (this.av.getFeaturesDisplayed () == null || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { -continue; -}if (features[i].featureGroup != null && !this.seqCanvas.fr.checkGroupVisibility (features[i].featureGroup, false)) { -continue; -}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { -tmp.addElement (features[i]); -}} -}features = new Array (tmp.size ()); -tmp.copyInto (features); -return features; -}, "jalview.datamodel.SequenceI,~N"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if (this.mouseWheelPressed) { -var oldWidth = this.av.getCharWidth (); -if (Math.abs (evt.getY () - this.lastMousePress.y) > Math.abs (evt.getX () - this.lastMousePress.x)) { -var fontSize = this.av.font.getSize (); -if (evt.getY () < this.lastMousePress.y && this.av.getCharHeight () > 1) { -fontSize--; -} else if (evt.getY () > this.lastMousePress.y) { -fontSize++; -}if (fontSize < 1) { -fontSize = 1; -}this.av.setFont ( new java.awt.Font (this.av.font.getName (), this.av.font.getStyle (), fontSize)); -this.av.setCharWidth (oldWidth); -} else { -if (evt.getX () < this.lastMousePress.x && this.av.getCharWidth () > 1) { -this.av.setCharWidth (this.av.getCharWidth () - 1); -} else if (evt.getX () > this.lastMousePress.x) { -this.av.setCharWidth (this.av.getCharWidth () + 1); -}if (this.av.getCharWidth () < 1) { -this.av.setCharWidth (1); -}}this.ap.fontChanged (); -var fm = this.getFontMetrics (this.av.getFont ()); -this.av.validCharWidth = fm.charWidth ('M') <= this.av.getCharWidth (); -this.lastMousePress = evt.getPoint (); -this.ap.paintAlignment (false); -this.ap.annotationPanel.image = null; -return; -}if (!this.editingSeqs) { -this.doMouseDraggedDefineMode (evt); -return; -}var res = this.findRes (evt); -if (res < 0) { -res = 0; -}if ((this.lastres == -1) || (this.lastres == res)) { -return; -}if ((res < this.av.getAlignment ().getWidth ()) && (res < this.lastres)) { -this.editSequence (false, res); -} else { -this.editSequence (true, res); -}this.mouseDragging = true; -if (this.scrollThread != null) { -this.scrollThread.setEvent (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "editSequence", -function (insertGap, startres) { -var fixedLeft = -1; -var fixedRight = -1; -var fixedColumns = false; -var sg = this.av.getSelectionGroup (); -var seq = this.av.getAlignment ().getSequenceAt (this.startseq); -if (!this.groupEditing && this.av.hasHiddenRows ()) { -if (this.av.isHiddenRepSequence (seq)) { -sg = this.av.getRepresentedSequences (seq); -this.groupEditing = true; -}}var message = new StringBuffer (); -if (this.groupEditing) { -message.append (jalview.util.MessageManager.getString ("action.edit_group")).append (":"); -if (this.editCommand == null) { -this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.edit_group")); -}} else { -message.append (jalview.util.MessageManager.getString ("label.edit_sequence")).append (" " + seq.getName ()); -var label = seq.getName (); -if (label.length > 10) { -label = label.substring (0, 10); -}if (this.editCommand == null) { -this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.formatMessage ("label.edit_params", Clazz.newArray (-1, [label]))); -}}if (insertGap) { -message.append (" insert "); -} else { -message.append (" delete "); -}message.append (Math.abs (startres - this.lastres) + " gaps."); -this.ap.alignFrame.setStatus (message.toString ()); -if (this.groupEditing || (sg != null && sg.getSequences (this.av.getHiddenRepSequences ()).contains (seq))) { -fixedColumns = true; -if (sg == null) { -if (!this.av.isHiddenRepSequence (seq)) { -this.endEditing (); -return; -}sg = this.av.getRepresentedSequences (seq); -}fixedLeft = sg.getStartRes (); -fixedRight = sg.getEndRes (); -if ((startres < fixedLeft && this.lastres >= fixedLeft) || (startres >= fixedLeft && this.lastres < fixedLeft) || (startres > fixedRight && this.lastres <= fixedRight) || (startres <= fixedRight && this.lastres > fixedRight)) { -this.endEditing (); -return; -}if (fixedLeft > startres) { -fixedRight = fixedLeft - 1; -fixedLeft = 0; -} else if (fixedRight < startres) { -fixedLeft = fixedRight; -fixedRight = -1; -}}if (this.av.hasHiddenColumns ()) { -fixedColumns = true; -var y1 = this.av.getColumnSelection ().getHiddenBoundaryLeft (startres); -var y2 = this.av.getColumnSelection ().getHiddenBoundaryRight (startres); -if ((insertGap && startres > y1 && this.lastres < y1) || (!insertGap && startres < y2 && this.lastres > y2)) { -this.endEditing (); -return; -}if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { -if (startres >= y2) { -fixedLeft = y2; -} else { -fixedRight = y2 - 1; -}}}if (this.groupEditing) { -var groupSeqs = sg.getSequences (this.av.getHiddenRepSequences ()).toArray ( new Array (0)); -if (insertGap) { -if (sg.getStartRes () == 0 && sg.getEndRes () == fixedRight && sg.getEndRes () == this.av.getAlignment ().getWidth () - 1) { -sg.setEndRes (this.av.getAlignment ().getWidth () + startres - this.lastres); -fixedRight = sg.getEndRes (); -}var blank = false; -for (fixedRight = fixedRight; fixedRight > this.lastres; fixedRight--) { -blank = true; -for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { -for (var j = 0; j < startres - this.lastres; j++) { -if (!jalview.util.Comparison.isGap (gs.getCharAt (fixedRight - j))) { -blank = false; -break; -}} -} -if (blank) { -break; -}} -if (!blank) { -if (sg.getSize () == this.av.getAlignment ().getHeight ()) { -if ((this.av.hasHiddenColumns () && startres < this.av.getColumnSelection ().getHiddenBoundaryRight (startres))) { -this.endEditing (); -return; -}var alWidth = this.av.getAlignment ().getWidth (); -if (this.av.hasHiddenRows ()) { -var hwidth = this.av.getAlignment ().getHiddenSequences ().getWidth (); -if (hwidth > alWidth) { -alWidth = hwidth; -}}sg.setEndRes (sg.getEndRes () + startres - this.lastres); -fixedRight = alWidth + startres - this.lastres; -} else { -this.endEditing (); -return; -}}} else if (!insertGap) { -for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { -for (var j = startres; j < this.lastres; j++) { -if (gs.getLength () <= j) { -continue; -}if (!jalview.util.Comparison.isGap (gs.getCharAt (j))) { -this.endEditing (); -return; -}} -} -}if (insertGap) { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j < startres; j++) { -this.insertChar (j, groupSeqs, fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, groupSeqs, startres, startres - this.lastres, this.av.getAlignment (), true); -}} else { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j > startres; j--) { -this.deleteChar (startres, groupSeqs, fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, groupSeqs, startres, this.lastres - startres, this.av.getAlignment (), true); -}}} else { -if (insertGap) { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j < startres; j++) { -this.insertChar (j, Clazz.newArray (-1, [seq]), fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, Clazz.newArray (-1, [seq]), this.lastres, startres - this.lastres, this.av.getAlignment (), true); -}} else { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j > startres; j--) { -if (!jalview.util.Comparison.isGap (seq.getCharAt (startres))) { -this.endEditing (); -break; -}this.deleteChar (startres, Clazz.newArray (-1, [seq]), fixedRight); -} -} else { -var max = 0; -for (var m = startres; m < this.lastres; m++) { -if (!jalview.util.Comparison.isGap (seq.getCharAt (m))) { -break; -}max++; -} -if (max > 0) { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seq]), startres, max, this.av.getAlignment (), true); -}}}}this.lastres = startres; -this.seqCanvas.repaint (); -}, "~B,~N"); -Clazz.defineMethod (c$, "insertChar", -function (j, seq, fixedColumn) { -var blankColumn = fixedColumn; -for (var s = 0; s < seq.length; s++) { -for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { -if (jalview.util.Comparison.isGap (seq[s].getCharAt (blankColumn))) { -break; -}} -if (blankColumn <= j) { -blankColumn = fixedColumn; -this.endEditing (); -return; -}} -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, blankColumn, 1, this.av.getAlignment (), true); -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, j, 1, this.av.getAlignment (), true); -}, "~N,~A,~N"); -Clazz.defineMethod (c$, "deleteChar", -function (j, seq, fixedColumn) { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, j, 1, this.av.getAlignment (), true); -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, fixedColumn, 1, this.av.getAlignment (), true); -}, "~N,~A,~N"); -Clazz.defineMethod (c$, "doMousePressedDefineMode", -function (evt) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}var res = this.findRes (evt); -var seq = this.findSeq (evt); -this.oldSeq = seq; -this.startWrapBlock = this.wrappedBlock; -if (seq == -1) { -return; -}var sequence = this.av.getAlignment ().getSequenceAt (seq); -if (sequence == null || res > sequence.getLength ()) { -return; -}this.stretchGroup = this.av.getSelectionGroup (); -if (this.stretchGroup == null) { -this.stretchGroup = this.av.getAlignment ().findGroup (sequence); -if (this.stretchGroup != null && res > this.stretchGroup.getStartRes () && res < this.stretchGroup.getEndRes ()) { -this.av.setSelectionGroup (this.stretchGroup); -} else { -this.stretchGroup = null; -}} else if (!this.stretchGroup.getSequences (null).contains (sequence) || this.stretchGroup.getStartRes () > res || this.stretchGroup.getEndRes () < res) { -this.stretchGroup = null; -var allGroups = this.av.getAlignment ().findAllGroups (sequence); -if (allGroups != null) { -for (var i = 0; i < allGroups.length; i++) { -if (allGroups[i].getStartRes () <= res && allGroups[i].getEndRes () >= res) { -this.stretchGroup = allGroups[i]; -break; -}} -}this.av.setSelectionGroup (this.stretchGroup); -}if ((evt.getModifiers () & 4) == 4) { -var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); -var links = null; -if (allFeatures != null) { -for (var i = 0; i < allFeatures.length; i++) { -if (allFeatures[i].links != null) { -if (links == null) { -links = new java.util.Vector (); -}for (var j = 0; j < allFeatures[i].links.size (); j++) { -links.addElement (allFeatures[i].links.elementAt (j)); -} -}} -}var popup = new jalview.appletgui.APopupMenu (this.ap, null, links); -this.add (popup); -popup.show (this, evt.getX (), evt.getY ()); -return; -}if (this.av.cursorMode) { -this.seqCanvas.cursorX = this.findRes (evt); -this.seqCanvas.cursorY = this.findSeq (evt); -this.seqCanvas.repaint (); -return; -}if (this.stretchGroup == null) { -var sg = new jalview.datamodel.SequenceGroup (); -sg.setStartRes (res); -sg.setEndRes (res); -sg.addSequence (sequence, false); -this.av.setSelectionGroup (sg); -this.stretchGroup = sg; -if (this.av.getConservationSelected ()) { -jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.av.getGlobalColourScheme (), "Background"); -}if (this.av.getAbovePIDThreshold ()) { -jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.av.getGlobalColourScheme (), "Background"); -}}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMouseReleasedDefineMode", -function (evt) { -if (this.stretchGroup == null) { -return; -}this.stretchGroup.recalcConservation (); -if (this.stretchGroup.cs != null) { -this.stretchGroup.cs.alignmentChanged (this.stretchGroup, this.av.getHiddenRepSequences ()); -if (this.stretchGroup.cs.conservationApplied ()) { -jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); -} else { -jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); -}}this.changeEndRes = false; -this.changeStartRes = false; -this.stretchGroup = null; -jalview.appletgui.PaintRefresher.Refresh (this.ap, this.av.getSequenceSetId ()); -this.ap.paintAlignment (true); -this.av.sendSelection (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMouseDraggedDefineMode", -function (evt) { -var res = this.findRes (evt); -var y = this.findSeq (evt); -if (this.wrappedBlock != this.startWrapBlock) { -return; -}if (this.stretchGroup == null) { -return; -}this.mouseDragging = true; -if (y > this.av.getAlignment ().getHeight ()) { -y = this.av.getAlignment ().getHeight () - 1; -}if (res >= this.av.getAlignment ().getWidth ()) { -res = this.av.getAlignment ().getWidth () - 1; -}if (this.stretchGroup.getEndRes () == res) { -this.changeEndRes = true; -} else if (this.stretchGroup.getStartRes () == res) { -this.changeStartRes = true; -}if (res < 0) { -res = 0; -}if (this.changeEndRes) { -if (res > (this.stretchGroup.getStartRes () - 1)) { -this.stretchGroup.setEndRes (res); -}} else if (this.changeStartRes) { -if (res < (this.stretchGroup.getEndRes () + 1)) { -this.stretchGroup.setStartRes (res); -}}var dragDirection = 0; -if (y > this.oldSeq) { -dragDirection = 1; -} else if (y < this.oldSeq) { -dragDirection = -1; -}while ((y != this.oldSeq) && (this.oldSeq > -1) && (y < this.av.getAlignment ().getHeight ())) { -var seq = this.av.getAlignment ().getSequenceAt (this.oldSeq); -this.oldSeq += dragDirection; -if (this.oldSeq < 0) { -break; -}var nextSeq = this.av.getAlignment ().getSequenceAt (this.oldSeq); -if (this.stretchGroup.getSequences (null).contains (nextSeq)) { -this.stretchGroup.deleteSequence (seq, false); -} else { -if (seq != null) { -this.stretchGroup.addSequence (seq, false); -}this.stretchGroup.addSequence (nextSeq, false); -}} -if (this.oldSeq < 0) { -this.oldSeq = -1; -}if (res > this.av.endRes || res < this.av.startRes || y < this.av.startSeq || y > this.av.endSeq) { -this.mouseExited (evt); -}if (this.scrollThread != null) { -this.scrollThread.setEvent (evt); -}this.seqCanvas.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (e) { -if (this.oldSeq < 0) { -this.oldSeq = 0; -}if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (e) { -if (this.av.getWrapAlignment ()) { -return; -}if (this.mouseDragging && this.scrollThread == null) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "scrollCanvas", -function (evt) { -if (evt == null) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}this.mouseDragging = false; -} else { -if (this.scrollThread == null) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); -}this.mouseDragging = true; -this.scrollThread.setEvent (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "selection", -function (seqsel, colsel, source) { -if (this.av != null && (this.av === source || !this.av.followSelection || (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).getSequenceSetId ().equals (this.av.getSequenceSetId ())))) { -return; -}if (this.selectionFromTranslation (seqsel, colsel, source)) { -return; -}var repaint = false; -var copycolsel = true; -if (this.av.getSelectionGroup () == null || !this.av.isSelectionGroupChanged (true)) { -var sgroup = null; -if (seqsel != null && seqsel.getSize () > 0) { -if (this.av.getAlignment () == null) { -System.out.println ("Selection message: alignviewport av SeqSetId=" + this.av.getSequenceSetId () + " ViewId=" + this.av.getViewId () + " 's alignment is NULL! returning immediatly."); -return; -}sgroup = seqsel.intersect (this.av.getAlignment (), (this.av.hasHiddenRows ()) ? this.av.getHiddenRepSequences () : null); -if ((sgroup == null || sgroup.getSize () == 0) && (colsel == null || colsel.size () == 0)) { -copycolsel = false; -}}if (sgroup != null && sgroup.getSize () > 0) { -this.av.setSelectionGroup (sgroup); -} else { -this.av.setSelectionGroup (null); -}repaint = this.av.isSelectionGroupChanged (true); -}if (copycolsel && (this.av.getColumnSelection () == null || !this.av.isColSelChanged (true))) { -if (colsel == null || colsel.size () == 0) { -if (this.av.getColumnSelection () != null) { -this.av.getColumnSelection ().clear (); -}} else { -if (this.av.getColumnSelection () == null) { -this.av.setColumnSelection ( new jalview.datamodel.ColumnSelection (colsel)); -} else { -this.av.getColumnSelection ().setElementsFrom (colsel); -}}repaint = new Boolean (repaint | this.av.isColSelChanged (true)).valueOf (); -}if (copycolsel && this.av.hasHiddenColumns () && (this.av.getColumnSelection () == null || this.av.getColumnSelection ().getHiddenColumns () == null)) { -System.err.println ("Bad things"); -}if (repaint) { -this.ap.scalePanelHolder.repaint (); -this.ap.repaint (); -}}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -Clazz.defineMethod (c$, "scrollTo", -function (row, column) { -row = row < 0 ? this.ap.av.startSeq : row; -column = column < 0 ? this.ap.av.startRes : column; -this.ap.scrollTo (column, column, row, true, true); -}, "~N,~N"); -Clazz.defineMethod (c$, "scrollToRow", -function (row) { -row = row < 0 ? this.ap.av.startSeq : row; -this.ap.scrollTo (this.ap.av.startRes, this.ap.av.startRes, row, true, true); -}, "~N"); -Clazz.defineMethod (c$, "scrollToColumn", -function (column) { -column = column < 0 ? this.ap.av.startRes : column; -this.ap.scrollTo (column, column, this.ap.av.startSeq, true, true); -}, "~N"); -Clazz.defineMethod (c$, "selectionFromTranslation", -function (seqsel, colsel, source) { -if (!(Clazz.instanceOf (source, jalview.api.AlignViewportI))) { -return false; -}var sourceAv = source; -if (sourceAv.getCodingComplement () !== this.av && this.av.getCodingComplement () !== sourceAv) { -return false; -}var sg = jalview.util.MappingUtils.mapSequenceGroup (seqsel, sourceAv, this.av); -this.av.setSelectionGroup (sg); -this.av.isSelectionGroupChanged (true); -var cs = jalview.util.MappingUtils.mapColumnSelection (colsel, sourceAv, this.av); -this.av.setColumnSelection (cs); -this.av.isColSelChanged (true); -this.ap.scalePanelHolder.repaint (); -this.ap.repaint (); -return true; -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -c$.$SeqPanel$ScrollThread$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.evt = null; -this.running = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.SeqPanel, "ScrollThread", Thread); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.SeqPanel.ScrollThread, []); -this.start (); -}); -Clazz.defineMethod (c$, "setEvent", -function (a) { -this.evt = a; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "stopScrolling", -function () { -this.running = false; -}); -Clazz.overrideMethod (c$, "run", -function () { -this.running = true; -while (this.running) { -if (this.evt != null) { -if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () < 0 && this.b$["jalview.appletgui.SeqPanel"].av.getStartSeq () > 0) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (true); -}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 ()) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (false); -}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () < 0) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (false); -} else if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().width) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (true); -}}try { -Thread.sleep (75); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -} -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +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 () { +c$ = Clazz.decorateAsClass (function () { +this.seqCanvas = null; +this.ap = null; +this.lastres = 0; +this.startseq = 0; +this.av = null; +this.seqEditOccurred = false; +this.scrollThread = null; +this.mouseDragging = false; +this.editingSeqs = false; +this.groupEditing = false; +this.oldSeq = -1; +this.changeEndSeq = false; +this.changeStartSeq = false; +this.changeEndRes = false; +this.changeStartRes = false; +this.stretchGroup = null; +this.keyboardNo1 = null; +this.keyboardNo2 = null; +this.mouseWheelPressed = false; +this.lastMousePress = null; +this.editCommand = null; +this.ssm = null; +this.startWrapBlock = -1; +this.wrappedBlock = -1; +this.lastMessage = null; +this.tooltip = null; +if (!Clazz.isClassDefined ("jalview.appletgui.SeqPanel.ScrollThread")) { +jalview.appletgui.SeqPanel.$SeqPanel$ScrollThread$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SeqPanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener, jalview.structure.SequenceListener, jalview.structure.SelectionListener]); +Clazz.makeConstructor (c$, +function (avp, p) { +Clazz.superConstructor (this, jalview.appletgui.SeqPanel, []); +this.av = avp; +this.setName ("seqPanel"); +this.seqCanvas = new jalview.appletgui.SeqCanvas (avp); +this.setLayout ( new java.awt.BorderLayout ()); +this.add (this.seqCanvas); +this.ap = p; +this.seqCanvas.addMouseMotionListener (this); +this.seqCanvas.addMouseListener (this); +this.ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); +this.ssm.addStructureViewerListener (this); +this.ssm.addSelectionListener (this); +this.seqCanvas.repaint (); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "endEditing", +function () { +if (this.editCommand != null && this.editCommand.getSize () > 0) { +this.ap.alignFrame.addHistoryItem (this.editCommand); +this.av.firePropertyChange ("alignment", null, this.av.getAlignment ().getSequences ()); +}this.startseq = -1; +this.lastres = -1; +this.editingSeqs = false; +this.groupEditing = false; +this.keyboardNo1 = null; +this.keyboardNo2 = null; +this.editCommand = null; +}); +Clazz.defineMethod (c$, "setCursorRow", +function () { +this.seqCanvas.cursorY = this.getKeyboardNo1 () - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "setCursorColumn", +function () { +this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "setCursorRowAndColumn", +function () { +if (this.keyboardNo2 == null) { +this.keyboardNo2 = new StringBuffer (); +} else { +this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; +this.seqCanvas.cursorY = this.getKeyboardNo2 () - 1; +this.scrollToVisible (); +}}); +Clazz.defineMethod (c$, "setCursorPosition", +function () { +var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); +this.seqCanvas.cursorX = sequence.findIndex (this.getKeyboardNo1 ()) - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "moveCursor", +function (dx, dy) { +this.seqCanvas.cursorX += dx; +this.seqCanvas.cursorY += dy; +if (this.av.hasHiddenColumns () && !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { +var original = this.seqCanvas.cursorX - dx; +var maxWidth = this.av.getAlignment ().getWidth (); +while (!this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX) && this.seqCanvas.cursorX < maxWidth && this.seqCanvas.cursorX > 0) { +this.seqCanvas.cursorX += dx; +} +if (this.seqCanvas.cursorX >= maxWidth || !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { +this.seqCanvas.cursorX = original; +}}this.scrollToVisible (); +}, "~N,~N"); +Clazz.defineMethod (c$, "scrollToVisible", +function () { +if (this.seqCanvas.cursorX < 0) { +this.seqCanvas.cursorX = 0; +} else if (this.seqCanvas.cursorX > this.av.getAlignment ().getWidth () - 1) { +this.seqCanvas.cursorX = this.av.getAlignment ().getWidth () - 1; +}if (this.seqCanvas.cursorY < 0) { +this.seqCanvas.cursorY = 0; +} else if (this.seqCanvas.cursorY > this.av.getAlignment ().getHeight () - 1) { +this.seqCanvas.cursorY = this.av.getAlignment ().getHeight () - 1; +}this.endEditing (); +if (this.av.getWrapAlignment ()) { +this.ap.scrollToWrappedVisible (this.seqCanvas.cursorX); +} else { +while (this.seqCanvas.cursorY < this.av.startSeq) { +this.ap.scrollUp (true); +} +while (this.seqCanvas.cursorY + 1 > this.av.endSeq) { +this.ap.scrollUp (false); +} +while (this.seqCanvas.cursorX < this.av.getColumnSelection ().adjustForHiddenColumns (this.av.startRes)) { +if (!this.ap.scrollRight (false)) { +break; +}} +while (this.seqCanvas.cursorX > this.av.getColumnSelection ().adjustForHiddenColumns (this.av.endRes)) { +if (!this.ap.scrollRight (true)) { +break; +}} +}this.setStatusMessage (this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY), this.seqCanvas.cursorX, this.seqCanvas.cursorY); +this.seqCanvas.repaint (); +}); +Clazz.defineMethod (c$, "setSelectionAreaAtCursor", +function (topLeft) { +var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); +if (this.av.getSelectionGroup () != null) { +var sg = this.av.getSelectionGroup (); +var min = this.av.getAlignment ().getHeight (); +var max = 0; +for (var i = 0; i < sg.getSize (); i++) { +var index = this.av.getAlignment ().findIndex (sg.getSequenceAt (i)); +if (index > max) { +max = index; +}if (index < min) { +min = index; +}} +max++; +if (topLeft) { +sg.setStartRes (this.seqCanvas.cursorX); +if (sg.getEndRes () < this.seqCanvas.cursorX) { +sg.setEndRes (this.seqCanvas.cursorX); +}min = this.seqCanvas.cursorY; +} else { +sg.setEndRes (this.seqCanvas.cursorX); +if (sg.getStartRes () > this.seqCanvas.cursorX) { +sg.setStartRes (this.seqCanvas.cursorX); +}max = this.seqCanvas.cursorY + 1; +}if (min > max) { +this.av.setSelectionGroup (null); +} else { +sg.clear (); +for (var i = min; i < max; i++) { +sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); +} +}}if (this.av.getSelectionGroup () == null) { +var sg = new jalview.datamodel.SequenceGroup (); +sg.setStartRes (this.seqCanvas.cursorX); +sg.setEndRes (this.seqCanvas.cursorX); +sg.addSequence (sequence, false); +this.av.setSelectionGroup (sg); +}this.ap.paintAlignment (false); +this.av.sendSelection (); +}, "~B"); +Clazz.defineMethod (c$, "insertGapAtCursor", +function (group) { +this.groupEditing = group; +this.startseq = this.seqCanvas.cursorY; +this.lastres = this.seqCanvas.cursorX; +this.editSequence (true, this.seqCanvas.cursorX + this.getKeyboardNo1 ()); +this.endEditing (); +}, "~B"); +Clazz.defineMethod (c$, "deleteGapAtCursor", +function (group) { +this.groupEditing = group; +this.startseq = this.seqCanvas.cursorY; +this.lastres = this.seqCanvas.cursorX + this.getKeyboardNo1 (); +this.editSequence (false, this.seqCanvas.cursorX); +this.endEditing (); +}, "~B"); +Clazz.defineMethod (c$, "numberPressed", +function (value) { +if (this.keyboardNo1 == null) { +this.keyboardNo1 = new StringBuffer (); +}if (this.keyboardNo2 != null) { +this.keyboardNo2.append (value); +} else { +this.keyboardNo1.append (value); +}}, "~S"); +Clazz.defineMethod (c$, "getKeyboardNo1", +function () { +try { +if (this.keyboardNo1 != null) { +var value = Integer.parseInt (this.keyboardNo1.toString ()); +this.keyboardNo1 = null; +return value; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +this.keyboardNo1 = null; +return 1; +}); +Clazz.defineMethod (c$, "getKeyboardNo2", +function () { +try { +if (this.keyboardNo2 != null) { +var value = Integer.parseInt (this.keyboardNo2.toString ()); +this.keyboardNo2 = null; +return value; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +this.keyboardNo2 = null; +return 1; +}); +Clazz.defineMethod (c$, "setStatusMessage", +function (sequence, res, seq) { +var text = new StringBuilder (32); +var seqno = seq == -1 ? "" : " " + (seq + 1); +text.append ("Sequence" + seqno + " ID: " + sequence.getName ()); +var residue = null; +var displayChar = String.valueOf (sequence.getCharAt (res)); +if (this.av.getAlignment ().isNucleotide ()) { +residue = jalview.schemes.ResidueProperties.nucleotideName.get (displayChar); +if (residue != null) { +text.append (" Nucleotide: ").append (residue); +}} else { +residue = "X".equalsIgnoreCase (displayChar) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (displayChar); +if (residue != null) { +text.append (" Residue: ").append (residue); +}}var pos = -1; +if (residue != null) { +pos = sequence.findPosition (res); +text.append (" (").append (Integer.toString (pos)).append (")"); +}this.ap.alignFrame.setStatus (text.toString ()); +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.defineMethod (c$, "setStatusMessage", +($fz = function (results) { +var matches = results.getResults (); +if (!matches.isEmpty ()) { +var m = matches.get (0); +var seq = m.getSequence (); +var sequenceIndex = this.av.getAlignment ().findIndex (seq); +var start = m.getStart () - 1; +this.setStatusMessage (seq, start, sequenceIndex); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.lastMousePress = evt.getPoint (); +if ((evt.getModifiers () & 8) == 8 && !this.av.MAC) { +this.mouseWheelPressed = true; +return; +}if (evt.isShiftDown () || evt.isControlDown () || evt.isAltDown ()) { +if (evt.isControlDown () || evt.isAltDown ()) { +this.groupEditing = true; +}this.editingSeqs = true; +} else { +this.doMousePressedDefineMode (evt); +return; +}var seq = this.findSeq (evt); +var res = this.findRes (evt); +if (seq < 0 || res < 0) { +return; +}if ((seq < this.av.getAlignment ().getHeight ()) && (res < this.av.getAlignment ().getSequenceAt (seq).getLength ())) { +this.startseq = seq; +this.lastres = res; +} else { +this.startseq = -1; +this.lastres = -1; +}return; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +var sequence = this.av.getAlignment ().getSequenceAt (this.findSeq (evt)); +if (evt.getClickCount () > 1) { +if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSize () == 1 && this.av.getSelectionGroup ().getEndRes () - this.av.getSelectionGroup ().getStartRes () < 2) { +this.av.setSelectionGroup (null); +}var features = this.findFeaturesAtRes (sequence, sequence.findPosition (this.findRes (evt))); +if (features != null && features.length > 0) { +var highlight = new jalview.datamodel.SearchResults (); +highlight.addResult (sequence, features[0].getBegin (), features[0].getEnd ()); +this.seqCanvas.highlightSearchResults (highlight); +}if (features != null && features.length > 0) { +this.seqCanvas.getFeatureRenderer ().amendFeatures ( Clazz.newArray (-1, [sequence]), features, false, this.ap); +this.seqCanvas.highlightSearchResults (null); +}}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.mouseDragging = false; +this.mouseWheelPressed = false; +this.ap.paintAlignment (true); +if (!this.editingSeqs) { +this.doMouseReleasedDefineMode (evt); +return; +}this.endEditing (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findRes", +function (evt) { +var res = 0; +var x = evt.getX (); +if (this.av.getWrapAlignment ()) { +var hgap = this.av.getCharHeight (); +if (this.av.getScaleAboveWrapped ()) { +hgap += this.av.getCharHeight (); +}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); +var y = evt.getY (); +y -= hgap; +x -= this.seqCanvas.LABEL_WEST; +var cwidth = this.seqCanvas.getWrappedCanvasWidth (this.getSize ().width); +if (cwidth < 1) { +return 0; +}this.wrappedBlock = Clazz.doubleToInt (y / cHeight); +this.wrappedBlock += Clazz.doubleToInt (this.av.getStartRes () / cwidth); +res = this.wrappedBlock * cwidth + Clazz.doubleToInt (x / this.av.getCharWidth ()); +} else { +res = (Clazz.doubleToInt (x / this.av.getCharWidth ())) + this.av.getStartRes (); +}if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}return res; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findSeq", +function (evt) { +var sqnum = this.findAlRow (evt); +return (sqnum < 0) ? 0 : sqnum; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findAlRow", +($fz = function (evt) { +var seq = 0; +var y = evt.getY (); +if (this.av.getWrapAlignment ()) { +var hgap = this.av.getCharHeight (); +if (this.av.getScaleAboveWrapped ()) { +hgap += this.av.getCharHeight (); +}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); +y -= hgap; +seq = Math.min (Clazz.doubleToInt ((y % cHeight) / this.av.getCharHeight ()), this.av.getAlignment ().getHeight () - 1); +if (seq < 0) { +seq = -1; +}} else { +seq = Math.min ((Clazz.doubleToInt (y / this.av.getCharHeight ())) + this.av.getStartSeq (), this.av.getAlignment ().getHeight () - 1); +if (seq < 0) { +seq = -1; +}}return seq; +}, $fz.isPrivate = true, $fz), "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMousePressed", +function (evt) { +var seq = this.findSeq (evt); +var res = this.findRes (evt); +if (seq < this.av.getAlignment ().getHeight () && res < this.av.getAlignment ().getSequenceAt (seq).getLength ()) { +this.startseq = seq; +this.lastres = res; +} else { +this.startseq = -1; +this.lastres = -1; +}return; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseOverSequence", +function (sequence, index, pos) { +var tmp = sequence.hashCode () + index + ""; +if (this.lastMessage == null || !this.lastMessage.equals (tmp)) { +this.ssm.mouseOverSequence (sequence, index, pos, this.av); +}this.lastMessage = tmp; +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.overrideMethod (c$, "highlightSequence", +function (results) { +if (this.av.isFollowHighlight ()) { +if (this.ap.scrollToPosition (results, true)) { +this.ap.alignFrame.repaint (); +}}this.setStatusMessage (results); +this.seqCanvas.highlightSearchResults (results); +}, "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "getVamsasSource", +function () { +return this.ap == null ? null : this.ap.av; +}); +Clazz.overrideMethod (c$, "updateColours", +function (seq, index) { +System.out.println ("update the seqPanel colours"); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var res = this.findRes (evt); +var seq = this.findSeq (evt); +if (seq >= this.av.getAlignment ().getHeight () || seq < 0 || res < 0) { +if (this.tooltip != null) { +this.tooltip.setTip (""); +}return; +}var sequence = this.av.getAlignment ().getSequenceAt (seq); +if (res > sequence.getLength ()) { +if (this.tooltip != null) { +this.tooltip.setTip (""); +}return; +}var respos = sequence.findPosition (res); +if (this.ssm != null) { +this.mouseOverSequence (sequence, res, respos); +}var text = new StringBuilder (); +text.append ("Sequence ").append (Integer.toString (seq + 1)).append (" ID: ").append (sequence.getName ()); +var obj = null; +var ch = String.valueOf (sequence.getCharAt (res)); +if (this.av.getAlignment ().isNucleotide ()) { +obj = jalview.schemes.ResidueProperties.nucleotideName.get (ch); +if (obj != null) { +text.append (" Nucleotide: ").append (obj); +}} else { +obj = "X".equalsIgnoreCase (ch) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (ch); +if (obj != null) { +text.append (" Residue: ").append (obj); +}}if (obj != null) { +text.append (" (").append (Integer.toString (respos)).append (")"); +}this.ap.alignFrame.setStatus (text.toString ()); +var tooltipText = new StringBuilder (); +var groups = this.av.getAlignment ().findAllGroups (sequence); +if (groups != null) { +for (var g = 0; g < groups.length; g++) { +if (groups[g].getStartRes () <= res && groups[g].getEndRes () >= res) { +if (!groups[g].getName ().startsWith ("JTreeGroup") && !groups[g].getName ().startsWith ("JGroup")) { +tooltipText.append (groups[g].getName ()).append (" "); +}if (groups[g].getDescription () != null) { +tooltipText.append (groups[g].getDescription ()); +}tooltipText.append ("\n"); +}} +}var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); +var index = 0; +while (index < allFeatures.length) { +var sf = allFeatures[index]; +tooltipText.append (sf.getType () + " " + sf.begin + ":" + sf.end); +if (sf.getDescription () != null) { +tooltipText.append (" " + sf.getDescription ()); +}if (sf.getValue ("status") != null) { +var status = sf.getValue ("status").toString (); +if (status.length > 0) { +tooltipText.append (" (" + sf.getValue ("status") + ")"); +}}tooltipText.append ("\n"); +index++; +} +if (this.tooltip == null) { +this.tooltip = new jalview.appletgui.Tooltip (tooltipText.toString (), this.seqCanvas); +} else { +this.tooltip.setTip (tooltipText.toString ()); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findFeaturesAtRes", +function (sequence, res) { +var tmp = new java.util.Vector (); +var features = sequence.getSequenceFeatures (); +if (features != null) { +for (var i = 0; i < features.length; i++) { +if (this.av.getFeaturesDisplayed () == null || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { +continue; +}if (features[i].featureGroup != null && !this.seqCanvas.fr.checkGroupVisibility (features[i].featureGroup, false)) { +continue; +}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { +tmp.addElement (features[i]); +}} +}features = new Array (tmp.size ()); +tmp.copyInto (features); +return features; +}, "jalview.datamodel.SequenceI,~N"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if (this.mouseWheelPressed) { +var oldWidth = this.av.getCharWidth (); +if (Math.abs (evt.getY () - this.lastMousePress.y) > Math.abs (evt.getX () - this.lastMousePress.x)) { +var fontSize = this.av.font.getSize (); +if (evt.getY () < this.lastMousePress.y && this.av.getCharHeight () > 1) { +fontSize--; +} else if (evt.getY () > this.lastMousePress.y) { +fontSize++; +}if (fontSize < 1) { +fontSize = 1; +}this.av.setFont ( new java.awt.Font (this.av.font.getName (), this.av.font.getStyle (), fontSize)); +this.av.setCharWidth (oldWidth); +} else { +if (evt.getX () < this.lastMousePress.x && this.av.getCharWidth () > 1) { +this.av.setCharWidth (this.av.getCharWidth () - 1); +} else if (evt.getX () > this.lastMousePress.x) { +this.av.setCharWidth (this.av.getCharWidth () + 1); +}if (this.av.getCharWidth () < 1) { +this.av.setCharWidth (1); +}}this.ap.fontChanged (); +var fm = this.getFontMetrics (this.av.getFont ()); +this.av.validCharWidth = fm.charWidth ('M') <= this.av.getCharWidth (); +this.lastMousePress = evt.getPoint (); +this.ap.paintAlignment (false); +this.ap.annotationPanel.image = null; +return; +}if (!this.editingSeqs) { +this.doMouseDraggedDefineMode (evt); +return; +}var res = this.findRes (evt); +if (res < 0) { +res = 0; +}if ((this.lastres == -1) || (this.lastres == res)) { +return; +}if ((res < this.av.getAlignment ().getWidth ()) && (res < this.lastres)) { +this.editSequence (false, res); +} else { +this.editSequence (true, res); +}this.mouseDragging = true; +if (this.scrollThread != null) { +this.scrollThread.setEvent (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "editSequence", +function (insertGap, startres) { +var fixedLeft = -1; +var fixedRight = -1; +var fixedColumns = false; +var sg = this.av.getSelectionGroup (); +var seq = this.av.getAlignment ().getSequenceAt (this.startseq); +if (!this.groupEditing && this.av.hasHiddenRows ()) { +if (this.av.isHiddenRepSequence (seq)) { +sg = this.av.getRepresentedSequences (seq); +this.groupEditing = true; +}}var message = new StringBuffer (); +if (this.groupEditing) { +message.append (jalview.util.MessageManager.getString ("action.edit_group")).append (":"); +if (this.editCommand == null) { +this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.edit_group")); +}} else { +message.append (jalview.util.MessageManager.getString ("label.edit_sequence")).append (" " + seq.getName ()); +var label = seq.getName (); +if (label.length > 10) { +label = label.substring (0, 10); +}if (this.editCommand == null) { +this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.formatMessage ("label.edit_params", Clazz.newArray (-1, [label]))); +}}if (insertGap) { +message.append (" insert "); +} else { +message.append (" delete "); +}message.append (Math.abs (startres - this.lastres) + " gaps."); +this.ap.alignFrame.setStatus (message.toString ()); +if (this.groupEditing || (sg != null && sg.getSequences (this.av.getHiddenRepSequences ()).contains (seq))) { +fixedColumns = true; +if (sg == null) { +if (!this.av.isHiddenRepSequence (seq)) { +this.endEditing (); +return; +}sg = this.av.getRepresentedSequences (seq); +}fixedLeft = sg.getStartRes (); +fixedRight = sg.getEndRes (); +if ((startres < fixedLeft && this.lastres >= fixedLeft) || (startres >= fixedLeft && this.lastres < fixedLeft) || (startres > fixedRight && this.lastres <= fixedRight) || (startres <= fixedRight && this.lastres > fixedRight)) { +this.endEditing (); +return; +}if (fixedLeft > startres) { +fixedRight = fixedLeft - 1; +fixedLeft = 0; +} else if (fixedRight < startres) { +fixedLeft = fixedRight; +fixedRight = -1; +}}if (this.av.hasHiddenColumns ()) { +fixedColumns = true; +var y1 = this.av.getColumnSelection ().getHiddenBoundaryLeft (startres); +var y2 = this.av.getColumnSelection ().getHiddenBoundaryRight (startres); +if ((insertGap && startres > y1 && this.lastres < y1) || (!insertGap && startres < y2 && this.lastres > y2)) { +this.endEditing (); +return; +}if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { +if (startres >= y2) { +fixedLeft = y2; +} else { +fixedRight = y2 - 1; +}}}if (this.groupEditing) { +var groupSeqs = sg.getSequences (this.av.getHiddenRepSequences ()).toArray ( new Array (0)); +if (insertGap) { +if (sg.getStartRes () == 0 && sg.getEndRes () == fixedRight && sg.getEndRes () == this.av.getAlignment ().getWidth () - 1) { +sg.setEndRes (this.av.getAlignment ().getWidth () + startres - this.lastres); +fixedRight = sg.getEndRes (); +}var blank = false; +for (fixedRight = fixedRight; fixedRight > this.lastres; fixedRight--) { +blank = true; +for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { +for (var j = 0; j < startres - this.lastres; j++) { +if (!jalview.util.Comparison.isGap (gs.getCharAt (fixedRight - j))) { +blank = false; +break; +}} +} +if (blank) { +break; +}} +if (!blank) { +if (sg.getSize () == this.av.getAlignment ().getHeight ()) { +if ((this.av.hasHiddenColumns () && startres < this.av.getColumnSelection ().getHiddenBoundaryRight (startres))) { +this.endEditing (); +return; +}var alWidth = this.av.getAlignment ().getWidth (); +if (this.av.hasHiddenRows ()) { +var hwidth = this.av.getAlignment ().getHiddenSequences ().getWidth (); +if (hwidth > alWidth) { +alWidth = hwidth; +}}sg.setEndRes (sg.getEndRes () + startres - this.lastres); +fixedRight = alWidth + startres - this.lastres; +} else { +this.endEditing (); +return; +}}} else if (!insertGap) { +for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { +for (var j = startres; j < this.lastres; j++) { +if (gs.getLength () <= j) { +continue; +}if (!jalview.util.Comparison.isGap (gs.getCharAt (j))) { +this.endEditing (); +return; +}} +} +}if (insertGap) { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j < startres; j++) { +this.insertChar (j, groupSeqs, fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, groupSeqs, startres, startres - this.lastres, this.av.getAlignment (), true); +}} else { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j > startres; j--) { +this.deleteChar (startres, groupSeqs, fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, groupSeqs, startres, this.lastres - startres, this.av.getAlignment (), true); +}}} else { +if (insertGap) { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j < startres; j++) { +this.insertChar (j, Clazz.newArray (-1, [seq]), fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, Clazz.newArray (-1, [seq]), this.lastres, startres - this.lastres, this.av.getAlignment (), true); +}} else { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j > startres; j--) { +if (!jalview.util.Comparison.isGap (seq.getCharAt (startres))) { +this.endEditing (); +break; +}this.deleteChar (startres, Clazz.newArray (-1, [seq]), fixedRight); +} +} else { +var max = 0; +for (var m = startres; m < this.lastres; m++) { +if (!jalview.util.Comparison.isGap (seq.getCharAt (m))) { +break; +}max++; +} +if (max > 0) { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seq]), startres, max, this.av.getAlignment (), true); +}}}}this.lastres = startres; +this.seqCanvas.repaint (); +}, "~B,~N"); +Clazz.defineMethod (c$, "insertChar", +function (j, seq, fixedColumn) { +var blankColumn = fixedColumn; +for (var s = 0; s < seq.length; s++) { +for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { +if (jalview.util.Comparison.isGap (seq[s].getCharAt (blankColumn))) { +break; +}} +if (blankColumn <= j) { +blankColumn = fixedColumn; +this.endEditing (); +return; +}} +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, blankColumn, 1, this.av.getAlignment (), true); +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, j, 1, this.av.getAlignment (), true); +}, "~N,~A,~N"); +Clazz.defineMethod (c$, "deleteChar", +function (j, seq, fixedColumn) { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, j, 1, this.av.getAlignment (), true); +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, fixedColumn, 1, this.av.getAlignment (), true); +}, "~N,~A,~N"); +Clazz.defineMethod (c$, "doMousePressedDefineMode", +function (evt) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}var res = this.findRes (evt); +var seq = this.findSeq (evt); +this.oldSeq = seq; +this.startWrapBlock = this.wrappedBlock; +if (seq == -1) { +return; +}var sequence = this.av.getAlignment ().getSequenceAt (seq); +if (sequence == null || res > sequence.getLength ()) { +return; +}this.stretchGroup = this.av.getSelectionGroup (); +if (this.stretchGroup == null) { +this.stretchGroup = this.av.getAlignment ().findGroup (sequence); +if (this.stretchGroup != null && res > this.stretchGroup.getStartRes () && res < this.stretchGroup.getEndRes ()) { +this.av.setSelectionGroup (this.stretchGroup); +} else { +this.stretchGroup = null; +}} else if (!this.stretchGroup.getSequences (null).contains (sequence) || this.stretchGroup.getStartRes () > res || this.stretchGroup.getEndRes () < res) { +this.stretchGroup = null; +var allGroups = this.av.getAlignment ().findAllGroups (sequence); +if (allGroups != null) { +for (var i = 0; i < allGroups.length; i++) { +if (allGroups[i].getStartRes () <= res && allGroups[i].getEndRes () >= res) { +this.stretchGroup = allGroups[i]; +break; +}} +}this.av.setSelectionGroup (this.stretchGroup); +}if ((evt.getModifiers () & 4) == 4) { +var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); +var links = null; +if (allFeatures != null) { +for (var i = 0; i < allFeatures.length; i++) { +if (allFeatures[i].links != null) { +if (links == null) { +links = new java.util.Vector (); +}for (var j = 0; j < allFeatures[i].links.size (); j++) { +links.addElement (allFeatures[i].links.elementAt (j)); +} +}} +}var popup = new jalview.appletgui.APopupMenu (this.ap, null, links); +this.add (popup); +popup.show (this, evt.getX (), evt.getY ()); +return; +}if (this.av.cursorMode) { +this.seqCanvas.cursorX = this.findRes (evt); +this.seqCanvas.cursorY = this.findSeq (evt); +this.seqCanvas.repaint (); +return; +}if (this.stretchGroup == null) { +var sg = new jalview.datamodel.SequenceGroup (); +sg.setStartRes (res); +sg.setEndRes (res); +sg.addSequence (sequence, false); +this.av.setSelectionGroup (sg); +this.stretchGroup = sg; +if (this.av.getConservationSelected ()) { +jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.av.getGlobalColourScheme (), "Background"); +}if (this.av.getAbovePIDThreshold ()) { +jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.av.getGlobalColourScheme (), "Background"); +}}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMouseReleasedDefineMode", +function (evt) { +if (this.stretchGroup == null) { +return; +}this.stretchGroup.recalcConservation (); +if (this.stretchGroup.cs != null) { +this.stretchGroup.cs.alignmentChanged (this.stretchGroup, this.av.getHiddenRepSequences ()); +if (this.stretchGroup.cs.conservationApplied ()) { +jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); +} else { +jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); +}}this.changeEndRes = false; +this.changeStartRes = false; +this.stretchGroup = null; +jalview.appletgui.PaintRefresher.Refresh (this.ap, this.av.getSequenceSetId ()); +this.ap.paintAlignment (true); +this.av.sendSelection (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMouseDraggedDefineMode", +function (evt) { +var res = this.findRes (evt); +var y = this.findSeq (evt); +if (this.wrappedBlock != this.startWrapBlock) { +return; +}if (this.stretchGroup == null) { +return; +}this.mouseDragging = true; +if (y > this.av.getAlignment ().getHeight ()) { +y = this.av.getAlignment ().getHeight () - 1; +}if (res >= this.av.getAlignment ().getWidth ()) { +res = this.av.getAlignment ().getWidth () - 1; +}if (this.stretchGroup.getEndRes () == res) { +this.changeEndRes = true; +} else if (this.stretchGroup.getStartRes () == res) { +this.changeStartRes = true; +}if (res < 0) { +res = 0; +}if (this.changeEndRes) { +if (res > (this.stretchGroup.getStartRes () - 1)) { +this.stretchGroup.setEndRes (res); +}} else if (this.changeStartRes) { +if (res < (this.stretchGroup.getEndRes () + 1)) { +this.stretchGroup.setStartRes (res); +}}var dragDirection = 0; +if (y > this.oldSeq) { +dragDirection = 1; +} else if (y < this.oldSeq) { +dragDirection = -1; +}while ((y != this.oldSeq) && (this.oldSeq > -1) && (y < this.av.getAlignment ().getHeight ())) { +var seq = this.av.getAlignment ().getSequenceAt (this.oldSeq); +this.oldSeq += dragDirection; +if (this.oldSeq < 0) { +break; +}var nextSeq = this.av.getAlignment ().getSequenceAt (this.oldSeq); +if (this.stretchGroup.getSequences (null).contains (nextSeq)) { +this.stretchGroup.deleteSequence (seq, false); +} else { +if (seq != null) { +this.stretchGroup.addSequence (seq, false); +}this.stretchGroup.addSequence (nextSeq, false); +}} +if (this.oldSeq < 0) { +this.oldSeq = -1; +}if (res > this.av.endRes || res < this.av.startRes || y < this.av.startSeq || y > this.av.endSeq) { +this.mouseExited (evt); +}if (this.scrollThread != null) { +this.scrollThread.setEvent (evt); +}this.seqCanvas.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (e) { +if (this.oldSeq < 0) { +this.oldSeq = 0; +}if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (e) { +if (this.av.getWrapAlignment ()) { +return; +}if (this.mouseDragging && this.scrollThread == null) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "scrollCanvas", +function (evt) { +if (evt == null) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}this.mouseDragging = false; +} else { +if (this.scrollThread == null) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); +}this.mouseDragging = true; +this.scrollThread.setEvent (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "selection", +function (seqsel, colsel, source) { +if (this.av != null && (this.av === source || !this.av.followSelection || (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).getSequenceSetId ().equals (this.av.getSequenceSetId ())))) { +return; +}if (this.selectionFromTranslation (seqsel, colsel, source)) { +return; +}var repaint = false; +var copycolsel = true; +if (this.av.getSelectionGroup () == null || !this.av.isSelectionGroupChanged (true)) { +var sgroup = null; +if (seqsel != null && seqsel.getSize () > 0) { +if (this.av.getAlignment () == null) { +System.out.println ("Selection message: alignviewport av SeqSetId=" + this.av.getSequenceSetId () + " ViewId=" + this.av.getViewId () + " 's alignment is NULL! returning immediatly."); +return; +}sgroup = seqsel.intersect (this.av.getAlignment (), (this.av.hasHiddenRows ()) ? this.av.getHiddenRepSequences () : null); +if ((sgroup == null || sgroup.getSize () == 0) && (colsel == null || colsel.size () == 0)) { +copycolsel = false; +}}if (sgroup != null && sgroup.getSize () > 0) { +this.av.setSelectionGroup (sgroup); +} else { +this.av.setSelectionGroup (null); +}repaint = this.av.isSelectionGroupChanged (true); +}if (copycolsel && (this.av.getColumnSelection () == null || !this.av.isColSelChanged (true))) { +if (colsel == null || colsel.size () == 0) { +if (this.av.getColumnSelection () != null) { +this.av.getColumnSelection ().clear (); +}} else { +if (this.av.getColumnSelection () == null) { +this.av.setColumnSelection ( new jalview.datamodel.ColumnSelection (colsel)); +} else { +this.av.getColumnSelection ().setElementsFrom (colsel); +}}repaint = new Boolean (repaint | this.av.isColSelChanged (true)).valueOf (); +}if (copycolsel && this.av.hasHiddenColumns () && (this.av.getColumnSelection () == null || this.av.getColumnSelection ().getHiddenColumns () == null)) { +System.err.println ("Bad things"); +}if (repaint) { +this.ap.scalePanelHolder.repaint (); +this.ap.repaint (); +}}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +Clazz.defineMethod (c$, "scrollTo", +function (row, column) { +row = row < 0 ? this.ap.av.startSeq : row; +column = column < 0 ? this.ap.av.startRes : column; +this.ap.scrollTo (column, column, row, true, true); +}, "~N,~N"); +Clazz.defineMethod (c$, "scrollToRow", +function (row) { +row = row < 0 ? this.ap.av.startSeq : row; +this.ap.scrollTo (this.ap.av.startRes, this.ap.av.startRes, row, true, true); +}, "~N"); +Clazz.defineMethod (c$, "scrollToColumn", +function (column) { +column = column < 0 ? this.ap.av.startRes : column; +this.ap.scrollTo (column, column, this.ap.av.startSeq, true, true); +}, "~N"); +Clazz.defineMethod (c$, "selectionFromTranslation", +function (seqsel, colsel, source) { +if (!(Clazz.instanceOf (source, jalview.api.AlignViewportI))) { +return false; +}var sourceAv = source; +if (sourceAv.getCodingComplement () !== this.av && this.av.getCodingComplement () !== sourceAv) { +return false; +}var sg = jalview.util.MappingUtils.mapSequenceGroup (seqsel, sourceAv, this.av); +this.av.setSelectionGroup (sg); +this.av.isSelectionGroupChanged (true); +var cs = jalview.util.MappingUtils.mapColumnSelection (colsel, sourceAv, this.av); +this.av.setColumnSelection (cs); +this.av.isColSelChanged (true); +this.ap.scalePanelHolder.repaint (); +this.ap.repaint (); +return true; +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +c$.$SeqPanel$ScrollThread$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.evt = null; +this.running = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.SeqPanel, "ScrollThread", Thread); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.SeqPanel.ScrollThread, []); +this.start (); +}); +Clazz.defineMethod (c$, "setEvent", +function (a) { +this.evt = a; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "stopScrolling", +function () { +this.running = false; +}); +Clazz.overrideMethod (c$, "run", +function () { +this.running = true; +while (this.running) { +if (this.evt != null) { +if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () < 0 && this.b$["jalview.appletgui.SeqPanel"].av.getStartSeq () > 0) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (true); +}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 ()) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (false); +}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () < 0) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (false); +} else if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().width) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (true); +}}try { +Thread.sleep (75); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +} +}); +c$ = Clazz.p0p (); +}; +});