88import java .util .ListIterator ;
99import java .util .stream .Collectors ;
1010
11- import processing .core .PApplet ;
12-
1311
1412public class TextTransform {
1513
@@ -256,7 +254,7 @@ public int getInputOffset(int outputOffset) {
256254 i = -(i + 1 );
257255 i -= 1 ;
258256 }
259- i = PApplet . constrain (i , 0 , outMap .size ()-1 );
257+ i = constrain (i , 0 , outMap .size ()-1 );
260258 Edit edit = outMap .get (i );
261259 int diff = outputOffset - edit .toOffset ;
262260 return edit .fromOffset + Math .min (diff , Math .max (0 , edit .fromLength - 1 ));
@@ -271,7 +269,7 @@ public int getOutputOffset(int inputOffset) {
271269 i = -(i + 1 );
272270 i -= 1 ;
273271 }
274- i = PApplet . constrain (i , 0 , inMap .size ()-1 );
272+ i = constrain (i , 0 , inMap .size ()-1 );
275273 Edit edit = inMap .get (i );
276274 int diff = inputOffset - edit .fromOffset ;
277275 return edit .toOffset + Math .min (diff , Math .max (0 , edit .toLength - 1 ));
@@ -283,6 +281,10 @@ public OffsetMapper thenMapping(OffsetMapper mapper) {
283281 }
284282 }
285283
284+ static public final int constrain (int amt , int low , int high ) {
285+ return (amt < low ) ? low : ((amt > high ) ? high : amt );
286+ }
287+
286288
287289 private static class CompositeOffsetMapper implements OffsetMapper {
288290 private List <OffsetMapper > mappers = new ArrayList <>();
0 commit comments