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 int cstart, cend = -1;
77 for (int ht = y2, eht = y2 - _aa.graphHeight; ht >= eht; ht -= scale)
81 + (contacts.getContactHeight() * (ht - eht) / _aa.graphHeight);
82 // TODO show maximum colour for range - sort of done
83 // also need a 'getMaxPosForRange(start,end)'
84 g.setColor(contacts.getColorForRange(cstart, cend));
88 g.fillRect(x * charWidth, ht, charWidth, 1 + (int) scale);
92 g.drawLine(x * charWidth, ht, (x + 1) * charWidth, ht);