- double contacts_per_pixel = 1d/pixels_per_contact;
- // number of contacts to render at a time
- int step = (pixels_per_contact<1) ? (int) Math.floor(contacts_per_pixel) : (int) Math.ceil(pixels_per_contact);
-
- int pixels_step = (int) Math.ceil(step*pixels_per_contact);
- int cstart, cend = -1;
- for (int ht = y2, eht = y2 - _aa.graphHeight; ht >= eht; ht -= pixels_step)
+ double contacts_per_pixel = ((double) contact_height)
+ / ((double) _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)