1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel"], "jalview.appletgui.IdCanvas", ["jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.PaintRefresher", "java.awt.Color", "$.Font"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.showScores = true;
11 this.$fastPaint = false;
12 this.searchResults = null;
13 this.avcharHeight = 0;
14 Clazz.instantialize (this, arguments);
15 }, jalview.appletgui, "IdCanvas", awt2swing.Panel);
16 Clazz.makeConstructor (c$,
18 Clazz.superConstructor (this, jalview.appletgui.IdCanvas, []);
19 this.setLayout (null);
21 jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ());
22 }, "jalview.appletgui.AlignViewport");
23 Clazz.defineMethod (c$, "drawIdString",
24 function (gg, hiddenRows, s, i, starty, ypos) {
25 var charHeight = this.av.getCharHeight ();
26 if (this.searchResults != null && this.searchResults.contains (s)) {
27 gg.setColor (java.awt.Color.black);
28 gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight);
29 gg.setColor (java.awt.Color.white);
30 } else if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSequences (null).contains (s)) {
31 gg.setColor (java.awt.Color.lightGray);
32 gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight);
33 gg.setColor (java.awt.Color.white);
35 gg.setColor (this.av.getSequenceColour (s));
36 gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight);
37 gg.setColor (java.awt.Color.black);
38 }gg.drawString (s.getDisplayId (this.av.getShowJVSuffix ()), 0, ((i - starty) * charHeight) + ypos + charHeight - (Clazz.doubleToInt (charHeight / 5)));
40 this.drawMarker (i, starty, ypos);
41 }}, "java.awt.Graphics,~B,jalview.datamodel.SequenceI,~N,~N,~N");
42 Clazz.defineMethod (c$, "fastPaint",
44 if (this.gg == null) {
47 }this.gg.copyArea (0, 0, this.getSize ().width, this.imgHeight, 0, -vertical * this.av.getCharHeight ());
48 var ss = this.av.startSeq;
49 var es = this.av.endSeq;
53 if (ss < this.av.startSeq) {
54 ss = this.av.startSeq;
56 transY = this.imgHeight - vertical * this.av.getCharHeight ();
57 }} else if (vertical < 0) {
59 if (es > this.av.endSeq) {
61 }}this.gg.translate (0, transY);
62 this.drawIds (ss, es);
63 this.gg.translate (0, -transY);
64 this.$fastPaint = true;
67 Clazz.overrideMethod (c$, "paintComponent",
69 if (this.getSize ().height < 0 || this.getSize ().width < 0) {
71 }if (this.$fastPaint) {
72 this.$fastPaint = false;
73 g.drawImage (this.image, 0, 0, this);
75 }this.imgHeight = this.getSize ().height;
76 this.imgHeight -= this.imgHeight % this.av.getCharHeight ();
77 if (this.imgHeight < 1) {
79 }if (this.image == null || this.imgHeight != this.image.getHeight (this)) {
80 this.image = this.createImage (this.getSize ().width, this.imgHeight);
81 this.gg = this.image.getGraphics ();
82 this.gg.setFont (this.av.getFont ());
83 }this.gg.setColor (java.awt.Color.white);
84 var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ());
85 this.gg.setFont (italic);
86 this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height);
87 this.drawIds (this.av.startSeq, this.av.endSeq);
88 g.drawImage (this.image, 0, 0, this);
89 }, "java.awt.Graphics");
90 Clazz.defineMethod (c$, "drawIds",
91 function (starty, endy) {
92 var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ());
93 this.avcharHeight = this.av.getCharHeight ();
94 this.gg.setFont (italic);
95 var currentColor = java.awt.Color.white;
96 var currentTextColor = java.awt.Color.black;
97 var doHiddenCheck = this.av.isDisplayReferenceSeq () || this.av.hasHiddenRows ();
98 var hiddenRows = this.av.hasHiddenRows () && this.av.getShowHiddenMarkers ();
99 if (this.av.getWrapAlignment ()) {
100 var maxwidth = this.av.getAlignment ().getWidth ();
101 var alheight = this.av.getAlignment ().getHeight ();
102 if (this.av.hasHiddenColumns ()) {
103 maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1;
104 }var annotationHeight = 0;
106 if (this.av.isShowAnnotation ()) {
107 var ap = new jalview.appletgui.AnnotationPanel (this.av);
108 annotationHeight = ap.adjustPanelHeight ();
109 labels = new jalview.appletgui.AnnotationLabels (this.av);
110 }var hgap = this.avcharHeight;
111 if (this.av.getScaleAboveWrapped ()) {
112 hgap += this.avcharHeight;
113 }var cHeight = alheight * this.avcharHeight + hgap + annotationHeight;
114 var rowSize = this.av.getEndRes () - this.av.getStartRes ();
115 for (var ypos = hgap, row = this.av.startRes; (ypos <= this.getSize ().height) && (row < maxwidth); ypos += cHeight, row += rowSize) {
116 for (var i = starty; i < alheight; i++) {
117 var s = this.av.getAlignment ().getSequenceAt (i);
118 this.gg.setFont (italic);
120 this.setHiddenFont (s);
121 }this.drawIdString (this.gg, hiddenRows, s, i, 0, ypos);
123 if (labels != null) {
124 this.gg.translate (0, ypos + (alheight * this.avcharHeight));
125 labels.drawComponent (this.gg, this.getSize ().width);
126 this.gg.translate (0, -ypos - (alheight * this.avcharHeight));
130 for (var i = starty; i < endy; i++) {
131 seq = this.av.getAlignment ().getSequenceAt (i);
134 }this.gg.setFont (italic);
136 this.setHiddenFont (seq);
137 }if ((this.searchResults != null) && this.searchResults.contains (seq)) {
138 currentColor = java.awt.Color.black;
139 currentTextColor = java.awt.Color.white;
140 } else if ((this.av.getSelectionGroup () != null) && this.av.getSelectionGroup ().getSequences (null).contains (seq)) {
141 currentColor = java.awt.Color.lightGray;
142 currentTextColor = java.awt.Color.black;
144 currentColor = this.av.getSequenceColour (seq);
145 currentTextColor = java.awt.Color.black;
146 }this.gg.setColor (currentColor);
147 this.gg.fillRect (0, (i - starty) * this.avcharHeight, this.getSize ().width, this.avcharHeight);
148 this.gg.setColor (currentTextColor);
149 this.gg.drawString (seq.getDisplayId (this.av.getShowJVSuffix ()), 0, (((i - starty) * this.avcharHeight) + this.avcharHeight) - (Clazz.doubleToInt (this.avcharHeight / 5)));
151 this.drawMarker (i, starty, 0);
154 Clazz.defineMethod (c$, "setHighlighted",
156 this.searchResults = list;
158 }, "java.util.List");
159 Clazz.defineMethod (c$, "drawMarker",
160 function (i, starty, yoffset) {
161 var hseqs = this.av.getAlignment ().getHiddenSequences ().hiddenSequences;
162 var hSize = hseqs.length;
164 var lastIndex = i - 1;
165 var nextIndex = i + 1;
166 for (var j = 0; j < hSize; j++) {
167 if (hseqs[j] != null) {
168 if (j - 1 < hiddenIndex) {
170 }if (j - 1 < lastIndex) {
172 }if (j - 1 < nextIndex) {
175 var below = (hiddenIndex > lastIndex + 1);
176 var above = (nextIndex > hiddenIndex + 1);
177 this.gg.setColor (java.awt.Color.blue);
179 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);
181 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);
183 Clazz.defineMethod (c$, "setHiddenFont",
185 var bold = new java.awt.Font (this.av.getFont ().getName (), 1, this.av.getFont ().getSize ());
186 if (this.av.isHiddenRepSequence (seq)) {
187 this.gg.setFont (bold);
190 }, "jalview.datamodel.SequenceI");