Package com.sgfj

Examples of com.sgfj.SGFProperty


        try {
            SGFParser reader = new SGFParser(jagoData);
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            SGFProperty p;
            p = tree.getProperty(SGFPropertyName.FF);
            assertEquals(4, p.getInt());

        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
View Full Code Here


    }

    public void testGetProperty() {
        try {
            setUp();
            SGFProperty prop = tree.getProperty(SGFPropertyName.SZ);
            assertEquals(SGFPropertyName.SZ, prop.name());
            assertEquals(19, prop.getInt());

            prop = tree.getProperty("SZ".toCharArray());
            assertEquals(SGFPropertyName.SZ, prop.name());
            assertEquals(19, prop.getInt());

            prop = tree.getProperty(23123);
            assertEquals(SGFPropertyName.SZ, prop.name());
            assertEquals(19, prop.getInt());
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

    protected void playNodeProperties() throws GameOverStoneException {
        SGFNode node = kifu.current();

        for (Enumeration e = node.getProperties(); e.hasMoreElements(); ) {
            SGFProperty prop = (SGFProperty) e.nextElement();
            try {
                if (prop.name() == SGFPropertyName.PL) {
                    char[] t = prop.getText().toCharArray();
                    switch (t[0]) {
                    case 'B':
                    case '1':
                        colorToPlay = Board.BLACK;
                        break;
                    case 'W':
                    case '2':
                        colorToPlay = Board.WHITE;
                        break;
                    }
                } else if (prop.name() == SGFPropertyName.AW) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.WHITE);
                } else if (prop.name() == SGFPropertyName.AB) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.BLACK);
                } else if (prop.name() == SGFPropertyName.AE) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.NONE);
                }
            } catch (SGFInvalidDataRequestException e1) {
                // DO NOTHING
View Full Code Here

        SGFNode lastMoveNode = game.kifuLastMove();

        // draw marks from properties
        for (Enumeration e = lastMoveNode.getProperties(); e.hasMoreElements(); ) {
            SGFProperty prop = (SGFProperty) e.nextElement();
            try {
                SGFPoint sgfp = prop.getPoint();
                if (isInView(sgfp)) {
                    WIT wit = getWit(sgfp);
                    if (prop.name() == SGFPropertyName.TR)
                        wit.addMark(WIT.TRIANGLE);
                    else if (prop.name() == SGFPropertyName.SQ)
                        wit.addMark(WIT.SQUARE);
                    else if (prop.name() == SGFPropertyName.CR)
                        wit.addMark(WIT.CIRCLE);
                    else if (prop.name() == SGFPropertyName.MA)
                        wit.addMark(WIT.CROSS);
                    else if (prop.name() == SGFPropertyName.SL)
                        wit.addMark(WIT.SELECTED);
                    else if (prop.name() == SGFPropertyName.DD)
                        wit.addMark(WIT.DIMMED);
                    else if (prop.name() == SGFPropertyName.TW)
                        wit.addMark(WIT.WHITE_TER);
                    else if (prop.name() == SGFPropertyName.TB)
                        wit.addMark(WIT.BLACK_TER);
                    else if (prop.name() == SGFPropertyName.LB)
                        wit.setLabel(prop.getText());
                    else if (prop.name() == SGFPropertyName.VW)
                        wit.addMark(WIT.VIEW);
                }
            } catch (SGFInvalidDataRequestException e1) {
            }
        }
View Full Code Here

        SGFNode root = game.kifuHead();
        SGFNode node = game.kifuLastMove();

        StringBuffer sb = new StringBuffer();
        for (Enumeration e = root.getProperties(); e.hasMoreElements(); ) {
            SGFProperty p = (SGFProperty) e.nextElement();
            sb.append(p.toString());
            sb.append("\n");
        }
        sgfRootProps.setText(sb.toString());

        sb.setLength(0);
        if (node != root)
            for (Enumeration e = node.getProperties(); e.hasMoreElements(); ) {
                SGFProperty p = (SGFProperty) e.nextElement();
                sb.append(p.toString());
                sb.append("\n");
            }
        sgfNodeProps.setText(sb.toString());

        display.setCurrent(sgfPropsForm);
View Full Code Here

        StringBuffer sb = new StringBuffer();

        SGFNode root = game.kifuHead();

        for (Enumeration e = root.getProperties(); e.hasMoreElements(); ) {
            SGFProperty p = (SGFProperty) e.nextElement();
            // skip point and comment properties in this screen
            if (!p.name().hasPoint() && p.name() != SGFPropertyName.C) {
                sb.append(p.toString());
                sb.append("\n");
            }
        }

        infoText.setText(sb.toString());
View Full Code Here

        SGFNode lastMoveNode = game.kifuLastMove();

        // draw marks from properties
        for (Enumeration e = lastMoveNode.getProperties(); e.hasMoreElements(); ) {
            SGFProperty prop = (SGFProperty) e.nextElement();
            try {
                SGFPoint sgfp = prop.getPoint();
                if (isInView(sgfp)) {
                    WIT wit = getWit(sgfp);
                    if (prop.name() == SGFPropertyName.TR)
                        wit.addMark(WIT.TRIANGLE);
                    else if (prop.name() == SGFPropertyName.SQ)
                        wit.addMark(WIT.SQUARE);
                    else if (prop.name() == SGFPropertyName.CR)
                        wit.addMark(WIT.CIRCLE);
                    else if (prop.name() == SGFPropertyName.MA)
                        wit.addMark(WIT.CROSS);
                    else if (prop.name() == SGFPropertyName.SL)
                        wit.addMark(WIT.SELECTED);
                    else if (prop.name() == SGFPropertyName.DD)
                        wit.addMark(WIT.DIMMED);
                    else if (prop.name() == SGFPropertyName.TW)
                        wit.addMark(WIT.WHITE_TER);
                    else if (prop.name() == SGFPropertyName.TB)
                        wit.addMark(WIT.BLACK_TER);
                    else if (prop.name() == SGFPropertyName.LB)
                        wit.setLabel(prop.getText());
                    else if (prop.name() == SGFPropertyName.VW)
                        wit.addMark(WIT.VIEW);
                }
            } catch (SGFInvalidDataRequestException e1) {
            }
        }
View Full Code Here

TOP

Related Classes of com.sgfj.SGFProperty

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.