/** * Finds which bin has that value. * * @param x The x value to search for * @param y The y value to search for * @return The bin, in array indexing format, which holds that x-y value */ public int findBin(double x, double y) { int bx = xAxis.getBin(x); int by = yAxis.getBin(y); if (this.isValidBins(bx, by)) { return (offset.getArrayIndex(bx, by)); } return -1; }
/** * Finds the bin content at that bin * * @param bx The x coordinate of the bin * @param by The y coordinate of the bin * @return The content at that bin */ public double getBinContent(int bx, int by) { if (this.isValidBins(bx, by)) { int buff = offset.getArrayIndex(bx, by); if (buff >= 0 && buff < hBuffer.length) { return hBuffer[buff]; } else { System.out.println("[Index] error for binx = " + bx + " biny = " + by); } } return 0.0; }
/** * Sets the bin to that value * * @param bx The x coordinate of the bin * @param by The y coordinate of the bin * @param w The desired value to set the bin to */ public void setBinContent(int bx, int by, double w) { if (this.isValidBins(bx, by)) { int buff = offset.getArrayIndex(bx, by); hBuffer[buff] = w; } }