Package com.barrybecker4.common.geometry

Examples of com.barrybecker4.common.geometry.Location


    /**
     * @return the tooltip for the panel given a mouse event
     */
    @Override
    public String getToolTipText( MouseEvent e ) {
        Location loc = getBoardRenderer().createLocation(e);
        StringBuilder sb = new StringBuilder( "<html><font=-3>" );

        if (controller_.getBoard() != null) {
            BoardPosition space = ((IRectangularBoard)controller_.getBoard()).getPosition(loc);
            if ( space != null && space.isOccupied() && GameContext.getDebugMode() >= 0 ) {
View Full Code Here


    @Override
    public String getToolTipText( MouseEvent e ) {
        if (get2PlayerController().isProcessing())
            return ""// avoids concurrent modification exception

        Location loc = getBoardRenderer().createLocation(e);
        StringBuilder sb = new StringBuilder( "<html><font=-3>" )// NON_NLS

        GoBoardPosition space = (GoBoardPosition) ((IRectangularBoard)controller_.getBoard()).getPosition( loc );
        if ( space != null && GameContext.getDebugMode() > 0 ) {
            String spaceText = space.getDescription();
View Full Code Here

        GoController controller = (GoController) viewer_.getController();
        // all derived classes must check this to disable user clicks while the computer is thinking
        if (controller.isProcessing()) {
            return;
        }
        Location loc = getRenderer().createLocation(e);
        GoBoard board = (GoBoard) controller.getBoard();
        boolean player1sTurn = controller.isPlayer1sTurn();

        GameContext.log( 3, "BoardViewer: mousePressed: player1sTurn()=" + player1sTurn);
View Full Code Here

    {
        GoController controller = (GoController) viewer_.getController();
        if (controller.isProcessing()) {
            return;
        }
        Location loc = getRenderer().createLocation(e);

        if ( getRenderer().getDraggedShowPiece() != null ) {
            getRenderer().getDraggedShowPiece().setLocation( loc );
        }
        viewer_.refresh();
View Full Code Here

        PenteController controller = (PenteController) viewer.getController();

        if (controller.isProcessing() || controller.isDone())   {
            return;
        }
        Location loc = getRenderer().createLocation(e);

        PenteBoard board = (PenteBoard) controller.getBoard();

        // if there is already a piece where the user clicked or its
        // out of bounds, then return without doing anything
        BoardPosition p = board.getPosition( loc);
        if ( (p == null) || !p.isUnoccupied() )
            return;

        TwoPlayerMove m =
            TwoPlayerMove.createMove( loc.getRow(), loc.getCol(), 0,
                                      new GamePiece(controller.isPlayer1sTurn()));

        viewer.continuePlay( m );
    }
View Full Code Here

    /**
     * @return true of the {@link MoveList} contains the specified move.
     */
    private boolean contains(TwoPlayerMove move, MoveList moves) {
        for (Move m : moves) {
            Location moveLocation = ((TwoPlayerMove)m).getToLocation();
            if (moveLocation.equals(move.getToLocation())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

     * The pot will be drawn in the middle of the table.
     */
    @Override
    protected void drawMarkers(Board board, PlayerList players, Graphics2D g2  ) {

        Location loc = new ByteLocation(board.getNumRows() >> 1, (board.getNumCols() >> 1) - 3);
        int pot = ((PokerTable)board).getPotValue();
        new ChipRenderer().render(g2, loc, pot, this.getCellSize());

        // now draw the players and their stuff (face, name, chips, cards, etc)
        super.drawMarkers(board, players, g2);
View Full Code Here

    public static void initialize(String localeName, List<String> resourcePaths, ILog logger) {
        assert resourcePaths != null;
        assert logger != null;
        logger_ = logger;

        messageContext_ = new MessageContext(resourcePaths);
        messageContext_.setLogger(logger_);
        messageContext_.setDebugMode(debug_);
        messageContext_.setLocale(localeName);
    }
View Full Code Here

     * @return the cut points
     */
    public double[] getCutPoints(Range range, int maxNumTicks) {

        validateArguments(range);
        Range finalRange = new Range(range);
        if (range.getExtent() <= MIN_RANGE) {
            finalRange.add(range.getMin() + MIN_RANGE);
        }

        List<Double> positions = new ArrayList<Double>(10);

        if (finalRange.getExtent() < MIN_RANGE) {
            positions.add(finalRange.getMin());
        } else {
            determineCutPoints(maxNumTicks, finalRange, positions);
        }

        double[] result = new double[positions.size()];
View Full Code Here

    void determineCutPoints(int maxTicks, Range finalRange, List<Double> positions) {

        double extent = Rounder.round(finalRange.getExtent(), false);
        double d = Rounder.round(extent / (maxTicks - 1), true);
        Range roundedRange =
                new Range(Math.floor(finalRange.getMin() / d) * d, Math.ceil(finalRange.getMax() / d) * d);

        addPoints(positions, roundedRange, finalRange, d);
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.common.geometry.Location

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.