Esempio n. 1
0
 private void drawCellWithColor(Graphics2D g2d, TileCell cell, Color color) {
   g2d.setColor(color);
   g2d.fill(
       new Rectangle(cell.getX() + 2, cell.getY() + 2, TileCell.WIDTH - 3, TileCell.HEIGHT - 3));
   g2d.setColor(Color.BLACK);
   g2d.drawRect(cell.getX(), cell.getY(), TileCell.WIDTH, TileCell.HEIGHT);
 }
Esempio n. 2
0
 private void drawCellG(Graphics2D g2d, TileCell cell) {
   if (!cell.isShow() || cell.getG() < 0) {
     return;
   }
   g2d.drawString("" + cell.getG(), cell.getX(), (cell.getY() + TileCell.WIDTH / 2));
   // System.out.println("draw... g=" +
   // cell.getG()+", x="+cell.getX()+", y="+ (cell.getY()+RECT_SIZE/2));
 }
Esempio n. 3
0
 private void drawMap(Graphics2D g2d, TileMap map) {
   for (TileCell[] columns : map.getCells()) {
     for (TileCell cell : columns) {
       if (cell.isEnd()) {
         drawCellWithColor(g2d, cell, Color.GREEN);
       } else if (cell.isPath()) {
         if (!cell.isStart()) {
           drawCellWithColor(g2d, cell, Color.YELLOW);
         }
         drawCellG(g2d, cell);
       } else if (!cell.isCanPass()) {
         drawCellWithColor(g2d, cell, Color.DARK_GRAY);
       } else {
         g2d.setColor(Color.BLACK);
         g2d.drawRect(cell.getX(), cell.getY(), TileCell.WIDTH, TileCell.HEIGHT);
         drawCellG(g2d, cell);
       }
     }
   }
 }