/** * */ package jalview.renderer; import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.ContactListI; import jalview.renderer.api.AnnotationRowRendererI; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; /** * @author jprocter * */ public class ContactMapRenderer implements AnnotationRowRendererI { /* * * // TODO Auto-generated method stub void drawProfileDensity(Graphics g, AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes, int eRes, float min, float max, int y) { * * */ @Override public void renderRow(Graphics g, int charWidth, int charHeight, boolean hasHiddenColumns, AlignViewportI viewport, ColumnSelection columnSelection, AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes, int eRes, float min, float max, int y) { if (sRes > aa_annotations.length) { return; } Font ofont = g.getFont(); eRes = Math.min(eRes, aa_annotations.length); int x = 0, y2 = y; g.setColor(Color.pink); g.drawLine(x, y2, (eRes - sRes) * charWidth, y2); int column; int aaMax = aa_annotations.length - 1; while (x < eRes - sRes) { column = sRes + x; if (hasHiddenColumns) { column = columnSelection.adjustForHiddenColumns(column); } if (column > aaMax) { break; } if (aa_annotations[column] == null) { x++; continue; } /* * {profile type, #values, total count, char1, pct1, char2, pct2...} */ ContactListI contacts = viewport.getContactList(_aa, column); if (contacts == null) { return; } int scale = Math .max(1, _aa.graphHeight / contacts.getContactHeight()); int step = _aa.graphHeight / scale; int valuesProcessed = 0; // profl[1] is the number of values in the profile for (int stp = 0, ht = y2, eht = y2 + _aa.graphHeight; ht < eht; ht += scale, stp++) { valuesProcessed = stp * step; g.setColor(contacts.getColorForScore(stp * step)); if (scale > 1) { g.fillRect(x * charWidth, ht, charWidth, scale); } else { g.drawLine(x * charWidth, ht, (x + 1) * charWidth, ht); } } } x++; } }