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