Package org.antlr.works.visualization.graphics.primitive

Examples of org.antlr.works.visualization.graphics.primitive.GDimension


    public boolean containsPoint(Point p) {
        return context.objectContainsPoint(this, p);
    }

    private void cacheGlobalDimension(GContext context) {
        globalDimension = new GDimension();
        globalDimension.addWidth(nodeDimension.width+linkDimension.width);
        globalDimension.addUp(GLiteral.max(nodeDimension.up, linkDimension.up));
        globalDimension.addDown(GLiteral.max(nodeDimension.down, linkDimension.down));
        globalDimension.cache(context);
    }
View Full Code Here


    public void setVirtualPosition(GPoint position) {
        this.virtualPosition = new GPoint(position);
    }

    public void setBranchDimension(GDimension dimension) {
        this.branchDim = new GDimension(dimension);
    }
View Full Code Here

        // This point is used to position each transition
        GPoint point = new GPoint(basePoint);
        point.addX(GContext.NODE_WIDTH+GContext.EPSILON_WIDTH);

        GDimension firstAlternativeDimension = null;

        for(int t=0; t<state.getNumberOfTransitions(); t++) {
            FATransition transition = state.transition(t);
            GLink link = getNode(state).getLink(transition);
View Full Code Here

        analysis.analyze(state);
        return recursiveRenderSizeSingle(state, null);
    }

    public GDimension recursiveRenderSizeSingle(FAState state, FAState endState) {
        GDimension dimension = new GDimension();

        dimension.addUp(GContext.NODE_UP);
        dimension.addDown(GContext.NODE_DOWN);

        while(state != endState && state != null) {
            if(state.isAlternative()) {
                GDimension altDim = recursiveRenderSizeAlternative(state);
                dimension.addWidth(GContext.NODE_WIDTH+altDim.width);
                dimension.maxUp(altDim.up);
                dimension.maxDown(altDim.down);
                state = alternativeEndState(state);
            } else if(state.isSingle()) {
View Full Code Here

    public GDimension recursiveRenderSizeAlternative(FAState state) {
        FAState alternativeEndState = alternativeEndState(state);

        GNode norigin = createNode(state);

        GDimension dimension = norigin.linkDimension;
        dimension.addWidth(GContext.EPSILON_WIDTH);

        GDimension firstTransitionDimension = null;

        for(int t=0; t<state.getNumberOfTransitions(); t++) {
            FATransition transition = state.transition(t);

            GLink link = new GLink();
            link.transition = transition;
            link.target = createNode(transition.target);
            norigin.addLink(link);

            boolean last = t == state.getNumberOfTransitions()-1;
            if(t == state.getNumberOfTransitions()-2 && state.transition(t+1).loop) {
                // If the last alternative is a loop, consider the last-1 alternative as the last one:
                // the loop will be displayed above the first transition (up) in order to see it easily
                // from the other transition(s).
                last = true;
            }

            link.setLast(last);

            if(transition.target == alternativeEndState) {
                GDimension transitionDimension = new GDimension();
                transitionDimension.addUp(GContext.EPSILON_UP);
                transitionDimension.addDown(GContext.EPSILON_DOWN);
                if(transition.loop)
                    transitionDimension.addDown(GContext.LINE_SPACE);

                if(transition.loop) {
                    link.setBranchDimension(transitionDimension);
                    dimension.maxUp(firstTransitionDimension.up+transitionDimension.up+transitionDimension.down);
                } else {
                    link.setBranchDimension(transitionDimension);
                    if(t == 0) {
                        firstTransitionDimension = transitionDimension;                       
                    }
                    dimension.addDown(transitionDimension.up);
                    dimension.addDown(transitionDimension.down);
                }
            } else {
                endOfAlternativeInfoMap.put(alternativeEndState, new EOAInfo(last));
                GDimension transitionDimension = recursiveRenderSizeSingle(transition.target, alternativeEndState);

                if(((t > 0) || (t == 0 && !state.transition(1).loop)) && !last)
                    dimension.addDown(GContext.LINE_SPACE);

                link.setBranchDimension(transitionDimension);

                transitionDimension.addWidth(GContext.EPSILON_WIDTH);
                dimension.maxWidth(transitionDimension.width);
                if(t == 0) {
                    // Remember the size of the first transition
                    firstTransitionDimension = transitionDimension;
                    // Add its "up" size to the transition "up" size
View Full Code Here

    private boolean dimensionComputed = false;

    private void ensureDimension() {
        if(dimensionComputed) return;

        GDimension d = getDimension();
        for (int i = 0; i < graphs.size(); i++) {
            GGraph graph = graphs.get(i);
            d.maxWidth(graph.getDimension().width);
            d.addUp(graph.getDimension().up);
            d.addDown(graph.getDimension().down);
            if (i > 0) {
                d.addDown(GContext.LINE_SPACE);
            }
        }

        dimensionComputed = true;
    }
View Full Code Here

    public void setNodes(List<GNode> nodes) {
        this.nodes = nodes;
    }

    public GDimension getDimension() {
        GDimension d = new GDimension(dimension);
        if(context.isShowRuleName()) {
            d.addWidth(nameWidth);           
        }
        return d;
    }
View Full Code Here

TOP

Related Classes of org.antlr.works.visualization.graphics.primitive.GDimension

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.