コード例 #1
0
  public void updateViewer(int tX, int tY, int sX, int sY) {
    int x, y, h, maxX, maxY;
    double posProb, posProbMax;

    posProb = 0.0;
    posProbMax = 0.0;
    maxX = maxY = -1;
    for (x = 0; x < rows; x++) {
      for (y = 0; y < cols; y++) {

        posProb = 0.0;
        posProb = loc.getCurrentProb(x, y);
        states[x][y][0].setText(String.format("%.4f", posProb));
        if (posProb == 0.0) {
          for (h = 0; h < 5; h++) {
            states[x][y][h].setBackground(Color.white);
          }
        } else if (posProb <= 0.1) {
          for (h = 0; h < 5; h++) {
            states[x][y][h].setBackground(Color.yellow);
          }

        } else if (posProb <= 0.3) {
          for (h = 0; h < 5; h++) {
            states[x][y][h].setBackground(Color.orange);
          }
        } else {
          for (h = 0; h < 5; h++) {
            states[x][y][h].setBackground(Color.red);
          }
        }
        if (posProb > posProbMax) {
          posProbMax = posProb;
          maxX = x;
          maxY = y;
        }
      }
    }
    if (maxX != -1) {
      states[maxX][maxY][0].setBackground(Color.lightGray);
      states[maxX][maxY][1].setBackground(Color.lightGray);
      states[maxX][maxY][2].setBackground(Color.lightGray);
      states[maxX][maxY][3].setBackground(Color.lightGray);
    }

    states[tX][tY][4].setBackground(Color.black);
    if (sX != -1) states[sX][sY][4].setBackground(Color.cyan);
  }