### Question:
GapInterpolator { public float star(short[][] arr, int x, int y) { float[] samplesX = new float[4]; float[] samplesY = new float[4]; int x1 = findNextValidIndex(arr, Direction.X_MINUS, x, y, limit); int x2 = findNextValidIndex(arr, Direction.X_PLUS, x, y, limit); int y1 = findNextValidIndex(arr, Direction.Y_MINUS, x, y, limit); int y2 = findNextValidIndex(arr, Direction.Y_PLUS, x, y, limit); boolean useX = x1 >= 0; boolean useY = y1 >= 0; float interpX = 0; float interpY = 0; if(useX) { int xWidth = x2 - x1; int maxX = arr[0].length - 1; int x0 = x1 - xWidth < 0 ? 0 : x1 - xWidth; int x3 = x2 + xWidth > maxX ? maxX : x2 + xWidth; samplesX[0] = findNearestValidValue(arr, x0, y, limit); samplesX[1] = arr[y][x1]; samplesX[2] = arr[y][x2]; samplesX[3] = findNearestValidValue(arr, x3, y, limit); float fracX = xWidth == 0 ? 0 : (x-x1) / (float) xWidth; interpX = igap.interpolateSampleX(samplesX, fracX); } if(useY) { int yWidth = y2 - y1; int maxY = arr.length - 1; int y0 = y1 - yWidth < 0 ? 0 : y1 - yWidth; int y3 = y2 + yWidth > maxY ? maxY : y2 + yWidth; samplesY[0] = findNearestValidValue(arr, x, y0, limit); samplesY[1] = arr[y1][x]; samplesY[2] = arr[y2][x]; samplesY[3] = findNearestValidValue(arr, x, y3, limit); float fracY = yWidth == 0 ? 0 : (y-y1) / (float) yWidth; interpY = igap.interpolateSampleY(samplesY, fracY); } if(useX && useY) { return (interpX + interpY) / 2f; } else if(useX) { return interpX; } else if(useY) { return interpY; } else { return 0; } } GapInterpolator(short gap); @Deprecated float area(short[][] arr, int x, int y); float star(short[][] arr, int x, int y);  }### Answer:
@Test public void testFullArray() { try { GapInterpolator gip = new GapInterpolator(g); float[][] result = copy(testArr3); for (int y = 0; y < result.length; y++) { for (int x = 0; x < result[0].length; x++) { if(result[y][x] == g) { result[y][x] = gip.star(testArr3, x, y); } } } } catch(Exception e) { fail(e.getMessage()); } }
@Test public void testStar() throws Exception { GapInterpolator gip = new GapInterpolator(g); float res = gip.star(testArr, 5, 5); }