@Override public DataGrid process(DataGrid grid) { if (grid.isPresenceAbsence()) return grid; ArrayList<DataLocation> locations = grid.getOrderedDataLocations(); int qIndex = (int) Math.floor((1 - paramValues[0] / 100.0) * locations.size()); double maxValue = locations.get(qIndex).value; double[][] values = MappingProject.grid.getEmptyGrid(); // filled with 0s und NoData where applicable int replaced = 0; for (int l = 0; l < locations.size(); l++) { if (locations.get(l).value <= maxValue) { values[locations.get(l).x][locations.get(l).y] = locations.get(l).value; } else { values[locations.get(l).x][locations.get(l).y] = maxValue; replaced++; } } // System.out.println(" Replaced "+replaced+" out of "+locations.size()+ " non-zero cells // with max value: " +maxValue); return new DataGrid(values, maxValue, grid.getMin(), grid.getNoDataValue()); }