Package com.barrybecker4.game.twoplayer.go.board.elements.position

Examples of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition


                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 void render(Graphics2D g2, TilePlacement tilePlacement,
                       Location topLeftCorner, double radius) {

        if (tilePlacement == null) return;
        boolean isOddRow = tilePlacement.getLocation().getRow() % 2 == 1;
        Location location =
            tilePlacement.getLocation().decrementOnCopy(topLeftCorner);

        double x = radius/2
                + ((location.getCol() - (isOddRow ? -0.25:  -0.75)) * 2 * radius * HexUtil.ROOT3D2);
        double y = radius/+ TOP_MARGIN
                + ((location.getRow() + 0.6) * 3.0 * radius / 2.0);

        Point point = new Point((int)x, (int)y);
        drawHexagon(g2, point, radius);
        pathRenderer.drawPath(g2, 0, tilePlacement, point, radius);
        pathRenderer.drawPath(g2, 1, tilePlacement, point, radius);
View Full Code Here

        hexRadius = (1.0 - MARGIN_FRAC) * minEdge / (board.getEdgeLength() * ROOT3 * .9);

        setHints(g2);
        drawGrid(g2, board);

        Location topLeftCorner = board.getBoundingBox().getTopLeftCorner();

        for (Location loc : board.getTantrixLocations()) {
            TilePlacement placement = board.getTilePlacement(loc);
            tileRenderer.render(g2, placement, topLeftCorner, hexRadius);
        }
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

     * Constructor.
     * @param func the array representing function values.
     * @param interpMethod method to use when interpolating
     */
    private ArrayFunction(double[] func, InterpolationMethod interpMethod) {
        this(func, new FunctionInverter(func).createInverseFunction(new Range(0, 1.0)), interpMethod);
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition

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.