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