Package com.barrybecker4.common.util

Examples of com.barrybecker4.common.util.Input


     */
    protected void parseSGFGameInfo( SGFGame game) {
        Enumeration e = game.getInfoTokens();
        int size = 13; // default unless specified
        while (e.hasMoreElements()) {
            InfoToken token = (InfoToken) e.nextElement();
            if (token instanceof SizeToken) {
                SizeToken sizeToken = (SizeToken)token;
                GameContext.log(2, "info token size ="+sizeToken.getSize());
                size = sizeToken.getSize();
            }
View Full Code Here


    {
        Enumeration trees = tree.getTrees();
        Enumeration leaves = tree.getLeaves();
        Enumeration tokens;
        while ( leaves != null && leaves.hasMoreElements() ) {
            SGFToken token;
            tokens = ((SGFLeaf) leaves.nextElement()).getTokens();

            boolean found = false;

            // While a move token hasn't been found, and there are more tokens to
View Full Code Here

        Enumeration e = game.getInfoTokens();
        int size = 13; // default unless specified
        while (e.hasMoreElements()) {
            InfoToken token = (InfoToken) e.nextElement();
            if (token instanceof SizeToken) {
                SizeToken sizeToken = (SizeToken)token;
                GameContext.log(2, "info token size ="+sizeToken.getSize());
                size = sizeToken.getSize();
            }
        }
        ((IRectangularBoard)controller_.getBoard()).setSize(size, size);
    }
View Full Code Here

    /**
     * create and show the server.
     */
    public static void main(String[] args) {

        CommandLineOptions options = new CommandLineOptions(args);

        if (verifyCmdLineOptions(options))  {
            String gameName = options.getValueForOption(GAME_OPTION);
            new OnlineGameServer(gameName, null);
        }
    }
View Full Code Here

    /**
     * create and show the server.
     */
    public static void main(String[] args) {

        CommandLineOptions options = new CommandLineOptions(args);

        if (OnlineGameServer.verifyCmdLineOptions(options)) {
            String gameName = options.getValueForOption(OnlineGameServer.GAME_OPTION);
            OnlineGameServerFrame frame = new OnlineGameServerFrame(gameName);
            frame.setVisible(true);
        }
    }
View Full Code Here

                token += ch;
            }
            else if (opDef.isOperator(ch)) {
                pushNodesForToken(token, nodes);
                token = "";
                nodes.add(new TreeNode(ch, opDef));
            }
            else {
                throw new Error("Unexpected character " + ch +" in expression: " + exp);
            }
            pos++;
View Full Code Here

    protected String processSubExpression(
        String exp, int pos, String token, int closingParenPos, List<TreeNode> nodes) {

        // recursive call for sub expression
        String subExp = exp.substring(pos, closingParenPos);
        TreeNode subTree = parse(subExp);
        subTree.hasParens = true;

        if (token != null && token.length() > 0) {
            // there was some leading token before the parenthesized expression.
            pushNodesForToken(token, nodes);
            token = "";
            nodes.add(new TreeNode(MathOperator.TIMES.getSymbol(), opDef));
        }
        else if (!nodes.isEmpty() && nodes.get(nodes.size() - 1).hasParens) {
            nodes.add(new TreeNode(MathOperator.TIMES.getSymbol(), opDef));
        }
        nodes.add(subTree);
        return token;
    }
View Full Code Here

        int len = token.length();
        if (token.charAt(len - 1) == 'x') {
            if (len > 1) {
                if (token.charAt(0) == MathOperator.MINUS.getSymbol()) {
                    nodes.add(new TreeNode("-1", opDef));
                }
                else {
                    nodes.add(getNodeForNumber(token.substring(0, len - 1)));
                }
                nodes.add(new TreeNode(MathOperator.TIMES.getSymbol(), opDef));
            }
            nodes.add(new TreeNode("x", opDef)); //NON-NLS
        }
        else {
            nodes.add(getNodeForNumber(token));
        }
    }
View Full Code Here

    private TreeNode getNodeForNumber(String token) {
        double num = Double.parseDouble(token);
        if (Double.isNaN(num)) {
            throw new IllegalStateException("Invalid number in expression: " + token);
        }
        return new TreeNode("" + num, opDef);
    }
View Full Code Here

     */
    public Location createLocation( MouseEvent e) {
        int size = Math.max(1, getCellSize());
        int row = (e.getY()- getMargin())/ size + 1;
        int col = (e.getX()- getMargin())/ size + 1;
        return new ByteLocation(row, col);
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.common.util.Input

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.