1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["jalview.api.SequenceRenderer"], "jalview.appletgui.SequenceRenderer", ["jalview.util.Comparison", "java.awt.Color", "$.Font"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 this.renderGaps = true;
7 this.currentSequenceGroup = null;
9 this.resBoxColour = null;
11 this.forOverview = false;
12 Clazz.instantialize (this, arguments);
13 }, jalview.appletgui, "SequenceRenderer", null, jalview.api.SequenceRenderer);
14 Clazz.makeConstructor (c$,
17 }, "jalview.appletgui.AlignViewport");
18 Clazz.defineMethod (c$, "prepare",
19 function (g, renderGaps) {
21 this.fm = g.getFontMetrics ();
22 this.renderGaps = renderGaps;
23 }, "java.awt.Graphics,~B");
24 Clazz.overrideMethod (c$, "getResidueBoxColour",
26 this.allGroups = this.av.getAlignment ().findAllGroups (seq);
27 if (this.inCurrentSequenceGroup (i)) {
28 if (this.currentSequenceGroup.getDisplayBoxes ()) {
29 this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
30 }} else if (this.av.getShowBoxes ()) {
31 this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
32 }return this.resBoxColour;
33 }, "jalview.datamodel.SequenceI,~N");
34 Clazz.overrideMethod (c$, "getResidueColour",
35 function (seq, position, fr) {
36 var col = this.getResidueBoxColour (seq, position);
38 col = fr.findFeatureColour (col, seq, position);
40 }, "jalview.datamodel.SequenceI,~N,jalview.api.FeatureRenderer");
41 Clazz.defineMethod (c$, "getBoxColour",
42 function (cs, seq, i) {
44 this.resBoxColour = cs.findColour (seq.getCharAt (i), i, seq);
45 } else if (this.forOverview && !jalview.util.Comparison.isGap (seq.getCharAt (i))) {
46 this.resBoxColour = java.awt.Color.lightGray;
48 this.resBoxColour = java.awt.Color.white;
49 }}, "jalview.schemes.ColourSchemeI,jalview.datamodel.SequenceI,~N");
50 Clazz.defineMethod (c$, "findSequenceColour",
52 this.allGroups = this.av.getAlignment ().findAllGroups (seq);
53 this.drawBoxes (seq, i, i, 0);
54 return this.resBoxColour;
55 }, "jalview.datamodel.SequenceI,~N");
56 Clazz.defineMethod (c$, "drawSequence",
57 function (seq, sg, start, end, y1) {
61 this.drawBoxes (seq, start, end, y1);
62 if (this.av.validCharWidth) {
63 this.drawText (seq, start, end, y1);
64 }}, "jalview.datamodel.SequenceI,~A,~N,~N,~N");
65 Clazz.defineMethod (c$, "drawBoxes",
66 function (seq, start, end, y1) {
68 var length = seq.getLength ();
70 var curWidth = this.av.getCharWidth ();
71 var avCharWidth = this.av.getCharWidth ();
72 var avCharHeight = this.av.getCharHeight ();
73 var tempColour = null;
75 this.resBoxColour = java.awt.Color.white;
77 if (this.inCurrentSequenceGroup (i)) {
78 if (this.currentSequenceGroup.getDisplayBoxes ()) {
79 this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
80 }} else if (this.av.getShowBoxes ()) {
81 this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
82 }}if (this.resBoxColour !== tempColour) {
83 if (tempColour != null) {
84 this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);
85 }this.graphics.setColor (this.resBoxColour);
87 curWidth = avCharWidth;
88 tempColour = this.resBoxColour;
90 curWidth += avCharWidth;
93 this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);
94 }, "jalview.datamodel.SequenceI,~N,~N,~N");
95 Clazz.defineMethod (c$, "drawText",
96 function (seq, start, end, y1) {
97 var avCharWidth = this.av.getCharWidth ();
98 var avCharHeight = this.av.getCharHeight ();
101 if (this.av.isUpperCasebold ()) {
102 boldFont = new java.awt.Font (this.av.getFont ().getName (), 1, avCharHeight);
103 this.graphics.setFont (this.av.getFont ());
104 }y1 += avCharHeight - Clazz.doubleToInt (avCharHeight / 5);
106 if (end + 1 >= seq.getLength ()) {
107 end = seq.getLength () - 1;
109 var srep = this.av.isDisplayReferenceSeq ();
110 for (var i = start; i <= end; i++) {
111 this.graphics.setColor (java.awt.Color.black);
112 s = seq.getCharAt (i);
113 if (!this.renderGaps && jalview.util.Comparison.isGap (s)) {
115 }if (this.inCurrentSequenceGroup (i)) {
116 if (!this.currentSequenceGroup.getDisplayText ()) {
118 }if (this.currentSequenceGroup.getColourText ()) {
119 this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
120 this.graphics.setColor (this.resBoxColour.darker ());
121 }if (this.currentSequenceGroup.getShowNonconserved ()) {
122 s = this.getDisplayChar (srep, i, s, '.');
124 if (!this.av.getShowText ()) {
126 }if (this.av.getColourText ()) {
127 this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
128 if (this.av.getShowBoxes ()) {
129 this.graphics.setColor (this.resBoxColour.darker ());
131 this.graphics.setColor (this.resBoxColour);
132 }}if (this.av.getShowUnconserved ()) {
133 s = this.getDisplayChar (srep, i, s, '.');
134 }}if (this.av.isUpperCasebold ()) {
135 this.fm = this.graphics.getFontMetrics ();
136 if ('A' <= s && s <= 'Z') {
138 this.graphics.setFont (boldFont);
141 this.graphics.setFont (this.av.font);
143 }}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);
144 this.graphics.drawString (String.valueOf (s), charOffset + avCharWidth * (i - start), y1);
146 }, "jalview.datamodel.SequenceI,~N,~N,~N");
147 Clazz.defineMethod (c$, "getDisplayChar",
148 ($fz = function (usesrep, position, s, c) {
149 var conschar = (usesrep) ? this.av.getAlignment ().getSeqrep ().getCharAt (position) : this.av.getAlignmentConsensusAnnotation ().annotations[position].displayCharacter.charAt (0);
150 if (conschar != '-' && s == conschar) {
153 }, $fz.isPrivate = true, $fz), "~B,~N,~S,~S");
154 Clazz.defineMethod (c$, "inCurrentSequenceGroup",
156 if (this.allGroups == null) {
158 }for (var i = 0; i < this.allGroups.length; i++) {
159 if (this.allGroups[i].getStartRes () <= res && this.allGroups[i].getEndRes () >= res) {
160 this.currentSequenceGroup = this.allGroups[i];
165 Clazz.defineMethod (c$, "drawHighlightedText",
166 function (seq, start, end, x1, y1) {
167 var avCharWidth = this.av.getCharWidth ();
168 var avCharHeight = this.av.getCharHeight ();
169 var pady = Clazz.doubleToInt (avCharHeight / 5);
171 this.graphics.setColor (java.awt.Color.black);
172 this.graphics.fillRect (x1, y1, avCharWidth * (end - start + 1), avCharHeight);
173 this.graphics.setColor (java.awt.Color.white);
175 if (this.av.validCharWidth) {
176 for (var i = start; i <= end; i++) {
177 if (i < seq.getLength ()) {
178 s = seq.getCharAt (i);
179 }charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);
180 this.graphics.drawString (String.valueOf (s), charOffset + x1 + avCharWidth * (i - start), y1 + avCharHeight - pady);
182 }}, "jalview.datamodel.SequenceI,~N,~N,~N,~N");
183 Clazz.defineMethod (c$, "drawCursor",
184 function (seq, res, x1, y1) {
185 var pady = Clazz.doubleToInt (this.av.getCharHeight () / 5);
187 this.graphics.setColor (java.awt.Color.black);
188 this.graphics.fillRect (x1, y1, this.av.getCharWidth (), this.av.getCharHeight ());
189 this.graphics.setColor (java.awt.Color.white);
190 this.graphics.setColor (java.awt.Color.white);
191 var s = seq.getCharAt (res);
192 if (this.av.validCharWidth) {
193 charOffset = Clazz.doubleToInt ((this.av.getCharWidth () - this.fm.charWidth (s)) / 2);
194 this.graphics.drawString (String.valueOf (s), charOffset + x1, (y1 + this.av.getCharHeight ()) - pady);
195 }}, "jalview.datamodel.SequenceI,~N,~N,~N");