use of catdata.Pair in project fql by CategoricalData.
the class XOptions method display.
// @Override
@Override
public Pair<JComponent, Function<Unit, Unit>> display() {
JSplitPane generalsplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JPanel x_1 = new JPanel(new GridLayout(Options.biggestSize, 1));
JPanel x_2 = new JPanel(new GridLayout(Options.biggestSize, 1));
generalsplit.add(x_1);
generalsplit.add(x_2);
JCheckBox reorder_joins_box = new JCheckBox("", reorder_joins);
JLabel reorder_joins_label = new JLabel("Re-order FROM clauses:");
x_1.add(reorder_joins_label);
x_2.add(reorder_joins_box);
JCheckBox fast_amalgams_box = new JCheckBox("", fast_amalgams);
JLabel fast_amalgams_label = new JLabel("Use fast amalgams on saturated presentations:");
x_1.add(fast_amalgams_label);
x_2.add(fast_amalgams_box);
JCheckBox validate_amalgams_box = new JCheckBox("", validate_amalgams);
JLabel validate_amalgams_label = new JLabel("Validate amalgams (if validating categories):");
x_1.add(validate_amalgams_label);
x_2.add(validate_amalgams_box);
JCheckBox x_typing_box = new JCheckBox("", x_typing);
JLabel typing_label = new JLabel("Type check:");
x_1.add(typing_label);
x_2.add(x_typing_box);
JTextField x_path_length_box = new JTextField(Integer.toString(MAX_PATH_LENGTH), 12);
JLabel x_path_length_label = new JLabel("Max path length:");
x_2.add(wrap(x_path_length_box));
x_1.add(x_path_length_label);
JPanel xArea = new JPanel(new FlowLayout(FlowLayout.LEFT));
JCheckBox x_cat_box = new JCheckBox("Cat", x_cat);
JCheckBox x_graph_box = new JCheckBox("Graph", x_graph);
JCheckBox x_textual_box = new JCheckBox("Text", x_text);
JCheckBox x_tabular_box = new JCheckBox("Table", x_tables);
JCheckBox x_adom_box = new JCheckBox("ADom", x_adom);
JCheckBox x_elem_box = new JCheckBox("Elements", x_elements);
JCheckBox x_json_box = new JCheckBox("JSON", x_json);
xArea.add(x_textual_box);
xArea.add(x_graph_box);
xArea.add(x_cat_box);
xArea.add(x_tabular_box);
xArea.add(x_adom_box);
xArea.add(x_elem_box);
xArea.add(x_json_box);
x_1.add(new JLabel("Viewers:"));
x_2.add(xArea);
for (int i = 0; i < Options.biggestSize - size(); i++) {
x_1.add(new JLabel());
x_2.add(new JLabel());
}
Function<Unit, Unit> fn = (Unit t) -> {
int mpl = MAX_PATH_LENGTH;
try {
try {
mpl = Integer.parseInt(x_path_length_box.getText());
} catch (NumberFormatException nfe) {
}
if (mpl < 1) {
mpl = MAX_PATH_LENGTH;
}
} catch (NumberFormatException nfe) {
}
MAX_PATH_LENGTH = mpl;
x_adom = x_adom_box.isSelected();
x_cat = x_cat_box.isSelected();
x_graph = x_graph_box.isSelected();
x_tables = x_tabular_box.isSelected();
x_adom = x_adom_box.isSelected();
fast_amalgams = fast_amalgams_box.isSelected();
validate_amalgams = validate_amalgams_box.isSelected();
reorder_joins = reorder_joins_box.isSelected();
x_typing = x_typing_box.isSelected();
x_elements = x_elem_box.isSelected();
x_json = x_json_box.isSelected();
return new Unit();
};
return new Pair<>(generalsplit, fn);
}
use of catdata.Pair in project fql by CategoricalData.
the class XParser method fromBlocks.
private static Map<Object, Pair<String, Block<String, String>>> fromBlocks(List l) {
Map<Object, Pair<String, Block<String, String>>> ret = new HashMap<>();
for (Object o : l) {
Tuple5 t = (Tuple5) o;
Block<String, String> b = fromBlock(t.c);
ret.put(t.a.toString(), new Pair<>(t.e.toString(), b));
}
return ret;
}
use of catdata.Pair in project fql by CategoricalData.
the class XParser method toInstConst.
/* public static final Parser<?> instance(Reference ref) {
Parser<?> node = Parsers.tuple(ident(), term(":"), ident());
Parser<?> p3 = Parsers.tuple(path(), term("="), path());
Parser<?> xxx = Parsers.tuple(section("variables", node),
section("equations", p3));
Parser kkk = ((Parser)term("INSTANCE")).or((Parser) term("instance"));
Parser<?> constant = Parsers
.tuple(kkk, xxx.between(term("{"), term("}")), term(":"),
ref.lazy());
return constant; */
private static XInst toInstConst(Object decl) {
Tuple4 y = (Tuple4) decl;
org.jparsec.functors.Pair x = (org.jparsec.functors.Pair) y.b;
Tuple3 nodes = (Tuple3) x.a;
Tuple3 arrows = (Tuple3) x.b;
List nodes0 = (List) nodes.b;
List arrows0 = (List) arrows.b;
List<Pair<String, String>> nodesX = new LinkedList<>();
for (Object o : nodes0) {
Tuple3 u = (Tuple3) o;
List<String> n2 = (List) u.a;
String l = (String) u.c;
for (String n : n2) {
// String n = (String) u.a;
nodesX.add(new Pair<>(n, l));
}
}
List<Pair<List<String>, List<String>>> eqsX = new LinkedList<>();
for (Object o : arrows0) {
Tuple3 u = (Tuple3) o;
List<String> n = (List<String>) u.a;
List<String> m = (List<String>) u.c;
eqsX.add(new Pair<>(n, m));
}
XInst ret = new XInst(toExp(y.d), nodesX, eqsX);
if (y.a.toString().equals("INSTANCE")) {
ret.saturated = true;
}
return ret;
}
use of catdata.Pair in project fql by CategoricalData.
the class XParser method toTrans.
private static XTransConst toTrans(Object decl) {
Tuple5 y = (Tuple5) decl;
// org.jparsec.functors.Pair x = (org.jparsec.functors.Pair) y.a;
Tuple3 nodes = (Tuple3) y.a;
// Tuple3 arrows = (Tuple3) x.b;
List nodes0 = (List) nodes.b;
// List arrows0 = (List) arrows.b;
List<Pair<Pair<String, String>, List<String>>> eqsX = new LinkedList<>();
for (Object o : nodes0) {
Tuple3 u = (Tuple3) o;
List<String> m = (List<String>) u.c;
if (u.a instanceof Tuple3) {
Tuple3 n = (Tuple3) u.a;
eqsX.add(new Pair<>(new Pair<>(n.a.toString(), n.c.toString()), m));
} else {
String n = (String) u.a;
eqsX.add(new Pair<>(new Pair<>(n, null), m));
}
}
XTransConst ret = new XTransConst(toExp(y.c), toExp(y.e), eqsX);
return ret;
}
use of catdata.Pair in project fql by CategoricalData.
the class XParser method fromSuperSoed.
/*
J = soed {
exists f:A->B, g:C->D;
forall a:A, a.f = p.q, a.g = p.f;
forall b:B, p = q;
} : X -> Y on I
*/
private static XSuperED fromSuperSoed(Object ooo) {
org.jparsec.functors.Pair ooo1 = (org.jparsec.functors.Pair) ooo;
Tuple4 a = (Tuple4) ooo1.a;
// List<Triple<String, List<String>, String>> es = new LinkedList<>();
List<SuperFOED> as = new LinkedList<>();
Map<String, List<String>> dom = new HashMap<>();
Map<String, String> cod = new HashMap<>();
List<Tuple5> es0 = (List<Tuple5>) a.b;
for (Tuple5 t : es0) {
if (dom.keySet().contains(t.a)) {
throw new RuntimeException("Duplicate function name " + t.a);
}
dom.put((String) t.a, (List<String>) t.c);
cod.put((String) t.a, (String) t.e);
}
List<Tuple4> as0 = (List<Tuple4>) a.d;
for (Tuple4 t : as0) {
List<Tuple3> aas = (List<Tuple3>) t.b;
Map<String, String> aa = new HashMap<>();
for (Tuple3 xxx : aas) {
if (aa.containsKey(xxx.a)) {
throw new RuntimeException("Duplicate var " + xxx.a);
}
aa.put((String) xxx.a, (String) xxx.c);
}
Tuple3 td = (Tuple3) t.d;
List<Tuple3> lhss = (List<Tuple3>) td.a;
List<Tuple3> rhss = (List<Tuple3>) td.c;
List<Pair<Triple<String, List<List<String>>, List<String>>, Triple<String, List<List<String>>, List<String>>>> cc = new LinkedList<>();
List<Pair<Triple<String, List<List<String>>, List<String>>, Triple<String, List<List<String>>, List<String>>>> bb = new LinkedList<>();
for (Tuple3 o : lhss) {
bb.add(new Pair<>(fromBulb(o.a), fromBulb(o.c)));
}
for (Tuple3 o : rhss) {
cc.add(new Pair<>(fromBulb(o.a), fromBulb(o.c)));
}
as.add(new SuperFOED(aa, bb, cc));
}
Tuple4 b = (Tuple4) ooo1.b;
String src = (String) b.b;
String dst = (String) b.c;
String i = (String) b.d;
// es, as, src, dst, i);
XSuperED ret = new XSuperED(dom, cod, as, src, dst, i);
return ret;
}
Aggregations