Package com.barrybecker4.game.common.board

Examples of com.barrybecker4.game.common.board.GamePiece


    }

    /** X axis domain */
    @Override
    public Range getDomain() {
        return new Range(xValues.get(0), xValues.get(xValues.size()-1));
    }
View Full Code Here


        return getInterpolatedValue(value);
    }

    @Override
    public Range getDomain() {
        return new Range(xValues[0], xValues[xValues.length-1]);
    }
View Full Code Here

        return Math.pow(base, value / scale);
    }

    @Override
    public Range getDomain() {
        return new Range(0, Double.MAX_VALUE);
    }
View Full Code Here

        return (value - offset) / scale;
    }

    @Override
    public Range getDomain() {
        return new Range(Double.MIN_VALUE, Double.MAX_VALUE);
    }
View Full Code Here

    /**
     * Constructor.
     */
    public ErrorFunction() {
        interpolator = new LinearInterpolator(ERROR_FUNCTION);
        inverseInterpolator = new LinearInterpolator(INVERSE_ERROR_FUNCTION);
    }
View Full Code Here

     */
    protected boolean processToken(SGFToken token, MoveList moveList) {

        boolean found = false;
        if (token instanceof PlacementToken ) {
            Move move = createMoveFromToken( token );
            GameContext.log(2, "creating move="+ move);
            moveList.add( move );
            found = true;
        } else {
            GameContext.log(0, "ignoring token "+token.getClass().getName());
View Full Code Here

    }

    @Override
    public void update(GameController controller) {
        setPlayerLabel(controller.getCurrentPlayer());
        Move lastMove =  controller.getLastMove();
        if (lastMove != null)  {
            moveNumLabel_.setText( (controller.getPlayers().getNumPlayers() + 2) + " " );
        }
        else {
            moveNumLabel_.setText( 1 + " " );
View Full Code Here

     */
    protected void restoreGame( SGFGame game )
    {
        parseSGFGameInfo(game);

        MoveList moveSequence = new MoveList();
        extractMoveList( game.getTree(), moveSequence );
        GameContext.log( 1, "move sequence= " + moveSequence );
        controller_.reset();

        for (Move m : moveSequence) {
View Full Code Here

     * This renders the current state of the Board to the screen.
     */
    public void render(Graphics g, Player currentPlayer, PlayerList players,
                       IBoard board, int panelWidth, int panelHeight ) {

        Board b = (Board)board;
        cellSize = calcCellSize( b, panelWidth, panelHeight );

        if ( draggedShowPiece_!=null) {
            draggedShowPiece_.getPiece().setTransparency( DRAG_TRANSPARENCY );
        }

        Graphics2D g2 = (Graphics2D)g;

        int gridOffset = 0;
        int start = 0;
        int nrows = b.getNumRows();
        int ncols = b.getNumCols();
        int nrows1 = nrows;
        int ncols1 = ncols;
        // if the grid is offset, it means the pieces will be shown at the vertices.
        if ( offsetGrid() ) {
            gridOffset = cellSize >> 1;
View Full Code Here

    *
    * @param g2 graphics context
    * @param position the position of the piece to render
    */
   public void render(Graphics2D g2, BoardPosition position, int cellSize, int margin, Board b) {
        GamePiece piece = position.getPiece();
        // if there is no piece, then nothing to render
        if (piece == null)
            return;

        int pieceSize = getPieceSize(cellSize, piece);
        Point pos = getPosition(position, cellSize, pieceSize, margin);
        Ellipse2D circle = new Ellipse2D.Float( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
        int hlOffset = (int) (pieceSize / 2.3 + 0.5)//spec highlight offset
        RoundGradientPaint rgp = new RoundGradientPaint(
                pos.x + hlOffset, pos.y + hlOffset, Color.white, SPEC_HIGHLIGHT_RADIUS, getPieceColor(piece) );

        g2.setPaint( rgp );
        g2.fill( circle );

        // only draw the outline if we are not in a debug mode.
        // when in debug mode we want to emphasize other annotations instead of the piece
        if ( piece.getTransparency() == 0 && (GameContext.getDebugMode() == 0) ) {
            g2.setColor( Color.black );
            g2.drawOval( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
        }

        if ( piece.getAnnotation() != null ) {
            int offset = (cellSize - pieceSize) >> 1;
            g2.setColor( getTextColor(piece) );
            g2.setFont( BASE_FONT );
            g2.drawString( piece.getAnnotation(), pos.x + 2*offset, pos.y + 3*offset);
        }
   }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.board.GamePiece

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.