getRelativeIndexFromScreenX method
This polyline displays a range from a data array.
x
must be given in pixels relative to dataArea's origin.
Then this function returns a relative index with respect to
cpd.uIndices0
ranging from
cpd.uIndices0
to cpd.uIndicescpd.uIndices.length-1
Implementation
double getRelativeIndexFromScreenX(int x) {
int xFirst; // first index in the display region of the uncompressed array
int xLast; // last index in the display region of the uncompressed array
int npointsInDisplayRegion;
double relX;
if (cpd.uIndices.isEmpty) // catch cases with corrupt data
return 0.0;
xFirst = cpd.uIndices[
0]; // first index in the display region of the uncompressed array
xLast = cpd.uIndices[cpd.uIndices.length -
1]; // last index in the display region of the uncompressed array
npointsInDisplayRegion = xLast - xFirst + 1;
relX = (x - insetx - xshift) *
(npointsInDisplayRegion - 1) /
effectivePolylineWidth;
if (relX < 0) relX = 0.0;
if (relX > npointsInDisplayRegion - 1) relX = npointsInDisplayRegion - 1.0;
return relX; // orig
}