Ejemplo n.º 1
0
  public void initialize(EditLevelScreen editLevelScreen) {

    this.editLevelScreen = editLevelScreen;

    removeAll();

    for (int row = 0; row < 9; row++) {
      for (int column = 0; column < 9; column++) {

        Square square = level.getGrid().getSquare(row, column);

        if (square != null) {

          SquareView squareView =
              new SquareView(
                  SQUARE_NORMAL_BACK_COLOR,
                  SQUARE_HOVERED_BACK_COLOR,
                  SQUARE_HOVERED_BACK_COLOR,
                  SQUARE_DISABLED_BACK_COLOR,
                  square,
                  NavigationBar.NO_ROUND);

          squareViews[row][column] = squareView;

          squareView.setPreferredSize(SquareView.SQUARE_VIEW_SIZE);
          squareView.setMaximumSize(SquareView.SQUARE_VIEW_SIZE);
          squareView.setMinimumSize(SquareView.SQUARE_VIEW_SIZE);

          squareView.setBounds(
              GRID_VIEW_PADDING_LEFT + column * ((int) SquareView.SQUARE_VIEW_SIZE.getWidth() - 1),
              GRID_VIEW_PADDING_TOP + row * ((int) SquareView.SQUARE_VIEW_SIZE.getHeight() - 1),
              (int) SquareView.SQUARE_VIEW_SIZE.getWidth(),
              (int) SquareView.SQUARE_VIEW_SIZE.getHeight());

          add(squareView);

          SquareViewController squareViewController =
              new SquareViewController(squareView, editLevelScreen);
          squareView.addMouseListener(squareViewController);
          squareView.addMouseMotionListener(squareViewController);

          squareView.normal();
        }
      }
    }
  }
Ejemplo n.º 2
0
 public Grid getGrid() {
   return level.getGrid();
 }