code: public double[][] getWindow( int size, boolean doCircular ) {
          if (size % 2 == 0) {
              size++;
          }
          double[][] window = new double[size][size];
          int delta = (size - 1) / 2;
          if (!doCircular) {
              for( int c = -delta; c <= delta; c++ ) {
                  int tmpCol = col + c;
                  for( int r = -delta; r <= delta; r++ ) {
                      int tmpRow = row + r;
                      GridNode n = new GridNode(gridIter, cols, rows, xRes, yRes, tmpCol, tmpRow);
                      window[r + delta][c + delta] = n.elevation;
                  }
              }
          } else {
              double radius = delta; // rows + half cell
              for( int c = -delta; c <= delta; c++ ) {
                  int tmpCol = col + c;
                  for( int r = -delta; r <= delta; r++ ) {
                      int tmpRow = row + r;
  
                      double distance = sqrt(c * c + r * r);
                      if (distance <= radius) {
                          GridNode n = new GridNode(gridIter, cols, rows, xRes, yRes, tmpCol, tmpRow);
                          window[r + delta][c + delta] = n.elevation;
                      } else {
                          window[r + delta][c + delta] = doubleNovalue;
                      }
                  }
              }
          }
          return window;
      }
docs: Get a window of values surrounding the current node.
  
  <p>Notes:</p>
  <ul>
  <li>the size has to be odd, so that the current node can be in the center.
  If the size is even, size+1 will be used.</li>
  <li>values outside the boundaries of the raster will be set to novalue.
  No exception is thrown.</li>
  </ul>
  
  @param size the size of the window. The window will be a matrix window[size][size].
  @param doCircular if <code>true</code> the window values are set to novalue
  were necessary to make it circular.
  @return the read window.