4 package jalview.renderer;
6 import jalview.api.AlignViewportI;
7 import jalview.datamodel.AlignmentAnnotation;
8 import jalview.datamodel.Annotation;
9 import jalview.datamodel.ColumnSelection;
10 import jalview.datamodel.ContactListI;
11 import jalview.renderer.api.AnnotationRowRendererI;
13 import java.awt.Color;
14 import java.awt.Graphics;
20 public class ContactMapRenderer implements AnnotationRowRendererI
24 public void renderRow(Graphics g, int charWidth, int charHeight,
25 boolean hasHiddenColumns, AlignViewportI viewport,
26 ColumnSelection columnSelection, AlignmentAnnotation _aa,
27 Annotation[] aa_annotations, int sRes, int eRes, float min,
30 if (sRes > aa_annotations.length)
34 eRes = Math.min(eRes, aa_annotations.length);
38 g.setColor(Color.pink);
40 g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
43 int aaMax = aa_annotations.length - 1;
44 while (x < eRes - sRes)
49 column = columnSelection.adjustForHiddenColumns(column);
57 if (aa_annotations[column] == null)
63 * {profile type, #values, total count, char1, pct1, char2, pct2...}
65 ContactListI contacts = viewport.getContactList(_aa, column);
72 // cell height to render
73 double scale = (_aa.graphHeight < contacts.getContactHeight()) ? 1
74 : (((double) _aa.graphHeight) / (double) contacts
76 // distance between contact map per cell
77 int step = (int) ((contacts.getContactHeight()) * scale / _aa.graphHeight);
79 // profl[1] is the number of values in the profile
80 for (int stp = 0, ht = y2, eht = y2 - _aa.graphHeight; ht > eht; ht -= scale, stp++)
83 .getColorForScore((int) (stp * step * ((double) _aa.graphHeight / (double) contacts
84 .getContactHeight()))));
88 g.fillRect(x * charWidth, ht, charWidth, 1 + (int) scale);
92 g.drawLine(x * charWidth, ht, (x + 1) * charWidth, ht);