Search in sources :

Example 11 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class SqlLoader method showLoader.

public static void showLoader() {
    CodeTextPanel output = new CodeTextPanel(BorderFactory.createEtchedBorder(), "Response", "");
    SqlLoader input = new SqlLoader(output, "");
    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    jsp.setBorder(BorderFactory.createEmptyBorder());
    jsp.setDividerSize(4);
    jsp.setResizeWeight(0.5d);
    jsp.add(input);
    jsp.add(output);
    JPanel ret = new JPanel(new GridLayout(1, 1));
    ret.add(jsp);
    GuiUtil.show(ret, 700, 600, "SQL Loader");
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) CodeTextPanel(catdata.ide.CodeTextPanel) JSplitPane(javax.swing.JSplitPane)

Example 12 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class FqlppDisplay method makeFnViewer.

private static JComponent makeFnViewer(Fn cat, Color src, Color dst) {
    Graph<Pair<String, Color>, Integer> g = buildFromFn(cat, src, dst);
    if (g.getVertexCount() == 0) {
        return new JPanel();
    } else if (g.getVertexCount() > DefunctGlobalOptions.debug.fqlpp.MAX_NODES) {
        CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getVertexCount() + " nodes, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_NODES);
        JPanel ret = new JPanel(new GridLayout(1, 1));
        ret.add(xxx);
        return ret;
    } else if (g.getEdgeCount() > DefunctGlobalOptions.debug.fqlpp.MAX_EDGES) {
        CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getEdgeCount() + " edges, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_EDGES);
        JPanel ret = new JPanel(new GridLayout(1, 1));
        ret.add(xxx);
        return ret;
    }
    return doFnView(g);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) CodeTextPanel(catdata.ide.CodeTextPanel) Pair(catdata.Pair)

Example 13 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class FqlppDisplay method showFtr.

