Search in sources :

Example 1 with QueryExp

use of catdata.fql.decl.QueryExp in project fql by CategoricalData.

the class FqlDisplay method handleInstanceFlowEdge.

private void handleInstanceFlowEdge(Object o) {
    InstExp i = (InstExp) o;
    Object f = i.accept(new Unit(), new InstExpVisitor<Object, Unit>() {

        @Override
        public MapExp visit(Unit env, Zero e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, One e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Two e) {
            throw new RuntimeException();
        }

        @Override
        public MapExp visit(Unit env, Plus e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Times e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Exp e) {
            throw new RuntimeException();
        }

        @Override
        public MapExp visit(Unit env, Const e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Delta e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, Sigma e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, Pi e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, FullSigma e) {
            return e.F;
        }

        @Override
        public Unit visit(Unit env, Relationalize e) {
            return null;
        }

        @Override
        public Unit visit(Unit env, External e) {
            return null;
        }

        @Override
        public Object visit(Unit env, Eval e) {
            return e.q;
        }

        @Override
        public Object visit(Unit env, FullEval e) {
            return e.q;
        }

        @Override
        public Object visit(Unit env, Kernel e) {
            return null;
        }

        @Override
        public Object visit(Unit env, Step e) {
            // (Step) this should return a pair
            return null;
        }
    });
    if (f == null) {
        return;
    }
    if (f instanceof QueryExp) {
        QueryExp q = (QueryExp) f;
        if (q instanceof QueryExp.Var) {
            QueryExp.Var qq = (QueryExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.queries, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            Query view = q.toQuery(prog);
            JPanel p = showQuery(prog, env, view);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else if (f instanceof FullQueryExp) {
        FullQueryExp q = (FullQueryExp) f;
        if (q instanceof FullQueryExp.Var) {
            FullQueryExp.Var qq = (FullQueryExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.full_queries, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            FullQuery view = q.toFullQuery(prog);
            JPanel p = showFullQuery(prog, env, view, q);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else if (f instanceof MapExp) {
        MapExp q = (MapExp) f;
        if (q instanceof MapExp.Var) {
            MapExp.Var qq = (MapExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.maps, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            Mapping view = q.toMap(prog);
            JPanel p = showMapping(env, prog.smap(view.source.toConst()), prog.smap(view.target.toConst()), view);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else {
        throw new RuntimeException();
    }
}
Also used : JPanel(javax.swing.JPanel) FullEval(catdata.fql.decl.InstExp.FullEval) FullQuery(catdata.fql.decl.FullQuery) Query(catdata.fql.decl.Query) FullQueryExp(catdata.fql.decl.FullQueryExp) QueryExp(catdata.fql.decl.QueryExp) Var(catdata.fql.decl.SigExp.Var) One(catdata.fql.decl.InstExp.One) FullSigma(catdata.fql.decl.InstExp.FullSigma) Sigma(catdata.fql.decl.InstExp.Sigma) FullQueryExp(catdata.fql.decl.FullQueryExp) Mapping(catdata.fql.decl.Mapping) Step(catdata.fql.decl.InstExp.Step) Unit(catdata.Unit) Pi(catdata.fql.decl.InstExp.Pi) Plus(catdata.fql.decl.InstExp.Plus) FullEval(catdata.fql.decl.InstExp.FullEval) Eval(catdata.fql.decl.InstExp.Eval) Kernel(catdata.fql.decl.InstExp.Kernel) Relationalize(catdata.fql.decl.InstExp.Relationalize) FullQuery(catdata.fql.decl.FullQuery) Zero(catdata.fql.decl.InstExp.Zero) Const(catdata.fql.decl.InstExp.Const) Two(catdata.fql.decl.InstExp.Two) InstExp(catdata.fql.decl.InstExp) MapExp(catdata.fql.decl.MapExp) Delta(catdata.fql.decl.InstExp.Delta) Times(catdata.fql.decl.InstExp.Times) External(catdata.fql.decl.InstExp.External) FullSigma(catdata.fql.decl.InstExp.FullSigma) FullQueryExp(catdata.fql.decl.FullQueryExp) Exp(catdata.fql.decl.InstExp.Exp) MapExp(catdata.fql.decl.MapExp) QueryExp(catdata.fql.decl.QueryExp) SigExp(catdata.fql.decl.SigExp) InstExp(catdata.fql.decl.InstExp)

Aggregations

Unit (catdata.Unit)1 FullQuery (catdata.fql.decl.FullQuery)1 FullQueryExp (catdata.fql.decl.FullQueryExp)1 InstExp (catdata.fql.decl.InstExp)1 Const (catdata.fql.decl.InstExp.Const)1 Delta (catdata.fql.decl.InstExp.Delta)1 Eval (catdata.fql.decl.InstExp.Eval)1 Exp (catdata.fql.decl.InstExp.Exp)1 External (catdata.fql.decl.InstExp.External)1 FullEval (catdata.fql.decl.InstExp.FullEval)1 FullSigma (catdata.fql.decl.InstExp.FullSigma)1 Kernel (catdata.fql.decl.InstExp.Kernel)1 One (catdata.fql.decl.InstExp.One)1 Pi (catdata.fql.decl.InstExp.Pi)1 Plus (catdata.fql.decl.InstExp.Plus)1 Relationalize (catdata.fql.decl.InstExp.Relationalize)1 Sigma (catdata.fql.decl.InstExp.Sigma)1 Step (catdata.fql.decl.InstExp.Step)1 Times (catdata.fql.decl.InstExp.Times)1 Two (catdata.fql.decl.InstExp.Two)1