Package com.sgfj

Examples of com.sgfj.SGFNode


        kifu.prev(true);
        return true;
    }

    public boolean nextVariant() throws SGFPropertyNotFoundException, GameException {
        SGFNode node = kifu.nextVariant(false);
        if (node == null)
            return false;
        super.undo();
        try {
            try {
                SGFMove move = node.getMoveProperty();
                boardPlay(move, true);
            } catch (SGFPropertyNotFoundException e) {
                advance();
            }
            kifu.nextVariant(true);
View Full Code Here


        }
        return true;
    }

    public boolean prevVariant() throws SGFPropertyNotFoundException, GameException {
        SGFNode node = kifu.prevVariant(false);
        if (node == null)
            return false;
        super.undo();
        try {
            try {
                SGFMove move = node.getMoveProperty();
                boardPlay(move, true);
            } catch (SGFPropertyNotFoundException e) {
                advance();
            }
            kifu.prevVariant(true);
View Full Code Here

        if (!(viewMode && kifu.next(false) == null))
            return super.getFullMoveStatusText(nodeName);

        String docScore;
        SGFNode head = kifu.first(false);
        try {
            docScore = head.getProperty(SGFPropertyName.RE).getText();
        } catch (Exception e) {
            docScore = "end";
        }

        return getMoveStatusText(nodeName) + ": " + docScore;
View Full Code Here

                        getWit(sgfp).addMark(WIT.HOSHI);
                }
            setupCells = false;
        }

        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) {
            }
        }

        // mark last move (if not marked in props)
        if (game.lastMove >= 0) {
            SGFPoint sgfp = game.board.xy(game.lastMove);
            if (isInView(sgfp) && (getWit(sgfp).bits & WIT.PURE_MARK) == 0)
                getWit(sgfp).addMark(WIT.CIRCLE);
        }

        // mark next move (if not marked in props)
        if (showNextMove) {
            SGFNodeIterator i = lastMoveNode.iterator();
            if (i.next(true) != null) {
                try {
                    SGFMove m = i.current().getMoveProperty();
                    if (isInView(m) && (getWit(m).bits & WIT.PURE_MARK) == 0)
                        getWit(m).addMark(WIT.CIRCLE);
                } catch (SGFPropertyNotFoundException e) {
                    // DO NOTHING
                }
            }
        }

        // mark ko move (if not marked in props)
        if (game.koMove >= 0) {
            SGFPoint sgfp = game.board.xy(game.koMove);
            if (isInView(sgfp) && (getWit(sgfp).bits & WIT.PURE_MARK) == 0)
                getWit(sgfp).addMark(WIT.SQUARE);
        }

        // mark variations
        if (showVariants) {
            SGFNodeIterator i = lastMoveNode.iterator();
            i.firstVariant(true);
            do {
                SGFNode node = i.current();
                if (node != lastMoveNode)
                    try {
                        SGFMove m = node.getMoveProperty();
                        if (isInView(m))
                            getWit(m).addMark(WIT.VARIANT);
                    } catch (SGFPropertyNotFoundException e) {
                        // DO NOTHING
                    }
            } while (i.nextVariant(true) != null);
        }

        // mark hints
        if (showMoveHints) {
            SGFNodeIterator i = lastMoveNode.iterator();
            if (i.next(true) != null) {
                i.firstVariant(true);
                do {
                    SGFNode node = i.current();
                    try {
                        SGFMove m = node.getMoveProperty();
                        if (isInView(m)) {
                            if ((node.bits & SGFNode.GOOD_MOVE) != 0)
                                getWit(m).addMark(WIT.GOOD_MOVE);
                            else if ((node.bits & SGFNode.BAD_MOVE) != 0)
                                getWit(m).addMark(WIT.BAD_MOVE);
View Full Code Here

        if (showMoveStatus)
            moveStatus = game.getFullMoveStatusText();

        if (showMoveStatus && commentLines > 1 || commentLines > 0) {
            SGFNode node = game.kifuLastMove();

            drawSolvedFailedIndicator = showSolvedFailedIndicator;
            goodMove = (node.bits & SGFNode.GOOD_MOVE) != 0;
            drawColorToPlayIndicator = showColorToPlayIndicator;

            // show solve/fail indicator if
            // 1) it's visible
            // 2) it's last node
            //    or no hints for next node
            //    or first fail node we want to see immediately
            // else show color to play indicator

            if (drawSolvedFailedIndicator) {
                SGFNodeIterator nextMoves = node.iterator();
                int bits = 0;
                if (nextMoves.next(true) != null) {
                    nextMoves.firstVariant(true);
                    do {
                        bits |= nextMoves.current().bits;
                    } while (nextMoves.nextVariant(true) != null);
                }

                //#ifdef debug
                System.out.println("Next move bits: " + bits);
                //#endif
                drawSolvedFailedIndicator =
                       ((bits & (SGFNode.GOOD_MOVE | SGFNode.BAD_MOVE)) == 0)
                    || (showFailedImmediately && (bits & SGFNode.BAD_MOVE) != 0);
            }

            try {
                comment = node.getCommentProperty();
            } catch (SGFException e) {
                // DO NOTHING
            }
        }
View Full Code Here

                try {
                    StringBuffer sb = new StringBuffer();
                    InputStream is = fc.openInputStream();
                    InputStreamReader isr = new InputStreamReader(is);
                    SGFParser parser = new SGFParser(isr);
                    SGFNode head = parser.parseHead();
                    is.close();
                    for (Enumeration e = head.getProperties(); e.hasMoreElements(); ) {
                        sb.append(e.nextElement().toString());
                        sb.append("\n");
                    }
                    props.append(new StringItem(T._("SGF Header"), sb.toString()));
                } catch (Exception e) {
View Full Code Here

                try {
                    StringBuffer sb = new StringBuffer();
                    InputStream is = fc.openInputStream();
                    InputStreamReader isr = new InputStreamReader(is);
                    SGFParser parser = new SGFParser(isr);
                    SGFNode head = parser.parseHead();
                    is.close();
                    for (Enumeration e = head.getProperties(); e.hasMoreElements(); ) {
                        sb.append(e.nextElement().toString());
                        sb.append("\n");
                    }
                    props.append(new StringItem(T._("SGF Header"), sb.toString()));
                } catch (Exception e) {
View Full Code Here

    }

    public void setGame(DocumentedGame game) {
        this.game = game;

        SGFNode root = game.kifuHead();

        String s;
        try {
            s = root.getProperty(SGFPropertyName.PW).getText();
            try {
                s += " [" + root.getProperty(SGFPropertyName.WR).getText() + "]";
            } catch (SGFException e) {
            }
        } catch (SGFException e) {
            s = T._("White");
        }
        whitePlayerName.setText("W: " + s);

        try {
            s = root.getProperty(SGFPropertyName.PB).getText();
            try {
                s += " [" + root.getProperty(SGFPropertyName.BR).getText() + "]";
            } catch (SGFException e) {
            }
        } catch (SGFException e) {
            s = T._("Black");
        }
View Full Code Here

        }
        boolean doPass() {
            return false;
        }
        boolean doUndo() {
            SGFNode lastSetupNode = game.kifuFirstMove(true).iterator().prev(false);
            if (game.kifuLastMove() != lastSetupNode && game.prev()) {
                if (gobanCanvas.showMoveHints) {
                    setCursor(game.kifuLastMove().iterator().next(false));
                } else {
                    if (hasRespondMove && game.kifuLastMove() != lastSetupNode)
View Full Code Here

        blackPlayerName.setText("B: " + s);
    }

    public void setProblem(Problem problem, ProblemEnumeration problemEnum) {
        if (problem != null) {
            SGFNode root = game.kifuHead();
            String name, diff;
            try {
                name = root.getProperty(SGFPropertyName.GN).getText();
            } catch (SGFException e) {
                name = "??";
            }
            try {
                diff = root.getProperty(SGFPropertyName.DI).getText();
            } catch (SGFException e) {
                diff = "??";
            }
            int enSize = problemEnum.size();
            int enCurr = problemEnum.current();
View Full Code Here

TOP

Related Classes of com.sgfj.SGFNode

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.