Beispiel #1
0
  public void paintComponent(Graphics g) throws RuntimeException {
    int squarewidth = getSquareWidth();
    int squareheight = getSquareHeight();

    int hoffset = getHorizontalOffset();
    int voffset = getVerticalOffset();

    for (int x = 0; x < grid.maxX(); x++) {
      for (int y = 0; y < grid.maxY(); y++) {
        Cell tmp = grid.grabObjectAt(x, y);

        if (tmp == null) {
          g.setColor(Color.gray.darker());
        } else {
          g.setColor(tmp.getColor());
        }

        g.fillRect(
            hoffset + x * squarewidth,
            voffset + ((grid.maxY() - y) * squareheight),
            squarewidth - 1,
            squareheight - 1);
      }
    }
  }