@SuppressWarnings("unchecked")
private JPanel showFtr(Functor view, Color c, @SuppressWarnings("unused") FunctorExp e) {
    JTabbedPane px = new JTabbedPane();
    if (view.source.isInfinite()) {
        CodeTextPanel p = new CodeTextPanel(BorderFactory.createEtchedBorder(), null, "Cannot display functors from " + view.source);
        px.add("Text", p);
        JPanel top = new JPanel(new GridLayout(1, 1));
        top.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        top.add(px);
        return top;
    }
    Signature<String, String> src_sig = null;
    Signature<String, String> dst_sig = null;
    String src_key = unr(env.cats, view.source, null);
    if (src_key != null) {
        CatExp r = CatOps.resolve(prog, prog.cats.get(src_key));
        if (r instanceof Const) {
            Const sig0 = (Const) r;
            src_sig = new Signature<>(sig0.nodes, sig0.arrows, sig0.eqs);
        }
    }
    String dst_key = unr(env.cats, view.target, null);
    if (dst_key != null) {
        CatExp r = CatOps.resolve(prog, prog.cats.get(dst_key));
        if (r instanceof Const) {
            Const sig0 = (Const) r;
            dst_sig = new Signature<>(sig0.nodes, sig0.arrows, sig0.eqs);
        }
    }
    if (src_sig != null && FinSet.FinSet.equals(view.target)) {
        if (DefunctGlobalOptions.debug.fqlpp.ftr_instance) {
            JPanel vwr = new JPanel(new GridLayout(1, 1));
            if (view.source.objects().isEmpty()) {
                px.add("Instance", vwr);
            } else {
                JComponent zzz = doFNView2(view, vwr, c, buildFromSig(src_sig), src_sig);
                JSplitPane newthing = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
                newthing.setResizeWeight(.5d);
                newthing.add(zzz);
                newthing.add(vwr);
                JPanel xxx = new JPanel(new GridLayout(1, 1));
                xxx.add(newthing);
                px.add("Instance", xxx);
            }
        }
        if (DefunctGlobalOptions.debug.fqlpp.ftr_joined) {
            // cast needed for javac for some reason
            px.add("Joined", (Component) makeJoined(src_sig, view).first);
        }
        if (DefunctGlobalOptions.debug.fqlpp.ftr_elements) {
            Graph g = buildElements(src_sig, view);
            if (g.getVertexCount() == 0) {
                px.add("Elements", new JPanel());
            } else if (g.getVertexCount() > DefunctGlobalOptions.debug.fqlpp.MAX_NODES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getVertexCount() + " nodes, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_NODES);
                px.add("Elements", xxx);
            } else if (g.getEdgeCount() > DefunctGlobalOptions.debug.fqlpp.MAX_EDGES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getEdgeCount() + " edges, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_EDGES);
                px.add("Elements", xxx);
            } else {
                px.add("Elements", doElementsView(c, g));
            }
        }
    }
    if (src_sig != null && dst_sig != null && !view.source.isInfinite() && !view.target.isInfinite()) {
        // JPanel vwr = new JPanel(new GridLayout(1, 1));
        if (DefunctGlobalOptions.debug.fqlpp.ftr_mapping) {
            Graph g = buildMapping(src_sig, dst_sig, view);
            if (g.getVertexCount() == 0) {
                px.add("Mapping", new JPanel());
            } else if (g.getVertexCount() > DefunctGlobalOptions.debug.fqlpp.MAX_NODES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getVertexCount() + " nodes, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_NODES);
                px.add("Mapping", xxx);
            } else if (g.getEdgeCount() > DefunctGlobalOptions.debug.fqlpp.MAX_EDGES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getEdgeCount() + " edges, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_EDGES);
                px.add("Mapping", xxx);
            } else {
                JComponent zzz = doMappingView(c, getColor(view.target), g);
                JPanel xxx = new JPanel(new GridLayout(1, 1));
                xxx.add(zzz);
                px.add("Mapping", xxx);
            }
        }
    }
    if (DefunctGlobalOptions.debug.fqlpp.ftr_graph) {
        JPanel vwr = new JPanel(new GridLayout(1, 1));
        Graph g = buildFromCat(view.source);
        if (view.source.objects().isEmpty()) {
            px.add("Graph", vwr);
        } else if (g.getVertexCount() > DefunctGlobalOptions.debug.fqlpp.MAX_NODES) {
            CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getVertexCount() + " nodes, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_NODES);
            px.add("Graph", xxx);
        } else if (g.getEdgeCount() > DefunctGlobalOptions.debug.fqlpp.MAX_EDGES) {
            CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getEdgeCount() + " edges, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_EDGES);
            px.add("Graph", xxx);
        } else {
            JComponent zzz = doFNView(view, vwr, c, g);
            JSplitPane newthing = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            newthing.setResizeWeight(.5d);
            newthing.add(zzz);
            newthing.add(vwr);
            JPanel xxx = new JPanel(new GridLayout(1, 1));
            xxx.add(newthing);
            px.add("Graph", xxx);
        }
    }
    if (DefunctGlobalOptions.debug.fqlpp.ftr_tabular) {
        List<JComponent> gp = new LinkedList<>();
        // JPanel gp = new JPanel(new GridLayout(2, 1));
        Object[][] rowData = new Object[view.source.objects().size()][2];
        int i = 0;
        for (Object o : view.source.objects()) {
            rowData[i][0] = Util.nice(o.toString());
            rowData[i][1] = Util.nice(view.applyO(o).toString());
            i++;
        }
        Object[] colNames = new Object[] { "Input", "Output" };
        JPanel gp1 = GuiUtil.makeTable(BorderFactory.createEtchedBorder(), "On Objects (" + view.source.objects().size() + ")", rowData, colNames);
        Object[][] rowData2 = new Object[view.source.arrows().size()][6];
        i = 0;
        for (Object o : view.source.arrows()) {
            rowData2[i][0] = Util.nice(o.toString());
            rowData2[i][1] = Util.nice(view.source.source(o).toString());
            rowData2[i][2] = Util.nice(view.source.target(o).toString());
            rowData2[i][3] = Util.nice(view.applyA(o).toString());
            rowData2[i][4] = Util.nice(view.target.source(view.applyA(o)).toString());
            rowData2[i][5] = Util.nice(view.target.target(view.applyA(o)).toString());
            i++;
        }
        Object[] colNames2 = new Object[] { "Input", "Source", "Target", "Output", "Source", "Target" };
        JPanel gp2 = GuiUtil.makeTable(BorderFactory.createEtchedBorder(), "On Arrows (" + view.source.arrows().size() + ")", rowData2, colNames2);
        gp.add(gp1);
        gp.add(gp2);
        px.add("Table", GuiUtil.makeGrid(gp));
    }
    if (DefunctGlobalOptions.debug.fqlpp.ftr_textual) {
        CodeTextPanel gp = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", Util.nice(view.toString()));
        px.add("Text", gp);
    }
    JPanel top = new JPanel(new GridLayout(1, 1));
    top.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    top.add(px);
    return top;
}
Also used : JPanel(javax.swing.JPanel) JTabbedPane(javax.swing.JTabbedPane) Const(catdata.fqlpp.CatExp.Const) JComponent(javax.swing.JComponent) LinkedList(java.util.LinkedList) Paint(java.awt.Paint) GridLayout(java.awt.GridLayout) Graph(edu.uci.ics.jung.graph.Graph) CodeTextPanel(catdata.ide.CodeTextPanel) JSplitPane(javax.swing.JSplitPane)

