- private int[] getIntervals(Vector fromShifts2, int[] fromStart, int[] fromEnd, int fromRatio2)
- {
- // correct for word direction for start and end
- int startpos = fromStart[0]+fromStart[2]*(fromRatio2-1);
- int endpos = fromEnd[0]+fromEnd[2]*(fromRatio2-1);
- int intv=0,intvSize= fromShifts2.size();
- int iv[],i=0,fs=-1,fe=-1; // containing intervals
- while (intv<intvSize && (fs==-1 || fe==-1)) {
- iv = (int[]) fromShifts2.elementAt(intv++);
- if (iv[0]<=iv[1]) {
- if (fs==-1 && startpos>=iv[0] && startpos<=iv[1]) {
+ protected static int[] getIntervals(List<int[]> shiftFrom,
+ int[] fromStart, int[] fromEnd, int fromRatio2)
+ {
+ if (fromStart == null || fromEnd == null)
+ {
+ return null;
+ }
+ int startpos, endpos;
+ startpos = fromStart[0]; // first position in fromStart
+ endpos = fromEnd[0]; // last position in fromEnd
+ int endindx = (fromRatio2 - 1); // additional positions to get to last
+ // position from endpos
+ int intv = 0, intvSize = shiftFrom.size();
+ int iv[], i = 0, fs = -1, fe_s = -1, fe = -1; // containing intervals
+ // search intervals to locate ones containing startpos and count endindx
+ // positions on from endpos
+ while (intv < intvSize && (fs == -1 || fe == -1))
+ {
+ iv = shiftFrom.get(intv++);
+ if (fe_s > -1)
+ {
+ endpos = iv[0]; // start counting from beginning of interval
+ endindx--; // inclusive of endpos
+ }
+ if (iv[0] <= iv[1])
+ {
+ if (fs == -1 && startpos >= iv[0] && startpos <= iv[1])
+ {