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;
15 import java.awt.Graphics;
21 public class ContactMapRenderer implements AnnotationRowRendererI
25 * // TODO Auto-generated method stub
26 void drawProfileDensity(Graphics g, AlignmentAnnotation _aa,
27 Annotation[] aa_annotations, int sRes, int eRes, float min,
35 public void renderRow(Graphics g, int charWidth, int charHeight,
36 boolean hasHiddenColumns, AlignViewportI viewport,
37 ColumnSelection columnSelection, AlignmentAnnotation _aa,
38 Annotation[] aa_annotations, int sRes, int eRes, float min,
41 if (sRes > aa_annotations.length)
45 Font ofont = g.getFont();
46 eRes = Math.min(eRes, aa_annotations.length);
50 g.setColor(Color.pink);
52 g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
55 int aaMax = aa_annotations.length - 1;
56 while (x < eRes - sRes)
61 column = columnSelection.adjustForHiddenColumns(column);
69 if (aa_annotations[column] == null)
75 * {profile type, #values, total count, char1, pct1, char2, pct2...}
77 ContactListI contacts = viewport.getContactList(_aa, column);
85 // cell height to render
86 double scale = (_aa.graphHeight < contacts.getContactHeight()) ? 1
87 : (((double) _aa.graphHeight) / (double) contacts
89 // distance between contact map per cell
90 int step = (int) ((contacts.getContactHeight()) * scale / _aa.graphHeight);
92 // profl[1] is the number of values in the profile
93 for (int stp = 0, ht = y2, eht = y2 - _aa.graphHeight; ht > eht; ht -= scale, stp++)
96 .getColorForScore((int) (stp * step * ((double) _aa.graphHeight / (double) contacts
97 .getContactHeight()))));
101 g.fillRect(x * charWidth, ht, charWidth, 1 + (int) scale);
103 g.drawLine(x * charWidth, ht, (x + 1) * charWidth, ht);