/** * Tests whether an index is in the valid index range for the line. * * @param index the index to test * @return <code>true</code> if the index is in the valid range */ public boolean isValidIndex(double index) { return (index >= getStartIndex() && index <= getEndIndex()); }
/** * Computes a valid index for this line * by clamping the given index to the valid range of index values * * @return a valid index value */ public 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; }