예제 #1
0
  @Override
  protected void renderCellContent(Graphics g, String theFact) {
    String[] cellFacts = theFact.split(" ");

    if (!cellFacts[4].equals("b")) {
      g.setColor(Color.BLACK);
      CommonGraphics.fillWithString(g, cellFacts[4], 1.2);
    }
  }
예제 #2
0
  @Override
  protected void renderCellContent(Graphics g, Set<String> theFacts) {
    if (theFacts.size() == 0) return;
    String theFact = theFacts.iterator().next();

    String[] cellFacts = theFact.split(" ");
    if (cellFacts.length == 5) {
      String cellType = cellFacts[2];
      int score = 10 * Integer.parseInt(cellFacts[3]);

      Color myColor = null;
      if (cellType.startsWith("red")) myColor = Color.red;
      if (cellType.startsWith("blue")) myColor = Color.blue;
      if (myColor == null) {
        System.err.println("Got weird piece: " + cellType);
        return;
      }

      g.setColor(myColor);
      CommonGraphics.fillWithString(g, "" + score, 1.5);
    } else {
      String cellType = cellFacts[4];
      if (!cellType.equals("b")) {
        Color myColor = null;
        if (cellType.startsWith("red")) myColor = Color.red;
        if (cellType.startsWith("blue")) myColor = Color.blue;
        if (myColor == null) {
          System.err.println("Got weird piece: " + cellType);
          return;
        }

        int width = g.getClipBounds().width;
        int height = g.getClipBounds().height;

        g.setColor(myColor);
        g.fillOval(2, 2, width - 4, height - 4);
        CommonGraphics.drawChessPiece(g, "wn");
      }
    }
  }