X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fappletgui%2FSeqCanvas.js;h=faa6bae8c6ebfd1cb875595397f3ce031445a027;hp=54fb6eedeaf48b04ba4b8a347ea49770834dee2c;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/appletgui/SeqCanvas.js b/site/j2s/jalview/appletgui/SeqCanvas.js index 54fb6ee..faa6bae 100644 --- a/site/j2s/jalview/appletgui/SeqCanvas.js +++ b/site/j2s/jalview/appletgui/SeqCanvas.js @@ -1,411 +1,411 @@ -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"); -}); +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"); +});