Examples of GContext


Examples of org.antlr.works.visualization.graphics.GContext

import java.awt.*;

public class NFANode {

    public static void draw(GNode node) {
        GContext context = node.getContext();
        context.setColor(context.nodeColor);
        float r = context.getPixelNodeWidth()/2;
        context.drawCircle(node.getX()+r, node.getY(), r, true);
        context.drawString(context.getBoxFont(), node.state.toString(), node.getX()+r, node.getY(), GContext.ALIGN_CENTER);
    }
View Full Code Here

Examples of org.antlr.works.visualization.graphics.GContext

import java.awt.*;

public class NFALink {

    public static void draw(GLink link) {
        GContext context = link.getContext();
       
        float sx = link.source.getX()+context.getPixelNodeWidth()/2;
        float sy = link.source.getY();

        float tx = link.target.getX()+context.getPixelNodeWidth()/2;
        float ty = link.target.getY();

        float startOffset = context.getPixelNodeWidth()/2;
        float endOffset = startOffset;

        float sloopBaseWidth = context.getPixelValue(GContext.EPSILON_WIDTH);

        context.setColor(context.linkColor);

        if(link.virtualPosition != null) {
            context.drawArcConnector(sx+(tx-sx)/2, link.getVirtualY(), sx, sy, startOffset, endOffset,
                    sloopBaseWidth, 0.25f*sloopBaseWidth, link.transition.loop);
            context.drawArcConnector(sx+(tx-sx)/2, link.getVirtualY(), tx, ty, startOffset, endOffset,
                    sloopBaseWidth, 0.25f*sloopBaseWidth, !link.transition.loop);
        } else if(sy > ty) {
            // Draw link upward
            if((tx-sx>sloopBaseWidth+startOffset+0.25f*sloopBaseWidth) && sloopBaseWidth>0) {
                context.drawArcConnector(sx, sy, tx, ty, startOffset, endOffset,
                        sloopBaseWidth, 0.25f*sloopBaseWidth, true);
            } else {
                context.drawSpline(sx, sy, tx, ty, startOffset, endOffset, 0, true);
            }
        } else {
            context.drawSpline(sx, sy, tx, ty, startOffset, endOffset, 0, true);
        }

        if(!link.transition.isEpsilon()) {
            Font font;
            if(link.transition.externalRuleRef)
                font = context.getRuleFont();
            else
                font = context.getBoxFont();

            context.setColor(context.getColorForLabel(link.transition.label));           
            context.drawString(font, link.transition.label, sx+(tx-sx)/2, sy-2, GContext.ALIGN_CENTER_UP);
        }
    }
View Full Code Here

Examples of org.antlr.works.visualization.graphics.GContext

import java.awt.*;

public class SDLink {

    public static boolean linkContainsPoint(GLink link, Point p) {
        GContext context = link.getContext();
        float ox = link.source.getX();
        float oy = link.source.getY();
        float width = link.source.linkDimension.getPixelWidth(context);

        return p.x>=ox && p.x<=ox+width &&
                p.y>=oy-context.getPixelBoxDown() && p.y<=oy+context.getPixelBoxDown()+context.getPixelBoxUp();
    }
View Full Code Here

Examples of org.antlr.works.visualization.graphics.GContext

        return p.x>=ox && p.x<=ox+width &&
                p.y>=oy-context.getPixelBoxDown() && p.y<=oy+context.getPixelBoxDown()+context.getPixelBoxUp();
    }

    public static void draw(GLink link) {
        GContext context = link.getContext();

        float sx = link.source.getX();
        float sy = link.source.getY();

        float tx = link.target.getX();
        float ty = link.target.getY();

        float sloopBaseWidth = context.getPixelValue(GContext.EPSILON_WIDTH);

        context.setColor(context.linkColor);

        if(link.transition.isEpsilon()) {
            if(link.virtualPosition != null) {
                drawDownSloop(context, link, sx, sy, sx+sloopBaseWidth, link.getVirtualY());
                context.drawLine(sx+sloopBaseWidth, link.getVirtualY(), tx-sloopBaseWidth, link.getVirtualY());
                drawUpSloop(context, link, tx-sloopBaseWidth, link.getVirtualY(), tx, ty);
            } else if(sy > ty) {
                // Draw link upward
                if((tx-sx>sloopBaseWidth) && sloopBaseWidth>0) {
                    context.drawLine(sx, sy, tx-sloopBaseWidth, sy);
                    drawUpSloop(context, link, tx-sloopBaseWidth, sy, tx, ty);
                } else
                    drawUpSloop(context, link, sx, sy, tx, ty);
            } else if(ty > sy) {
                // Draw link downward
                drawDownSloop(context, link, sx, sy, tx, ty);
            } else {
                // Single horizontal link
                context.drawLine(sx, sy, tx, ty);

                // Draw an arrow if the link's target is the last node of the rule
                if(link.target.lastNodeOfRule)
                    context.drawRightArrow(tx, ty, context.getPixelArrowWidth(), context.getPixelArrowHeight());
            }

        } else {
            drawBox(context, link);
        }
View Full Code Here

Examples of org.antlr.works.visualization.graphics.GContext

            return;

        try {
            GEnginePS engine = new GEnginePS();

            GContext context = graph.getContext();
            GEngine oldEngine = context.engine;
            context.setEngine(engine);
            graph.draw();
            context.setEngine(oldEngine);

            XJUtils.writeStringToFile(engine.getPSText(), file);
        } catch (Exception e) {
            window.consoleTab.println(e);
            XJAlert.display(window.getJavaContainer(), "Error", "Cannot export to EPS file: "+file+"\nError: "+e);
View Full Code Here

Examples of org.antlr.works.visualization.graphics.GContext

    public SyntaxDiagramTab(GrammarWindow editor) {
        super(editor);

        skin = new SDSkin();

        context = new GContext();
        context.setEngine(new GEngineGraphics());
        context.setSkin(skin);
        context.setProvider(this);

        panel = new GPanel(editor, context);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.