Search in sources :

Example 1 with Node

use of catdata.mpl.MplStrict.Node in project fql by CategoricalData.

the class Mpl method doTermView.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static <O, A> JComponent doTermView(Color src, Color dst, Graph<Node<O, A>, Integer> sgv) {
    if (sgv.getVertexCount() == 0) {
        return new JPanel();
    }
    Layout layout = new FRLayout<>(sgv);
    layout.setSize(new Dimension(600, 400));
    VisualizationViewer vv = new VisualizationViewer<>(layout);
    Function<Node<O, A>, Color> vertexPaint = x -> {
        if (x.isInput) {
            return src;
        }
        return dst;
    };
    DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
    gm.setMode(Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    gm.setMode(Mode.PICKING);
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    Function<Node<O, A>, String> ttt = arg0 -> {
        String w = arg0.isInput ? "in" : "out";
        return arg0.term + " #" + arg0.which + " " + w;
    };
    vv.getRenderContext().setVertexLabelTransformer(ttt);
    vv.getRenderContext().setEdgeLabelTransformer(xx -> "");
    GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
    JPanel ret = new JPanel(new GridLayout(1, 1));
    ret.add(zzz);
    ret.setBorder(BorderFactory.createEtchedBorder());
    return ret;
}
Also used : Color(java.awt.Color) MplSym(catdata.mpl.Mpl.MplTerm.MplSym) MplPair(catdata.mpl.Mpl.MplTerm.MplPair) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) MplConst(catdata.mpl.Mpl.MplTerm.MplConst) MplId(catdata.mpl.Mpl.MplTerm.MplId) MplRho(catdata.mpl.Mpl.MplTerm.MplRho) MplUnit(catdata.mpl.Mpl.MplType.MplUnit) GridLayout(java.awt.GridLayout) Node(catdata.mpl.MplStrict.Node) MplComp(catdata.mpl.Mpl.MplTerm.MplComp) Map(java.util.Map) JTabbedPane(javax.swing.JTabbedPane) Graph(edu.uci.ics.jung.graph.Graph) MplSch(catdata.mpl.Mpl.MplExp.MplSch) LinkedList(java.util.LinkedList) Pair(catdata.Pair) JComponent(javax.swing.JComponent) MplProd(catdata.mpl.Mpl.MplType.MplProd) Layout(edu.uci.ics.jung.algorithms.layout.Layout) Function(com.google.common.base.Function) CodeTextPanel(catdata.ide.CodeTextPanel) MplAlpha(catdata.mpl.Mpl.MplTerm.MplAlpha) Util(catdata.Util) MplVar(catdata.mpl.Mpl.MplExp.MplVar) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) Unit(catdata.Unit) MplLambda(catdata.mpl.Mpl.MplTerm.MplLambda) MplTr(catdata.mpl.Mpl.MplTerm.MplTr) MplBase(catdata.mpl.Mpl.MplType.MplBase) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) List(java.util.List) MplEval(catdata.mpl.Mpl.MplExp.MplEval) Triple(catdata.Triple) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) JPanel(javax.swing.JPanel) Mode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode) JPanel(javax.swing.JPanel) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) Node(catdata.mpl.MplStrict.Node) Color(java.awt.Color) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) GridLayout(java.awt.GridLayout) GridLayout(java.awt.GridLayout) Layout(edu.uci.ics.jung.algorithms.layout.Layout) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer)

Aggregations

Pair (catdata.Pair)1 Triple (catdata.Triple)1 Unit (catdata.Unit)1 Util (catdata.Util)1 CodeTextPanel (catdata.ide.CodeTextPanel)1 MplEval (catdata.mpl.Mpl.MplExp.MplEval)1 MplSch (catdata.mpl.Mpl.MplExp.MplSch)1 MplVar (catdata.mpl.Mpl.MplExp.MplVar)1 MplAlpha (catdata.mpl.Mpl.MplTerm.MplAlpha)1 MplComp (catdata.mpl.Mpl.MplTerm.MplComp)1 MplConst (catdata.mpl.Mpl.MplTerm.MplConst)1 MplId (catdata.mpl.Mpl.MplTerm.MplId)1 MplLambda (catdata.mpl.Mpl.MplTerm.MplLambda)1 MplPair (catdata.mpl.Mpl.MplTerm.MplPair)1 MplRho (catdata.mpl.Mpl.MplTerm.MplRho)1 MplSym (catdata.mpl.Mpl.MplTerm.MplSym)1 MplTr (catdata.mpl.Mpl.MplTerm.MplTr)1 MplBase (catdata.mpl.Mpl.MplType.MplBase)1 MplProd (catdata.mpl.Mpl.MplType.MplProd)1 MplUnit (catdata.mpl.Mpl.MplType.MplUnit)1