private boolean calculateVolumes() { int x, y; double z, z2; double dVolumePos = 0; double dVolumeNeg = 0; double dVolume = 0; double dDif; final double dArea = m_LowerGrid.getWindowCellSize() * m_LowerGrid.getWindowCellSize(); for (y = 0; (y < m_iNY) && setProgress(y, m_iNY); y++) { for (x = 0; x < m_iNX; x++) { z = m_LowerGrid.getCellValueAsDouble(x, y); z2 = m_UpperGrid.getCellValueAsDouble(x, y); if (!m_LowerGrid.isNoDataValue(z) && !m_UpperGrid.isNoDataValue(z2)) { dDif = (z2 - z); dVolume += Math.abs(dDif); if (dDif > 0) { dVolumePos += dDif; } else { dVolumeNeg += -dDif; } } } } if (m_Task.isCanceled()) { return false; } else { dVolume *= dArea; dVolumePos *= dArea; dVolumeNeg *= dArea; final DecimalFormat df = new DecimalFormat("##.##"); final HTMLDoc doc = new HTMLDoc(); doc.open(Sextante.getText("Volumes")); doc.addHeader(Sextante.getText("Volumes"), 2); doc.startUnorderedList(); doc.addListElement(Sextante.getText("Volume_+") + df.format(dVolumePos)); doc.addListElement(Sextante.getText("Volume_-") + df.format(dVolumeNeg)); doc.addListElement(Sextante.getText("Total_volume") + df.format(dVolume)); doc.close(); addOutputText(VOL, Sextante.getText("Volume"), doc.getHTMLCode()); return true; } }