Search in sources :

Example 1 with Int

use of catdata.fql.decl.Type.Int in project fql by CategoricalData.

the class Signature method view.

@SuppressWarnings("serial")
public JPanel view() {
    Object[][] arr = new Object[eqs.size()][2];
    int i = 0;
    for (Eq eq : eqs) {
        arr[i][0] = eq.lhs;
        arr[i][1] = eq.rhs;
        i++;
    }
    Arrays.sort(arr, Comparator.comparing(f4 -> f4[0].toString()));
    JTable eqsComponent = new JTable(arr, new Object[] { "lhs", "rhs" }) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            return new Dimension(d.width, d.height);
        }
    };
    List<JComponent> p = new LinkedList<>();
    JPanel eqsTemp = new JPanel(new GridLayout(1, 1));
    eqsTemp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), "Equations (" + eqs.size() + ")"));
    eqsTemp.add(new JScrollPane(eqsComponent));
    Object[][] sn = new String[nodes.size()][1];
    int ii = 0;
    for (Node n : nodes) {
        sn[ii++][0] = n.string;
    }
    Arrays.sort(sn, Comparator.comparing(f3 -> f3[0].toString()));
    JTable nodesComponent = new JTable(sn, new String[] { "Name" }) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            return new Dimension(d.width, d.height);
        }
    };
    JPanel nodesTemp = new JPanel(new GridLayout(1, 1));
    nodesTemp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), "Nodes (" + nodes.size() + ")"));
    nodesTemp.add(new JScrollPane(nodesComponent));
    Object[][] es = new String[edges.size()][3];
    int jj = 0;
    for (Edge eq : edges) {
        es[jj][0] = eq.name;
        es[jj][1] = eq.source.string;
        es[jj][2] = eq.target.string;
        jj++;
    }
    Arrays.sort(es, Comparator.comparing(f2 -> f2[0].toString()));
    JTable esC = new JTable(es, new String[] { "Name", "Source", "Target" }) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            return new Dimension(d.width, d.height);
        }
    };
    JPanel edgesTemp = new JPanel(new GridLayout(1, 1));
    edgesTemp.add(new JScrollPane(esC));
    edgesTemp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), "Arrows (" + edges.size() + ")"));
    Object[][] as = new String[attrs.size()][3];
    jj = 0;
    for (Attribute<Node> a : attrs) {
        as[jj][0] = a.name;
        as[jj][1] = a.source.string;
        as[jj][2] = a.target.toString();
        jj++;
    }
    Arrays.sort(as, Comparator.comparing(f -> f[0].toString()));
    JTable asC = new JTable(as, new String[] { "Name", "Source", "Type" }) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            return new Dimension(d.width, d.height);
        }
    };
    JPanel attrsTemp = new JPanel(new GridLayout(1, 1));
    attrsTemp.add(new JScrollPane(asC));
    attrsTemp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), "Attributes (" + attrs.size() + ")"));
    p.add(nodesTemp);
    p.add(edgesTemp);
    p.add(attrsTemp);
    p.add(eqsTemp);
    return FqlUtil.makeGrid(p);
}
Also used : Color(java.awt.Color) UIManager(javax.swing.UIManager) Arrays(java.util.Arrays) Map(java.util.Map) Int(catdata.fql.decl.Type.Int) DirectedSparseMultigraph(edu.uci.ics.jung.graph.DirectedSparseMultigraph) BorderLayout(java.awt.BorderLayout) Fn(catdata.fql.Fn) Pair(catdata.Pair) Function(com.google.common.base.Function) Font(java.awt.Font) Collection(java.util.Collection) Set(java.util.Set) Inst(catdata.fql.cat.Inst) PSMGen(catdata.fql.sql.PSMGen) BorderFactory(javax.swing.BorderFactory) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) List(java.util.List) Paint(java.awt.Paint) Entry(java.util.Map.Entry) Triple(catdata.Triple) JTable(javax.swing.JTable) BasicStroke(java.awt.BasicStroke) FqlUtil(catdata.fql.FqlUtil) JPanel(javax.swing.JPanel) DefunctGlobalOptions(catdata.ide.DefunctGlobalOptions) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) EmbeddedDependency(catdata.fql.sql.EmbeddedDependency) HashMap(java.util.HashMap) Constructor(java.lang.reflect.Constructor) FQLException(catdata.fql.FQLException) GridLayout(java.awt.GridLayout) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) ToStringLabeller(edu.uci.ics.jung.visualization.decorators.ToStringLabeller) FinCat(catdata.fql.cat.FinCat) JTabbedPane(javax.swing.JTabbedPane) Graph(edu.uci.ics.jung.graph.Graph) Const(catdata.fql.decl.SigExp.Const) LinkedList(java.util.LinkedList) Stroke(java.awt.Stroke) JComponent(javax.swing.JComponent) Layout(edu.uci.ics.jung.algorithms.layout.Layout) JButton(javax.swing.JButton) CodeTextPanel(catdata.ide.CodeTextPanel) IntRef(catdata.IntRef) ActionEvent(java.awt.event.ActionEvent) JScrollPane(javax.swing.JScrollPane) LeftKanCat(catdata.fql.cat.LeftKanCat) Arr(catdata.fql.cat.Arr) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) JTextArea(javax.swing.JTextArea) Comparator(java.util.Comparator) Collections(java.util.Collections) FqlOptions(catdata.fql.FqlOptions) Mode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) Paint(java.awt.Paint) LinkedList(java.util.LinkedList) GridLayout(java.awt.GridLayout) JTable(javax.swing.JTable)

Aggregations

IntRef (catdata.IntRef)1 Pair (catdata.Pair)1 Triple (catdata.Triple)1 FQLException (catdata.fql.FQLException)1 Fn (catdata.fql.Fn)1 FqlOptions (catdata.fql.FqlOptions)1 FqlUtil (catdata.fql.FqlUtil)1 Arr (catdata.fql.cat.Arr)1 FinCat (catdata.fql.cat.FinCat)1 Inst (catdata.fql.cat.Inst)1 LeftKanCat (catdata.fql.cat.LeftKanCat)1 Const (catdata.fql.decl.SigExp.Const)1 Int (catdata.fql.decl.Type.Int)1 EmbeddedDependency (catdata.fql.sql.EmbeddedDependency)1 PSMGen (catdata.fql.sql.PSMGen)1 CodeTextPanel (catdata.ide.CodeTextPanel)1 DefunctGlobalOptions (catdata.ide.DefunctGlobalOptions)1 Function (com.google.common.base.Function)1 Layout (edu.uci.ics.jung.algorithms.layout.Layout)1 DirectedSparseMultigraph (edu.uci.ics.jung.graph.DirectedSparseMultigraph)1