Example 14 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class FqlppDisplay method showFn.

@SuppressWarnings("unchecked")
private JPanel showFn(Fn view, Color src, Color dst) {
    JTabbedPane px = new JTabbedPane();
    if (DefunctGlobalOptions.debug.fqlpp.fn_graph) {
        JComponent gp = makeFnViewer(view, src, dst);
        px.add("Graph", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.fn_tabular) {
        Object[][] rowData = new Object[view.source.size()][2];
        int i = 0;
        for (Object o : view.source) {
            rowData[i][0] = Util.nice(o.toString());
            rowData[i][1] = Util.nice(view.apply(o).toString());
            i++;
        }
        Object[] colNames = new Object[] { unr(env.sets, view.source, "..."), unr(env.sets, view.target, "...") };
        JPanel gp = GuiUtil.makeTable(BorderFactory.createEtchedBorder(), view.source.size() + " elements in domain, " + view.target.size() + " elements in codomain", rowData, colNames);
        px.add("Table", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.fn_textual) {
        CodeTextPanel gp = new CodeTextPanel(BorderFactory.createEtchedBorder(), view.source.size() + " elements in domain, " + view.target.size() + " elements in codomain", Util.nice(view.toStringLong()));
        px.add("Text", gp);
    }
    JPanel top = new JPanel(new GridLayout(1, 1));
    top.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    top.add(px);
    return top;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane) JComponent(javax.swing.JComponent) Paint(java.awt.Paint)

Example 15 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class FqlppDisplay method showCat.

private JPanel showCat(Category<?, ?> view, Color c) {
    JTabbedPane px = new JTabbedPane();
    Signature<String, String> sig = null;
    String key = unr(env.cats, view, null);
    if (key != null) {
        CatExp r = CatOps.resolve(prog, prog.cats.get(key));
        if (r instanceof Const) {
            Const sig0 = (Const) r;
            sig = new Signature<>(sig0.nodes, sig0.arrows, sig0.eqs);
        }
    }
    if (sig != null && !view.isInfinite()) {
        if (DefunctGlobalOptions.debug.fqlpp.cat_schema) {
            Graph g = buildFromSig(sig);
            if (g.getVertexCount() == 0) {
                px.add("Schema", new JPanel());
            } else if (g.getVertexCount() > DefunctGlobalOptions.debug.fqlpp.MAX_NODES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getVertexCount() + " nodes, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_NODES);
                px.add("Schema", xxx);
            } else if (g.getEdgeCount() > DefunctGlobalOptions.debug.fqlpp.MAX_EDGES) {
                CodeTextPanel xxx = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "Graph has " + g.getEdgeCount() + " edges, which exceeds limit of " + DefunctGlobalOptions.debug.fqlpp.MAX_EDGES);
                px.add("Schema", xxx);
            } else {
                px.add("Schema", doSchemaView(c, g));
            }
        }
    }
    if (DefunctGlobalOptions.debug.fqlpp.cat_graph && !view.isInfinite()) {
        JComponent gp = makeCatViewer(view, c);
        px.add("Graph", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.cat_tabular && !view.isInfinite()) {
        JPanel gp = catTable(view);
        px.add("Table", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.cat_textual) {
        CodeTextPanel gp = new CodeTextPanel(BorderFactory.createEtchedBorder(), null, Util.nice(view.toString()));
        px.add("Text", gp);
    }
    JPanel top = new JPanel(new GridLayout(1, 1));
    top.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    top.add(px);
    return top;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) Graph(edu.uci.ics.jung.graph.Graph) CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane) Const(catdata.fqlpp.CatExp.Const) JComponent(javax.swing.JComponent)

Aggregations

CodeTextPanel (catdata.ide.CodeTextPanel)31 JTabbedPane (javax.swing.JTabbedPane)19 JPanel (javax.swing.JPanel)18 GridLayout (java.awt.GridLayout)17 LinkedList (java.util.LinkedList)11 JComponent (javax.swing.JComponent)11 Paint (java.awt.Paint)10 List (java.util.List)9 Graph (edu.uci.ics.jung.graph.Graph)7 HashMap (java.util.HashMap)7 JSplitPane (javax.swing.JSplitPane)7 Pair (catdata.Pair)6 Unit (catdata.Unit)5 Const (catdata.fqlpp.CatExp.Const)5 Map (java.util.Map)5 Set (java.util.Set)5 JButton (javax.swing.JButton)5 JScrollPane (javax.swing.JScrollPane)5 Triple (catdata.Triple)4 Util (catdata.Util)4