Package org.lilypondbeans.jccparser

Examples of org.lilypondbeans.jccparser.SimpleNode


    private void autoGenerateNodes() {
        generateNodesForBreak(0, true);
        Iterator<SimpleNode> it = score.getAllBreaks().iterator();
        while (it.hasNext()) {
            SimpleNode br = it.next();
            generateNodesForBreak(br.getBeattime(), false);
        }
    }
View Full Code Here


        maxX = 0;
        xpos.put(new Double(0), 0);
        int maxLeft = 0;
        long lastLineBreak = 0;
        for (int x = 0; x < allLayoutObjects.size(); x++) {
            SimpleNode nd = allLayoutObjects.get(x);

            //a new lineBreak is generated
            if (nd.id == ParserTreeConstants.JJTBAR && lastX - lastLineBreak > MAX_LINE_LEN) {
                lastLineBreak = lastX;
                score.registerBreak(nd);
                nd.setLayoutObject(LayoutObject.NULL_LAYOUT());
                nd.getlayoutObject().priority = 99;
                generateNodesForBreak(nd.getBeattime(),false);
                Collections.sort(allLayoutObjects);
                x--;
                continue;
            }
            if (nd.getBeattime() != lastBeattime || nd.getlayoutObject().priority != lastPriority) {
                maxLeft = nd.getlayoutObject().distanceLeft;//distanceLeft=maxLeft beacause ordering
                Integer intp = xpos.get(nd.getBeattime());
                if (intp == null) {
                    if (nd.id == ParserTreeConstants.JJTBAR) {
                        ((ASTBar) nd).unvisible = true;
                    } else {
                        new Exception("invalid beattime " + nd.toString());
                    }
                } else {
                    lastX = xpos.get(nd.getBeattime()) + maxLeft;
                }
                lastBeattime = nd.getBeattime();
                lastPriority = nd.getlayoutObject().priority;
            }
            //manuell linebreak -> count virtuell linebreaks from begin
            if (nd.id == ParserTreeConstants.JJTFUNCTION && nd.jjtGetFirstToken().kind == ParserConstants.break_) {
                lastLineBreak = lastX;
            }
            //register beattime for next group
            double newBeatTime = round(nd.getBeattime() + nd.duration);
            Integer oldPos = xpos.get(newBeatTime);
            int nextPos = lastX + nd.getlayoutObject().distanceRight;
            if (oldPos == null || nextPos > oldPos) {
                xpos.put(newBeatTime, nextPos);
            }
            nd.getlayoutObject().x = lastX;
            //move all higher registred positions if needed
            Iterator<Entry<Double, Integer>> itv = xpos.tailMap(newBeatTime, false).entrySet().iterator();
            int toMove = 0;
            while (itv.hasNext()) {
                Entry<Double, Integer> n = itv.next();
                int test = n.getValue() - nd.getlayoutObject().x;
                if (test <= toMove) {
                    toMove = -test;
                }
                if (toMove > 0) {
                    n.setValue(n.getValue() + toMove + 5);//5 -> should not stand on the same position like node
View Full Code Here

    }

    public SimpleNode getElementAtPoint(int x, int y) {
        //
        double best = 10000000;//getDiff(x, y, bestOf);
        SimpleNode ret = null;
        for (SimpleNode test : allLayoutObjects) {
            double diff = getDiff(x, y, test);
            if (diff < best) {
                ret = test;
                best = diff;
View Full Code Here

    public void setBuffer(String buffer) {
        this.buffer = buffer;
    }

    public void gotoUp() {
        SimpleNode el = UpdateNodeTask.getInstance().getLastCurrent();
        if (el.jjtGetParent().id == ParserTreeConstants.JJTCHORD && el.id == ParserTreeConstants.JJTPITCH) {
            ASTChord chord = (ASTChord) el.jjtGetParent();//ignore others in same chord
            SimpleNode ret = ((ASTChord) el.jjtGetParent()).getHigherPitch((ASTPitch) el);
            if (ret != null) {
                NetbeansTextEditor.getInstance().selectPosition(ret);
                return;
            } else {
                el = el.jjtGetParent();
View Full Code Here

    /* private void selectNext(ASTContext parent, int x) {
    selectNext(parent,x,-1);
    }*/
    private void selectNext(ASTContext parent, int x, int line, boolean onlyPitches) {
        int best = Integer.MAX_VALUE;
        SimpleNode found = null;
        ASTScore score = ((ASTScore) parent.getContext(ASTContext.TYPE_SCORE));
        Iterator<SimpleNode> it = score.layoutCalculator.getAllLayoutObjects().iterator();
        while (it.hasNext()) {
            SimpleNode nd = it.next();
            if (nd.getParentContext() == parent
                    && nd.getlayoutObject() != null
                    && nd.getlayoutObject().centre != null
                    && Math.abs(nd.getlayoutObject().centre.getX() - x) < best
                    && (line == -1 || score.layoutCalculator.getLine(nd) == line)
                    && (!onlyPitches || nd.id == ParserTreeConstants.JJTPITCH)) {
                best = Math.abs((int) nd.getlayoutObject().centre.getX() - x);
                found = nd;
            }
        }
        if (found != null) {
            NetbeansTextEditor.getInstance().selectPosition(found);
View Full Code Here

            NetbeansTextEditor.getInstance().selectPosition(found);
        }
    }

    public void gotoDown() {
        SimpleNode el = UpdateNodeTask.getInstance().getLastCurrent();
        if (el.jjtGetParent().id == ParserTreeConstants.JJTCHORD && el.id == ParserTreeConstants.JJTPITCH) {
            ASTChord chord = (ASTChord) el.jjtGetParent();//ignore others in same chord
            SimpleNode ret = ((ASTChord) el.jjtGetParent()).getLowerPitch((ASTPitch) el);
            if (ret != null) {
                NetbeansTextEditor.getInstance().selectPosition(ret);
                return;
            } else {
                el = el.jjtGetParent();
View Full Code Here

    public static SimpleNode getNext(SimpleNode el) {
        if (el.jjtGetParent().id == ParserTreeConstants.JJTCHORD) {
            el = el.jjtGetParent();//ignore others in same chord
        }
        ASTContext voice = el.getParentContext().getContext(ASTContext.TYPE_VOICE);
        SimpleNode next = el;
        while (next.id != ParserTreeConstants.JJTPITCH || next.getBeattime() <= el.getBeattime()) {
            next = voice.findNext(next);
            if (next == null) {
                return null;
            }
        }
        if (next.jjtGetParent().id == ParserTreeConstants.JJTCHORD) {
            return ((ASTChord) next.jjtGetParent()).getHighestPitch();
        }
        return next;//im nächsten weitersuchen?
    }
View Full Code Here

        }
        ASTContext voice = el.getParentContext().getContext(ASTContext.TYPE_VOICE);
        if (voice == null) {
            return null;
        }
        SimpleNode next = el;
        while (next.id != ParserTreeConstants.JJTPITCH || next.getBeattime() >= el.getBeattime()) {
            next = voice.findPrev(next);
            if (next == null) {
                return null;
            }
        }
        if (next.jjtGetParent().id == ParserTreeConstants.JJTCHORD) {
            return ((ASTChord) next.jjtGetParent()).getHighestPitch();
        }
        return next;//im nächsten weitersuchen?
    }
View Full Code Here

    public void gotoPrev() {
        NetbeansTextEditor.getInstance().selectPosition(getPrev(UpdateNodeTask.getInstance().getLastCurrent()));
    }

    public void oktaveUp() {
        SimpleNode el = UpdateNodeTask.getInstance().getLastCurrent();
        if (el == null || el.id != ParserTreeConstants.JJTPITCH) {
            return;
        }
        ASTPitch pitch = (ASTPitch) el;
        pitch.octave++;
View Full Code Here

            double cur = map.next();
            NodeVector<SimpleNode> v = beattimeToPositions.get(cur);
            Iterator<SimpleNode> it = v.iterator();
            boolean canRemove = true;//Pausen am Ende können entfernt werden
            while (it.hasNext()) {
                SimpleNode next = it.next();
                if (next.duration > 0) {
                    if (next.id == ParserTreeConstants.JJTPITCH && ((ASTPitch) next).isBreake())
                        ; else {
                        canRemove = false;
                        break;
View Full Code Here

TOP

Related Classes of org.lilypondbeans.jccparser.SimpleNode

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.