X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FContactMapRenderer.java;h=7a052da6e6d6e0d07d98de38e15d2905e3280277;hb=b4940c3adf6345861921c7abdf948e0a0c9beb61;hp=bed54e83e7359ef29ead08b92102f1608db301b2;hpb=f0396bb4ab9e52c708accd64eb326b0f1262637e;p=jalview.git diff --git a/src/jalview/renderer/ContactMapRenderer.java b/src/jalview/renderer/ContactMapRenderer.java index bed54e8..7a052da 100644 --- a/src/jalview/renderer/ContactMapRenderer.java +++ b/src/jalview/renderer/ContactMapRenderer.java @@ -48,8 +48,14 @@ public class ContactMapRenderer implements AnnotationRowRendererI column = sRes + x; if (hasHiddenColumns) { - column = hiddenColumns.adjustForHiddenColumns(column); + column = hiddenColumns.visibleToAbsoluteColumn(column); } + // // TODO: highlight columns selected + // boolean colsel = false; + // if (columnSelection != null) + // { + // colsel = columnSelection.contains(column); + // } if (column > aaMax) { @@ -61,32 +67,61 @@ public class ContactMapRenderer implements AnnotationRowRendererI x++; continue; } - /* - * {profile type, #values, total count, char1, pct1, char2, pct2...} - */ + if (_aa.sequenceRef != null) + { + // get the sequence position for the column + column = _aa.sequenceRef.findPosition(column) - 1; + } ContactListI contacts = viewport.getContactList(_aa, column); if (contacts == null) { return; } + int contact_height = contacts.getContactHeight(); + // fractional number of contacts covering each pixel + double contacts_per_pixel = ((double) contact_height) + / ((double) _aa.graphHeight); - // cell height to render - double scale = (_aa.graphHeight < contacts.getContactHeight()) ? 1 - : ((double) _aa.graphHeight) - / (double) contacts.getContactHeight(); - int cstart, cend = -1; - for (int ht = y2, eht = y2 - _aa.graphHeight; ht >= eht; ht -= scale) + int pixels_step; + + if (contacts_per_pixel >= 1) { - cstart = cend + 1; - cend = Math.max(cstart + 1, contacts.getContactHeight() - * ((ht - y2) / _aa.graphHeight)); - // TODO show maximum colour for range - sort of done - // also need a 'getMaxPosForRange(start,end)' - g.setColor(getColorForRange(min, max, contacts, cstart, cend)); + // many contacts rendered per pixel + pixels_step = 1; + } + else + { + // pixel height for each contact + pixels_step = (int) Math + .ceil(((double) _aa.graphHeight) / (double) contact_height); + } - if (scale > 1) + int cstart = 0, cend; + + for (int ht = y2, + eht = y2 - _aa.graphHeight; ht >= eht; ht -= pixels_step) + { + cstart = (int) Math.floor(((double) y2 - ht) * contacts_per_pixel); + cend = (int) Math.min(contact_height, + Math.ceil(cstart + contacts_per_pixel * pixels_step)); + + // TODO show maximum colour for range - sort of done + // also need a 'getMaxPosForRange(start,end)' to accurately render + Color col = getColorForRange(min, max, contacts, cstart, cend); + + // TODO: show selected region + // if (colsel || columnSelection!=null && + // columnSelection.intersects(cstart,cend)) + // { + // g.setColor(col.brighter()); + // } + // else { - g.fillRect(x * charWidth, ht, charWidth, 1 + (int) scale); + g.setColor(col); + } + if (pixels_step > 1) + { + g.fillRect(x * charWidth, ht, charWidth, 1 + pixels_step); } else { @@ -100,7 +135,6 @@ public class ContactMapRenderer implements AnnotationRowRendererI Color minColor = Color.white, maxColor = Color.magenta; - Color shadeFor(float min, float max, float value) { return jalview.util.ColorUtils.getGraduatedColour(value, 0, minColor,