clampIndex method
Computes a valid index for this line by clamping the given index to the valid range of index values
@return a valid index value
Implementation
double clampIndex(double index) {
double posIndex = positiveIndex(index);
double startIndex = getStartIndex();
if (posIndex < startIndex) return startIndex;
double endIndex = getEndIndex();
if (posIndex > endIndex) return endIndex;
return posIndex;
}