X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fappletgui%2FIdCanvas.js;h=673b00eb312218f118fd80416a0a255ca2acdb8e;hp=7c5a1c2b7ccc1b9dac0e68f17de9bd132659366d;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/appletgui/IdCanvas.js b/site/j2s/jalview/appletgui/IdCanvas.js index 7c5a1c2..673b00e 100644 --- a/site/j2s/jalview/appletgui/IdCanvas.js +++ b/site/j2s/jalview/appletgui/IdCanvas.js @@ -1,191 +1,191 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel"], "jalview.appletgui.IdCanvas", ["jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.PaintRefresher", "java.awt.Color", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.showScores = true; -this.maxIdLength = -1; -this.maxIdStr = null; -this.image = null; -this.gg = null; -this.imgHeight = 0; -this.$fastPaint = false; -this.searchResults = null; -this.avcharHeight = 0; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "IdCanvas", awt2swing.Panel); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.IdCanvas, []); -this.setLayout (null); -this.av = av; -jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); -}, "jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "drawIdString", -function (gg, hiddenRows, s, i, starty, ypos) { -var charHeight = this.av.getCharHeight (); -if (this.searchResults != null && this.searchResults.contains (s)) { -gg.setColor (java.awt.Color.black); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.white); -} else if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSequences (null).contains (s)) { -gg.setColor (java.awt.Color.lightGray); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.white); -} else { -gg.setColor (this.av.getSequenceColour (s)); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.black); -}gg.drawString (s.getDisplayId (this.av.getShowJVSuffix ()), 0, ((i - starty) * charHeight) + ypos + charHeight - (Clazz.doubleToInt (charHeight / 5))); -if (hiddenRows) { -this.drawMarker (i, starty, ypos); -}}, "java.awt.Graphics,~B,jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "fastPaint", -function (vertical) { -if (this.gg == null) { -this.repaint (); -return; -}this.gg.copyArea (0, 0, this.getSize ().width, this.imgHeight, 0, -vertical * this.av.getCharHeight ()); -var ss = this.av.startSeq; -var es = this.av.endSeq; -var transY = 0; -if (vertical > 0) { -ss = es - vertical; -if (ss < this.av.startSeq) { -ss = this.av.startSeq; -} else { -transY = this.imgHeight - vertical * this.av.getCharHeight (); -}} else if (vertical < 0) { -es = ss - vertical; -if (es > this.av.endSeq) { -es = this.av.endSeq; -}}this.gg.translate (0, transY); -this.drawIds (ss, es); -this.gg.translate (0, -transY); -this.$fastPaint = true; -this.repaint (); -}, "~N"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.getSize ().height < 0 || this.getSize ().width < 0) { -return; -}if (this.$fastPaint) { -this.$fastPaint = false; -g.drawImage (this.image, 0, 0, this); -return; -}this.imgHeight = this.getSize ().height; -this.imgHeight -= this.imgHeight % this.av.getCharHeight (); -if (this.imgHeight < 1) { -return; -}if (this.image == null || this.imgHeight != this.image.getHeight (this)) { -this.image = this.createImage (this.getSize ().width, this.imgHeight); -this.gg = this.image.getGraphics (); -this.gg.setFont (this.av.getFont ()); -}this.gg.setColor (java.awt.Color.white); -var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); -this.gg.setFont (italic); -this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -this.drawIds (this.av.startSeq, this.av.endSeq); -g.drawImage (this.image, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawIds", -function (starty, endy) { -var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); -this.avcharHeight = this.av.getCharHeight (); -this.gg.setFont (italic); -var currentColor = java.awt.Color.white; -var currentTextColor = java.awt.Color.black; -var doHiddenCheck = this.av.isDisplayReferenceSeq () || this.av.hasHiddenRows (); -var hiddenRows = this.av.hasHiddenRows () && this.av.getShowHiddenMarkers (); -if (this.av.getWrapAlignment ()) { -var maxwidth = this.av.getAlignment ().getWidth (); -var alheight = this.av.getAlignment ().getHeight (); -if (this.av.hasHiddenColumns ()) { -maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; -}var annotationHeight = 0; -var labels = null; -if (this.av.isShowAnnotation ()) { -var ap = new jalview.appletgui.AnnotationPanel (this.av); -annotationHeight = ap.adjustPanelHeight (); -labels = new jalview.appletgui.AnnotationLabels (this.av); -}var hgap = this.avcharHeight; -if (this.av.getScaleAboveWrapped ()) { -hgap += this.avcharHeight; -}var cHeight = alheight * this.avcharHeight + hgap + annotationHeight; -var rowSize = this.av.getEndRes () - this.av.getStartRes (); -for (var ypos = hgap, row = this.av.startRes; (ypos <= this.getSize ().height) && (row < maxwidth); ypos += cHeight, row += rowSize) { -for (var i = starty; i < alheight; i++) { -var s = this.av.getAlignment ().getSequenceAt (i); -this.gg.setFont (italic); -if (doHiddenCheck) { -this.setHiddenFont (s); -}this.drawIdString (this.gg, hiddenRows, s, i, 0, ypos); -} -if (labels != null) { -this.gg.translate (0, ypos + (alheight * this.avcharHeight)); -labels.drawComponent (this.gg, this.getSize ().width); -this.gg.translate (0, -ypos - (alheight * this.avcharHeight)); -}} -} else { -var seq; -for (var i = starty; i < endy; i++) { -seq = this.av.getAlignment ().getSequenceAt (i); -if (seq == null) { -continue; -}this.gg.setFont (italic); -if (doHiddenCheck) { -this.setHiddenFont (seq); -}if ((this.searchResults != null) && this.searchResults.contains (seq)) { -currentColor = java.awt.Color.black; -currentTextColor = java.awt.Color.white; -} else if ((this.av.getSelectionGroup () != null) && this.av.getSelectionGroup ().getSequences (null).contains (seq)) { -currentColor = java.awt.Color.lightGray; -currentTextColor = java.awt.Color.black; -} else { -currentColor = this.av.getSequenceColour (seq); -currentTextColor = java.awt.Color.black; -}this.gg.setColor (currentColor); -this.gg.fillRect (0, (i - starty) * this.avcharHeight, this.getSize ().width, this.avcharHeight); -this.gg.setColor (currentTextColor); -this.gg.drawString (seq.getDisplayId (this.av.getShowJVSuffix ()), 0, (((i - starty) * this.avcharHeight) + this.avcharHeight) - (Clazz.doubleToInt (this.avcharHeight / 5))); -if (hiddenRows) { -this.drawMarker (i, starty, 0); -}} -}}, "~N,~N"); -Clazz.defineMethod (c$, "setHighlighted", -function (list) { -this.searchResults = list; -this.repaint (); -}, "java.util.List"); -Clazz.defineMethod (c$, "drawMarker", -function (i, starty, yoffset) { -var hseqs = this.av.getAlignment ().getHiddenSequences ().hiddenSequences; -var hSize = hseqs.length; -var hiddenIndex = i; -var lastIndex = i - 1; -var nextIndex = i + 1; -for (var j = 0; j < hSize; j++) { -if (hseqs[j] != null) { -if (j - 1 < hiddenIndex) { -hiddenIndex++; -}if (j - 1 < lastIndex) { -lastIndex++; -}if (j - 1 < nextIndex) { -nextIndex++; -}}} -var below = (hiddenIndex > lastIndex + 1); -var above = (nextIndex > hiddenIndex + 1); -this.gg.setColor (java.awt.Color.blue); -if (below) { -this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty) * this.avcharHeight + yoffset, (i - starty) * this.avcharHeight + yoffset + Clazz.doubleToInt (this.avcharHeight / 4), (i - starty) * this.avcharHeight + yoffset]), 3); -}if (above) { -this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty + 1) * this.avcharHeight + yoffset, (i - starty + 1) * this.avcharHeight + yoffset - Clazz.doubleToInt (this.avcharHeight / 4), (i - starty + 1) * this.avcharHeight + yoffset]), 3); -}}, "~N,~N,~N"); -Clazz.defineMethod (c$, "setHiddenFont", -function (seq) { -var bold = new java.awt.Font (this.av.getFont ().getName (), 1, this.av.getFont ().getSize ()); -if (this.av.isHiddenRepSequence (seq)) { -this.gg.setFont (bold); -return true; -}return false; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel"], "jalview.appletgui.IdCanvas", ["jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.PaintRefresher", "java.awt.Color", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.showScores = true; +this.maxIdLength = -1; +this.maxIdStr = null; +this.image = null; +this.gg = null; +this.imgHeight = 0; +this.$fastPaint = false; +this.searchResults = null; +this.avcharHeight = 0; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "IdCanvas", awt2swing.Panel); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.IdCanvas, []); +this.setLayout (null); +this.av = av; +jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); +}, "jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "drawIdString", +function (gg, hiddenRows, s, i, starty, ypos) { +var charHeight = this.av.getCharHeight (); +if (this.searchResults != null && this.searchResults.contains (s)) { +gg.setColor (java.awt.Color.black); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.white); +} else if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSequences (null).contains (s)) { +gg.setColor (java.awt.Color.lightGray); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.white); +} else { +gg.setColor (this.av.getSequenceColour (s)); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.black); +}gg.drawString (s.getDisplayId (this.av.getShowJVSuffix ()), 0, ((i - starty) * charHeight) + ypos + charHeight - (Clazz.doubleToInt (charHeight / 5))); +if (hiddenRows) { +this.drawMarker (i, starty, ypos); +}}, "java.awt.Graphics,~B,jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "fastPaint", +function (vertical) { +if (this.gg == null) { +this.repaint (); +return; +}this.gg.copyArea (0, 0, this.getSize ().width, this.imgHeight, 0, -vertical * this.av.getCharHeight ()); +var ss = this.av.startSeq; +var es = this.av.endSeq; +var transY = 0; +if (vertical > 0) { +ss = es - vertical; +if (ss < this.av.startSeq) { +ss = this.av.startSeq; +} else { +transY = this.imgHeight - vertical * this.av.getCharHeight (); +}} else if (vertical < 0) { +es = ss - vertical; +if (es > this.av.endSeq) { +es = this.av.endSeq; +}}this.gg.translate (0, transY); +this.drawIds (ss, es); +this.gg.translate (0, -transY); +this.$fastPaint = true; +this.repaint (); +}, "~N"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.getSize ().height < 0 || this.getSize ().width < 0) { +return; +}if (this.$fastPaint) { +this.$fastPaint = false; +g.drawImage (this.image, 0, 0, this); +return; +}this.imgHeight = this.getSize ().height; +this.imgHeight -= this.imgHeight % this.av.getCharHeight (); +if (this.imgHeight < 1) { +return; +}if (this.image == null || this.imgHeight != this.image.getHeight (this)) { +this.image = this.createImage (this.getSize ().width, this.imgHeight); +this.gg = this.image.getGraphics (); +this.gg.setFont (this.av.getFont ()); +}this.gg.setColor (java.awt.Color.white); +var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); +this.gg.setFont (italic); +this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +this.drawIds (this.av.startSeq, this.av.endSeq); +g.drawImage (this.image, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawIds", +function (starty, endy) { +var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); +this.avcharHeight = this.av.getCharHeight (); +this.gg.setFont (italic); +var currentColor = java.awt.Color.white; +var currentTextColor = java.awt.Color.black; +var doHiddenCheck = this.av.isDisplayReferenceSeq () || this.av.hasHiddenRows (); +var hiddenRows = this.av.hasHiddenRows () && this.av.getShowHiddenMarkers (); +if (this.av.getWrapAlignment ()) { +var maxwidth = this.av.getAlignment ().getWidth (); +var alheight = this.av.getAlignment ().getHeight (); +if (this.av.hasHiddenColumns ()) { +maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; +}var annotationHeight = 0; +var labels = null; +if (this.av.isShowAnnotation ()) { +var ap = new jalview.appletgui.AnnotationPanel (this.av); +annotationHeight = ap.adjustPanelHeight (); +labels = new jalview.appletgui.AnnotationLabels (this.av); +}var hgap = this.avcharHeight; +if (this.av.getScaleAboveWrapped ()) { +hgap += this.avcharHeight; +}var cHeight = alheight * this.avcharHeight + hgap + annotationHeight; +var rowSize = this.av.getEndRes () - this.av.getStartRes (); +for (var ypos = hgap, row = this.av.startRes; (ypos <= this.getSize ().height) && (row < maxwidth); ypos += cHeight, row += rowSize) { +for (var i = starty; i < alheight; i++) { +var s = this.av.getAlignment ().getSequenceAt (i); +this.gg.setFont (italic); +if (doHiddenCheck) { +this.setHiddenFont (s); +}this.drawIdString (this.gg, hiddenRows, s, i, 0, ypos); +} +if (labels != null) { +this.gg.translate (0, ypos + (alheight * this.avcharHeight)); +labels.drawComponent (this.gg, this.getSize ().width); +this.gg.translate (0, -ypos - (alheight * this.avcharHeight)); +}} +} else { +var seq; +for (var i = starty; i < endy; i++) { +seq = this.av.getAlignment ().getSequenceAt (i); +if (seq == null) { +continue; +}this.gg.setFont (italic); +if (doHiddenCheck) { +this.setHiddenFont (seq); +}if ((this.searchResults != null) && this.searchResults.contains (seq)) { +currentColor = java.awt.Color.black; +currentTextColor = java.awt.Color.white; +} else if ((this.av.getSelectionGroup () != null) && this.av.getSelectionGroup ().getSequences (null).contains (seq)) { +currentColor = java.awt.Color.lightGray; +currentTextColor = java.awt.Color.black; +} else { +currentColor = this.av.getSequenceColour (seq); +currentTextColor = java.awt.Color.black; +}this.gg.setColor (currentColor); +this.gg.fillRect (0, (i - starty) * this.avcharHeight, this.getSize ().width, this.avcharHeight); +this.gg.setColor (currentTextColor); +this.gg.drawString (seq.getDisplayId (this.av.getShowJVSuffix ()), 0, (((i - starty) * this.avcharHeight) + this.avcharHeight) - (Clazz.doubleToInt (this.avcharHeight / 5))); +if (hiddenRows) { +this.drawMarker (i, starty, 0); +}} +}}, "~N,~N"); +Clazz.defineMethod (c$, "setHighlighted", +function (list) { +this.searchResults = list; +this.repaint (); +}, "java.util.List"); +Clazz.defineMethod (c$, "drawMarker", +function (i, starty, yoffset) { +var hseqs = this.av.getAlignment ().getHiddenSequences ().hiddenSequences; +var hSize = hseqs.length; +var hiddenIndex = i; +var lastIndex = i - 1; +var nextIndex = i + 1; +for (var j = 0; j < hSize; j++) { +if (hseqs[j] != null) { +if (j - 1 < hiddenIndex) { +hiddenIndex++; +}if (j - 1 < lastIndex) { +lastIndex++; +}if (j - 1 < nextIndex) { +nextIndex++; +}}} +var below = (hiddenIndex > lastIndex + 1); +var above = (nextIndex > hiddenIndex + 1); +this.gg.setColor (java.awt.Color.blue); +if (below) { +this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty) * this.avcharHeight + yoffset, (i - starty) * this.avcharHeight + yoffset + Clazz.doubleToInt (this.avcharHeight / 4), (i - starty) * this.avcharHeight + yoffset]), 3); +}if (above) { +this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty + 1) * this.avcharHeight + yoffset, (i - starty + 1) * this.avcharHeight + yoffset - Clazz.doubleToInt (this.avcharHeight / 4), (i - starty + 1) * this.avcharHeight + yoffset]), 3); +}}, "~N,~N,~N"); +Clazz.defineMethod (c$, "setHiddenFont", +function (seq) { +var bold = new java.awt.Font (this.av.getFont ().getName (), 1, this.av.getFont ().getSize ()); +if (this.av.isHiddenRepSequence (seq)) { +this.gg.setFont (bold); +return true; +}return false; +}, "jalview.datamodel.SequenceI"); +});