Example #1
0
  public void createGrid() {

    this.removeAll();

    this.Cells = new View_Cell[Controller_ForestArea.getHeight()][Controller_ForestArea.getWidth()];
    Controller_ForestArea.updatePropWithTab();

    for (int i = 0; i < Controller_ForestArea.getHeight(); i++) {
      this.gbc.gridy = i;

      for (int j = 0; j < Controller_ForestArea.getWidth(); j++) {
        this.gbc.gridx = j;

        switch (Controller_ForestArea.getForestAreaTab()[i][j]) {
          case 0:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.EMPTY.getColor());
            break;
          case 1:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.YOUNG_PLANT.getColor());
            break;
          case 2:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.SMALL_TREE.getColor());
            break;
          case 3:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.ADULT_TREE.getColor());
            break;
          case 4:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.FIRE.getColor());
            break;
          case 5:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.INFECT.getColor());
            break;
          case 6:
            this.Cells[i][j] = new View_Cell(i, j, Enum_Cell.ASH.getColor());
            break;
        }

        this.add(this.Cells[i][j], this.gbc);
      }
    }
    this.revalidate();
    this.repaint();
  }
Example #2
0
  public void setCellAt(int x, int y, int cell) {

    switch (cell) {
      case 0:
        Controller_ForestArea.setForestAreaTabAt(x, y, 0);
        this.Cells[x][y].setBackground(Enum_Cell.EMPTY.getColor());
        break;
      case 1:
        Controller_ForestArea.setForestAreaTabAt(x, y, 1);
        this.Cells[x][y].setBackground(Enum_Cell.YOUNG_PLANT.getColor());
        break;
      case 2:
        Controller_ForestArea.setForestAreaTabAt(x, y, 2);
        this.Cells[x][y].setBackground(Enum_Cell.SMALL_TREE.getColor());
        break;
      case 3:
        Controller_ForestArea.setForestAreaTabAt(x, y, 3);
        this.Cells[x][y].setBackground(Enum_Cell.ADULT_TREE.getColor());
        break;
      case 4:
        Controller_ForestArea.setForestAreaTabAt(x, y, 4);
        this.Cells[x][y].setBackground(Enum_Cell.FIRE.getColor());
        break;
      case 5:
        Controller_ForestArea.setForestAreaTabAt(x, y, 5);
        this.Cells[x][y].setBackground(Enum_Cell.INFECT.getColor());
        break;
      case 6:
        Controller_ForestArea.setForestAreaTabAt(x, y, 6);
        this.Cells[x][y].setBackground(Enum_Cell.ASH.getColor());
        break;
    }

    // this.revalidate();
    this.repaint();
    View_StatMenu.updateLabelStat();
  }
Example #3
0
  public void updateGridColors() {

    Controller_ForestArea.updatePropWithTab();

    for (int i = 0; i < Controller_ForestArea.getHeight(); i++) {

      for (int j = 0; j < Controller_ForestArea.getWidth(); j++) {

        switch (Controller_ForestArea.getForestAreaTab()[i][j]) {
          case 0:
            this.Cells[i][j].setBackground(Enum_Cell.EMPTY.getColor());
            break;
          case 1:
            this.Cells[i][j].setBackground(Enum_Cell.YOUNG_PLANT.getColor());
            break;
          case 2:
            this.Cells[i][j].setBackground(Enum_Cell.SMALL_TREE.getColor());
            break;
          case 3:
            this.Cells[i][j].setBackground(Enum_Cell.ADULT_TREE.getColor());
            break;
          case 4:
            this.Cells[i][j].setBackground(Enum_Cell.FIRE.getColor());
            break;
          case 5:
            this.Cells[i][j].setBackground(Enum_Cell.INFECT.getColor());
            break;
          case 6:
            this.Cells[i][j].setBackground(Enum_Cell.ASH.getColor());
            break;
        }
      }
    }
    // this.revalidate();

  }