List of usage examples for java.lang Math ceil
public static double ceil(double a)
From source file:algorithm.NQueens.java
/** * Calculates statistics for the current data in the fitness, similarity, and mutation rate * buffers. After the statistics have been calculated they are added to the appropriate * fitnessStats, similarityStats, and mutationStats class members. * // w w w.j a va 2 s. com * @param units The units for generations such as thousands (1000) or millions. */ @SuppressWarnings("serial") public static void calcStatistics(int units) { /* Calculate fitness stats */ DescriptiveStatistics descStats = new DescriptiveStatistics(Doubles.toArray(fitnessBuffer)); fitnessStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); /* Calculate chromosome similarity stats */ descStats = new DescriptiveStatistics(Doubles.toArray(similarityBuffer)); similarityStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); /* Calculate mutation rate stats for variable mutation */ if (mutation == null) { descStats = new DescriptiveStatistics(Doubles.toArray(mutationBuffer)); mutationStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); } /* Calculate the duplicate solutions statistics */ if (duplicateBuffer.size() > 0) { final DescriptiveStatistics descDupStats = new DescriptiveStatistics( Doubles.toArray(duplicateBuffer.values())); duplicateStats.put((int) Math.ceil(numGenerations / (double) units), new ArrayList<Double>() { { add((double) duplicateBuffer.size()); add(descDupStats.getMean()); } }); } else { duplicateStats.put((int) Math.ceil(numGenerations / (double) units), new ArrayList<Double>() { { add(0.0); add(0.0); } }); } /* Clear the buffers */ mutationBuffer.clear(); fitnessBuffer.clear(); similarityBuffer.clear(); duplicateBuffer.clear(); }
From source file:com.forsrc.utils.MyRsaUtils.java
/** * String 2 big integers big integer [ ]. * * @param plaintext the plaintext//from www. ja v a2s. co m * @return the big integer [ ] */ public static BigInteger[] string2BigIntegers(String plaintext) { String base64 = base64Encode(plaintext); int length = (int) Math.ceil(base64.length() * 1.0d / BLOCK_SIZE); BigInteger[] bigIntegers = new BigInteger[length]; String text = null; for (int i = 0; i < length - 1; i++) { int start = i * BLOCK_SIZE; text = base64.substring(start, start + BLOCK_SIZE); bigIntegers[i] = toBigInteger(text); } if (length == 1) { bigIntegers[0] = toBigInteger(base64); } if (length > 1) { int start = (length - 1) * BLOCK_SIZE; text = base64.substring(start, base64.length()); bigIntegers[length - 1] = toBigInteger(text); } return bigIntegers; }
From source file:com.mycompany.flooringmvc.controllers.FlooringController.java
@RequestMapping(value = "/", method = RequestMethod.PUT) @ResponseBody/*from ww w . j a v a2 s.co m*/ public Order editContact(@Valid @RequestBody Order order) { List<Product> products = pdao.getProducts(); List<Tax> states = tdao.getTaxes(); String state = order.getState(); state = state.toUpperCase(); double tax = tdao.getTax(state); String type = order.getProduct(); double results[] = getCosts(type); double area = order.getArea(); double mcs = results[0]; double lcs = results[1]; double lc = Math.ceil(lcs * area); double mc = Math.ceil(mcs * area); double pretotal = Math.ceil(lc + mc); double ttax = tax / 100; double taxtotal = pretotal * ttax; double total = pretotal + taxtotal; order.setLaborCost(lc); order.setLaborCostSqf(lcs); order.setMatCostSqf(mcs); order.setMaterialCost(mc); order.setTax(tax); order.setTaxTotal(taxtotal); order.setTotal(total); for (Product p : products) { if (order.getProduct().equals(type)) { order.setProductId(p.getId()); } } for (Tax t : states) { if (order.getState().equals(state)) { order.setStateId(t.getId()); } } dao.update(order); return order; }
From source file:jbosscomp.view.backing.Comparator.java
public BigDecimal getSubscriptionCost() { RichInputNumberSpinbox rinsTotalJBossCores = (RichInputNumberSpinbox) get( "#{backingBeanScope.backing_comparator.jbossCoresY1}"); BigDecimal totalCores = new BigDecimal(rinsTotalJBossCores.getValue().toString()); Double index = totalCores.doubleValue() / 16.0; index = Math.ceil(index); int i = index.intValue(); if (i >= subscriptionCosts.length) i = 0;//from w w w . j a v a 2 s . c o m return new BigDecimal(subscriptionCosts[i]); }
From source file:com.esd.ps.InspectorController.java
/** * ?//from www .j a v a 2s .co m * @param userName * @param timeMark * @param page * @param session * @return */ @RequestMapping(value = "/inspectorManager", method = RequestMethod.POST) @ResponseBody public Map<String, Object> inspectorManagerPost(String userName, int timeMark, int page, HttpSession session) { logger.debug("userName:{},timeMark:{}", userName, timeMark); Map<String, Object> map = new HashMap<String, Object>(); int userId = Integer.parseInt(session.getAttribute(Constants.USER_ID).toString()); int inspectorId = 0; try { inspectorId = inspectorService.getInspectorIdByUserId(userId); } catch (BindingException n) { inspectorId = -1; } //int insCount = inspectorService.getCount(); int totle = workerRecordService.getWorkerIdCountGroupByWorkerId(inspectorId, userName, timeMark, 1, 3, Constants.LIMIT_MIN); int count = 0; count = totle; // if(totle == 0){ // return null; // } // count = totle/insCount; // if(count == 0){ // count = 1; // } List<Map<String, Object>> list = workerRecordService.getWorkerIdGroupByWorkerId(inspectorId, userName, timeMark, 1, 3, page, Constants.ROW, Constants.LIMIT_MIN); //SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATETIME_FORMAT); List<Map<String, Object>> list1 = new ArrayList<>(); for (Iterator<Map<String, Object>> iterator = list.iterator(); iterator.hasNext();) { Map<String, Object> map1 = (Map<String, Object>) iterator.next(); logger.debug("map1:{}", map1); int workerId = Integer.parseInt(map1.get("worker_id").toString()); String workerRealName = workerService.getWorkerRealNameByWorkerId(workerId); map1.put("workerRealName", workerRealName); list1.add(map1); } int totlePage = (int) Math.ceil((double) count / (double) Constants.ROW); List<inspector> insList = inspectorService.getAll(); map.put("inspectorIds", insList); map.put(Constants.LIST, list1); map.put(Constants.TOTLE, count); map.put(Constants.TOTLE_PAGE, totlePage); return map; }
From source file:net.coasterman10.Annihilation.object.Shop.java
private void openShop(Player player) { int size = 9 * (int) Math.ceil(items.size() / 9.0); Inventory shopInv = Bukkit.getServer().createInventory(player, size, name + " Shop"); for (int i = 0; i < items.size(); i++) { ShopItem item = items.get(i);//from w ww .j a v a2s. co m if (item != null) shopInv.setItem(i, item.getShopStack()); else shopInv.setItem(i, null); } player.openInventory(shopInv); }
From source file:simulation.AureoZauleckAnsLab2.java
/** * */// ww w . ja v a 2 s . c om public AureoZauleckAnsLab2() { // TODO code application logic here Scanner sc = new Scanner(System.in); String choice_s = ""; int choice = 0; do { DisplayMenu(); choice_s = sc.next(); String title = ""; Scanner s = new Scanner(System.in); //test input if (IsNumber(choice_s)) { choice = Convert(choice_s); } else { do { System.out.println("Please enter a number only."); choice_s = sc.next(); } while (!IsNumber(choice_s)); choice = Convert(choice_s); } if (choice == 1) { System.out.println("*** CATEGORICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); //sc = new Scanner(System.in); title = s.nextLine(); System.out.println("this is the title: " + title); ArrayList a = new ArrayList<>(); ArrayList<Double> percentages = new ArrayList<>(); ArrayList<ArrayList> all; a = GetData(); Collections.sort(a); all = Stratified(a); System.out.println("GROUPED DATA: " + all); System.out.println("size " + all.size()); double percent = 0.0, sum = 0.0; for (int i = 0; i < all.size(); i++) { ArrayList inner = new ArrayList<>(); inner = all.get(i); //System.out.println(inner); int inner_n = inner.size(); percent = GetPercentage(N, inner_n); percentages.add(percent); sum += percent; System.out.println("" + inner.get(0) + "\t" + " " + percent); } System.out.println("\t" + "total " + Math.ceil(sum)); System.out.println("all = " + all); JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (all.size() + 2), 2)); table.setValueAt("VALUE LABELS", 0, 0); table.setValueAt("PERCENTAGE", 0, 1); table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1); for (int i = 0; i < all.size(); i++) { table.setValueAt(all.get(i).get(0), i + 1, 0); table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1); } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); int type = 0, testT = 0; String typeTest = ""; do { System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 2); if (type == 1) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < all.size(); i++) { dataset.setValue( all.get(i).get(0).toString() + " = " + new DecimalFormat("#.##").format(percentages.get(i)) + "%", percentages.get(i)); } JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data true, // include legend true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); JFrame l = new JFrame(); l.setContentPane(chartPanel); l.setSize(400, 400); l.setVisible(true); } else { //do nothing? } int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while (type2 < 1 || type2 > 2); if (type2 == 1) { DisplayTable(all, percentages, title); } else { //do nothing? } } else if (choice == 2) { System.out.println("*** NUMERICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); title = s.nextLine(); System.out.println("this is the title " + title); ArrayList<Double> a = new ArrayList<>(); //ArrayList<ArrayList> all; //a = GetData2(); double[] arr = { 70, 36, 43, 69, 82, 48, 34, 62, 35, 15, 59, 139, 46, 37, 42, 30, 55, 56, 36, 82, 38, 89, 54, 25, 35, 24, 22, 9, 55, 19 }; /* double[] arr = {112, 100, 127,120,134,118,105,110,109,112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114}; */ N = arr.length; double t = 0.0; for (int i = 0; i < N; i++) { a.add(arr[i]); } Collections.sort(a); System.out.println("sorted a " + a); double min = (double) a.get(0); double max = (double) a.get(N - 1); System.out.println("Min" + min); System.out.println("Max" + max); double k = Math.ceil(1 + 3.322 * Math.log10(N)); System.out.println("K " + k); double range = GetRange(min, max); System.out.println("Range " + range); double width = Math.ceil(range / k); //todo, i ceiling sa 1st decimal point System.out.println("Width " + width); ArrayList<Double> cl = new ArrayList<>(); cl.add(min); double rest; for (int i = 1; i < k; i++) { cl.add(min += width); } ArrayList<Double> cl2 = new ArrayList<>(); double cl2min = cl.get(1) - 1; cl2.add(cl2min); for (int i = 1; i < k; i++) { cl2.add(cl2min += width); } System.out.println("cl 1 " + cl); System.out.println("cl 2 " + cl2); ArrayList<Double> tlcl = new ArrayList<>(); double tlclmin = cl.get(0) - Multiplier(cl.get(0)); tlcl.add(tlclmin); for (int i = 1; i < k; i++) { tlcl.add(tlclmin += width); } ArrayList<Double> tucl = new ArrayList<>(); double tuclmin = cl2.get(0) + Multiplier(cl2.get(0)); tucl.add(tuclmin); for (int i = 1; i < k; i++) { tucl.add(tuclmin += width); } System.out.println("tlcl 1 " + tlcl); System.out.println("tucl 2 " + tucl); System.out.println("N " + N); ArrayList<Double> midList = new ArrayList<>(); double mid = (cl.get(0) + cl2.get(0)) / 2; midList.add(mid); for (int i = 1; i < k; i++) { midList.add((tlcl.get(i) + tucl.get(i)) / 2); } for (int i = 0; i < k; i++) { System.out.println((tlcl.get(i) + tucl.get(i)) / 2); } System.out.println("mid" + midList); ArrayList<ArrayList<Double>> freq = new ArrayList<>(); double ctr = 0.0; for (int j = 0; j < k; j++) { for (int i = 0; i < N; i++) { if ((a.get(i) >= tlcl.get(j)) && (a.get(i) <= tucl.get(j))) { freq.add(new ArrayList<Double>()); freq.get(j).add(a.get(i)); } } } ArrayList<Double> freqSize = new ArrayList<>(); double size = 0.0; for (int i = 0; i < k; i++) { size = (double) freq.get(i).size(); freqSize.add(size); } ArrayList<Double> freqPercent = new ArrayList<>(); for (int i = 0; i < k; i++) { freqPercent.add(freqSize.get(i) / N * 100); } ArrayList<Double> cfs = new ArrayList<>(); double cf = freqSize.get(0); cfs.add(cf); for (int i = 1; i < k; i++) { cf = freqSize.get(i) + cfs.get(i - 1); cfs.add(cf); } double sum = 0.0; for (int i = 1; i < cfs.size(); i++) { sum += cfs.get(i); } ArrayList<Double> cps = new ArrayList<>(); double cp = 0.0; for (int i = 0; i < k; i++) { cp = (cfs.get(i) / N) * 100; cps.add(cp); } System.out.println("T o t a l: " + sum); System.out.println(cfs); System.out.println(cps); System.out.println("frequency list " + freq); System.out.println("frequency sizes " + freqSize); System.out.println("frequency percentages " + freqPercent); System.out.println(); System.out.println(title); System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(cl.get(i) + " - " + cl2.get(i) + "\t" + tlcl.get(i) + " - " + tucl.get(i) + "\t" + midList.get(i) + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //2 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //3 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println("<=" + cl2.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + " and <=" + cl2.get(i) + "\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); int type = 0, testT = 0; String typeTest = ""; do { do { System.out.println(); System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 2); if (type == 1) { int bins = (int) k; System.out.println(); System.out.println("You may input a label for your X axis:"); String x = ""; x = s.nextLine(); createHistogram(a, bins, title, x); int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println(); System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while ((type2 < 1 || type2 > 2) && type != 2); if (type2 == 1) { DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); } else { //do nothing? } } } while (type != 2); } else if (choice == 3) { System.out.println("*** QUIT ***"); } } while (choice != 3); System.out.println("Thank you for your time."); s = new Simulation(); }
From source file:org.geowebcache.grid.GridSetFactory.java
/** * Note that you should provide EITHER resolutions or scales. Providing both will cause a * precondition violation exception.//from w w w . j ava2 s .com * * @param name * @param srs * @param extent * @param resolutions * @param scales * @param tileWidth * @param tileHeight * @param pixelSize * @param yCoordinateFirst * @return */ public static GridSet createGridSet(final String name, final SRS srs, final BoundingBox extent, boolean alignTopLeft, double[] resolutions, double[] scaleDenoms, Double metersPerUnit, double pixelSize, String[] scaleNames, int tileWidth, int tileHeight, boolean yCoordinateFirst) { Assert.notNull(name, "name is null"); Assert.notNull(srs, "srs is null"); Assert.notNull(extent, "extent is null"); Assert.isTrue(!extent.isNull() && extent.isSane(), "Extent is invalid: " + extent); Assert.isTrue(resolutions != null || scaleDenoms != null); Assert.isTrue(resolutions == null || scaleDenoms == null, "Only one of resolutions or scaleDenoms should be provided, not both"); for (int i = 1; resolutions != null && i < resolutions.length; i++) { if (resolutions[i] >= resolutions[i - 1]) { throw new IllegalArgumentException("Each resolution should be lower than it's prior one. Res[" + i + "] == " + resolutions[i] + ", Res[" + (i - 1) + "] == " + resolutions[i - 1] + "."); } } for (int i = 1; scaleDenoms != null && i < scaleDenoms.length; i++) { if (scaleDenoms[i] >= scaleDenoms[i - 1]) { throw new IllegalArgumentException( "Each scale denominator should be lower than it's prior one. Scale[" + i + "] == " + scaleDenoms[i] + ", Scale[" + (i - 1) + "] == " + scaleDenoms[i - 1] + "."); } } GridSet gridSet = baseGridSet(name, srs, tileWidth, tileHeight); gridSet.setResolutionsPreserved(resolutions != null); gridSet.setPixelSize(pixelSize); gridSet.setOriginalExtent(extent); gridSet.yBaseToggle = alignTopLeft; gridSet.setyCoordinateFirst(yCoordinateFirst); if (metersPerUnit == null) { if (srs.equals(SRS.getEPSG4326())) { gridSet.setMetersPerUnit(EPSG4326_TO_METERS); } else if (srs.equals(SRS.getEPSG3857())) { gridSet.setMetersPerUnit(EPSG3857_TO_METERS); } else { if (resolutions == null) { log.warn("GridSet " + name + " was defined without metersPerUnit, assuming 1m/unit." + " All scales will be off if this is incorrect."); } else { log.warn("GridSet " + name + " was defined without metersPerUnit. " + "Assuming 1m per SRS unit for WMTS scale output."); gridSet.setScaleWarning(true); } gridSet.setMetersPerUnit(1.0); } } else { gridSet.setMetersPerUnit(metersPerUnit); } if (resolutions == null) { gridSet.setGridLevels(new Grid[scaleDenoms.length]); } else { gridSet.setGridLevels(new Grid[resolutions.length]); } for (int i = 0; i < gridSet.getGridLevels().length; i++) { Grid curGrid = new Grid(); if (scaleDenoms != null) { curGrid.setScaleDenominator(scaleDenoms[i]); curGrid.setResolution(pixelSize * (scaleDenoms[i] / gridSet.getMetersPerUnit())); } else { curGrid.setResolution(resolutions[i]); curGrid.setScaleDenominator( (resolutions[i] * gridSet.getMetersPerUnit()) / DEFAULT_PIXEL_SIZE_METER); } final double mapUnitWidth = tileWidth * curGrid.getResolution(); final double mapUnitHeight = tileHeight * curGrid.getResolution(); final long tilesWide = (long) Math.ceil((extent.getWidth() - mapUnitWidth * 0.01) / mapUnitWidth); final long tilesHigh = (long) Math.ceil((extent.getHeight() - mapUnitHeight * 0.01) / mapUnitHeight); curGrid.setNumTilesWide(tilesWide); curGrid.setNumTilesHigh(tilesHigh); if (scaleNames == null || scaleNames[i] == null) { curGrid.setName(gridSet.getName() + ":" + i); } else { curGrid.setName(scaleNames[i]); } gridSet.getGridLevels()[i] = curGrid; } return gridSet; }
From source file:cgpanalyser.gui.chart.XYChartPanel.java
/** * @return the markerStart rounded up */ public int getMarkerStart() { return (int) Math.ceil(mouseMarker.getMarkerStart()); }
From source file:edu.umn.cs.spatialHadoop.indexing.GridPartitioner.java
@Override public void overlapPartitions(Shape shape, ResultCollector<Integer> matcher) { if (shape == null) return;/*from www.j a v a 2s .c o m*/ Rectangle shapeMBR = shape.getMBR(); if (shapeMBR == null) return; int col1, col2, row1, row2; col1 = (int) Math.floor((shapeMBR.x1 - x) / tileWidth); col2 = (int) Math.ceil((shapeMBR.x2 - x) / tileWidth); row1 = (int) Math.floor((shapeMBR.y1 - y) / tileHeight); row2 = (int) Math.ceil((shapeMBR.y2 - y) / tileHeight); if (col1 < 0) col1 = 0; if (row1 < 0) row1 = 0; for (int col = col1; col < col2; col++) for (int row = row1; row < row2; row++) matcher.collect(getCellNumber(col, row)); }