-
- /*
- * Distorts an item's coordinate.
- * @param x the undistorted coordinate
- * @param coordinate of the anchor or focus point
- * @param d disortion factor
- * @param min the beginning of the display
- * @param max the end of the display
- * @return the distorted coordinate
- */
- private int fisheye(int idx)
- {
- // Autocompute distortion factor
- // 20 is the pixel size of the item at centre of focus
- double d = label_cache.length * 20 / allocation.height;
- if ( d <= 1 )
- return idx * allocation.height / label_cache.length;
-
- double a = (double)cur_el * allocation.height / label_cache.length;
- double x = (double)idx * allocation.height / label_cache.length;
- double max = (double)allocation.height;
-
- if (idx < cur_el)
- {
- double m = a;
- if ( m == 0 ) m = max;
- double v = (double)(a - x) / m;
- v = (double)(d+1)/(d+(1/v));
- return (int)Math.round(a - m*v);
- } else {
- double m = max-a;
- if ( m == 0 ) m = max;
- double v = (double)(x - a) / m;
- v = (double)(d+1)/(d+(1/v));
- return (int)Math.round(a + m*v);
- }
- }