code: private static void generateRows(DancingLinks dancer,
                                     Piece piece,
                                     int width,
                                     int height,
                                     boolean flip,
                                     boolean[] row,
                                     boolean upperLeft) {
      // for each rotation
      int[] rotations = piece.getRotations();
      for(int rotIndex = 0; rotIndex < rotations.length; ++rotIndex) {
        // get the shape
        boolean[][] shape = piece.getShape(flip, rotations[rotIndex]);
        // find all of the valid offsets
        for(int x=0; x < width; ++x) {
          for(int y=0; y < height; ++y) {
            if (y + shape.length <= height && x + shape[0].length <= width &&
                (!upperLeft || 
                    (isSide(x, shape[0].length, width) && 
                     isSide(y, shape.length, height)))) {
              // clear the columns related to the points on the board
              for(int idx=0; idx < width * height; ++idx) {
                row[idx] = false;
              }
              // mark the shape
              for(int subY=0; subY < shape.length; ++subY) {
                for(int subX=0; subX < shape[0].length; ++subX) {
                  row[(y + subY) * width + x + subX] = shape[subY][subX];
                }
              }
              dancer.addRow(row);
            }         
          }
        }
      }
    }
docs: For a given piece, generate all of the potential placements and add them
  as rows to the model.
  @param dancer the problem model
  @param piece the piece we are trying to place
  @param width the width of the board
  @param height the height of the board
  @param flip is the piece flipped over?
  @param row a workspace the length of the each row in the table
  @param upperLeft is the piece constrained to the upper left of the board?
  this is used on a single piece to eliminate most of the trivial
  roations of the solution.