Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / appletgui / SeqCanvas.js
index 54fb6ee..faa6bae 100644 (file)
-Clazz.declarePackage ("jalview.appletgui");\r
-Clazz.load (["awt2swing.Panel"], "jalview.appletgui.SeqCanvas", ["jalview.appletgui.AnnotationPanel", "$.FeatureRenderer", "$.PaintRefresher", "$.SequenceRenderer", "jalview.util.Comparison", "java.awt.Color"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.fr = null;\r
-this.sr = null;\r
-this.img = null;\r
-this.gg = null;\r
-this.imgWidth = 0;\r
-this.imgHeight = 0;\r
-this.av = null;\r
-this.searchResults = null;\r
-this.$fastPaint = false;\r
-this.cursorX = 0;\r
-this.cursorY = 0;\r
-this.avcharHeight = 0;\r
-this.avcharWidth = 0;\r
-this.lastsr = 0;\r
-this.LABEL_WEST = 0;\r
-this.LABEL_EAST = 0;\r
-this.annotations = null;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.appletgui, "SeqCanvas", awt2swing.Panel);\r
-Clazz.makeConstructor (c$, \r
-function (av) {\r
-Clazz.superConstructor (this, jalview.appletgui.SeqCanvas, []);\r
-this.av = av;\r
-this.fr =  new jalview.appletgui.FeatureRenderer (av);\r
-this.sr =  new jalview.appletgui.SequenceRenderer (av);\r
-jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ());\r
-this.updateViewport ();\r
-}, "jalview.appletgui.AlignViewport");\r
-Clazz.defineMethod (c$, "updateViewport", \r
- function () {\r
-this.avcharHeight = this.av.getCharHeight ();\r
-this.avcharWidth = this.av.getCharWidth ();\r
-});\r
-Clazz.defineMethod (c$, "getViewport", \r
-function () {\r
-return this.av;\r
-});\r
-Clazz.defineMethod (c$, "getFeatureRenderer", \r
-function () {\r
-return this.fr;\r
-});\r
-Clazz.defineMethod (c$, "getSequenceRenderer", \r
-function () {\r
-return this.sr;\r
-});\r
-Clazz.defineMethod (c$, "drawNorthScale", \r
- function (g, startx, endx, ypos) {\r
-var scalestartx = startx - startx % 10 + 10;\r
-g.setColor (java.awt.Color.black);\r
-for (var i = scalestartx; i < endx; i += 10) {\r
-var value = i;\r
-if (this.av.hasHiddenColumns ()) {\r
-value = this.av.getColumnSelection ().adjustForHiddenColumns (value);\r
-}g.drawString (String.valueOf (value), (i - startx - 1) * this.avcharWidth, ypos - (Clazz.doubleToInt (this.avcharHeight / 2)));\r
-g.drawLine (((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), (ypos + 2) - (Clazz.doubleToInt (this.avcharHeight / 2)), ((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), ypos - 2);\r
-}\r
-}, "java.awt.Graphics,~N,~N,~N");\r
-Clazz.defineMethod (c$, "drawWestScale", \r
- function (g, startx, endx, ypos) {\r
-var fm = this.getFontMetrics (this.av.getFont ());\r
-ypos += this.avcharHeight;\r
-if (this.av.hasHiddenColumns ()) {\r
-startx = this.av.getColumnSelection ().adjustForHiddenColumns (startx);\r
-endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx);\r
-}var maxwidth = this.av.getAlignment ().getWidth ();\r
-if (this.av.hasHiddenColumns ()) {\r
-maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1;\r
-}for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) {\r
-var seq = this.av.getAlignment ().getSequenceAt (i);\r
-var index = startx;\r
-var value = -1;\r
-while (index < endx) {\r
-if (jalview.util.Comparison.isGap (seq.getCharAt (index))) {\r
-index++;\r
-continue;\r
-}value = this.av.getAlignment ().getSequenceAt (i).findPosition (index);\r
-break;\r
-}\r
-if (value != -1) {\r
-var x = this.LABEL_WEST - fm.stringWidth (String.valueOf (value)) - Clazz.doubleToInt (this.avcharWidth / 2);\r
-g.drawString (value + "", x, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5)));\r
-}}\r
-}, "java.awt.Graphics,~N,~N,~N");\r
-Clazz.defineMethod (c$, "drawEastScale", \r
- function (g, startx, endx, ypos) {\r
-ypos += this.avcharHeight;\r
-if (this.av.hasHiddenColumns ()) {\r
-endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx);\r
-}var seq;\r
-for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) {\r
-seq = this.av.getAlignment ().getSequenceAt (i);\r
-var index = endx;\r
-var value = -1;\r
-while (index > startx) {\r
-if (jalview.util.Comparison.isGap (seq.getCharAt (index))) {\r
-index--;\r
-continue;\r
-}value = seq.findPosition (index);\r
-break;\r
-}\r
-if (value != -1) {\r
-g.drawString (String.valueOf (value), 0, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5)));\r
-}}\r
-}, "java.awt.Graphics,~N,~N,~N");\r
-Clazz.defineMethod (c$, "fastPaint", \r
-function (horizontal, vertical) {\r
-if (this.$fastPaint || this.gg == null) {\r
-return;\r
-}this.updateViewport ();\r
-if (this.lastsr + horizontal != this.av.startRes) {\r
-horizontal = this.av.startRes - this.lastsr;\r
-}this.lastsr = this.av.startRes;\r
-this.$fastPaint = true;\r
-this.gg.copyArea (horizontal * this.avcharWidth, vertical * this.avcharHeight, this.imgWidth - horizontal * this.avcharWidth, this.imgHeight - vertical * this.avcharHeight, -horizontal * this.avcharWidth, -vertical * this.avcharHeight);\r
-var sr = this.av.startRes;\r
-var er = this.av.endRes;\r
-var ss = this.av.startSeq;\r
-var es = this.av.endSeq;\r
-var transX = 0;\r
-var transY = 0;\r
-if (horizontal > 0) {\r
-transX = (er - sr - horizontal) * this.avcharWidth;\r
-sr = er - horizontal;\r
-} else if (horizontal < 0) {\r
-er = sr - horizontal;\r
-} else if (vertical > 0) {\r
-ss = es - vertical;\r
-if (ss < this.av.startSeq) {\r
-ss = this.av.startSeq;\r
-} else {\r
-transY = this.imgHeight - vertical * this.avcharHeight;\r
-}} else if (vertical < 0) {\r
-es = ss - vertical;\r
-if (es > this.av.endSeq) {\r
-es = this.av.endSeq;\r
-}}this.gg.translate (transX, transY);\r
-this.drawPanel (this.gg, sr, er, ss, es, 0);\r
-this.gg.translate (-transX, -transY);\r
-this.repaint ();\r
-}, "~N,~N");\r
-Clazz.overrideMethod (c$, "paintComponent", \r
-function (g) {\r
-if (this.img != null && (this.$fastPaint || (this.getSize ().width != g.getClipBounds ().width) || (this.getSize ().height != g.getClipBounds ().height))) {\r
-g.drawImage (this.img, 0, 0, this);\r
-this.$fastPaint = false;\r
-return;\r
-}if (this.$fastPaint) {\r
-g.drawImage (this.img, 0, 0, this);\r
-this.$fastPaint = false;\r
-return;\r
-}this.updateViewport ();\r
-this.imgWidth = this.getSize ().width;\r
-this.imgHeight = this.getSize ().height;\r
-this.imgWidth -= this.imgWidth % this.avcharWidth;\r
-this.imgHeight -= this.imgHeight % this.avcharHeight;\r
-if (this.imgWidth < 1 || this.imgHeight < 1) {\r
-return;\r
-}if (this.img == null || this.imgWidth != this.img.getWidth (this) || this.imgHeight != this.img.getHeight (this)) {\r
-this.img = this.createImage (this.imgWidth, this.imgHeight);\r
-this.gg = this.img.getGraphics ();\r
-this.gg.setFont (this.av.getFont ());\r
-}this.gg.setColor (java.awt.Color.white);\r
-this.gg.fillRect (0, 0, this.imgWidth, this.imgHeight);\r
-if (this.av.getWrapAlignment ()) {\r
-this.drawWrappedPanel (this.gg, this.imgWidth, this.imgHeight, this.av.startRes);\r
-} else {\r
-this.drawPanel (this.gg, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq, 0);\r
-}g.drawImage (this.img, 0, 0, this);\r
-}, "java.awt.Graphics");\r
-Clazz.defineMethod (c$, "getWrappedCanvasWidth", \r
-function (cwidth) {\r
-cwidth -= cwidth % this.av.getCharWidth ();\r
-var fm = this.getFontMetrics (this.av.getFont ());\r
-this.LABEL_EAST = 0;\r
-this.LABEL_WEST = 0;\r
-if (this.av.getScaleRightWrapped ()) {\r
-this.LABEL_EAST = fm.stringWidth (this.getMask ());\r
-}if (this.av.getScaleLeftWrapped ()) {\r
-this.LABEL_WEST = fm.stringWidth (this.getMask ());\r
-}return Clazz.doubleToInt ((cwidth - this.LABEL_EAST - this.LABEL_WEST) / this.av.getCharWidth ());\r
-}, "~N");\r
-Clazz.defineMethod (c$, "getMask", \r
-function () {\r
-var mask = "0";\r
-var maxWidth = 0;\r
-var tmp;\r
-var alignment = this.av.getAlignment ();\r
-for (var i = 0; i < alignment.getHeight (); i++) {\r
-tmp = alignment.getSequenceAt (i).getEnd ();\r
-if (tmp > maxWidth) {\r
-maxWidth = tmp;\r
-}}\r
-for (var i = maxWidth; i > 0; i /= 10) {\r
-mask += "0";\r
-}\r
-return mask;\r
-});\r
-Clazz.defineMethod (c$, "drawWrappedPanel", \r
- function (g, canvasWidth, canvasHeight, startRes) {\r
-var al = this.av.getAlignment ();\r
-var fm = this.getFontMetrics (this.av.getFont ());\r
-if (this.av.getScaleRightWrapped ()) {\r
-this.LABEL_EAST = fm.stringWidth (this.getMask ());\r
-}if (this.av.getScaleLeftWrapped ()) {\r
-this.LABEL_WEST = fm.stringWidth (this.getMask ());\r
-}var hgap = this.avcharHeight;\r
-if (this.av.getScaleAboveWrapped ()) {\r
-hgap += this.avcharHeight;\r
-}var cWidth = Clazz.doubleToInt ((canvasWidth - this.LABEL_EAST - this.LABEL_WEST) / this.avcharWidth);\r
-var cHeight = this.av.getAlignment ().getHeight () * this.avcharHeight;\r
-this.av.setWrappedWidth (cWidth);\r
-this.av.endRes = this.av.startRes + cWidth;\r
-var endx;\r
-var ypos = hgap;\r
-var maxwidth = this.av.getAlignment ().getWidth () - 1;\r
-if (this.av.hasHiddenColumns ()) {\r
-maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1;\r
-}while ((ypos <= canvasHeight) && (startRes < maxwidth)) {\r
-endx = startRes + cWidth - 1;\r
-if (endx > maxwidth) {\r
-endx = maxwidth;\r
-}g.setColor (java.awt.Color.black);\r
-if (this.av.getScaleLeftWrapped ()) {\r
-this.drawWestScale (g, startRes, endx, ypos);\r
-}if (this.av.getScaleRightWrapped ()) {\r
-g.translate (canvasWidth - this.LABEL_EAST, 0);\r
-this.drawEastScale (g, startRes, endx, ypos);\r
-g.translate (-(canvasWidth - this.LABEL_EAST), 0);\r
-}g.translate (this.LABEL_WEST, 0);\r
-if (this.av.getScaleAboveWrapped ()) {\r
-this.drawNorthScale (g, startRes, endx, ypos);\r
-}if (this.av.hasHiddenColumns () && this.av.getShowHiddenMarkers ()) {\r
-g.setColor (java.awt.Color.blue);\r
-var res;\r
-for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) {\r
-res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startRes;\r
-if (res < 0 || res > endx - startRes) {\r
-continue;\r
-}this.gg.fillPolygon ( Clazz.newIntArray (-1, [res * this.avcharWidth - Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth + Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth]),  Clazz.newIntArray (-1, [ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)) + 8]), 3);\r
-}\r
-}if (g.getClip () == null) {\r
-g.setClip (0, 0, cWidth * this.avcharWidth, canvasHeight);\r
-}this.drawPanel (g, startRes, endx, 0, al.getHeight (), ypos);\r
-g.setClip (null);\r
-if (this.av.isShowAnnotation ()) {\r
-g.translate (0, cHeight + ypos + 4);\r
-if (this.annotations == null) {\r
-this.annotations =  new jalview.appletgui.AnnotationPanel (this.av);\r
-}this.annotations.drawComponent (g, startRes, endx + 1);\r
-g.translate (0, -cHeight - ypos - 4);\r
-}g.translate (-this.LABEL_WEST, 0);\r
-ypos += cHeight + this.getAnnotationHeight () + hgap;\r
-startRes += cWidth;\r
-}\r
-}, "java.awt.Graphics,~N,~N,~N");\r
-Clazz.defineMethod (c$, "getAnnotationHeight", \r
-function () {\r
-if (!this.av.isShowAnnotation ()) {\r
-return 0;\r
-}if (this.annotations == null) {\r
-this.annotations =  new jalview.appletgui.AnnotationPanel (this.av);\r
-}return this.annotations.adjustPanelHeight ();\r
-});\r
-Clazz.defineMethod (c$, "drawPanel", \r
- function (g1, startRes, endRes, startSeq, endSeq, offset) {\r
-if (!this.av.hasHiddenColumns ()) {\r
-this.draw (g1, startRes, endRes, startSeq, endSeq, offset);\r
-} else {\r
-var screenY = 0;\r
-var blockStart = startRes;\r
-var blockEnd = endRes;\r
-if (this.av.hasHiddenColumns ()) {\r
-for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) {\r
-var hideStart = region[0];\r
-var hideEnd = region[1];\r
-if (hideStart <= blockStart) {\r
-blockStart += (hideEnd - hideStart) + 1;\r
-continue;\r
-}blockEnd = hideStart - 1;\r
-g1.translate (screenY * this.avcharWidth, 0);\r
-this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset);\r
-if (this.av.getShowHiddenMarkers ()) {\r
-g1.setColor (java.awt.Color.blue);\r
-g1.drawLine ((blockEnd - blockStart + 1) * this.avcharWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * this.avcharWidth - 1, (endSeq - startSeq) * this.avcharHeight + offset);\r
-}g1.translate (-screenY * this.avcharWidth, 0);\r
-screenY += blockEnd - blockStart + 1;\r
-blockStart = hideEnd + 1;\r
-}\r
-}if (screenY <= (endRes - startRes)) {\r
-blockEnd = blockStart + (endRes - startRes) - screenY;\r
-g1.translate (screenY * this.avcharWidth, 0);\r
-this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset);\r
-g1.translate (-screenY * this.avcharWidth, 0);\r
-}}}, "java.awt.Graphics,~N,~N,~N,~N,~N");\r
-Clazz.defineMethod (c$, "draw", \r
-function (g, startRes, endRes, startSeq, endSeq, offset) {\r
-g.setFont (this.av.getFont ());\r
-this.sr.prepare (g, this.av.isRenderGaps ());\r
-this.updateViewport ();\r
-var nextSeq;\r
-for (var i = startSeq; i < endSeq; i++) {\r
-nextSeq = this.av.getAlignment ().getSequenceAt (i);\r
-if (nextSeq == null) {\r
-continue;\r
-}this.sr.drawSequence (nextSeq, this.av.getAlignment ().findAllGroups (nextSeq), startRes, endRes, offset + ((i - startSeq) * this.avcharHeight));\r
-if (this.av.isShowSequenceFeatures ()) {\r
-this.fr.drawSequence (g, nextSeq, startRes, endRes, offset + ((i - startSeq) * this.avcharHeight));\r
-}if (this.searchResults != null) {\r
-var visibleResults = this.searchResults.getResults (nextSeq, startRes, endRes);\r
-if (visibleResults != null) {\r
-for (var r = 0; r < visibleResults.length; r += 2) {\r
-this.sr.drawHighlightedText (nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight));\r
-}\r
-}}if (this.av.cursorMode && this.cursorY == i && this.cursorX >= startRes && this.cursorX <= endRes) {\r
-this.sr.drawCursor (nextSeq, this.cursorX, (this.cursorX - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight));\r
-}}\r
-if (this.av.getSelectionGroup () != null || this.av.getAlignment ().getGroups ().size () > 0) {\r
-this.drawGroupsBoundaries (g, startRes, endRes, startSeq, endSeq, offset);\r
-}}, "java.awt.Graphics,~N,~N,~N,~N,~N");\r
-Clazz.defineMethod (c$, "drawGroupsBoundaries", \r
- function (g, startRes, endRes, startSeq, endSeq, offset) {\r
-var group = this.av.getSelectionGroup ();\r
-var sx = -1;\r
-var sy = -1;\r
-var ex = -1;\r
-var groupIndex = -1;\r
-if ((group == null) && (this.av.getAlignment ().getGroups ().size () > 0)) {\r
-group = this.av.getAlignment ().getGroups ().get (0);\r
-groupIndex = 0;\r
-}if (group != null) {\r
-do {\r
-var oldY = -1;\r
-var i = 0;\r
-var inGroup = false;\r
-var top = -1;\r
-var bottom = -1;\r
-var alHeight = this.av.getAlignment ().getHeight () - 1;\r
-for (i = startSeq; i < endSeq; i++) {\r
-sx = (group.getStartRes () - startRes) * this.avcharWidth;\r
-sy = offset + ((i - startSeq) * this.avcharHeight);\r
-ex = (((group.getEndRes () + 1) - group.getStartRes ()) * this.avcharWidth) - 1;\r
-if (sx + ex < 0 || sx > this.imgWidth) {\r
-continue;\r
-}if ((sx <= (endRes - startRes) * this.avcharWidth) && group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i))) {\r
-if ((bottom == -1) && (i >= alHeight || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i + 1)))) {\r
-bottom = sy + this.avcharHeight;\r
-}if (!inGroup) {\r
-if (((top == -1) && (i == 0)) || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i - 1))) {\r
-top = sy;\r
-}oldY = sy;\r
-inGroup = true;\r
-if (group === this.av.getSelectionGroup ()) {\r
-g.setColor (java.awt.Color.red);\r
-} else {\r
-g.setColor (group.getOutlineColour ());\r
-}}} else {\r
-if (inGroup) {\r
-if (sx >= 0 && sx < this.imgWidth) {\r
-g.drawLine (sx, oldY, sx, sy);\r
-}if (sx + ex < this.imgWidth) {\r
-g.drawLine (sx + ex, oldY, sx + ex, sy);\r
-}if (sx < 0) {\r
-ex += sx;\r
-sx = 0;\r
-}if (sx + ex > this.imgWidth) {\r
-ex = this.imgWidth;\r
-} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) {\r
-ex = (endRes - startRes + 1) * this.avcharWidth;\r
-}if (top != -1) {\r
-g.drawLine (sx, top, sx + ex, top);\r
-top = -1;\r
-}if (bottom != -1) {\r
-g.drawLine (sx, bottom, sx + ex, bottom);\r
-bottom = -1;\r
-}inGroup = false;\r
-}}}\r
-if (inGroup) {\r
-sy = offset + ((i - startSeq) * this.avcharHeight);\r
-if (sx >= 0 && sx < this.imgWidth) {\r
-g.drawLine (sx, oldY, sx, sy);\r
-}if (sx + ex < this.imgWidth) {\r
-g.drawLine (sx + ex, oldY, sx + ex, sy);\r
-}if (sx < 0) {\r
-ex += sx;\r
-sx = 0;\r
-}if (sx + ex > this.imgWidth) {\r
-ex = this.imgWidth;\r
-} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) {\r
-ex = (endRes - startRes + 1) * this.avcharWidth;\r
-}if (top != -1) {\r
-g.drawLine (sx, top, sx + ex, top);\r
-top = -1;\r
-}if (bottom != -1) {\r
-g.drawLine (sx, bottom - 1, sx + ex, bottom - 1);\r
-bottom = -1;\r
-}inGroup = false;\r
-}groupIndex++;\r
-if (groupIndex >= this.av.getAlignment ().getGroups ().size ()) {\r
-break;\r
-}group = this.av.getAlignment ().getGroups ().get (groupIndex);\r
-} while (groupIndex < this.av.getAlignment ().getGroups ().size ());\r
-}}, "java.awt.Graphics,~N,~N,~N,~N,~N");\r
-Clazz.defineMethod (c$, "highlightSearchResults", \r
-function (results) {\r
-this.searchResults = results;\r
-this.repaint ();\r
-}, "jalview.datamodel.SearchResults");\r
-});\r
+Clazz.declarePackage ("jalview.appletgui");
+Clazz.load (["awt2swing.Panel"], "jalview.appletgui.SeqCanvas", ["jalview.appletgui.AnnotationPanel", "$.FeatureRenderer", "$.PaintRefresher", "$.SequenceRenderer", "jalview.util.Comparison", "java.awt.Color"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.fr = null;
+this.sr = null;
+this.img = null;
+this.gg = null;
+this.imgWidth = 0;
+this.imgHeight = 0;
+this.av = null;
+this.searchResults = null;
+this.$fastPaint = false;
+this.cursorX = 0;
+this.cursorY = 0;
+this.avcharHeight = 0;
+this.avcharWidth = 0;
+this.lastsr = 0;
+this.LABEL_WEST = 0;
+this.LABEL_EAST = 0;
+this.annotations = null;
+Clazz.instantialize (this, arguments);
+}, jalview.appletgui, "SeqCanvas", awt2swing.Panel);
+Clazz.makeConstructor (c$, 
+function (av) {
+Clazz.superConstructor (this, jalview.appletgui.SeqCanvas, []);
+this.av = av;
+this.fr =  new jalview.appletgui.FeatureRenderer (av);
+this.sr =  new jalview.appletgui.SequenceRenderer (av);
+jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ());
+this.updateViewport ();
+}, "jalview.appletgui.AlignViewport");
+Clazz.defineMethod (c$, "updateViewport", 
+ function () {
+this.avcharHeight = this.av.getCharHeight ();
+this.avcharWidth = this.av.getCharWidth ();
+});
+Clazz.defineMethod (c$, "getViewport", 
+function () {
+return this.av;
+});
+Clazz.defineMethod (c$, "getFeatureRenderer", 
+function () {
+return this.fr;
+});
+Clazz.defineMethod (c$, "getSequenceRenderer", 
+function () {
+return this.sr;
+});
+Clazz.defineMethod (c$, "drawNorthScale", 
+ function (g, startx, endx, ypos) {
+var scalestartx = startx - startx % 10 + 10;
+g.setColor (java.awt.Color.black);
+for (var i = scalestartx; i < endx; i += 10) {
+var value = i;
+if (this.av.hasHiddenColumns ()) {
+value = this.av.getColumnSelection ().adjustForHiddenColumns (value);
+}g.drawString (String.valueOf (value), (i - startx - 1) * this.avcharWidth, ypos - (Clazz.doubleToInt (this.avcharHeight / 2)));
+g.drawLine (((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), (ypos + 2) - (Clazz.doubleToInt (this.avcharHeight / 2)), ((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), ypos - 2);
+}
+}, "java.awt.Graphics,~N,~N,~N");
+Clazz.defineMethod (c$, "drawWestScale", 
+ function (g, startx, endx, ypos) {
+var fm = this.getFontMetrics (this.av.getFont ());
+ypos += this.avcharHeight;
+if (this.av.hasHiddenColumns ()) {
+startx = this.av.getColumnSelection ().adjustForHiddenColumns (startx);
+endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx);
+}var maxwidth = this.av.getAlignment ().getWidth ();
+if (this.av.hasHiddenColumns ()) {
+maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1;
+}for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) {
+var seq = this.av.getAlignment ().getSequenceAt (i);
+var index = startx;
+var value = -1;
+while (index < endx) {
+if (jalview.util.Comparison.isGap (seq.getCharAt (index))) {
+index++;
+continue;
+}value = this.av.getAlignment ().getSequenceAt (i).findPosition (index);
+break;
+}
+if (value != -1) {
+var x = this.LABEL_WEST - fm.stringWidth (String.valueOf (value)) - Clazz.doubleToInt (this.avcharWidth / 2);
+g.drawString (value + "", x, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5)));
+}}
+}, "java.awt.Graphics,~N,~N,~N");
+Clazz.defineMethod (c$, "drawEastScale", 
+ function (g, startx, endx, ypos) {
+ypos += this.avcharHeight;
+if (this.av.hasHiddenColumns ()) {
+endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx);
+}var seq;
+for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) {
+seq = this.av.getAlignment ().getSequenceAt (i);
+var index = endx;
+var value = -1;
+while (index > startx) {
+if (jalview.util.Comparison.isGap (seq.getCharAt (index))) {
+index--;
+continue;
+}value = seq.findPosition (index);
+break;
+}
+if (value != -1) {
+g.drawString (String.valueOf (value), 0, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5)));
+}}
+}, "java.awt.Graphics,~N,~N,~N");
+Clazz.defineMethod (c$, "fastPaint", 
+function (horizontal, vertical) {
+if (this.$fastPaint || this.gg == null) {
+return;
+}this.updateViewport ();
+if (this.lastsr + horizontal != this.av.startRes) {
+horizontal = this.av.startRes - this.lastsr;
+}this.lastsr = this.av.startRes;
+this.$fastPaint = true;
+this.gg.copyArea (horizontal * this.avcharWidth, vertical * this.avcharHeight, this.imgWidth - horizontal * this.avcharWidth, this.imgHeight - vertical * this.avcharHeight, -horizontal * this.avcharWidth, -vertical * this.avcharHeight);
+var sr = this.av.startRes;
+var er = this.av.endRes;
+var ss = this.av.startSeq;
+var es = this.av.endSeq;
+var transX = 0;
+var transY = 0;
+if (horizontal > 0) {
+transX = (er - sr - horizontal) * this.avcharWidth;
+sr = er - horizontal;
+} else if (horizontal < 0) {
+er = sr - horizontal;
+} else if (vertical > 0) {
+ss = es - vertical;
+if (ss < this.av.startSeq) {
+ss = this.av.startSeq;
+} else {
+transY = this.imgHeight - vertical * this.avcharHeight;
+}} else if (vertical < 0) {
+es = ss - vertical;
+if (es > this.av.endSeq) {
+es = this.av.endSeq;
+}}this.gg.translate (transX, transY);
+this.drawPanel (this.gg, sr, er, ss, es, 0);
+this.gg.translate (-transX, -transY);
+this.repaint ();
+}, "~N,~N");
+Clazz.overrideMethod (c$, "paintComponent", 
+function (g) {
+if (this.img != null && (this.$fastPaint || (this.getSize ().width != g.getClipBounds ().width) || (this.getSize ().height != g.getClipBounds ().height))) {
+g.drawImage (this.img, 0, 0, this);
+this.$fastPaint = false;
+return;
+}if (this.$fastPaint) {
+g.drawImage (this.img, 0, 0, this);
+this.$fastPaint = false;
+return;
+}this.updateViewport ();
+this.imgWidth = this.getSize ().width;
+this.imgHeight = this.getSize ().height;
+this.imgWidth -= this.imgWidth % this.avcharWidth;
+this.imgHeight -= this.imgHeight % this.avcharHeight;
+if (this.imgWidth < 1 || this.imgHeight < 1) {
+return;
+}if (this.img == null || this.imgWidth != this.img.getWidth (this) || this.imgHeight != this.img.getHeight (this)) {
+this.img = this.createImage (this.imgWidth, this.imgHeight);
+this.gg = this.img.getGraphics ();
+this.gg.setFont (this.av.getFont ());
+}this.gg.setColor (java.awt.Color.white);
+this.gg.fillRect (0, 0, this.imgWidth, this.imgHeight);
+if (this.av.getWrapAlignment ()) {
+this.drawWrappedPanel (this.gg, this.imgWidth, this.imgHeight, this.av.startRes);
+} else {
+this.drawPanel (this.gg, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq, 0);
+}g.drawImage (this.img, 0, 0, this);
+}, "java.awt.Graphics");
+Clazz.defineMethod (c$, "getWrappedCanvasWidth", 
+function (cwidth) {
+cwidth -= cwidth % this.av.getCharWidth ();
+var fm = this.getFontMetrics (this.av.getFont ());
+this.LABEL_EAST = 0;
+this.LABEL_WEST = 0;
+if (this.av.getScaleRightWrapped ()) {
+this.LABEL_EAST = fm.stringWidth (this.getMask ());
+}if (this.av.getScaleLeftWrapped ()) {
+this.LABEL_WEST = fm.stringWidth (this.getMask ());
+}return Clazz.doubleToInt ((cwidth - this.LABEL_EAST - this.LABEL_WEST) / this.av.getCharWidth ());
+}, "~N");
+Clazz.defineMethod (c$, "getMask", 
+function () {
+var mask = "0";
+var maxWidth = 0;
+var tmp;
+var alignment = this.av.getAlignment ();
+for (var i = 0; i < alignment.getHeight (); i++) {
+tmp = alignment.getSequenceAt (i).getEnd ();
+if (tmp > maxWidth) {
+maxWidth = tmp;
+}}
+for (var i = maxWidth; i > 0; i /= 10) {
+mask += "0";
+}
+return mask;
+});
+Clazz.defineMethod (c$, "drawWrappedPanel", 
+ function (g, canvasWidth, canvasHeight, startRes) {
+var al = this.av.getAlignment ();
+var fm = this.getFontMetrics (this.av.getFont ());
+if (this.av.getScaleRightWrapped ()) {
+this.LABEL_EAST = fm.stringWidth (this.getMask ());
+}if (this.av.getScaleLeftWrapped ()) {
+this.LABEL_WEST = fm.stringWidth (this.getMask ());
+}var hgap = this.avcharHeight;
+if (this.av.getScaleAboveWrapped ()) {
+hgap += this.avcharHeight;
+}var cWidth = Clazz.doubleToInt ((canvasWidth - this.LABEL_EAST - this.LABEL_WEST) / this.avcharWidth);
+var cHeight = this.av.getAlignment ().getHeight () * this.avcharHeight;
+this.av.setWrappedWidth (cWidth);
+this.av.endRes = this.av.startRes + cWidth;
+var endx;
+var ypos = hgap;
+var maxwidth = this.av.getAlignment ().getWidth () - 1;
+if (this.av.hasHiddenColumns ()) {
+maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1;
+}while ((ypos <= canvasHeight) && (startRes < maxwidth)) {
+endx = startRes + cWidth - 1;
+if (endx > maxwidth) {
+endx = maxwidth;
+}g.setColor (java.awt.Color.black);
+if (this.av.getScaleLeftWrapped ()) {
+this.drawWestScale (g, startRes, endx, ypos);
+}if (this.av.getScaleRightWrapped ()) {
+g.translate (canvasWidth - this.LABEL_EAST, 0);
+this.drawEastScale (g, startRes, endx, ypos);
+g.translate (-(canvasWidth - this.LABEL_EAST), 0);
+}g.translate (this.LABEL_WEST, 0);
+if (this.av.getScaleAboveWrapped ()) {
+this.drawNorthScale (g, startRes, endx, ypos);
+}if (this.av.hasHiddenColumns () && this.av.getShowHiddenMarkers ()) {
+g.setColor (java.awt.Color.blue);
+var res;
+for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) {
+res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startRes;
+if (res < 0 || res > endx - startRes) {
+continue;
+}this.gg.fillPolygon ( Clazz.newIntArray (-1, [res * this.avcharWidth - Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth + Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth]),  Clazz.newIntArray (-1, [ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)) + 8]), 3);
+}
+}if (g.getClip () == null) {
+g.setClip (0, 0, cWidth * this.avcharWidth, canvasHeight);
+}this.drawPanel (g, startRes, endx, 0, al.getHeight (), ypos);
+g.setClip (null);
+if (this.av.isShowAnnotation ()) {
+g.translate (0, cHeight + ypos + 4);
+if (this.annotations == null) {
+this.annotations =  new jalview.appletgui.AnnotationPanel (this.av);
+}this.annotations.drawComponent (g, startRes, endx + 1);
+g.translate (0, -cHeight - ypos - 4);
+}g.translate (-this.LABEL_WEST, 0);
+ypos += cHeight + this.getAnnotationHeight () + hgap;
+startRes += cWidth;
+}
+}, "java.awt.Graphics,~N,~N,~N");
+Clazz.defineMethod (c$, "getAnnotationHeight", 
+function () {
+if (!this.av.isShowAnnotation ()) {
+return 0;
+}if (this.annotations == null) {
+this.annotations =  new jalview.appletgui.AnnotationPanel (this.av);
+}return this.annotations.adjustPanelHeight ();
+});
+Clazz.defineMethod (c$, "drawPanel", 
+ function (g1, startRes, endRes, startSeq, endSeq, offset) {
+if (!this.av.hasHiddenColumns ()) {
+this.draw (g1, startRes, endRes, startSeq, endSeq, offset);
+} else {
+var screenY = 0;
+var blockStart = startRes;
+var blockEnd = endRes;
+if (this.av.hasHiddenColumns ()) {
+for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) {
+var hideStart = region[0];
+var hideEnd = region[1];
+if (hideStart <= blockStart) {
+blockStart += (hideEnd - hideStart) + 1;
+continue;
+}blockEnd = hideStart - 1;
+g1.translate (screenY * this.avcharWidth, 0);
+this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset);
+if (this.av.getShowHiddenMarkers ()) {
+g1.setColor (java.awt.Color.blue);
+g1.drawLine ((blockEnd - blockStart + 1) * this.avcharWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * this.avcharWidth - 1, (endSeq - startSeq) * this.avcharHeight + offset);
+}g1.translate (-screenY * this.avcharWidth, 0);
+screenY += blockEnd - blockStart + 1;
+blockStart = hideEnd + 1;
+}
+}if (screenY <= (endRes - startRes)) {
+blockEnd = blockStart + (endRes - startRes) - screenY;
+g1.translate (screenY * this.avcharWidth, 0);
+this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset);
+g1.translate (-screenY * this.avcharWidth, 0);
+}}}, "java.awt.Graphics,~N,~N,~N,~N,~N");
+Clazz.defineMethod (c$, "draw", 
+function (g, startRes, endRes, startSeq, endSeq, offset) {
+g.setFont (this.av.getFont ());
+this.sr.prepare (g, this.av.isRenderGaps ());
+this.updateViewport ();
+var nextSeq;
+for (var i = startSeq; i < endSeq; i++) {
+nextSeq = this.av.getAlignment ().getSequenceAt (i);
+if (nextSeq == null) {
+continue;
+}this.sr.drawSequence (nextSeq, this.av.getAlignment ().findAllGroups (nextSeq), startRes, endRes, offset + ((i - startSeq) * this.avcharHeight));
+if (this.av.isShowSequenceFeatures ()) {
+this.fr.drawSequence (g, nextSeq, startRes, endRes, offset + ((i - startSeq) * this.avcharHeight));
+}if (this.searchResults != null) {
+var visibleResults = this.searchResults.getResults (nextSeq, startRes, endRes);
+if (visibleResults != null) {
+for (var r = 0; r < visibleResults.length; r += 2) {
+this.sr.drawHighlightedText (nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight));
+}
+}}if (this.av.cursorMode && this.cursorY == i && this.cursorX >= startRes && this.cursorX <= endRes) {
+this.sr.drawCursor (nextSeq, this.cursorX, (this.cursorX - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight));
+}}
+if (this.av.getSelectionGroup () != null || this.av.getAlignment ().getGroups ().size () > 0) {
+this.drawGroupsBoundaries (g, startRes, endRes, startSeq, endSeq, offset);
+}}, "java.awt.Graphics,~N,~N,~N,~N,~N");
+Clazz.defineMethod (c$, "drawGroupsBoundaries", 
+ function (g, startRes, endRes, startSeq, endSeq, offset) {
+var group = this.av.getSelectionGroup ();
+var sx = -1;
+var sy = -1;
+var ex = -1;
+var groupIndex = -1;
+if ((group == null) && (this.av.getAlignment ().getGroups ().size () > 0)) {
+group = this.av.getAlignment ().getGroups ().get (0);
+groupIndex = 0;
+}if (group != null) {
+do {
+var oldY = -1;
+var i = 0;
+var inGroup = false;
+var top = -1;
+var bottom = -1;
+var alHeight = this.av.getAlignment ().getHeight () - 1;
+for (i = startSeq; i < endSeq; i++) {
+sx = (group.getStartRes () - startRes) * this.avcharWidth;
+sy = offset + ((i - startSeq) * this.avcharHeight);
+ex = (((group.getEndRes () + 1) - group.getStartRes ()) * this.avcharWidth) - 1;
+if (sx + ex < 0 || sx > this.imgWidth) {
+continue;
+}if ((sx <= (endRes - startRes) * this.avcharWidth) && group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i))) {
+if ((bottom == -1) && (i >= alHeight || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i + 1)))) {
+bottom = sy + this.avcharHeight;
+}if (!inGroup) {
+if (((top == -1) && (i == 0)) || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i - 1))) {
+top = sy;
+}oldY = sy;
+inGroup = true;
+if (group === this.av.getSelectionGroup ()) {
+g.setColor (java.awt.Color.red);
+} else {
+g.setColor (group.getOutlineColour ());
+}}} else {
+if (inGroup) {
+if (sx >= 0 && sx < this.imgWidth) {
+g.drawLine (sx, oldY, sx, sy);
+}if (sx + ex < this.imgWidth) {
+g.drawLine (sx + ex, oldY, sx + ex, sy);
+}if (sx < 0) {
+ex += sx;
+sx = 0;
+}if (sx + ex > this.imgWidth) {
+ex = this.imgWidth;
+} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) {
+ex = (endRes - startRes + 1) * this.avcharWidth;
+}if (top != -1) {
+g.drawLine (sx, top, sx + ex, top);
+top = -1;
+}if (bottom != -1) {
+g.drawLine (sx, bottom, sx + ex, bottom);
+bottom = -1;
+}inGroup = false;
+}}}
+if (inGroup) {
+sy = offset + ((i - startSeq) * this.avcharHeight);
+if (sx >= 0 && sx < this.imgWidth) {
+g.drawLine (sx, oldY, sx, sy);
+}if (sx + ex < this.imgWidth) {
+g.drawLine (sx + ex, oldY, sx + ex, sy);
+}if (sx < 0) {
+ex += sx;
+sx = 0;
+}if (sx + ex > this.imgWidth) {
+ex = this.imgWidth;
+} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) {
+ex = (endRes - startRes + 1) * this.avcharWidth;
+}if (top != -1) {
+g.drawLine (sx, top, sx + ex, top);
+top = -1;
+}if (bottom != -1) {
+g.drawLine (sx, bottom - 1, sx + ex, bottom - 1);
+bottom = -1;
+}inGroup = false;
+}groupIndex++;
+if (groupIndex >= this.av.getAlignment ().getGroups ().size ()) {
+break;
+}group = this.av.getAlignment ().getGroups ().get (groupIndex);
+} while (groupIndex < this.av.getAlignment ().getGroups ().size ());
+}}, "java.awt.Graphics,~N,~N,~N,~N,~N");
+Clazz.defineMethod (c$, "highlightSearchResults", 
+function (results) {
+this.searchResults = results;
+this.repaint ();
+}, "jalview.datamodel.SearchResults");
+});