Package com.barrybecker4.common.geometry

Examples of com.barrybecker4.common.geometry.Location


    /**
     * 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 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

        currentLocation_.setLocation( currentLocation_.getX() + v.getX(),  currentLocation_.getY() + v.getY());

        // if the destination planet lies on the line from where we were to where we are now,
        // then we overshot. set the currentLocation to the destination planet location.
        Line2D.Double line = new Line2D.Double(oldLocation, currentLocation_);
        Location dLoc = destination_.getLocation();
        if (line.intersects(dLoc.getCol(),  dLoc.getRow(), INTERSECT_TOLERANCE, INTERSECT_TOLERANCE)) {
            currentLocation_.setLocation(dLoc.getCol(), dLoc.getRow());
            // the order never leaves once it has arrived. The order will be destroyed.
            hasArrived_ = true;
        }
    }
View Full Code Here

    /**
     * @return a unit vector pointing in the current direction of movement.
     */
    private Point2D getUnitDirection() {
        Location dLoc = destination_.getLocation();
        Point2D unitVec =
                new Point2D.Double(dLoc.getCol() - currentLocation_.getX(), dLoc.getRow() - currentLocation_.getY());
        double dist = unitVec.distance(new Point2D.Double(0, 0));
        unitVec.setLocation(unitVec.getX()/dist, unitVec.getY()/dist);
        return unitVec;
    }
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.