示例#1
0
 /**
  * Draws one square (and any pieces piled there) at coordinates x, y.
  *
  * @param highlight If true, highlights this square as a legal move.
  */
 public void drawSquare(Deque<Integer> pile, double x, double y, boolean highlight) {
   if (pile != null) {
     if (highlight) {
       StdDraw.setPenColor(VERY_LIGHT_BLUE);
     } else {
       StdDraw.setPenColor(LIGHT_BLUE);
     }
     StdDraw.filledSquare(x, y, 0.45);
     x -= 0.2;
     y -= 0.2;
     for (int c : pile) {
       StdDraw.setPenColor(c == FocusModel.BLACK ? java.awt.Color.BLACK : java.awt.Color.WHITE);
       StdDraw.filledEllipse(x, y, 0.2, 0.1);
       StdDraw.setPenColor(c == FocusModel.BLACK ? java.awt.Color.WHITE : java.awt.Color.BLACK);
       StdDraw.ellipse(x, y, 0.2, 0.1);
       x += 0.1;
       y += 0.1;
     }
   }
 }