package com.github.apixandru.games.rummikub.ui;

import javax.swing.*;
import java.awt.*;

import static com.github.apixandru.games.rummikub.ui.Main.TILE_HEIGHT;
import static com.github.apixandru.games.rummikub.ui.Main.TILE_WIDTH;

/**
 * @author Alexandru-Constantin Bledea
 * @since December 19, 2015
 */
public class JGridPanel extends JPanel {

    private static final int COLS = 20;

    final CardSlot[][] slots;

    /**
     * @param rows
     * @param y
     */
    JGridPanel(final int rows, final int y) {
        slots = new CardSlot[COLS][rows];
        setLayout(new GridLayout(rows, COLS));
        setBounds(0, y == 0 ? 0 : y * TILE_HEIGHT + 60, COLS * TILE_WIDTH, rows * TILE_HEIGHT);
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < COLS; j++) {
                final CardSlot slot = new CardSlot(i, j);
                slots[j][i] = slot;
                add(slot);
            }
        }
    }

}

@@ -456,17 +456,22 @@
  @param 
-y
+offset
 %0A     */
@@ -512,17 +512,22 @@
 nal int 
-y
+offset
 ) %7B%0A    
@@ -555,18 +555,18 @@
 lot%5B
-COLS%5D%5Brows
+rows%5D%5BCOLS
 %5D;%0A 
@@ -632,17 +632,22 @@
 unds(0, 
-y
+offset
  == 0 ? 
@@ -650,17 +650,22 @@
 0 ? 0 : 
-y
+offset
  * TILE_
@@ -738,16 +738,16 @@
 int 
-i
+y
  = 0; 
-i
+y
  %3C r
@@ -751,17 +751,17 @@
 %3C rows; 
-i
+y
 ++) %7B%0A  
@@ -783,16 +783,16 @@
 int 
-j
+x
  = 0; 
-j
+x
  %3C C
@@ -796,17 +796,17 @@
 %3C COLS; 
-j
+x
 ++) %7B%0A  
@@ -858,12 +858,12 @@
 lot(
-i, j
+x, y
 );%0A 
@@ -887,12 +887,12 @@
 ots%5B
-j%5D%5Bi
+y%5D%5Bx
 %5D = 

fix grid code (how do i always get this wrong?)