{
return;
}
- int contact_height = contacts.getContactHeight();
- // fractional number of contacts covering each pixel
- double contacts_per_pixel = ((double) contact_height)
- / ((double) _aa.graphHeight);
+ // Bean holding mapping from contact list to pixels
+ final ContactGeometry cgeom = new ContactGeometry(contacts,
+ _aa.graphHeight);
- int pixels_step;
-
- if (contacts_per_pixel >= 1)
- {
- // 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);
- }
-
- int cstart = 0, cend;
-
- for (int ht = y2,
- eht = y2 - _aa.graphHeight; ht >= eht; ht -= pixels_step)
+ for (int ht = y2, eht = y2
+ - _aa.graphHeight; ht >= eht; ht -= cgeom.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));
+ ContactGeometry.contactInterval ci = cgeom.mapFor(y2 - ht,
+ y2 - ht + cgeom.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
{
if (_aa.sequenceRef == null)
{
- rowsel = columnSelection.intersects(cstart, cend);
+ rowsel = columnSelection.intersects(ci.cStart, ci.cEnd);
}
else
{
// TODO check we have correctly mapped cstart to local sequence
// numbering
- int s = _aa.sequenceRef.findIndex(cstart);
- int e = _aa.sequenceRef.findIndex(cend);
+ int s = _aa.sequenceRef.findIndex(ci.cStart);
+ int e = _aa.sequenceRef.findIndex(ci.cEnd);
if (s > 0 && s < _aa.sequenceRef.getLength())
{
rowsel = columnSelection.intersects(s, e);
if (colsel || rowsel)
{
- col = getSelectedColorForRange(min, max, contacts, cstart, cend);
+ col = getSelectedColorForRange(min, max, contacts, ci.cStart,
+ ci.cEnd);
g.setColor(col);
}
else
{
- col = getColorForRange(min, max, contacts, cstart, cend);
+ col = getColorForRange(min, max, contacts, ci.cStart, ci.cEnd);
g.setColor(col);
}
- if (pixels_step > 1)
+ if (cgeom.pixels_step > 1)
{
- g.fillRect(x * charWidth, ht, charWidth, 1 + pixels_step);
+ g.fillRect(x * charWidth, ht, charWidth, 1 + cgeom.pixels_step);
}
else
{