/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: EpiFrame.java Description: This class implements a frame which allows the user to run the category tool "Epimorphism" on the current category. */ import java.awt.*; import java.awt.event.*; import borland.jbcl.layout.*; import borland.jbcl.control.*; public class EpiFrame extends Frame { Panel panel1 = new Panel(); XYLayout xYLayout1 = new XYLayout(); Button epi_button = new Button(); Button close_button = new Button(); TextArea viewbox = new TextArea("", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY); MainWindow ed; Category cat = new Category(); Label epiLabel = new Label(); TextField epiPath = new TextField(); CheckboxControl allpaths_checkbox = new CheckboxControl(); int numepis = 0; boolean supress_output = false; boolean endopassed = false; public EpiFrame(MainWindow edit) { ed = edit; cat = ed.cat.makeDual(); ed.enableMenus(false); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } add(panel1); pack(); } public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY || e.key == Event.ENTER) { ed.enableMenus(true); hide(); //hide frame dispose(); //free resources return true; } return super.handleEvent(e); } private void jbInit() throws Exception { this.setBackground(Color.lightGray); this.setSize(new Dimension(453, 203)); this.setTitle("GDCT: Epimorphism"); panel1.setBackground(Color.lightGray); xYLayout1.setWidth(453); xYLayout1.setHeight(203); epi_button.setLabel("Epi?"); epi_button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { epi_button_actionPerformed(e); } }); close_button.setLabel("Close"); epiLabel.setText("Epimorphism path:"); allpaths_checkbox.setLabel("Check all paths"); allpaths_checkbox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { allpaths_checkbox_itemStateChanged(e); } }); viewbox.setEditable(false); viewbox.setBackground(Color.white); close_button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { close_button_actionPerformed(e); } }); panel1.setLayout(xYLayout1); panel1.add(epi_button, new XYConstraints(9, 169, 69, 25)); panel1.add(close_button, new XYConstraints(86, 169, 61, 25)); panel1.add(viewbox, new XYConstraints(156, 9, 286, 185)); panel1.add(epiLabel, new XYConstraints(8, 39, 125, 20)); panel1.add(epiPath, new XYConstraints(6, 64, 138, 21)); panel1.add(allpaths_checkbox, new XYConstraints(8, 10, 141, 24)); } public void generate_epis(int path[], int domain, HomTree pathtree, int maxloop) /* Parameters: path: the current path domain: the current object of the path codomain: the object we are trying to find all arrows to objects: an array of integers which keeps the function from exceeding the maximum number of loops yestree: tree of verified epimorphisms notree: tree of verified non-epimorphisms Purpose: To find all epimorphisms from domain to codomain */ { int i, j, len, number, endo = 0; int arrow_array[] = new int [cat.numarr]; path = cat.reduce(path); len = cat.path_len(path); if (path[0] == -2) path[0] = -1; for (i=0; i 0) { if (isepi(path)) { numepis++; viewbox.append(ed.cat.path_to_string(cat.reverse_path(path)) + " is an epimorphism!\n"); } } number = cat.all_arr(domain, arrow_array); if (number > 0) for (i=0; i=0; j--) path[j+1] = path[j]; path[0] = arrow_array[i]; generate_epis(path, cat.arr[arrow_array[i]][1], pathtree, maxloop); for (j=0; j<=len; j++) path[j] = path[j+1]; } } } else endopassed = true; } void epi_button_actionPerformed(ActionEvent e) { endopassed = false; if (allpaths_checkbox.isChecked()) { int i, j; int path[] = new int[ed.ini.getMAXARR()]; int objects[] = new int[cat.numobj]; HomTree pathtree; supress_output = true; numepis = 0; for (i=0; i=0; j--) path[j+1] = path[j]; path[0] = arrows[i]; // check recursively if (!check_epi(alphatree, aepitree, epi, path, cat.arr[path[0]][1], codomain, pathtree)) return false; // now remove the arrow and object from the path for (j=0; j<=pathlen; j++) path[j] = path[j+1]; } // if we're at the second object, then add the path to the tree if (path[0] != -1 && cat.arr[path[0]][1] == codomain) { int alpha[] = cat.reduce(path); if (alphatree.addPath(alpha)) { alpha = cat.reduce(cat.append_path(path, epi)); if (!aepitree.addPath(alpha)) return false; } } } } else endopassed = true; return true; } void allpaths_checkbox_itemStateChanged(ItemEvent e) { epiLabel.setVisible(!allpaths_checkbox.isChecked()); epiPath.setVisible(!allpaths_checkbox.isChecked()); } }