Example #1
0
  public final void setBoardStyle(BoardStyle newStyle) {
    // We don't allow any changes to the board's dimensions; only changes to
    // the appearance of the board.
    if (boardStyle != null
        && (boardStyle.getFrameWidth() != newStyle.getFrameWidth()
            || boardStyle.getSquareSize() != newStyle.getSquareSize()
            || boardStyle.getHeight() != newStyle.getHeight())) {
      throw new ChessException(
          "New board style dimensions do not match the current board dimensions");
    }

    boardStyle = newStyle;
    chessPieceSet = ChessSet.getChessSet(boardStyle.getPieceStyleName());
  }
Example #2
0
 /**
  * Get the region above a square into which a chesspiece gets drawn
  *
  * @param row the board row
  * @param col the board column
  * @return a Cuboid representing the drawing space
  */
 public Cuboid getPieceRegion(int row, int col) {
   Cuboid sq =
       getSquare(row, col)
           .expand(CuboidDirection.Up, boardStyle.getHeight() - 1)
           .shift(CuboidDirection.Up, 1);
   return sq;
 }
Example #3
0
 /**
  * Board constructor.
  *
  * @param origin
  * @param rotation
  * @param boardStyleName
  * @param pieceStyleName
  * @throws ChessException
  */
 public ChessBoard(
     Location origin, BoardRotation rotation, String boardStyleName, String pieceStyleName)
     throws ChessException {
   setBoardStyle(boardStyleName);
   setPieceStyle(pieceStyleName != null ? pieceStyleName : boardStyle.getPieceStyleName());
   this.rotation = rotation;
   a1Center = new PersistableLocation(origin);
   a1Corner = initA1Corner(origin, rotation);
   h8Corner = initH8Corner(a1Corner.getLocation());
   board = new Cuboid(a1Corner.getLocation(), h8Corner.getLocation());
   areaBoard = board.expand(CuboidDirection.Up, boardStyle.getHeight());
   frameBoard = board.outset(CuboidDirection.Horizontal, boardStyle.getFrameWidth());
   aboveFullBoard =
       frameBoard
           .shift(CuboidDirection.Up, 1)
           .expand(CuboidDirection.Up, boardStyle.getHeight() - 1);
   fullBoard = frameBoard.expand(CuboidDirection.Up, boardStyle.getHeight() + 1);
   validateBoardPosition();
 }
  private void paintStruts(MassBlockUpdate mbu) {
    MaterialData struts = boardStyle.getStrutsMaterial();

    // vertical struts at the frame corners
    Cuboid c =
        new Cuboid(frameBoard.getLowerNE())
            .shift(CuboidDirection.Up, 1)
            .expand(CuboidDirection.Up, boardStyle.getHeight());
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.South, frameBoard.getSizeX() - 1);
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.West, frameBoard.getSizeZ() - 1);
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.North, frameBoard.getSizeZ() - 1);
    c.fill(struts, mbu);

    // horizontal struts along roof edge
    Cuboid roof = frameBoard.shift(CuboidDirection.Up, boardStyle.getHeight() + 1);
    roof.getFace(CuboidDirection.East).fill(struts, mbu);
    roof.getFace(CuboidDirection.North).fill(struts, mbu);
    roof.getFace(CuboidDirection.West).fill(struts, mbu);
    roof.getFace(CuboidDirection.South).fill(struts, mbu);
  }