/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: MainWindow.java Description: This class contains the main window that is displayed when the GDCT application is opened. It contains the GUI for the text-based and graphical manipulation of categories and functors as well as an extensive menu system that allows the user to easily access all of the tools and options available. */ //import statements import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import java.util.*; import java.lang.System; import borland.jbcl.layout.*; import borland.jbcl.control.*; public class MainWindow extends Frame { //Construct the frame TextArea viewbox = new TextArea(); Panel textPanel = new Panel(); Button loadCatButton = new Button(); java.awt.List catLoadList = new java.awt.List(); java.awt.List catDisplayList = new java.awt.List(); Button catDisplayButton = new Button(); TextArea vbox = new TextArea(); CardLayout textCardLayout = new CardLayout(); Button makeDualOKButton = new Button(); LoadCATFrame catLoad; LoadCGLFrame cglLoad; LoadFUNFrame funLoad; LoadFGLFrame fglLoad; Panel panel1 = new Panel(); Button doneButton = new Button(); Panel displayPanel = new Panel(); Panel graphicalPanel = new Panel(); CardLayout graphicalCardLayout = new CardLayout(); Panel VGJPanel = new Panel(); Panel functorDisplayPanel = new Panel(); Label label2 = new Label(); Choice functorChoice = new Choice(); XYLayout xYLayout2 = new XYLayout(); // GridBagLayout xYLayout2 = new GridBagLayout(); TextArea functorArrowArea = new TextArea(); TextArea functorObjectArea = new TextArea(); Label label8 = new Label(); Label label9 = new Label(); Panel funcDisplayControls = new Panel(); Button forwardButton = new Button(); Button backButton = new Button(); Button animateButton = new Button(); XYLayout xYLayout5 = new XYLayout(); GridBagLayout gridBagLayout3 = new GridBagLayout(); Button resetButton = new Button(); Panel panel2 = new Panel(); XYLayout xYLayout3 = new XYLayout(); Panel panel3 = new Panel(); XYLayout xYLayout6 = new XYLayout(); Checkbox textDisplayCheckBox = new Checkbox(); Checkbox graphicalDisplayCheckBox = new Checkbox(); Panel functorPanel = new Panel(); XYLayout xYLayout4 = new XYLayout(); Label categoryLabel = new Label(); Label objectLabel = new Label(); Label arrowLabel = new Label(); Label relationLabel = new Label(); Label commentLabel = new Label(); Choice categoryChoice = new Choice(); TextArea objectArea = new TextArea("", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY); TextArea arrowArea = new TextArea("", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY); TextArea relationArea = new TextArea("", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY); TextArea commentArea = new TextArea("", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY); CheckboxMenuItem categoryCommentsMenuItem = new CheckboxMenuItem(); GridBagLayout gridBagLayout1 = new GridBagLayout(); Panel dummyPanel = new Panel(); GridBagLayout gridBagLayout2 = new GridBagLayout(); Label label3 = new Label(); Label label4 = new Label(); Label label5 = new Label(); Choice functorFromChoice = new Choice(); Choice functorToChoice = new Choice(); TextField functorNameField = new TextField(); TextField functorInputField = new TextField(); TextArea functorDisplayArea = new TextArea(); //GroupBox groupBox4 = new GroupBox(); Label inputLabel = new Label(); Label label6 = new Label(); Label label7 = new Label(); TextField categoryNameField = new TextField(); Label catInputLabel = new Label(); TextField catInputField = new TextField(); Label label1 = new Label(); XYLayout xYLayout1 = new XYLayout(); Panel createFunctorDisplay = new Panel(); //Menu Items Menu openMenu = new Menu(); Menu menu3 = new Menu(); Menu menu4 = new Menu(); Menu menu6 = new Menu(); Menu menu2 = new Menu(); Menu menu7 = new Menu(); Menu menu8 = new Menu(); Menu menu9 = new Menu(); Menu menu11 = new Menu(); //File Menu Items MenuBar menuBar1 = new MenuBar(); Menu fileMenu = new Menu(); MenuItem openCGLMenuItem = new MenuItem(); MenuItem openCategoryMenuItem = new MenuItem(); MenuItem loadCGLMenuItem = new MenuItem(); MenuItem loadCategoryMenuItem = new MenuItem(); MenuItem saveCGLMenuItem = new MenuItem(); MenuItem saveCategoryMenuItem = new MenuItem(); MenuItem saveGMLMenuItem = new MenuItem(); MenuItem openFGLMenuItem = new MenuItem(); MenuItem openFunctorMenuItem = new MenuItem(); MenuItem loadFGLMenuItem = new MenuItem(); MenuItem loadFUNMenuItem = new MenuItem(); MenuItem saveFGLMenuItem = new MenuItem(); MenuItem saveFunctorMenuItem = new MenuItem(); MenuItem postscriptMenuItem = new MenuItem(); MenuItem printTextMenuItem = new MenuItem(); MenuItem printGraphicalMenuItem = new MenuItem(); MenuItem printFUNMenuItem = new MenuItem(); MenuItem exitMenuItem = new MenuItem(); MenuItem recent1MenuItem = new MenuItem(); MenuItem recent2MenuItem = new MenuItem(); MenuItem recent3MenuItem = new MenuItem(); MenuItem recent4MenuItem = new MenuItem(); MenuItem recent5MenuItem = new MenuItem(); MenuItem recent6MenuItem = new MenuItem(); MenuItem recent7MenuItem = new MenuItem(); MenuItem recent8MenuItem = new MenuItem(); //Categories Menu Items Menu categoriesMenu = new Menu(); MenuItem createCategoryMenuItem = new MenuItem(); MenuItem openCGLMenuItem2 = new MenuItem(); MenuItem openCategoryMenuItem2 = new MenuItem(); MenuItem loadCGLMenuItem2 = new MenuItem(); MenuItem loadCategoryMenuItem2 = new MenuItem(); MenuItem saveCGLMenuItem2 = new MenuItem(); MenuItem saveCategoryMenuItem2 = new MenuItem(); MenuItem saveGMLMenuItem2 = new MenuItem(); MenuItem closeCategoryMenuItem = new MenuItem(); MenuItem postscriptMenuItem2 = new MenuItem(); MenuItem printCATMenuItem2 = new MenuItem(); MenuItem printCGLMenuItem2 = new MenuItem(); //Edit Categories Menu Items Menu editCategoryMenu = new Menu(); MenuItem changeNameMenuItem = new MenuItem(); MenuItem addDataMenuItem = new MenuItem(); MenuItem removeDataMenuItem = new MenuItem(); MenuItem gmlViewerMenuItem = new MenuItem(); //Functors Menu Items Menu functorsMenu = new Menu(); MenuItem createFunctorMenuItem = new MenuItem(); MenuItem openFGLMenuItem2 = new MenuItem(); MenuItem openFunctorMenuItem2 = new MenuItem(); MenuItem loadFGLMenuItem2 = new MenuItem(); MenuItem loadFUNMenuItem2 = new MenuItem(); MenuItem saveFGLMenuItem2 = new MenuItem(); MenuItem saveFunctorMenuItem2 = new MenuItem(); MenuItem closeFunctorMenuItem = new MenuItem(); MenuItem printFUNMenuItem2 = new MenuItem(); MenuItem printFGLMenuItem2 = new MenuItem(); //Tools Menu Items Menu toolMenu = new Menu(); MenuItem makeConfluentMenuItem = new MenuItem(); MenuItem initialObjectMenuItem = new MenuItem(); MenuItem equalityCompMenuItem = new MenuItem(); MenuItem makeDualMenuItem = new MenuItem(); MenuItem sumMenuItem = new MenuItem(); MenuItem productMenuItem = new MenuItem(); MenuItem terminalObjectMenuItem = new MenuItem(); //Settings Menu Items Menu settingsMenu = new Menu(); MenuItem catGraphicalSettingsMenuItem = new MenuItem(); MenuItem textSettingsMenuItem = new MenuItem(); MenuItem endomorphismMenuItem = new MenuItem(); MenuItem funcGraphicalSettingsMenuItem = new MenuItem(); MenuItem animationSettingsMenuItem = new MenuItem(); MenuItem loadSettings = new MenuItem(); CheckboxMenuItem categoryDisplay = new CheckboxMenuItem(); CheckboxMenuItem functorDisplay = new CheckboxMenuItem(); CheckboxMenuItem showControlsMenuItem = new CheckboxMenuItem(); CheckboxMenuItem checkboxMenuItem1 = new CheckboxMenuItem(); //Help Menu Items Menu helpMenu = new Menu(); MenuItem helpMenuItem = new MenuItem(); MenuItem aboutGDCTMenuItem = new MenuItem(); MenuItem aboutAuthorsMenuItem = new MenuItem(); //global variables for reading file from server URL fileURL; InputStream input; DataInputStream dataInput; //global variables for creating categories and functors int editoption = 0; int editsub =0; int menuoption = 0; int submenu = 0; //Default Category File Category cat = new Category(); Category A = new Category(); Category B = new Category(); Category diagram = new Category(); //Creates the list container for the storage of cateories CategoryList catList = new CategoryList(); //Default Functor Files FunctorNode fnode = new FunctorNode(this); private CatFunctor functor = new CatFunctor(); private CatFunctor func = new CatFunctor(); //Creates the list container for the storage of functors FunctorList f_list = new FunctorList(); //Constants used in this class //StringChecker sc; IniSettings ini = new IniSettings(); //Default Constructor public MainWindow(GDCTIntro a) { try { try { Thread.sleep(3000); a.setVisible(false); a.dispose(); } catch (Exception e) { } jbInit(); } catch (Exception e) { e.printStackTrace(); } } public MainWindow() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //Window Settings this.setLayout(gridBagLayout1); this.setSize(new Dimension(960, 585)); terminalObjectMenuItem.setLabel("Terminal Object?"); terminalObjectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { terminalObjectMenuItem_actionPerformed(e); } }); loadFUNMenuItem.setLabel("Download Functor (FUN)"); loadFUNMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadFUNMenuItem_actionPerformed(e); } }); loadFGLMenuItem.setLabel("Download Functor (FGL)"); loadFGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadFGLMenuItem_actionPerformed(e); } }); loadCGLMenuItem.setLabel("Download Category (CGL)"); loadCGLMenuItem.setShortcut(new MenuShortcut(76)); loadCGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCGLMenuItem_actionPerformed(e); } }); animationSettingsMenuItem.setLabel("Functor Animation Settings"); resetButton.setLabel("Reset"); panel2.setBackground(Color.white); panel3.setBackground(Color.white); menu2.setLabel("Open Category"); menu7.setLabel("Save Category"); menu8.setLabel("Print Category"); menu9.setLabel("Print"); checkboxMenuItem1.setLabel("Show Functor Comments"); checkboxMenuItem1.setState(true); menu11.setLabel("Print Functor"); panel3.setLayout(xYLayout6); panel2.setLayout(xYLayout3); resetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { resetButton_actionPerformed(e); } }); animationSettingsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { animationSettingsMenuItem_actionPerformed(e); } }); openCGLMenuItem2.setLabel("Open Category (CGL)"); openCGLMenuItem2.setShortcut(new MenuShortcut(79)); openCGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openCGLMenuItem_actionPerformed(e); } }); loadCGLMenuItem2.setLabel("Download Category (CGL)"); loadCGLMenuItem2.setShortcut(new MenuShortcut(68)); loadCGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCGLMenuItem_actionPerformed(e); } }); saveCGLMenuItem2.setLabel("Save Category (CGL)"); saveCGLMenuItem2.setShortcut(new MenuShortcut(83)); saveCGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveCGLMenuItem_actionPerformed(e); } }); printCATMenuItem2.setLabel("Print Category (Text)"); printCGLMenuItem2.setLabel("Print Category (Graphical)"); postscriptMenuItem2.setLabel("Print Category (Postscript)"); postscriptMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { postscriptMenuItem_actionPerformed(e); } }); gmlViewerMenuItem.setLabel("View GML"); gmlViewerMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { gmlViewerMenuItem_actionPerformed(e); } }); saveGMLMenuItem2.setLabel("Save Category (GML)"); saveGMLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveGMLMenuItem_actionPerformed(e); } }); printFUNMenuItem.setLabel("Print Functor (Text)"); printFUNMenuItem2.setLabel("Print Functor (Text)"); printFGLMenuItem2.setLabel("Print Functor (Graphical)"); bugReportMenuItem.setLabel("Bug Report"); menu1.setLabel("Open Functor"); menu5.setLabel("Save Functor"); loadFUNMenuItem2.setLabel("Download Functor (FUN)"); loadFUNMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadFUNMenuItem_actionPerformed(e); } }); openFGLMenuItem2.setLabel("Open Functor (FGL)"); openFGLMenuItem2.setShortcut(new MenuShortcut(70)); openFGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openFGLMenuItem_actionPerformed(e); } }); openFunctorMenuItem2.setLabel("Open Functor (FUN)"); openFunctorMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openFunctorMenuItem_actionPerformed(e); } }); loadFGLMenuItem2.setLabel("Download Functor (FGL)"); loadFGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadFGLMenuItem_actionPerformed(e); } }); saveFunctorMenuItem2.setLabel("Save Functor (FUN)"); saveFunctorMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveFunctorMenuItem_actionPerformed(e); } }); saveFGLMenuItem2.setLabel("Save Functor (FGL)"); saveFGLMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveFGLMenuItem_actionPerformed(e); } }); bugReportMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { bugReportMenuItem_actionPerformed(e); } }); isoMenuItem.setLabel("Isomorphism?"); twocatdisplay_button.setLabel("Two Category Display"); twocatdisplay_button.setState(true); twocatdisplay_button.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { twocatdisplay_button_itemStateChanged(e); } }); diagramdisplay_button.setLabel("Diagram Display"); diagramdisplay_button.setState(false); panel4.setLayout(xYLayout7); diagramdisplay_button.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { diagramdisplay_button_itemStateChanged(e); } }); isoMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { isoMenuItem_actionPerformed(e); } }); coequalizerMenuItem.setLabel("Coequalizer?"); coequalizerMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { coequalizerMenuItem_actionPerformed(e); } }); equalizerMenuItem.setLabel("Equalizer?"); equalizerMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { equalizerMenuItem_actionPerformed(e); } }); epiMenuItem.setLabel("Epimorphism?"); epiMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { epiMenuItem_actionPerformed(e); } }); monoMenuItem.setLabel("Monomorphism?"); monoMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { monoMenuItem_actionPerformed(e); } }); this.setBackground(new Color(192, 192, 192)); //Temporary Button Settings viewbox.setBackground(Color.white); viewbox.setEditable(false); //Help Menu Settings helpMenu.setLabel("Help"); aboutGDCTMenuItem.setLabel("About GDCT"); aboutGDCTMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { aboutGDCTMenuItem_actionPerformed(e); } }); helpMenuItem.setLabel("Help Topics Index"); helpMenuItem.setShortcut(new MenuShortcut(72)); helpMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { helpMenuItem_actionPerformed(e); } }); //Settings Menu Settings settingsMenu.setLabel("Settings"); endomorphismMenuItem.setLabel("Endomorphism Limit"); endomorphismMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { endomorphismMenuItem_actionPerformed(e); } }); //Recent Category Files recent1MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent2MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent3MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent4MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent5MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent6MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent7MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); recent8MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { recentMenuItem_actionPerformed(e); } }); //File Menu Settings fileMenu.setLabel("File"); openCategoryMenuItem.setLabel("Open Category (CAT)"); openCategoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openCategoryMenuItem_actionPerformed(e); } }); saveCategoryMenuItem.setLabel("Save Category (CAT)"); saveCategoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveCategoryMenuItem_actionPerformed(e); } }); exitMenuItem.setLabel("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { exitMenuItem_actionPerformed(e); } }); //Categories Menu Settings categoriesMenu.setLabel("Categories"); saveGMLMenuItem.setLabel("Save Category (GML)"); saveGMLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveGMLMenuItem_actionPerformed(e); } }); postscriptMenuItem.setLabel("Print Category (Postscript)"); postscriptMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { postscriptMenuItem_actionPerformed(e); } }); printTextMenuItem.setLabel("Print Category (Text)"); printTextMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { printTextMenuItem_actionPerformed(e); } }); printGraphicalMenuItem.setLabel("Print Category (Graphical)"); printGraphicalMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { printGraphicalMenuItem_actionPerformed(e); } }); createCategoryMenuItem.setLabel("Create Category"); createCategoryMenuItem.setShortcut(new MenuShortcut(67)); createCategoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { createCategoryMenuItem_actionPerformed(e); } }); openCategoryMenuItem2.setLabel("Open Category (CAT)"); openCategoryMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openCategoryMenuItem_actionPerformed(e); } }); loadCategoryMenuItem2.setLabel("Download Category (CAT)"); loadCategoryMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCategoryMenuItem_actionPerformed(e); } }); loadCategoryMenuItem.setLabel("Download Category (CAT)"); loadCategoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCategoryMenuItem_actionPerformed(e); } }); saveCategoryMenuItem2.setLabel("Save Category (CAT)"); saveCategoryMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveCategoryMenuItem_actionPerformed(e); } }); closeCategoryMenuItem.setLabel("Close Category"); closeCategoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { closeCategoryMenuItem_actionPerformed(e); } }); functorsMenu.setLabel("Functors"); createFunctorMenuItem.setLabel("Create Functor"); createFunctorMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { createFunctorMenuItem_actionPerformed(e); } }); openFunctorMenuItem.setLabel("Open Functor (FUN)"); openFunctorMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openFunctorMenuItem_actionPerformed(e); } }); saveFunctorMenuItem.setLabel("Save Functor (FUN)"); saveFunctorMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveFunctorMenuItem_actionPerformed(e); } }); closeFunctorMenuItem.setLabel("Close Functor"); closeFunctorMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { closeFunctorMenuItem_actionPerformed(e); } }); toolMenu.setLabel("Tools"); openCGLMenuItem.setLabel("Open Category (CGL)"); openCGLMenuItem.setShortcut(new MenuShortcut(79)); openCGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openCGLMenuItem_actionPerformed(e); } }); menu3.setLabel("Save Category"); saveCGLMenuItem.setLabel("Save Category (CGL)"); saveCGLMenuItem.setShortcut(new MenuShortcut(83)); label3.setText("Domain Category:"); label4.setText("Codomain Category:"); label5.setText("Functor Name:"); inputLabel.setForeground(SystemColor.textHighlight); inputLabel.setFont(new Font("Dialog", 1, 12)); label6.setText("Functor Display:"); label7.setText("Category Name:"); label1.setText("Category Data Entered:"); createFunctorDisplay.setBackground(Color.lightGray); funcPanel1.setBackground(Color.lightGray); funcPanel2.setBackground(Color.lightGray); functorDisplayPanel.setLayout(xYLayout2); label2.setText("Functor Name:"); label8.setText("Objects:"); label9.setText("Arrows:"); funcDisplayControls.setBackground(Color.lightGray); funcDisplayControls.setLayout(xYLayout5); forwardButton.setLabel("Forward >>"); forwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { forwardButton_actionPerformed(e); } }); backButton.setLabel("<< Back"); backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { backButton_actionPerformed(e); } }); animateButton.setLabel("Auto Animate"); animateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { animateButton_actionPerformed(e); } }); functorChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { functorChoice_itemStateChanged(e); } }); createFunctorDisplay.setLayout(gridBagLayout3); functorToChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { functorToChoice_itemStateChanged(e); } }); functorFromChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { functorFromChoice_itemStateChanged(e); } }); saveCGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveCGLMenuItem_actionPerformed(e); } }); aboutAuthorsMenuItem.setLabel("About Authors"); aboutAuthorsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { aboutAuthorsMenuItem_actionPerformed(e); } }); loadSettings.setLabel("Set Server"); categoryLabel.setText("Category Name:"); objectLabel.setText("Objects:"); arrowLabel.setText("Arrows:"); relationLabel.setText("Relations:"); commentLabel.setText("Comments:"); categoryChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { categoryChoice_itemStateChanged(e); } }); categoryCommentsMenuItem.setLabel("Show Category Comments"); if (ini.checkCatComments()) categoryCommentsMenuItem.setState(true); else categoryCommentsMenuItem.setState(false); openMenu.setLabel("Open Category"); categoryCommentsMenuItem.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { categoryCommentsMenuItem_itemStateChanged(e); } }); loadSettings.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadSettings_actionPerformed(e); } }); functorPanel.setLayout(xYLayout4); makeConfluentMenuItem.setLabel("Make Confluent"); makeConfluentMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { makeConfluentMenuItem_actionPerformed(e); } }); initialObjectMenuItem.setLabel("Initial Object?"); initialObjectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { initialObjectMenuItem_actionPerformed(e); } }); equalityCompMenuItem.setLabel("Equality of Composites"); equalityCompMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { equalityCompMenuItem_actionPerformed(e); } }); makeDualMenuItem.setLabel("Make Dual"); makeDualMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { makeDualMenuItem_actionPerformed(e); } }); sumMenuItem.setLabel("Sum?"); sumMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { sumMenuItem_actionPerformed(e); } }); productMenuItem.setLabel("Product?"); productMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { productMenuItem_actionPerformed(e); } }); editCategoryMenu.setLabel("Edit Category"); editCategoryMenu.setShortcut(new MenuShortcut(69)); changeNameMenuItem.setLabel("Change Name"); changeNameMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { changeNameMenuItem_actionPerformed(e); } }); addDataMenuItem.setLabel("Add Data"); addDataMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { addDataMenuItem_actionPerformed(e); } }); removeDataMenuItem.setLabel("Remove Data"); removeDataMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { removeDataMenuItem_actionPerformed(e); } }); loadCatButton.setLabel("OK"); doneButton.setLabel("Done"); doneButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { doneButton_actionPerformed(e); } }); showControlsMenuItem.setLabel("Show VGJ Controls"); if (ini.checkCatControls() == true) showControlsMenuItem.setState(true); else showControlsMenuItem.setState(false); showControlsMenuItem.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { showControlsMenuItem_itemStateChanged(e); } }); catGraphicalSettingsMenuItem.setLabel("Category Graphical Settings"); catGraphicalSettingsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { catGraphicalSettingsMenuItem_actionPerformed(e); } }); funcGraphicalSettingsMenuItem.setLabel("Functor Graphical Settings"); categoryDisplay.setLabel("Category Display"); categoryDisplay.setState(true); categoryDisplay.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { categoryDisplay_itemStateChanged(e); } }); functorDisplay.setLabel("Functor Display"); functorDisplay.setState(false); functorDisplay.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { functorDisplay_itemStateChanged(e); } }); saveFGLMenuItem.setLabel("Save Functor (FGL)"); saveFGLMenuItem.setShortcut(new MenuShortcut(71)); openFGLMenuItem.setLabel("Open Functor (FGL)"); openFGLMenuItem.setShortcut(new MenuShortcut(70)); openFGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openFGLMenuItem_actionPerformed(e); } }); menu4.setLabel("Open Functor"); menu6.setLabel("Save Functor"); saveFGLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveFGLMenuItem_actionPerformed(e); } }); funcGraphicalSettingsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { funcGraphicalSettingsMenuItem_actionPerformed(e); } }); textSettingsMenuItem.setLabel("Set Font"); textSettingsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { textSettingsMenuItem_actionPerformed(e); } }); makeDualOKButton.setLabel("ok"); //makeDualOKButton.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(ActionEvent e) { // makeDualOKButton_actionPerformed(e); // } //}); catDisplayButton.setLabel("ok"); /* catDisplayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { catDisplayButton_actionPerformed(e); } }); catDisplayList.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { catDisplayButton_actionPerformed(e); } }); */ graphicalPanel.setLayout(graphicalCardLayout); displayPanel.setLayout(gridBagLayout2); panel1.setLayout(xYLayout1); loadCatButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCatButton_actionPerformed(e); } }); catLoadList.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { loadCatButton_actionPerformed(e); } }); settingsMenu.setLabel("Settings"); textPanel.setLayout(textCardLayout); this.setTitle("Graphical Database for Category Theory [GDCT " + ini.getCurrentVersion() + "]"); objectArea.setBackground(Color.white); arrowArea.setBackground(Color.white); relationArea.setBackground(Color.white); commentArea.setBackground(Color.white); this.add(textPanel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(9, 5, 0, 0), 0, 0)); textPanel.add(panel1, "inputPanel"); panel1.add(viewbox, new XYConstraints(8, 210, 214, 307)); panel1.add(doneButton, new XYConstraints(14, 114, 207, 27)); panel1.add(label7, new XYConstraints(8, 33, 96, -1)); panel1.add(categoryNameField, new XYConstraints(106, 33, 116, -1)); panel1.add(catInputLabel, new XYConstraints(8, 81, 98, -1)); panel1.add(catInputField, new XYConstraints(106, 81, 116, -1)); panel1.add(label1, new XYConstraints(8, 179, -1, -1)); textPanel.add(displayPanel, "displayPanel"); displayPanel.add(categoryLabel, new GridBagConstraints2(0, 0, 4, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(13, 5, 0, 0), 0, 0)); displayPanel.add(objectLabel, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); displayPanel.add(arrowLabel, new GridBagConstraints2(0, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); displayPanel.add(relationLabel, new GridBagConstraints2(0, 5, 2, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); displayPanel.add(commentLabel, new GridBagConstraints2(0, 7, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); displayPanel.add(categoryChoice, new GridBagConstraints2(4, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(13, 0, 0, 1), 100, 1)); displayPanel.add(objectArea, new GridBagConstraints2(0, 2, 5, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 1), 141, -97)); displayPanel.add(arrowArea, new GridBagConstraints2(0, 4, 5, 1, 1.0, 2.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 1), 141, -54)); displayPanel.add(relationArea, new GridBagConstraints2(0, 6, 5, 1, 1.0, 2.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 1), 141, -62)); displayPanel.add(commentArea, new GridBagConstraints2(0, 8, 5, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 1), 141, -83)); displayPanel.add(dummyPanel, new GridBagConstraints2(0, 9, 5, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 11, 0), 220, 8)); if (ini.checkCatComments()) { commentLabel.setVisible(true); commentArea.setVisible(true); } else { commentLabel.setVisible(false); commentArea.setVisible(false); } //String imageName = "intro.jpg"; //NewCanvas introImage = new NewCanvas(imageName); //introImage.setSize(300, 300); //functorPanel.add(introImage, new XYConstraints(15, 125, 350, 450)); textPanel.add(functorPanel, "Create Functor"); functorPanel.add(functorInputField, new XYConstraints(129, 157, 92, 24)); functorPanel.add(functorDisplayArea, new XYConstraints(10, 218, 214, 309)); //functorPanel.add(groupBox4, new XYConstraints(16, 135, 216, 10)); functorPanel.add(functorToChoice, new XYConstraints(125, 92, 97, -1)); functorPanel.add(functorFromChoice, new XYConstraints(125, 62, 97, -1)); functorPanel.add(functorNameField, new XYConstraints(126, 29, 96, -1)); functorPanel.add(label4, new XYConstraints(9, 94, 113, -1)); functorPanel.add(label3, new XYConstraints(9, 64, 105, 25)); functorPanel.add(label5, new XYConstraints(8, 31, 85, -1)); functorPanel.add(inputLabel, new XYConstraints(10, 158, 91, -1)); functorPanel.add(label6, new XYConstraints(11, 195, -1, -1)); textPanel.add(functorDisplayPanel, "Functor Display"); functorDisplayPanel.add(label2, new XYConstraints(12, 14, 87, -1)); functorDisplayPanel.add(functorChoice, new XYConstraints(107, 11, 128, -1)); // HERE functorDisplayPanel.add(functorArrowArea, new XYConstraints(10, 337, 223, 190)); functorDisplayPanel.add(functorObjectArea, new XYConstraints(10, 118, 223, 190)); functorDisplayPanel.add(label8, new XYConstraints(10, 92, -1, -1)); functorDisplayPanel.add(label9, new XYConstraints(12, 311, 127, 21)); functorDisplayPanel.add(twocatdisplay_button, new XYConstraints(52, 43, 150, 22)); functorDisplayPanel.add(diagramdisplay_button, new XYConstraints(52, 67, 129, 22)); this.add(graphicalPanel, new GridBagConstraints2(2, 0, 2, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(9, 10, 0, 12), 643, 539)); graphicalPanel.add(VGJPanel, "panel3"); graphicalPanel.add(createFunctorDisplay, "createFunctor"); createFunctorDisplay.add(funcPanel1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 0, 0), 314, 487)); createFunctorDisplay.add(funcPanel2, new GridBagConstraints2(1, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 14, 0, 3), 302, 487)); createFunctorDisplay.add(funcDisplayControls, new GridBagConstraints2(0, 1, 2, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 3, 4), 182, 4)); funcDisplayControls.add(panel2, new XYConstraints(118, 1, 100, 34)); panel2.add(animateButton, new XYConstraints(9, 3, 83, 28)); funcDisplayControls.add(panel3, new XYConstraints(226, 1, 285, 34)); panel3.add(backButton, new XYConstraints(6, 3, 83, 28)); panel3.add(forwardButton, new XYConstraints(99, 3, 82, 28)); panel3.add(resetButton, new XYConstraints(192, 3, 83, 28)); menuBar1.add(fileMenu); menuBar1.add(categoriesMenu); menuBar1.add(functorsMenu); menuBar1.add(toolMenu); menuBar1.add(settingsMenu); menuBar1.add(helpMenu); functorArrowArea.setEditable(false); functorObjectArea.setEditable(false); functorArrowArea.setBackground(Color.white); functorObjectArea.setBackground(Color.white); helpMenu.add(helpMenuItem); helpMenu.addSeparator(); helpMenu.add(bugReportMenuItem); helpMenu.addSeparator(); helpMenu.add(aboutGDCTMenuItem); helpMenu.add(aboutAuthorsMenuItem); settingsMenu.add(categoryDisplay); settingsMenu.add(functorDisplay); settingsMenu.addSeparator(); //settingsMenu.add(textSettingsMenuItem); settingsMenu.add(catGraphicalSettingsMenuItem); settingsMenu.add(funcGraphicalSettingsMenuItem); settingsMenu.add(animationSettingsMenuItem); settingsMenu.add(loadSettings); settingsMenu.add(endomorphismMenuItem); settingsMenu.addSeparator(); settingsMenu.add(showControlsMenuItem); settingsMenu.add(categoryCommentsMenuItem); settingsMenu.add(checkboxMenuItem1); fileMenu.add(openMenu); fileMenu.add(menu3); fileMenu.addSeparator(); fileMenu.add(menu1); fileMenu.add(menu5); fileMenu.addSeparator(); this.setMenuBar(menuBar1); fileMenu.add(menu9); fileMenu.addSeparator(); fileMenu.add(exitMenuItem); fileMenu.addSeparator(); fileMenu.add(recent1MenuItem); fileMenu.add(recent2MenuItem); fileMenu.add(recent3MenuItem); fileMenu.add(recent4MenuItem); fileMenu.add(recent5MenuItem); fileMenu.add(recent6MenuItem); fileMenu.add(recent7MenuItem); fileMenu.add(recent8MenuItem); categoriesMenu.add(createCategoryMenuItem); categoriesMenu.add(editCategoryMenu); categoriesMenu.addSeparator(); categoriesMenu.add(menu2); categoriesMenu.add(menu7); categoriesMenu.add(closeCategoryMenuItem); categoriesMenu.addSeparator(); categoriesMenu.add(menu8); functorsMenu.add(createFunctorMenuItem); functorsMenu.addSeparator(); functorsMenu.add(menu4); functorsMenu.add(menu6); functorsMenu.add(closeFunctorMenuItem); functorsMenu.addSeparator(); functorsMenu.add(menu11); toolMenu.add(makeConfluentMenuItem); toolMenu.add(equalityCompMenuItem); toolMenu.add(makeDualMenuItem); toolMenu.add(isoMenuItem); toolMenu.addSeparator(); toolMenu.add(initialObjectMenuItem); toolMenu.add(epiMenuItem); toolMenu.add(coequalizerMenuItem); toolMenu.add(sumMenuItem); sumMenuItem.setEnabled(true); toolMenu.addSeparator(); toolMenu.add(terminalObjectMenuItem); toolMenu.add(monoMenuItem); toolMenu.add(equalizerMenuItem); toolMenu.add(productMenuItem); productMenuItem.setEnabled(true); editCategoryMenu.add(changeNameMenuItem); editCategoryMenu.addSeparator(); editCategoryMenu.add(addDataMenuItem); editCategoryMenu.add(removeDataMenuItem); editCategoryMenu.addSeparator(); editCategoryMenu.add(gmlViewerMenuItem); openMenu.add(openCGLMenuItem); openMenu.add(openCategoryMenuItem); openMenu.addSeparator(); openMenu.add(loadCGLMenuItem); openMenu.add(loadCategoryMenuItem); menu3.add(saveCGLMenuItem); menu3.add(saveCategoryMenuItem); menu3.add(saveGMLMenuItem); menu4.add(openFGLMenuItem); menu4.add(openFunctorMenuItem); menu4.addSeparator(); menu4.add(loadFGLMenuItem); menu4.add(loadFUNMenuItem); menu6.add(saveFGLMenuItem); menu6.add(saveFunctorMenuItem); menu2.add(openCGLMenuItem2); menu2.add(openCategoryMenuItem2); menu2.addSeparator(); menu2.add(loadCGLMenuItem2); menu2.add(loadCategoryMenuItem2); menu7.add(saveCGLMenuItem2); menu7.add(saveCategoryMenuItem2); menu7.add(saveGMLMenuItem2); menu8.add(printCATMenuItem2); menu8.add(printCGLMenuItem2); menu8.add(postscriptMenuItem2); menu9.add(printTextMenuItem); menu9.add(printGraphicalMenuItem); menu9.add(postscriptMenuItem); menu9.addSeparator(); menu9.add(printFUNMenuItem); menu11.add(printFUNMenuItem2); menu11.add(printFGLMenuItem2); menu1.add(openFGLMenuItem2); menu1.add(openFunctorMenuItem2); menu1.addSeparator(); menu1.add(loadFGLMenuItem2); menu1.add(loadFUNMenuItem2); menu5.add(saveFGLMenuItem2); menu5.add(saveFunctorMenuItem2); openFGLMenuItem.setEnabled(true); openFGLMenuItem2.setEnabled(true); loadFGLMenuItem2.setEnabled(true); loadFGLMenuItem.setEnabled(true); //loadCGLMenuItem.setEnabled(false); textPanel.setName("panel3"); textCardLayout.show(textPanel, "displayPanel"); construct(new Graph(true)); construct2(new Graph(true), new Graph(true)); objectArea.setEditable(false); arrowArea.setEditable(false); relationArea.setEditable(false); recentCatFiles(); CategoryNode current = catList.head; while(current != null) { categoryChoice.addItem(current.cat.name); current = current.next; } } //Overriden so we can exit on System Close protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { saveModifiedCats(); System.exit(0); } } //This class contains the information about the last 8 category //files that have been opened void recentCatFiles() //This function adds the recent category files to the category open menu { ini.readRecentFiles(); if (ini.getRecent(1).equals("")) fileMenu.remove(recent1MenuItem); else { recent1MenuItem.setLabel(ini.getRecent(1)); fileMenu.add(recent1MenuItem); } if (ini.getRecent(2).equals("")) fileMenu.remove(recent2MenuItem); else { recent2MenuItem.setLabel(ini.getRecent(2)); fileMenu.add(recent2MenuItem); } if (ini.getRecent(3).equals("")) fileMenu.remove(recent3MenuItem); else { recent3MenuItem.setLabel(ini.getRecent(3)); fileMenu.add(recent3MenuItem); } if (ini.getRecent(4).equals("")) fileMenu.remove(recent4MenuItem); else { recent4MenuItem.setLabel(ini.getRecent(4)); fileMenu.add(recent4MenuItem); } if (ini.getRecent(5).equals("")) fileMenu.remove(recent5MenuItem); else { recent5MenuItem.setLabel(ini.getRecent(5)); fileMenu.add(recent5MenuItem); } if (ini.getRecent(6).equals("")) fileMenu.remove(recent6MenuItem); else { recent6MenuItem.setLabel(ini.getRecent(6)); fileMenu.add(recent6MenuItem); } if (ini.getRecent(7).equals("")) fileMenu.remove(recent7MenuItem); else { recent7MenuItem.setLabel(ini.getRecent(7)); fileMenu.add(recent7MenuItem); } if (ini.getRecent(8).equals("")) fileMenu.remove(recent8MenuItem); else { recent8MenuItem.setLabel(ini.getRecent(8)); fileMenu.add(recent8MenuItem); } } public void functorDisplay() //Change the main window to the functor display format { if (categoryDisplay.getState() && catList.head != null) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } else if (functorDisplay.getState() && fnode != null) { functorFromCanvas.unselectItems(); GraphEdit ge = new GraphEdit(functorFromGraph, functorFromCanvas); fnode.A.gml = ge.getGMLText(); ge.dispose(); functorToCanvas.unselectItems(); ge = new GraphEdit(functorToGraph, functorToCanvas); fnode.B.gml = ge.getGMLText(); ge.dispose(); graphCanvas_.unselectItems(); ge = new GraphEdit(graph_, graphCanvas_); diagram.gml = ge.getGMLText(); ge.dispose(); } //Switch card layout panels for category Display textCardLayout.show(textPanel, "Functor Display"); graphicalCardLayout.show(graphicalPanel, "panel3"); graphicalCardLayout.show(graphicalPanel, "createFunctor"); //Set the title of the main window if (functorChoice.getItemCount() != 0) { if (fnode != null) { this.setTitle("Graphical Database for Category Theory [" + fnode.f.filename + "]"); } } else this.setTitle("Graphical Database for Category Theory [" + ini.getCurrentVersion() + "]"); // display the diagram if (diagram.gml != null && diagram.gml.length() != 0) { displayCategoryGraph(diagram.gml); } else { // diagram.gml = new String(); displayCategoryGraph(""); } if (diagramdisplay_button.getState()) graphicalCardLayout.show(graphicalPanel, "panel3"); // check the menu items appropriately categoryDisplay.setState(false); functorDisplay.setState(true); validate(); } public void categoryDisplay() //Change the main window to the category display format { // save the currently displayed diagram if there is one if (functorDisplay.getState()) // && func != null) { if (f_list.head != null) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); diagram.gml = ge.getGMLText(); ge.dispose(); } } else if (categoryDisplay.getState() && !functorDisplay.getState() && catList.head != null) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } //Switch card layout panels for category Display textCardLayout.show(textPanel, "displayPanel"); graphicalCardLayout.show(graphicalPanel, "createFunctor"); graphicalCardLayout.show(graphicalPanel, "panel3"); categoryDisplay.setState(true); functorDisplay.setState(false); //Set the title of the main window if (categoryChoice.getItemCount() != 0) { if (categoryChoice.getSelectedItem() != null) { this.setTitle("Graphical Database for Category Theory [" + catList.getNode(categoryChoice.getSelectedItem()).filename + "]"); } displayCategoryGraph(cat.gml); } else this.setTitle("Graphical Database for Category Theory [" + ini.getCurrentVersion() + "]"); // draw the current category if (cat == null || categoryChoice.getItemCount() == 0) { displayCategoryGraph(""); } validate(); } void addRecentCat(String fname) //This method adds a recently opened, loaded, or saved file //to the list of recent category files { int i, j; for (i=1; i <= 8; i++) { if (ini.getRecent(i).equals(fname)) { for (j=i; j < 8; j++) { ini.setRecent(j, ini.getRecent(j+1)); } ini.setRecent(8, ""); } } for (i=7; i >= 1; i--) { ini.setRecent(i+1, ini.getRecent(i)); } ini.setRecent(1, fname); recentCatFiles(); validate(); } private void centerFrame(Frame f) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = f.getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; f.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); } //---------------------------------Action Listners------------------------------ void categoryChoice_itemStateChanged(ItemEvent e) //Action Listener that is called when a category is selected from //the category name pulldown menu { boolean test = false; // save the gml for the current category if (cat != null) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } if (categoryChoice.getItemCount() != 0) { // get the new category from the list cat = catList.getNode(categoryChoice.getSelectedItem()); if (!cat.filename.equals("")) { this.setTitle("Graphical Database for Category Theory [" + cat.filename + "]"); } else { this.setTitle("Graphical Database for Category Theory [ GDCT " + ini.getCurrentVersion() + "]"); } if (cat == null || cat.name == "") { validate(); return; } // display the new category if (cat.gml.equals("")) GraphCategory(graph_, graphCanvas_, cat); else { displayCategoryGraph(cat.gml); displayCategoryText(cat); graphCanvas_.update(true); } validate(); } } void functorChoice_itemStateChanged(ItemEvent e) //Action Listener that is called when a functor is selected from //the functor name pulldown menu { //Save layout of categories associated with current //functor before displaying new functor if (fnode != null) { GraphEdit ge; graphCanvas_.unselectItems(); ge = new GraphEdit(graph_, graphCanvas_); fnode.diagram.gml = ge.getGMLText(); ge.dispose(); functorFromCanvas.unselectItems(); ge = new GraphEdit(functorFromGraph, functorFromCanvas); fnode.A.gml = ge.getGMLText(); ge.dispose(); functorToCanvas.unselectItems(); ge = new GraphEdit(functorToGraph, functorToCanvas); fnode.B.gml = ge.getGMLText(); ge.dispose(); //Retrieve selected functor node from list of functors fnode = f_list.getNode(functorChoice.getSelectedItem()); func = fnode.f; A = fnode.A; B = fnode.B; diagram = fnode.diagram; //Delete current text in functorArea functorArrowArea.setText(""); functorObjectArea.setText(""); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); //display category A associated with current functor if (A.gml.equals("")) GraphCategory(functorFromGraph, functorFromCanvas, A); else { functorFromCanvas = new GraphCanvas(functorFromGraph, this, A); boolean drawGraph = displayCategoryGraph(fnode.A.gml, functorFromGraph); DDimension port_dim = functorFromPanel.getPortSize(); DDimension cont_dim = functorFromPanel.getContentSize(); double x = (cont_dim.width - port_dim.width) / 2.0; double y = (cont_dim.height - port_dim.height) / 2.0; functorFromPanel.scrollTo((int)x, (int)y); } //display category B associated with current functor if (B.gml.equals("")) GraphCategory(functorToGraph, functorToCanvas, B); else { functorToCanvas = new GraphCanvas(functorToGraph, this, B); boolean drawGraph = displayCategoryGraph(fnode.B.gml, functorToGraph); DDimension port_dim = functorToPanel.getPortSize(); DDimension cont_dim = functorToPanel.getContentSize(); double x = (cont_dim.width - port_dim.width) / 2.0; double y = (cont_dim.height - port_dim.height) / 2.0; functorToPanel.scrollTo((int)x, (int)y); } //display diagram category associated with current functor if (diagram.gml.equals("")) { graphCanvas_.unselectItems(); GraphCategory(graph_, graphCanvas_, diagram); ge = new GraphEdit(graph_, graphCanvas_); diagram.gml = ge.getGMLText(); ge.dispose(); } else { displayCategoryGraph(diagram.gml); } if (diagramdisplay_button.getState()) graphCanvas_.update(true); } validate(); } void categoryDisplay_itemStateChanged(ItemEvent e) //Action Listener that is called when "Category Display" //is selected from the Settings menu { if (categoryDisplay.getState() == true) { //Switch card layout panels for category Display categoryDisplay(); } else categoryDisplay.setState(true); } void functorDisplay_itemStateChanged(ItemEvent e) //Action Listener that is called when "Functor Display" //is selected from the Settings menu { if (functorDisplay.getState() == true) { //Switch card layout panels for category Display functorDisplay(); } else functorDisplay.setState(true); } void animateButton_actionPerformed(ActionEvent e) //Action Listener that is called when the "Auto Animate" button //is selected from the Functor Display panel { try { //Animate objects functorFromCanvas.animationObjects(); for (animateObj = 0; animateObj < A.numobj; animateObj++) { //First node in list on each graph Node toNode = functorToGraph.firstNode(); Node fromNode = functorFromGraph.firstNode(); for (fromNode = functorFromGraph.firstNode(); fromNode != null; fromNode = functorFromGraph.nextNode(fromNode)) { //functorToCanvas.paintOver(); //functorFromCanvas.paintOver(); if (A.obj[animateObj].equals(fromNode.getLabel())) { fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, ini.getAColor()); lastFromNode = fromNode; } else fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); } for (toNode = functorToGraph.firstNode(); toNode != null; toNode = functorToGraph.nextNode(toNode)) { if (B.obj[func.obj[animateObj]].equals(toNode.getLabel())) { toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, ini.getBColor()); lastToNode = toNode; } else toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); } Thread.sleep(ini.getAnimationDelay()); functorFromCanvas.paintOver(); functorToCanvas.paintOver(); } // Animate arrows functorFromCanvas.animationArrows(); for (animateArr = 0; animateArr < A.numarr; animateArr++) { functorToCanvas.paintOver(); functorFromCanvas.paintOver(); if (animateArr == 0) { lastFromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); lastToNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); } //boolean directed = functorToGraph.isDirected(); Enumeration toEdges = functorToGraph.getEdges(); Enumeration fromEdges = functorFromGraph.getEdges(); int j = 0; while(fromEdges.hasMoreElements()) { Edge fromEdge = (Edge)(fromEdges.nextElement()); fromEdge.getEdgePresent(fromEdge.getLabel(), A.arrow[animateArr], functorFromCanvas, ini, true); /* if (A.arrow[animateArr].equals(fromEdge.getLabel())) fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, cons.AColor, false, null); else fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, Color.black, false, null); */ j++; } j = 0; while (func.arr[animateArr][j] != -1) { while(toEdges.hasMoreElements()) { Edge toEdge = (Edge)(toEdges.nextElement()); toEdge.getEdgePresent(toEdge.getLabel(), B.arrow[func.arr[animateArr][j]], functorToCanvas, ini, true); /* if (B.arrow[func.arr[animateArr][j]].equals(toEdge.getLabel())) toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, cons.BColor, false, null); else toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, Color.black, false, null); */ } j++; } Thread.sleep(ini.getAnimationDelay()); } } catch (Exception ex) { new MessageDialog(this, "Error", "Exception occured while running functor animation", true); } //Reset object and arrow counters animateObj = 0; animateArr = 0; //Reset Canvas Areas functorFromCanvas.paintOver(); functorToCanvas.paintOver(); functorFromCanvas.animationStopped(); } Node lastToNode; Node lastFromNode; int animateObj = 0; int animateArr = 0; boolean forward = false; boolean back = false; void backButton_actionPerformed(ActionEvent e) //Action Listener that is called when "<< Back" button //is selected from the Functor Display panel { functorToCanvas.paintOver(); functorFromCanvas.paintOver(); if (forward == true) { if ((animateObj <= A.numobj) && (animateArr == 0)) { animateObj = animateObj - 2; } else if (animateArr == 1) animateObj = A.numobj-1; else if ((animateObj == A.numobj) && (animateArr <= A.numarr)) { animateArr = animateArr - 2; } } back = true; forward = false; //Animate objects if ((animateObj >= 0) && (animateObj < A.numobj)) { if (animateArr == 1) { animateArr = 0; animateObj = A.numobj-1; //Edges from hash table Enumeration toEdges = functorToGraph.getEdges(); Enumeration fromEdges = functorFromGraph.getEdges(); //repaint all edges in Category A and Category B black while(fromEdges.hasMoreElements()) { Edge fromEdge = (Edge)(fromEdges.nextElement()); fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, Color.black, false, null); } while(toEdges.hasMoreElements()) { Edge toEdge = (Edge)(toEdges.nextElement()); toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, Color.black, false, null); } } //First node in list on each graph Node toNode = functorToGraph.firstNode(); Node fromNode = functorFromGraph.firstNode(); for (fromNode = functorFromGraph.firstNode(); fromNode != null; fromNode = functorFromGraph.nextNode(fromNode)) { if (A.obj[animateObj].equals(fromNode.getLabel())) { fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, ini.getAColor()); lastFromNode = fromNode; } else fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); } for (toNode = functorToGraph.firstNode(); toNode != null; toNode = functorToGraph.nextNode(toNode)) { if (B.obj[func.obj[animateObj]].equals(toNode.getLabel())) { toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, ini.getBColor()); lastToNode = toNode; } else toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); } animateObj--; } // Animate arrows else if ((animateObj == A.numobj) && (animateArr < A.numarr) && (animateArr >= 0)) { if ((animateArr == 0) && (lastFromNode != null)) lastFromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); if ((animateArr == 0) && (lastToNode != null)) lastToNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); Enumeration toEdges = functorToGraph.getEdges(); Enumeration fromEdges = functorFromGraph.getEdges(); //boolean directed = functorToGraph.isDirected(); while(fromEdges.hasMoreElements()) { Edge fromEdge = (Edge)(fromEdges.nextElement()); fromEdge.getEdgePresent(fromEdge.getLabel(), A.arrow[animateArr], functorFromCanvas, ini, true); /* if (A.arrow[animateArr].equals(fromEdge.getLabel())) fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, cons.AColor, false, null); else fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, Color.black, false, null); */ } int j =0; while (func.arr[animateArr][j] != -1) { while(toEdges.hasMoreElements()) { Edge toEdge = (Edge)(toEdges.nextElement()); toEdge.getEdgePresent(toEdge.getLabel(), B.arrow[func.arr[animateArr][j]], functorToCanvas, ini, true); /* if (B.arrow[func.arr[animateArr][j]].equals(toEdge.getLabel())) toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, cons.BColor, false, null); else toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, Color.black, false, null); */ } j++; } animateArr--; if (animateArr == -1) { animateObj--; animateArr = 0; } } else if ((animateObj == A.numobj) && (animateArr == A.numarr)) { animateObj = 0; animateArr = A.numarr - 1; } //edge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, cons.BColor); } void forwardButton_actionPerformed(ActionEvent e) //Action Listener that is called when "Forward >>" button //is selected from the Functor Display panel { functorToCanvas.paintOver(); functorFromCanvas.paintOver(); if (back == true) { if (animateObj < A.numobj) animateObj += 2; else if ((animateObj >= A.numobj) && (animateArr == 0)) { animateObj = A.numobj; animateArr = 0; } else if ((animateObj == A.numobj) && (animateArr < A.numarr)) { animateArr += 2; } } forward = true; back = false; //Animate objects if (animateObj < A.numobj) { //First node in list on each graph Node toNode = functorToGraph.firstNode(); Node fromNode = functorFromGraph.firstNode(); for (fromNode = functorFromGraph.firstNode(); fromNode != null; fromNode = functorFromGraph.nextNode(fromNode)) { if (A.obj[animateObj].equals(fromNode.getLabel())) { fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, ini.getAColor()); lastFromNode = fromNode; } else fromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); } for (toNode = functorToGraph.firstNode(); toNode != null; toNode = functorToGraph.nextNode(toNode)) { if (B.obj[func.obj[animateObj]].equals(toNode.getLabel())) { toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, ini.getBColor()); lastToNode = toNode; } else toNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); } animateObj++; } // Animate arrows else if ((animateObj == A.numobj) && (animateArr < A.numarr)) { if ((animateArr == 0) && (lastFromNode != null)) lastFromNode.draw(this, functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.quality_, Color.black); if ((animateArr == 0) && (lastToNode != null)) lastToNode.draw(this, functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.quality_, Color.black); Enumeration toEdges = functorToGraph.getEdges(); Enumeration fromEdges = functorFromGraph.getEdges(); //boolean directed = functorToGraph.isDirected(); while(fromEdges.hasMoreElements()) { Edge fromEdge = (Edge)(fromEdges.nextElement()); fromEdge.getEdgePresent(fromEdge.getLabel(), A.arrow[animateArr], functorFromCanvas, ini, true); //if (A.arrow[animateArr].equals(fromEdge.getLabel())) // fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, cons.AColor, false, null); //else // fromEdge.draw(functorFromCanvas.getGraphicsInternal_(), functorFromCanvas.viewTransform_, functorFromCanvas.xyPlane_, true, false, functorFromCanvas.quality_, functorFromCanvas, 1, Color.black, false, null); } int j =0; while (func.arr[animateArr][j] != -1) { while(toEdges.hasMoreElements()) { Edge toEdge = (Edge)(toEdges.nextElement()); toEdge.getEdgePresent(toEdge.getLabel(), B.arrow[func.arr[animateArr][j]], functorToCanvas, ini, true); /*if (B.arrow[func.arr[animateArr][j]].equals(toEdge.getLabel())) toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, cons.BColor, false, null); else toEdge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, Color.black, false, null);*/ } j++; } animateArr++; } //edge.draw(functorToCanvas.getGraphicsInternal_(), functorToCanvas.viewTransform_, functorToCanvas.xyPlane_, true, false, functorToCanvas.quality_, functorToCanvas, 1, cons.BColor); } void resetButton_actionPerformed(ActionEvent e) //Action Listener that is called when "Reset" button //is selected from the Functor Display panel { //Reset object and arrow counters animateObj = 0; animateArr = 0; //reset boolean values for which button was pressed last forward = false; back = false; //reset Canvas functorToCanvas.paintOver(); functorFromCanvas.paintOver(); } void openCategoryMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Open Category" menu option //is selected { //Switch card layout panels for category Display categoryDisplay(); //Open *.CAT File [ie. text file] FileDialog c = new FileDialog(this, "Open Category File (CAT)", FileDialog.LOAD); c.setVisible(true); //c.setFile ("*.cat"); // Set initial filename filter String file = c.getFile(); if (file != null) { if (categoryChoice.getItemCount() != 0) { // save the current category's GML graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } cat = new Category(); file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, false, true); if (!f.readCATFile(cat)) { return; } // now open the new file and store it in cat this.setTitle("Graphical Database for Category Theory [" + file + "]"); addRecentCat(file); validate(); cat.filename = (file); // create GML for this category and display it displayCategoryText(cat); categoryChoice.add(cat.name); categoryChoice.select(cat.name); GraphCategory(graph_, graphCanvas_, cat); graphCanvas_.unselectItems(); GraphEdit ged = new GraphEdit(graph_, graphCanvas_); cat.gml = ged.getGMLText(); displayCategoryGraph(cat.gml); ged.dispose(); } } void openCGLMenuItem_actionPerformed(ActionEvent e) //This function is called when the "Open Category (CGL)" menu //option is selected. It opens a category file that contains both //the text(CAT) and graphical(GML) version of the category { categoryDisplay(); //Open *.CGL File [ie. text and graphical file] FileDialog c = new FileDialog(this, "Open Category File (CGL)", FileDialog.LOAD); c.setVisible(true); String file = c.getFile(); if (file != null) { if (categoryChoice.getItemCount() != 0) { // save the current category's GML graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } cat = new Category(); file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, false, true); if (!f.readCGLFile(cat)) { return; } // now open the new file and store it in cat this.setTitle("Graphical Database for Category Theory [" + file + "]"); addRecentCat(file); validate(); cat.filename = file; // display the new category displayCategoryText(cat); displayCategoryGraph(cat.gml); categoryChoice.add(cat.name); categoryChoice.select(cat.name); } } void recentMenuItem_actionPerformed(ActionEvent e) //This function is called when the user selects one of the recently listed //category files to open { /* if (e.getActionCommand().startsWith("http://")) { new MessageDialog(this, "Error", "Loading of recent category files is not yet implemented", true); }*/ if (e.getActionCommand().toLowerCase().endsWith(".cat"))// || e.getActionCommand().endsWith(".CAT")) { if (cat != null) { categoryDisplay(); graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } cat = new Category(); String file = e.getActionCommand(); FileProcessing f; //If *.CAT file is on a server... if (e.getActionCommand().startsWith("http://")) { f = new FileProcessing(file, this, false, false); //Indicate that category file was loaded from server cat.mod.downloadCat = true; } //If *.CAT file is on the local machine else f = new FileProcessing(file, this, false, true); if (cat != null) { this.setTitle("Graphical Database for Category Theory [" + file + "]"); addRecentCat(file); validate(); cat.filename = (file); f.readCATFile(cat); displayCategoryText(cat); categoryChoice.add(cat.name); categoryChoice.select(cat.name); GraphCategory(graph_, graphCanvas_, cat); GraphEdit ged = new GraphEdit(graph_, graphCanvas_); cat.gml = ged.getGMLText(); ged.dispose(); } } //else if (e.getActionCommand().endsWith(".cgl") || e.getActionCommand().endsWith(".CGL")) else if (e.getActionCommand().toLowerCase().endsWith(".cgl")) { if (cat != null) { categoryDisplay(); graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); } cat = new Category(); GraphCategory(graph_, graphCanvas_, cat); String file = e.getActionCommand(); FileProcessing f; //If *.CGL file is on a server... if (e.getActionCommand().startsWith("http://")) { f = new FileProcessing(file, this, false, false); //Indicate that category file was loaded from server cat.mod.downloadCat = true; } //If *.CGL file is on the local machine else f = new FileProcessing(file, this, false, true); //if (cat != null) //{ this.setTitle("Graphical Database for Category Theory [" + file + "]"); addRecentCat(file); validate(); cat.filename = (file); f.readCGLFile(cat); displayCategoryText(cat); categoryChoice.add(cat.name); categoryChoice.select(cat.name); //} } else if (e.getActionCommand().toLowerCase().endsWith(".fun")) { functorDisplay(); fnode = f_list.getNode(functorChoice.getSelectedItem()); if (fnode != null && functorDisplay.getState()) { //Save layout of categories associated with current //functor before displaying new functor functorFromCanvas.unselectItems(); GraphEdit ge = new GraphEdit(functorFromGraph, functorFromCanvas); fnode.A.gml = ge.getGMLText(); ge.dispose(); functorToCanvas.unselectItems(); ge = new GraphEdit(functorToGraph, functorToCanvas); fnode.B.gml = ge.getGMLText(); ge.dispose(); graphCanvas_.unselectItems(); ge = new GraphEdit(graph_, graphCanvas_); fnode.diagram.gml = ge.getGMLText(); ge.dispose(); } //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); diagram = new Category(); //Open *.FUN File [ie. functor text file] String file = e.getActionCommand(); FileProcessing f; //If *.FUN file is on a server... if (e.getActionCommand().startsWith("http://")) { f = new FileProcessing(file, this, false, false); //Indicate that category files was loaded from server A.mod.downloadCat = true; B.mod.downloadCat = true; } //If *.FUN file is on the local machine else f = new FileProcessing(file, this, false, true); if (file != null) { validate(); //Read functor (*.FUN) file including two associated categories A and B. f.readFUNFile(func, A, B); //Display Category A GraphCategory(functorFromGraph, functorFromCanvas, A); functorFromCanvas.unselectItems(); GraphEdit ged = new GraphEdit(functorFromGraph, functorFromCanvas); A.gml = ged.getGMLText(); ged.dispose(); //Display Category B GraphCategory(functorToGraph, functorToCanvas, B); functorToCanvas.unselectItems(); ged = new GraphEdit(functorToGraph, functorToCanvas); B.gml = ged.getGMLText(); ged.dispose(); //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); addRecentCat(file); } } else if (e.getActionCommand().toLowerCase().endsWith(".fgl")) { //Switch card layout panels for category Display functorDisplay(); fnode = f_list.getNode(functorChoice.getSelectedItem()); if (fnode != null && functorDisplay.getState()) { //Save layout of categories associated with current //functor before displaying new functor functorFromCanvas.unselectItems(); GraphEdit ge = new GraphEdit(functorFromGraph, functorFromCanvas); fnode.A.gml = ge.getGMLText(); ge.dispose(); functorToCanvas.unselectItems(); ge = new GraphEdit(functorToGraph, functorToCanvas); fnode.B.gml = ge.getGMLText(); ge.dispose(); graphCanvas_.unselectItems(); ge = new GraphEdit(graph_, graphCanvas_); fnode.diagram.gml = ge.getGMLText(); ge.dispose(); } //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); diagram = new Category(); //Open *.FUN File [ie. functor text file] String file = e.getActionCommand(); FileProcessing f; //If *.FUN file is on a server... if (e.getActionCommand().startsWith("http://")) { f = new FileProcessing(file, this, false, false); //Indicate that category files was loaded from server A.mod.downloadCat = true; B.mod.downloadCat = true; } //If *.FUN file is on the local machine else f = new FileProcessing(file, this, false, true); if (file != null) { validate(); //Read functor (*.FGL) file including two associated categories A and B. f.readFGLFile(func, A, B); //Display Categories A and B displayCategoryGraph(A.gml, functorFromGraph); displayCategoryGraph(B.gml, functorToGraph); //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); addRecentCat(file); } } } void saveCategoryMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Save Category" menu option //is selected { categoryDisplay(); if (categoryChoice.getItemCount() != 0) { FileDialog c = new FileDialog(this, "Save Category File (CAT)", FileDialog.SAVE); c.setVisible(true); String file = c.getFile(); if (file != null) { file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, true, true); f.saveCATFile(); addRecentCat(file); } } else new MessageDialog(this, "Error", "Unable to save, no categories are currently open", true); } void saveCGLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Save Category (CGL)" menu option //is selected { categoryDisplay(); if (categoryChoice.getItemCount() != 0) { //Save Current Display of Category in Category class graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); //Save Category information including current display //of category in file FileDialog c = new FileDialog(this, "Save Category File (CGL)", FileDialog.SAVE); c.setVisible(true); String file = c.getFile(); if (file != null) { file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, true, true); f.saveCGLFile(); addRecentCat(file); } //Save current graphical display as original cat.originalGml = cat.gml; } else new MessageDialog(this, "Error", "Unable to save, no categories are currently open", true); } void saveGMLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Save Category (GML)" menu //option is selected { categoryDisplay(); try { String filename; FileDialog fd; fd = new FileDialog(this, "Save Category File (GML)", FileDialog.SAVE); fd.setVisible(true); filename = fd.getFile(); if(filename != null) { // Work around JDK Windows bug. if(filename.endsWith(".*.*")) { String tmpstr = filename.substring(0, filename.length() - 4); filename = tmpstr; } filename = fd.getDirectory() + filename; PrintWriter ps = new PrintWriter(new FileOutputStream(filename)); if(GMLfile_ == null) { GMLfile_ = new GMLobject(null, GMLobject.GMLfile); GMLfile_.addObjectToEnd(new GMLobject("graph", GMLobject.GMLlist)); } GMLobject gmlgraph = GMLfile_.getGMLSubObject("graph", GMLobject.GMLlist, false); graph_.setGMLvalues(gmlgraph); gmlgraph.prune(); ps.println(GMLfile_.toString(0)); ps.close(); filename_ = filename; } } catch(Throwable ex) { MessageDialog dg = new MessageDialog(this, "Error", "Error saving GML version of category file.", true); } } void exitMenuItem_actionPerformed(ActionEvent e) //When exit menu option is selected, close program { saveModifiedCats(); dispose(); System.exit(0); } void saveModifiedCats() //This method checks all open categories and prompts the user //if a modified file or a newly created file has not been saved { boolean test = false; /* graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); */ for (int i=0; i < categoryChoice.getItemCount(); i++) { categoryChoice.select(i); cat = catList.getNode(categoryChoice.getSelectedItem()); if (!cat.filename.equals("")) { this.setTitle("Graphical Database for Category Theory [" + cat.filename + "]"); validate(); } else { this.setTitle("Graphical Database for Category Theory [ GDCT " + ini.getCurrentVersion() + "]"); validate(); } displayCategoryText(cat); if (cat.gml.equals("")) GraphCategory(graph_, graphCanvas_, cat); else { test = displayCategoryGraph(cat.gml); graphCanvas_.update(true); } //If category has been modified if (cat.isModified()) { //Open save dialog for category sCat SaveDialog sd = new SaveDialog(this, true); sd.setCategory(this); sd.setSize(400,275); sd.setResizable(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = sd.getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; sd.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); sd.setVisible(true); } } } void postscriptMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Print Category (Postscript)" //menu option is selected { categoryDisplay(); if(psDialog_ == null) psDialog_ = new PSdialog(this, graphCanvas_); else { psDialog_.pack(); psDialog_.setVisible(true); } } void printTextMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Print Category (Text)" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open to print", true); } else { //Initialize printCategory class printCategory p = new printCategory(this); //Call method to print text version of current category p.printTextCategory(); } } void printGraphicalMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Print Category (Graphical)" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open to print", true); } else { //Initialize printCategory class printCategory p = new printCategory(this); //Call method to print current category graphical p.printGraphicalCategory(); } } void printFUNMenuItem2_actionPerformed(ActionEvent e) //Action Listener that is called when "Print Functor (Text)" //menu option is selected { functorDisplay(); if (f_list.head == null && f_list.tail == null) { new MessageDialog(this, "Error", "There are no functor files open", true); } else { //Initialize printFunctor class printFunctor p = new printFunctor(this); //Call method to print text version of current functor p.printTextFunctor(); } } void aboutGDCTMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "About GDCT" menu //option is selected { AboutFrame a = new AboutFrame(); a.setSize(433,225); centerFrame(a); a.setResizable(false); a.setVisible(true); } void bugReportMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Bug Report" menu //option is selected { BugFrame b = new BugFrame(); b.setSize(475,400); centerFrame(b); b.setResizable(false); b.setVisible(true); } /* void aboutVGJMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "About VGJ" menu //option is selected { VGJAboutFrame a = new VGJAboutFrame(); a.setSize(475,350); centerFrame(a); a.setResizable(false); a.setVisible(true); } */ void aboutAuthorsMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "About Authors" menu //option is selected { AboutAuthors a = new AboutAuthors(); a.setSize(604,570); centerFrame(a); a.setResizable(false); a.setVisible(true); } void helpMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Help Menu" menu //option is selected { HelpFrame h = new HelpFrame(); h.setSize(700,500); centerFrame(h); h.setVisible(true); } void endomorphismMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Endomorphism" menu option //is selected { EndomorphismFrame endo = new EndomorphismFrame(this); endo.setSize(230,285); centerFrame(endo); endo.setVisible(true); } void showControlsMenuItem_itemStateChanged(ItemEvent e) //Action Listener that is called when "Show VGJ Controls" menu option //is selected { categoryDisplay(); if (showControlsMenuItem.getState()) { t.setVisible(true); ini.setCatControls(true); } else { t.setVisible(false); ini.setCatControls(false); } validate(); } void categoryCommentsMenuItem_itemStateChanged(ItemEvent e) //Action Listener that is called when "Show Comments" menu option //is selected { categoryDisplay(); if (categoryCommentsMenuItem.getState()) { commentLabel.setVisible(true); commentArea.setVisible(true); ini.setCatComments(true); } else { commentLabel.setVisible(false); commentArea.setVisible(false); ini.setCatComments(false); } validate(); } void editGMLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "View GML Text Representation" menu option //is selected { categoryDisplay(); graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); ge.pack(); ge.setVisible(true); } /* void centerOffsetMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Center Viewing Offset" //menu option is selected { DDimension port_dim = viewingPanel_.getPortSize(); DDimension cont_dim = viewingPanel_.getContentSize(); double x = (cont_dim.width - port_dim.width) / 2.0; double y = (cont_dim.height - port_dim.height) / 2.0; viewingPanel_.scrollTo((int)x, (int)y); portScroller_.setOffset(x, y); } */ void loadSettings_actionPerformed(ActionEvent e) //Action Listener that is called when "Server Settings" menu //option is selected { SettingsServer s = new SettingsServer(this); s.setSize(370, 250); centerFrame(s); s.setResizable(false); s.setVisible(true); } void catGraphicalSettingsMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Category Graphical Settings" menu //option is selected { categoryDisplay(); SettingsGraphical s = new SettingsGraphical(this); s.setSize(340, 218); //centerFrame(s);//got rid of this s.setModal(true);//these were added (mkgrvs) s.setLocation(getLocation());//this added (mkgrvs) s.setResizable(false); s.setVisible(true); } void funcGraphicalSettingsMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Functor Graphical Settings" menu //option is selected { functorDisplay(); SettingsFuncGraphical t = new SettingsFuncGraphical(this); t.setSize(480, 420); //centerFrame(t);//commented out mkgrvs t.setModal(true);//mkgrvs t.setLocation(getLocation());//added mkgrvs t.setResizable(false); t.setVisible(true); } void textSettingsMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Text Settings" menu //option is selected { categoryDisplay(); SettingsText s = new SettingsText(this); s.setSize(505, 235); centerFrame(s); s.setResizable(false); s.setVisible(true); } void animationSettingsMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Functor Animation Settings" menu //option is selected { functorDisplay(); SettingsAnimation s = new SettingsAnimation(this); s.setSize(420, 170); centerFrame(s); s.setResizable(false); s.setVisible(true); } void createFunctorMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Create Functot" menu option //is selected { editsub = 0; submenu = 1; A = new Category(); B = new Category(); diagram = new Category(); fnode = new FunctorNode(this); func = new CatFunctor(); boolean drawGraph = false; if (catList.isEmpty()) new MessageDialog(this, "Error", "Categories must be opened or created before functor can be created", true); else { functorNameField.setText(""); functorFromChoice.removeAll(); functorToChoice.removeAll(); functorInputField.setText(""); functorDisplayArea.setText(""); funcDisplayControls.setVisible(false); textCardLayout.show(textPanel, "Create Functor"); graphicalCardLayout.show(graphicalPanel, "createFunctor"); // check and disable the menu items appropriately categoryDisplay.setState(false); functorDisplay.setState(true); enableMenus(false); menuoption = 2; CategoryNode current = catList.head; while(current != null) { functorFromChoice.add(current.cat.name); functorToChoice.add(current.cat.name); current = current.next; } A = catList.getNode(functorFromChoice.getSelectedItem()); B = catList.getNode(functorToChoice.getSelectedItem()); drawGraph = displayCategoryGraph(A.gml, functorToGraph); drawGraph = displayCategoryGraph(B.gml, functorFromGraph); if (A.numobj != 0) { inputLabel.setText("Object " + A.obj[editsub] + "--> "); inputLabel.validate(); submenu = 1; } else if (A.numarr != 0) { inputLabel.setText("Arrow " + A.arrow[editsub] + "--> "); inputLabel.validate(); submenu = 1; } else { new MessageDialog(this, "Error", "Category " + A.name + " has no objects and arrows", true); } } } void functorFromChoice_itemStateChanged(ItemEvent e) //Action Listener that is called when the "Functor From" Choice menu //option is selected { A = new Category(); editsub = 0; A = catList.getNode(functorFromChoice.getSelectedItem()); //displayCategory functorFromCanvas = new GraphCanvas(functorFromGraph, this, cat); boolean drawGraph = displayCategoryGraph(A.gml, functorFromGraph); DDimension port_dim = functorFromPanel.getPortSize(); DDimension cont_dim = functorFromPanel.getContentSize(); double x = (cont_dim.width - port_dim.width) / 2.0; double y = (cont_dim.height - port_dim.height) / 2.0; functorFromPanel.scrollTo((int)x, (int)y); if (A.numobj != 0) { inputLabel.setText("Object " + A.obj[editsub] + "--> "); inputLabel.validate(); submenu = 1; } else if (A.numarr != 0) { inputLabel.setText("Arrow " + A.arrow[editsub] + "--> "); inputLabel.validate(); submenu = 1; } else { new MessageDialog(this, "Error", "Category " + A.name + " has no objects and arrows", true); } } void functorToChoice_itemStateChanged(ItemEvent e) //Action Listener that is called when the "Functor To" Choice menu //option is selected { B = new Category(); editsub = 0; B = catList.getNode(functorToChoice.getSelectedItem()); //displayCategory boolean drawGraph = displayCategoryGraph(B.gml, functorToGraph); DDimension port_dim = functorToPanel.getPortSize(); DDimension cont_dim = functorToPanel.getContentSize(); double x = (cont_dim.width - port_dim.width) / 2.0; double y = (cont_dim.height - port_dim.height) / 2.0; functorToPanel.scrollTo((int)x, (int)y); //drawGraph.validate(); } public void createFunctor(String functorName, Category A, Category B) //This function creates a functor from Category A to Category B with //the name functorName { //Get Functor Name func.name = functorName; //Initialize submenu to 2 if objects exist or //to 3 if only arrows exist if (submenu == 1) { if (A.numobj != 0) submenu++; else if (A.numarr != 0) submenu = 3; functorInputField.requestFocus(); } //Get Objects else if (submenu == 2) { String temp = functorInputField.getText(); //check to see that object is a valid object of B if(B.check_obj(temp)) { new MessageDialog(this, "Error", temp + " is not an object of Category " + B.name, true); } else { //Save the object if in B func.obj[editsub] = B.object_number(temp); editsub++; } //If number of objects in category A is reached... if (editsub == (A.numobj)) { editsub = 0; functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); functorInputField.setText(""); //If arrows exist in category A... if (A.numarr != 0) { submenu = 3; inputLabel.setText("Arrow " + A.arrow[editsub] + "--> "); inputLabel.validate(); } else { editsub =0; editoption = 0; submenu = 0; menuoption = 0; functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); functorInputField.setText(""); //Switch card layout panels for functor display textCardLayout.show(textPanel, "Functor Display"); graphicalCardLayout.show(graphicalPanel, "createFunctor"); funcDisplayControls.setVisible(true); validate(); //Make functor fnode.functor_type = 0; fnode.A = A; fnode.B = B; fnode.diagram = diagram; fnode.f = func; //Add functor to functor list f_list.insertNode(fnode, functorArrowArea); //display selected functor in objectArea and arrowArea functorChoice.add(func.name); displayFunctor(fnode.f); } } else { //check to see that object is a valid object of B if(!B.check_obj(temp)) { if (editsub == 1) functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); else functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); } inputLabel.setText("Object " + A.obj[editsub] + "--> "); inputLabel.validate(); functorInputField.setText(""); } } //Get Arrows else if (submenu == 3) { int path[] = new int[ini.getMAXWORD()]; String path_string = functorInputField.getText(); //If path is an identity arrow if(path_string.equals("1")) { func.arr[editsub][0] = ini.getIdentityCode(); func.arr[editsub][1] = -1; //right = "0"; //right[0] = '\x0'; editsub++; /*if (((c.arr[leftrel[0]][1]) != (c.arr[leftrel[path_len(leftrel)-1]][0])) && (rightrel[0] == cons.id_code)) { new MessageDialog(this, "Error", left + " cannot equal identity, not an endomorphism", true); add = false; } */ //path = copy_path(path,string_to_path(path_string, cat)); //func.arr[editsub] = copy_path(func.arr[editsub],path); } else { //checks to see that the string the user enters //contains only arrows that exist in category B if(!(B.check_string(path_string))) { new MessageDialog(this, "Error", "One or more of the arrows specified do not exist in Category " + B.name, true); } else { path = B.copy_path(B.string_to_path(path_string)); //checks to see that domains and codomains of each arrow in path match up if(!(B.check_path(path))) { new MessageDialog(this, "Error", "Domains and codomains of each arrow in path do not match", true); } else { //Checks to see that domain and codomain of path match up with //domain and codomain of arrow under the functor if((!(check_domain(path,editsub,func,A,B))) || (!(check_codomain(path,editsub,func,A,B)))) { new MessageDialog(this, "Error", "Domain or codomain of path does not match up with arrow under the functor", true); } else { int reduced_path[] = new int[ini.getMAXWORD()]; reduced_path = B.reduce(path); //reduced_path = path; func.arr[editsub] = cat.copy_path(reduced_path); editsub++; } } } } //If number of arrows in category A is reached... if (editsub == A.numarr) { //reset values editsub =0; editoption = 0; submenu = 0; menuoption = 0; functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); functorInputField.setText(""); //Switch card layout panels for category Display textCardLayout.show(textPanel, "Functor Display"); graphicalCardLayout.show(graphicalPanel, "createFunctor"); categoryDisplay.setState(false); functorDisplay.setState(true); funcDisplayControls.setVisible(true); updateDiagramCategory(); validate(); //Make Functor fnode.functor_type = 0; fnode.A = A; fnode.B = B; fnode.diagram = diagram; fnode.f = func; //Add functor to functor list f_list.insertNode(fnode, functorArrowArea); //Display functor displayFunctor(fnode.f); functorChoice.add(func.name); // enable menu items and set checkboxes enableMenus(true); } else { submenu = 3; functorDisplayArea.append(inputLabel.getText() + " " + functorInputField.getText() + "\n"); functorInputField.setText(""); inputLabel.setText("Arrow " + A.arrow[editsub] + "--> "); inputLabel.validate(); } } } void openFunctorMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when the "Open Functor" menu //option is selected { //Switch card layout panels for category Display functorDisplay(); fnode = f_list.getNode(functorChoice.getSelectedItem()); if (fnode != null) fnode.diagram = diagram; //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); diagram = new Category(); //Open *.FUN File [ie. functor text file] FileDialog c = new FileDialog(this, "Open Functor File (FUN)", FileDialog.LOAD); c.setVisible(true); String file = c.getFile(); if (file != null) { //Read functor (*.FUN) file including two associated categories A and B. file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, false, true); if (!f.readFUNFile(func, A, B)) { return; } addRecentCat(file); func.filename = file; this.setTitle("Graphical Database for Category Theory [" + file + "]"); validate(); //Display Category A GraphCategory(functorFromGraph, functorFromCanvas, A); functorFromCanvas.unselectItems(); GraphEdit ged = new GraphEdit(functorFromGraph, functorFromCanvas); A.gml = ged.getGMLText(); ged.dispose(); //Display Category B GraphCategory(functorToGraph, functorToCanvas, B); functorToCanvas.unselectItems(); ged = new GraphEdit(functorToGraph, functorToCanvas); B.gml = ged.getGMLText(); ged.dispose(); if (twocatdisplay_button.getState() && func != null) functorToCanvas.update(true); //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); } } void openFGLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when the "Open Functor" menu //option is selected { functorDisplay(); fnode = f_list.getNode(functorChoice.getSelectedItem()); if (fnode != null) fnode.diagram = diagram; //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); diagram = new Category(); //Open *.FUN File [ie. functor text file] FileDialog c = new FileDialog(this, "Open Functor File (FGL)", FileDialog.LOAD); c.setVisible(true); String file = c.getFile(); if (file != null) { //Read functor (*.FUN) file including two associated categories A and B. file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, false, true); if (!f.readFGLFile(func, A, B)) { return; } addRecentCat(file); func.filename = file; this.setTitle("Graphical Database for Category Theory [" + file + "]"); validate(); //Display Categories A and B displayCategoryGraph(A.gml, functorFromGraph); displayCategoryGraph(B.gml, functorToGraph); if (twocatdisplay_button.getState() && func != null) { functorToCanvas.update(true); } //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); } } void saveFunctorMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when the "Save Functor (FUN)" menu //option is selected { //Switch card layout panels for category Display functorDisplay(); if (functorChoice.getItemCount() != 0) { FileDialog c = new FileDialog(this, "Save Functor File (FUN)", FileDialog.SAVE); c.setVisible(true); String file = c.getFile(); if (file != null) { file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, true, true); f.saveFUNFile(fnode.A, fnode.B, fnode.f); } } else new MessageDialog(this, "Error", "Unable to save, no functors are currently open", true); } void saveFGLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when the "Save Functor (FGL)" menu //option is selected { //Switch card layout panels for category Display functorDisplay(); if (functorChoice.getItemCount() != 0) { FileDialog c = new FileDialog(this, "Save Functor File (FGL)", FileDialog.SAVE); c.setVisible(true); String file = c.getFile(); if (file != null) { file = c.getDirectory() + c.getFile(); FileProcessing f = new FileProcessing(file, this, true, true); f.saveFGLFile(fnode.A, fnode.B, fnode.f); } } else new MessageDialog(this, "Error", "Unable to save, no functors are currently open", true); } public void closeFunctorMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when the "Close Functor" menu //option is selected { functorDisplay(); fnode = f_list.getNode(functorChoice.getSelectedItem()); if (fnode == null) { new MessageDialog(this, "Error", "There are no functor files open", true); } else { f_list.removeNode(fnode.f.name); functorChoice.remove(functorChoice.getSelectedItem()); if (functorChoice.getItemCount() == 0) { func = new CatFunctor(); A = new Category(); B = new Category(); diagram = new Category(); fnode = null; functorObjectArea.setText(""); functorArrowArea.setText(""); displayCategoryGraph("", functorFromGraph); displayCategoryGraph("", functorToGraph); } functorChoice_itemStateChanged(new ItemEvent(functorChoice, 0, new Object(), 0)); functorDisplay(); } } public void displayFunctor(CatFunctor F) //This method displays a functor in the specified text area. The //parameters are F which is the functor to be displayed and t which //is the text area where the functor will be displayed { int i =0,j; //clear display areas functorObjectArea.setText(""); functorArrowArea.setText(""); //Display functor objects for (i=0;i " + B.obj[F.obj[i]] + "\n"); functorObjectArea.append(A.obj[i] + " |--> " + B.obj[F.obj[i]] + "\n"); /*for (i=0;i "); //functorArrowArea.append(F.name + "(" + A.arrow[i] + ") = "); j = 0; if (F.arr[i][j] == -2) functorArrowArea.append("1\n"); else { while (F.arr[i][j] != -1) { if (j == 0) functorArrowArea.append("" + B.arrow[F.arr[i][j]]); else functorArrowArea.append("*" + B.arrow[F.arr[i][j]]); j++; } } functorArrowArea.append("\n"); } //If all arrows not displayed... if (A.numarr != 0) { functorArrowArea.append(A.arrow[i] + " |--> "); //functorArrowArea.append(F.name + "(" + A.arrow[i] + ") = "); j = 0; if (F.arr[i][j] == -2) functorArrowArea.append("1\n"); else { while (F.arr[i][j] != -1) { if (j == 0) functorArrowArea.append("" + B.arrow[F.arr[i][j]]); else functorArrowArea.append("*" + B.arrow[F.arr[i][j]]); j++; } } functorArrowArea.append("\n"); } else functorArrowArea.append("\n"); } /* Parameters: path: the path in B that the arrow goes to under the functor arrow: the arrow of A that goes to the path under the functor f: a category functor A: the category that the functor goes from B: the category that the functor goes to Purpose: To check that the object which is the domain of the arrow in A goes to the object which is the domain of the path in B that the arrow goes to under the functor Design: Returns true if the domains match up, false otherwise */ boolean check_domain(int path[], int arrow, CatFunctor f, Category A, Category B) { if(f.obj[A.arr[arrow][0]] != B.arr[path[B.path_len(path)-1]][0]) { new MessageDialog(this, "Error", B.path_to_string(path) + " has an invalid domain.", true); return(false); } return(true); } boolean check_codomain(int path[], int arrow, CatFunctor f, Category A, Category B) //This function checks that the object which is the codomain of the arrow in //A goes to the object which is the codomain of the path in B that the arrow goes //to under the functor. It returns true if the codomains match up, false otherwise { if(f.obj[A.arr[arrow][1]] != B.arr[path[0]][1]) { new MessageDialog(this, "Error", B.path_to_string(path) + " has an invalid codomain.", true); return(false); } return(true); } void createCategoryMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Create Category" menu option //is selected { this.setTitle("Graphical Database for Category Theory [ GDCT " + ini.getCurrentVersion() + "]"); validate(); catInputField.setText(""); categoryNameField.setText(""); viewbox.setText(""); categoryNameField.setEditable(true); doneButton.setVisible(false); catInputField.setVisible(false); catInputLabel.setVisible(false); textCardLayout.show(textPanel, "inputPanel"); if (catList.head != null) { boolean graph = displayCategoryGraph("graph [directed 1]"); } cat = new Category(); menuoption = 1; enableMenus(false); } String temp = new String(); public void CatMenuEnter(Event e) //Method is called when user is in category Menu and //has a pressed the enter button { int check = 0; if (menuoption == 1) { if (submenu == 0) { //if name != names in list cat.name = categoryNameField.getText(); categoryNameField.setEditable(false); viewbox.append("Category Name: " + cat.name + "\n"); submenu = 1; catInputLabel.setText("Object Name:"); catInputLabel.validate(); doneButton.setLabel("Objects Complete"); doneButton.validate(); doneButton.setVisible(true); catInputField.setVisible(true); catInputLabel.setVisible(true); catInputField.requestFocus(); } else if (submenu == 1) { String temp = catInputField.getText(); if (temp.equals("")) { submenu = 2; catInputLabel.setText("Arrow Name:"); doneButton.setLabel("Arrows Complete"); return; } for (int i = 0; i < cat.numobj; i++) { if (temp.equals(cat.obj[i])) check = 1; } if ((check == 0)) { viewbox.append("Object: " + catInputField.getText() + "\n"); catInputField.setText(""); catInputField.requestFocus(); cat.obj[cat.numobj] = temp; cat.numobj++; if (cat.numobj == 1) GraphCategory(graph_, graphCanvas_, cat); else { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); addObjectGML(cat.gml); boolean test = displayCategoryGraph(cat.gml); } } else { new MessageDialog(this, "Error", "Multiple declaration of object " + temp, true); } catInputField.requestFocus(); catInputLabel.setText("Object Name:"); catInputLabel.validate(); graphCanvas_.update(true); } else if (submenu == 2) { String temp = catInputField.getText(); if (temp.equals("")) { submenu = 5; catInputLabel.setText("LHS of Equation:"); doneButton.setLabel("Relations Complete"); return; } for (int i = 0; i < cat.numarr; i++) { if (temp.equals(cat.arrow[i])) check = 1; } if (check == 0) { viewbox.append(" Arrow: " + catInputField.getText()); catInputField.setText(""); cat.arrow[cat.numarr] = temp; submenu = 3; catInputLabel.setText("Domain of " + cat.arrow[cat.numarr] + ": "); catInputLabel.validate(); catInputField.requestFocus(); } else { new MessageDialog(this, "Error", "Multiple declaration of arrow " + temp, true); } graphCanvas_.update(true); } else if ((submenu == 3) && (cat.numobj != 0)) { String temp = catInputField.getText(); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].equals(temp)) { check = 1; cat.arr[cat.numarr][0] = i; } } if (check == 1) { viewbox.append(":" + catInputField.getText() + "->"); catInputField.setText(""); submenu = 4; catInputLabel.setText("CoDomain of " + cat.arrow[cat.numarr] + ": "); catInputLabel.validate(); catInputField.requestFocus(); } else { new MessageDialog(this, "Error", "Invalid Domain Declaration. Domain " + temp + " Not Found", true); catInputLabel.setText("Domain of " + cat.arrow[cat.numarr] + ": "); catInputLabel.validate(); } graphCanvas_.update(true); } else if (submenu == 4) { String temp = catInputField.getText(); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].equals(temp)) { check = 1; cat.arr[cat.numarr][1] = i; } } if (check == 1) { viewbox.append(catInputField.getText() + "\n"); catInputField.setText(""); cat.numarr++; graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); addArrowGML(cat.gml, (cat.numarr)-1); boolean test = displayCategoryGraph(cat.gml); catInputField.requestFocus(); catInputLabel.setText("Arrow Name: "); catInputLabel.validate(); submenu = 2; } else { new MessageDialog(this, "Error", "Invalid CoDomain Declaration. CoDomain " + temp + " Not Found", true); catInputLabel.setText("CoDomain of " + cat.arrow[cat.numarr] + ": "); catInputLabel.validate(); } graphCanvas_.update(true); } else if (submenu == 5) { temp = catInputField.getText(); if (temp.equals("")) { submenu = 7; catInputLabel.setText("Comments:"); doneButton.setLabel("Comments Complete"); return; } viewbox.append("Relation: " + temp + " = "); catInputField.setText(""); submenu = 6; catInputLabel.setText("RHS of equation :"); catInputLabel.validate(); catInputField.requestFocus(); } else if (submenu == 6) { viewbox.append(catInputField.getText() + "\n"); get_rel(temp, catInputField.getText(), cat); catInputField.setText(""); submenu = 5; //GraphCategory(graph_, graphCanvas_, cat); catInputLabel.setText("LHS of equation :"); catInputLabel.validate(); graphCanvas_.update(true); } else if (submenu == 7) { cat.comment = catInputField.getText(); viewbox.append("\ncomments:\n" + cat.comment); submenu = 0; menuoption = 0; //Indicate that category was created using //the "Create Category" tool in GDCT Application cat.mod.createCat = true; catList.insertNode(cat); //put category in Linked List textCardLayout.show(textPanel, "displayPanel"); // Enable menu items again enableMenus(true); //Clear graphical display HERE categoryChoice.addItem(cat.name); categoryChoice.select(cat.name); displayCategoryText(cat); graphCanvas_.update(true); } } } void doneButton_actionPerformed(ActionEvent e) // Function is called on an exit menu choice or delete from the WM menu { if (menuoption == 1) { if (submenu == 1) { catInputLabel.setText("Arrow Name:"); catInputLabel.validate(); doneButton.setLabel("Arrows Complete"); doneButton.validate(); submenu = 2; graphCanvas_.update(true); } else if (submenu == 2) { submenu = 5; catInputLabel.setText("LHS of Equation:"); catInputLabel.validate(); doneButton.setLabel("Relations Complete"); doneButton.validate(); graphCanvas_.update(true); } else if (submenu == 5 || submenu == 6) { submenu = 7; catInputLabel.setText("Comments:"); catInputLabel.validate(); doneButton.setLabel("Comments Complete"); doneButton.validate(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); addRelationGML(cat.gml); boolean test = displayCategoryGraph(cat.gml); graphCanvas_.update(true); } else if (submenu == 7) { cat.comment = catInputField.getText(); viewbox.append("\ncomments:\n" + cat.comment); submenu = 0; menuoption = 0; catList.insertNode(cat); //put category in Linked List textCardLayout.show(textPanel, "displayPanel"); // Enable menu items again fileMenu.setEnabled(true); categoriesMenu.setEnabled(true); functorsMenu.setEnabled(true); toolMenu.setEnabled(true); settingsMenu.setEnabled(true); //Clear graphical display HERE categoryChoice.add(cat.name); categoryChoice.select(cat.name); displayCategoryText(cat); graphCanvas_.update(true); } catInputField.requestFocus(); //workbox.requestFocus(); } } void loadCategoryMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Load Category" menu option //is selected { // textCardLayout.show(textPanel, "displayPanel"); categoryDisplay(); catLoadList.removeAll(); try { fileURL = new URL(ini.getServer() + ini.getCatDir()); } catch (MalformedURLException except) { new MessageDialog(this, "Error", ini.getServer() + ini.getCatDir() + " is not a valid URL", true); } try { input = fileURL.openStream(); dataInput = new DataInputStream(input); dataInput.close(); catLoad = new LoadCATFrame(this, loadCatButton, catLoadList); catLoad.setSize(380,280); centerFrame(catLoad); catLoad.setResizable(false); catLoad.setVisible(true); } catch(IOException ioe) { new MessageDialog(this, "Error", "Unable to connect to " + ini.getServer() + ini.getCatDir(), true); } } void loadCGLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Download Category (CGL)" menu option //is selected { categoryDisplay(); catLoadList.removeAll(); try { fileURL = new URL(ini.getServer() + ini.getCatDir()); } catch (MalformedURLException except) { new MessageDialog(this, "Error", ini.getServer() + ini.getCatDir() + " is not a valid URL", true); } try { input = fileURL.openStream(); dataInput = new DataInputStream(input); dataInput.close(); cglLoad = new LoadCGLFrame(this, loadCatButton, catLoadList); cglLoad.setSize(380,280); centerFrame(cglLoad); cglLoad.setResizable(false); cglLoad.setVisible(true); } catch(IOException ioe) { new MessageDialog(this, "Error", "Unable to connect to " + ini.getServer() + ini.getCatDir(), true); } } void loadFUNMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Download Functor (FUN)" menu option //is selected { functorDisplay(); catLoadList.removeAll(); try { fileURL = new URL(ini.getServer() + ini.getFunDir()); } catch (MalformedURLException except) { new MessageDialog(this, "Error", ini.getServer() + ini.getCatDir() + " is not a valid URL", true); } try { input = fileURL.openStream(); dataInput = new DataInputStream(input); dataInput.close(); funLoad = new LoadFUNFrame(this, loadCatButton, catLoadList); funLoad.setSize(380,280); centerFrame(funLoad); funLoad.setResizable(false); funLoad.setVisible(true); } catch(IOException ioe) { new MessageDialog(this, "Error", "Unable to connect to " + ini.getServer() + ini.getFunDir(), true); } } void loadFGLMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Download Functor (FGL)" menu option //is selected { functorDisplay(); catLoadList.removeAll(); try { fileURL = new URL(ini.getServer() + ini.getFglDir()); } catch (MalformedURLException except) { new MessageDialog(this, "Error", ini.getServer() + ini.getCatDir() + " is not a valid URL", true); } try { input = fileURL.openStream(); dataInput = new DataInputStream(input); dataInput.close(); fglLoad = new LoadFGLFrame(this, loadCatButton, catLoadList); fglLoad.setSize(380,280); centerFrame(fglLoad); fglLoad.setResizable(false); fglLoad.setVisible(true); } catch(IOException ioe) { new MessageDialog(this, "Error", "Unable to connect to " + ini.getServer() + ini.getFglDir(), true); } } /* void listCategoriesMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "List Categories" menu option //is selected { catDisplayList.removeAll(); ListNode current = List.head; while(current != null) { catDisplayList.addItem(current.cat.name); current = current.next; } if (catDisplayList.getItemCount() == 0) { new MessageDialog(this, "Error", "There are no category files open to Display\nCategory File must be Loaded or\nCreated before being Displayed", true); } else { ListCatFrame l = new ListCatFrame(catDisplayList); l.setSize(210,250); l.setResizable(false); l.setVisible(true); } }*/ /* void displayCategoryMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Display Category" menu option //is selected { catDisplayList.removeAll(); ListNode current = List.head; while(current != null) { catDisplayList.addItem(current.cat.name); current = current.next; } if (catDisplayList.getItemCount() == 0) { new MessageDialog(this, "Error", "There are no category files open to Display\nCategory File must be Loaded or\nCreated before being Displayed", true); } else { d = new DisplayCatFrame(catDisplayButton, catDisplayList, textDisplayCheckBox, graphicalDisplayCheckBox); d.setSize(350,250); d.setResizable(false); d.setVisible(true); } } */ /* void catDisplayButton_actionPerformed(ActionEvent e) { String name; if ((catDisplayList.getItemCount() != 0) && (catDisplayList.getSelectedItem() != null)) { name = catDisplayList.getSelectedItem(); catDisplayList.removeAll(); d.setVisible(false); d.dispose(); if (!name.equals("")) { cat = List.getNode(name); if (name.equals(cat.name)) { textCardLayout.show(textPanel, "displayPanel"); //Clear graphical display HERE if (textDisplayCheckBox.getState() == true) displayCategory(cat); if (graphicalDisplayCheckBox.getState() == true) GraphCategory(graph_, graphCanvas_, cat); } } else viewbox.append("Invalid Category Name\n"); } else { new MessageDialog(this, "Error", "No Category File Selected\nCategory Must be Selected Before\nit can be Displayed", true); } } */ public void displayCategoryText(Category c) //Displays category in the viewbox text area { int counter = 0; objectArea.setText(""); arrowArea.setText(""); relationArea.setText(""); commentArea.setText(""); for (int i = 0; i < c.numobj; i++) { if (i < (c.numobj - 1)) objectArea.append(c.obj[i] + ", "); if (i == (c.numobj - 1)) objectArea.append(c.obj[i] + ".\n"); } for (int i = 0; i < c.numarr; i++) { if (i < (c.numarr - 1)) { arrowArea.append(c.arrow[i] + ":"); arrowArea.append(c.obj[c.arr[i][0]] + "->"); arrowArea.append(c.obj[c.arr[i][1]] + ", "); } if (i == (c.numarr - 1)) { arrowArea.append(c.arrow[i] + ":"); arrowArea.append(c.obj[c.arr[i][0]] + "->"); arrowArea.append(c.obj[c.arr[i][1]] +". " ); } counter++; if ((counter == 4) || (i == (c.numarr-1))) { counter = 0; arrowArea.append("\n"); } } print_rel(c, relationArea); commentArea.setText(c.comment); objectArea.setCaretPosition(0); arrowArea.setCaretPosition(0); relationArea.setCaretPosition(0); commentArea.setCaretPosition(0); } public void print_rel(Category c, TextArea v) //prints relations of category on the screen { String relations = new String(); int i,j; int counter = 0; for (i=0;i screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; sd.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); sd.setVisible(true); } catList.removeNode(cat.name); categoryChoice.remove(categoryChoice.getSelectedIndex()); if (categoryChoice.getItemCount() == 0) { cat = null; displayCategoryGraph(""); objectArea.setText(""); arrowArea.setText(""); relationArea.setText(""); commentArea.setText(""); } categoryChoice_itemStateChanged(new ItemEvent(categoryChoice, 0, new Object(), 0)); categoryDisplay(); } } void initialObjectMenuItem_actionPerformed(ActionEvent e) { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open" , true); } else { InitialObjectFrame io = new InitialObjectFrame(catList, this); io.setSize(480,290); centerFrame(io); io.setResizable(false); io.setVisible(true); } } void terminalObjectMenuItem_actionPerformed(ActionEvent e) { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open" , true); } else { TerminalObjectFrame to = new TerminalObjectFrame(catList, this); to.setSize(480,290); centerFrame(to); to.setResizable(false); to.setVisible(true); } } void sumMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Sum?" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { SumFrame s = new SumFrame(this); s.setSize(520,210); centerFrame(s); s.setResizable(false); s.setVisible(true); } } void productMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Product?" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { ProductFrame s = new ProductFrame(this); s.setSize(520,210); centerFrame(s); s.setResizable(false); s.setVisible(true); } } void makeConfluentMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Make Confluent" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { MakeConfluentFrame mc = new MakeConfluentFrame(this); mc.setSize(350,220); centerFrame(mc); mc.setResizable(false); mc.setVisible(true); } } void equalityCompMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Equality of Composites" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { //Store gml of current category in catgory node boolean test = false; graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); //open equality of composites frame EqualityComposites eq = new EqualityComposites(catList, this); eq.setSize(510,210); centerFrame(eq); eq.setResizable(false); eq.setVisible(true); } } void makeDualMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Make Dual Category" //menu option is selected { if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { //Store gml of current category in catgory node boolean test = false; graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); //open dual category frame DualCategoryFrame dual = new DualCategoryFrame(this); dual.setSize(350,150); centerFrame(dual); dual.setResizable(false); dual.setVisible(true); } } void gmlViewerMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "View GML" //menu option is selected { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); ge.pack(); centerFrame(ge); ge.setVisible(true); } void changeNameMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Change Name" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { ChangeNameFrame n = new ChangeNameFrame(catList, this); n.setSize(350,150); centerFrame(n); n.setResizable(false); n.setVisible(true); } } void addDataMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Add Object" //menu option is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { AddDataFrame a = new AddDataFrame(this); a.setSize(355,330); centerFrame(a); a.setResizable(false); a.setVisible(true); } } void removeDataMenuItem_actionPerformed(ActionEvent e) //Action Listener that is called when "Remove Data" menu option //is selected { categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { RemoveDataFrame r = new RemoveDataFrame(this); r.setSize(450,390); centerFrame(r); //r.setResizable(false); r.setVisible(true); } } void loadCatButton_actionPerformed(ActionEvent e) //Action Listener that is called when "Open Category" menu option //is selected { String filename = catLoadList.getSelectedItem(); GraphEdit ged; if (filename.toLowerCase().endsWith("cat")) { //Switch card layout panels for category Display categoryDisplay(); //Load *.CAT File [ie. text file] graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); cat = new Category(); this.setTitle("Graphical Database for Category Theory [" + ini.getServer() + ini.getCatDir() + filename + "]"); addRecentCat(ini.getServer() + ini.getCatDir() + filename); validate(); cat.filename = (ini.getServer() + ini.getCatDir() + filename); FileProcessing f = new FileProcessing(ini.getServer() + ini.getCatDir() + filename, this, false, false); //Indicate that category file was loaded from server cat.mod.downloadCat = true; //Read category from server f.readCATFile(cat); displayCategoryText(cat); categoryChoice.add(cat.name); categoryChoice.select(cat.name); GraphCategory(graph_, graphCanvas_, cat); graphCanvas_.unselectItems(); ged = new GraphEdit(graph_, graphCanvas_); cat.gml = ged.getGMLText(); ged.dispose(); catLoad.setVisible(false); catLoad.dispose(); displayCategoryText(cat); displayCategoryGraph(cat.gml); } else if (filename.toLowerCase().endsWith("cgl")) { cglLoad.setVisible(false); cglLoad.dispose(); //Switch card layout panels for category Display categoryDisplay(); graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); cat.gml = ge.getGMLText(); ge.dispose(); cat = new Category(); this.setTitle("Graphical Database for Category Theory [" + ini.getServer() + ini.getCglDir() + filename + "]"); addRecentCat(ini.getServer() + ini.getCglDir() + filename); validate(); cat.filename = ini.getServer() + ini.getCglDir() + filename; FileProcessing f = new FileProcessing(ini.getServer() + ini.getCglDir() + filename, this, false, false); //Indicate that category file was loaded from server cat.mod.downloadCat = true; //Read category from server f.readCGLFile(cat); categoryChoice.add(cat.name); categoryChoice.select(cat.name); displayCategoryText(cat); displayCategoryGraph(cat.gml); } else if (filename.toLowerCase().endsWith("fun")) { funLoad.setVisible(false); funLoad.dispose(); //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); //Switch card layout panels for category Display functorDisplay(); //Open *.FUN File [ie. functor text file] FileProcessing f = new FileProcessing(ini.getServer() + ini.getFunDir() + filename, this, false, false); //Read functor (*.FUN) file including two associated categories A and B. f.readFUNFile(func, A, B); addRecentCat(ini.getServer() + ini.getFunDir() + filename); func.filename = ini.getServer() + ini.getFunDir() + filename; this.setTitle("Graphical Database for Category Theory [" + ini.getServer() + ini.getFunDir() + filename + "]"); //Display Category A GraphCategory(functorFromGraph, functorFromCanvas, A); functorFromCanvas.unselectItems(); ged = new GraphEdit(functorFromGraph, functorFromCanvas); A.gml = ged.getGMLText(); ged.dispose(); //Display Category B GraphCategory(functorToGraph, functorToCanvas, B); functorToCanvas.unselectItems(); ged = new GraphEdit(functorToGraph, functorToCanvas); B.gml = ged.getGMLText(); ged.dispose(); //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); } else if (filename.toLowerCase().endsWith("fgl")) { fglLoad.setVisible(false); fglLoad.dispose(); //Intitial global variables used in open functor func = new CatFunctor(); A = new Category(); B = new Category(); //Switch card layout panels for category Display functorDisplay(); //Open *.FGL File [ie. functor text file] FileProcessing f = new FileProcessing(ini.getServer() + ini.getFglDir() + filename, this, false, false); //Read functor (*.FUN) file including two associated categories A and B. f.readFGLFile(func, A, B); addRecentCat(ini.getServer() + ini.getFglDir() + filename); func.filename = ini.getServer() + ini.getFglDir() + filename; this.setTitle("Graphical Database for Category Theory [" + ini.getServer() + ini.getFglDir() + filename + "]"); //Display Category A if (A.gml.equals("")) { GraphCategory(functorFromGraph, functorFromCanvas, A); functorFromCanvas.unselectItems(); ged = new GraphEdit(functorFromGraph, functorFromCanvas); A.gml = ged.getGMLText(); ged.dispose(); } else { displayCategoryGraph(A.gml, functorFromGraph); } //Display Category B if (B.gml.equals("")) { GraphCategory(functorToGraph, functorToCanvas, B); functorToCanvas.unselectItems(); ged = new GraphEdit(functorToGraph, functorToCanvas); B.gml = ged.getGMLText(); ged.dispose(); } else { displayCategoryGraph(B.gml, functorToGraph); } //Display Diagram Category updateDiagramCategory(); //display selected functor in objectArea and arrowArea displayFunctor(fnode.f); } } /* public void ReadServerCatFile(String fname) //This method loads a category file from a server //This allows the applet to access files on the home //server as well as files on any other server { String text; StringTokenizer tokens; cat = new Category(); int linecount = 0; String temp; boolean end_of_cat = false; try { fileURL = new URL(ini.getServer() + ini.getCatDir() + fname); } catch (MalformedURLException except) { new MessageDialog(this, "Error", "Unable to open" + fname + "File unable to Load", true); } cat.filename = ini.getServer() + ini.getCatDir() + fname; this.setTitle("Graphical Database for Category Theory [" + cat.filename + "]"); validate(); try { input = fileURL.openStream(); dataInput = new DataInputStream(input); viewbox.append("File Loaded\n\n"); viewbox.append("The File Contents are:\n\n"); while((text=dataInput.readLine()) != null) { if (text.charAt(0) == '#') //If line is a comment { String com = text.substring(1, text.length()); cat.comment = cat.comment + com; } if (text.charAt(0) != '#') //If line isn't a comment { tokens = new StringTokenizer(text); //Split line apart in terms of spaces linecount++; if (linecount == 2) cat.name = tokens.nextToken(); if (linecount == 4) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); if (!(temp.equals("."))) { cat.obj[cat.numobj] = temp.charAt(0) + ""; cat.numobj++; } } } if (linecount == 6) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); if (!(temp.equals("."))) { cat.arrow[cat.numarr] = temp.charAt(0) + ""; char tmp = temp.charAt(2); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].charAt(0) == tmp) cat.arr[cat.numarr][0] = i; } tmp = temp.charAt(5); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].charAt(0) == tmp) cat.arr[cat.numarr][1] = i; } cat.numarr++; } } } if ((linecount >= 8) && (end_of_cat != true)) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); if (!(temp.equals("."))) { String left = temp; temp = tokens.nextToken(); temp = tokens.nextToken(); int i = 0; String right = temp.substring(0, temp.length() - 1); //objectArea.append("left = " + left); //objectArea.append(" right = " + right + "\n"); get_rel(left, right, cat); } else end_of_cat = true; } } } viewbox.append(text + "\n"); } List.insertNode(cat); dataInput.close(); } catch(IOException e) { new MessageDialog(this, "Error", "Unable to open file " + fname + " File Not Found", true); } } */ /* public void ReadServerCGLFile(String fname) //This method loads a category file from a server //This allows the applet to access files on the home //server as well as files on any other server { String text; StringTokenizer tokens; cat = new Category(); int linecount = 0; String temp; boolean end_of_cat = false; try { fileURL = new URL(ini.getServer() + ini.getCglDir() + fname); } catch (MalformedURLException except) { new MessageDialog(this, "Error", "Unable to open file File unable to Load", true); } cat.filename = ini.getServer() + ini.getCglDir() + fname; this.setTitle("Graphical Database for Category Theory [" + cat.filename + "]"); validate(); try { input = fileURL.openStream(); dataInput = new DataInputStream(input); viewbox.append("File Loaded\n\n"); viewbox.append("The File Contents are:\n\n"); while((text=dataInput.readLine()) != null) { if (text.charAt(0) == '#') //If line is a comment { String com = text.substring(1, text.length()); cat.comment = cat.comment + com; } if (text.charAt(0) != '#') //If line isn't a comment { tokens = new StringTokenizer(text); //Split line apart in terms of spaces linecount++; if (linecount == 2) cat.name = tokens.nextToken(); if (linecount == 4) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); if (!(temp.equals("."))) { cat.obj[cat.numobj] = temp.charAt(0) + ""; cat.numobj++; } } } if (linecount == 6) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); if (!(temp.equals("."))) { cat.arrow[cat.numarr] = temp.charAt(0) + ""; char tmp = temp.charAt(2); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].charAt(0) == tmp) cat.arr[cat.numarr][0] = i; } tmp = temp.charAt(5); for (int i = 0; i < cat.numobj; i++) { if (cat.obj[i].charAt(0) == tmp) cat.arr[cat.numarr][1] = i; } cat.numarr++; } } } if ((linecount >= 8) && (end_of_cat != true)) { while(tokens.hasMoreTokens() && (end_of_cat != true)) { temp = tokens.nextToken(); if (!(temp.equals("."))) { String left = temp; temp = tokens.nextToken(); temp = tokens.nextToken(); int i = 0; String right = temp.substring(0, temp.length() - 1); //objectArea.append("left = " + left); //objectArea.append(" right = " + right + "\n"); get_rel(left, right, cat); } else end_of_cat = true; } } else if (end_of_cat == true) { while(tokens.hasMoreTokens()) { temp = tokens.nextToken(); objectArea.append(temp); } } } viewbox.append(text + "\n"); } List.insertNode(cat); dataInput.close(); } catch(IOException e) { new MessageDialog(this, "Error", "Unable to open file " + fname + " File Not Found", true); } } */ public void get_rel(String left, String right, Category c) /* Parameters: A: category Purpose: Allows the user to input as many relations as they want to Design: Allocates space for the new relations and checks them for valid composition as well as valid left and right domains and codomains. */ { boolean add; int leftrel[] = new int [ini.getMAXWORD()]; int rightrel[] = new int [ini.getMAXWORD()]; int j; add = true; if (right.compareTo("1") == 0) { rightrel[0] = ini.getIdentityCode(); rightrel[1] = -1; //right = "0"; //right[0] = '\x0'; if(!(c.check_string(left))) { add = false; } leftrel = c.copy_path(c.string_to_path(left)); for (j=0;j', '(', ')', '='}; int cLength = 11; MenuItem bugReportMenuItem = new MenuItem(); Menu menu1 = new Menu(); Menu menu5 = new Menu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); MenuItem menuItem4 = new MenuItem(); MenuItem menuItem5 = new MenuItem(); MenuItem menuItem6 = new MenuItem(); MenuItem isoMenuItem = new MenuItem(); CheckboxControl twocatdisplay_button = new CheckboxControl(); CheckboxControl diagramdisplay_button = new CheckboxControl(); GridBagLayout gridBagLayout4 = new GridBagLayout(); Panel panel4 = new Panel(); XYLayout xYLayout7 = new XYLayout(); MenuItem coequalizerMenuItem = new MenuItem(); MenuItem equalizerMenuItem = new MenuItem(); MenuItem epiMenuItem = new MenuItem(); MenuItem monoMenuItem = new MenuItem(); boolean checkStrings(String text) //This method checks the string text to determine if it is the same as any of //strings defined as special strings. It returns true if string is ok and false //if string contains one of the special strings { text = text.toLowerCase(); for (int i =0 ; i < sLength; i++) { if (text.equals(specialStrings[i])) { new MessageDialog(this, "Error", text + " is a special word and can not be used.", true); return false; } } return true; } boolean checkChars(String text) //This method checks the string text to determine if it it contains any //of the special characters defined above. It returns true if string is //ok and false if string contains one of the special characters { for (int i =0 ; i < cLength; i++) { for (int j=0; j < text.length(); j++) { if (text.charAt(j) == (specialChars[i])) { if ((specialChars[i] == '*') && (menuoption == 1) && ((submenu == 5) || (submenu == 6))) { } else if ((specialChars[i] == '*') && (menuoption == 2) && (submenu == 3)) { } else { new MessageDialog(this, "Error", text + " contains the special character " + text.charAt(j) + " and can not be used.", true); return false; } } } } return true; } boolean check(String text) //Check string for special words and characters { //boolean variables boolean s = false; boolean c = false; //check words and characters s = checkStrings(text); c = checkChars(text); //return appropriate boolean expression if ((s == true) && (c == true)) return true; else return false; } public void isoMenuItem_actionPerformed(ActionEvent e) { // switch to category display mode, then create the iso frame categoryDisplay(); if (catList.head == null && catList.tail == null) { new MessageDialog(this, "Error", "There are no category files open", true); } else { IsoFrame f = new IsoFrame(this); centerFrame(f); f.setResizable(false); f.setVisible(true); } } //------------------Methods to deal with diagram display--------------------------- public void diagramdisplay_button_itemStateChanged(ItemEvent e) { // save the diagram's GML if (functorDisplay.getState()) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); diagram.gml = ge.getGMLText(); ge.dispose(); } // switch to diagram display mode if (twocatdisplay_button.getState() && !diagramdisplay_button.getState()) { diagramdisplay_button.setState(false); twocatdisplay_button.setState(true); ini.setDiagramDisplay(false); // functorDisplay(); } // switch to two category display mode else { diagramdisplay_button.setState(true); twocatdisplay_button.setState(false); ini.setDiagramDisplay(true); functorDisplay(); } } public void twocatdisplay_button_itemStateChanged(ItemEvent e) { // save the diagram's GML if (functorDisplay.getState()) { graphCanvas_.unselectItems(); GraphEdit ge = new GraphEdit(graph_, graphCanvas_); diagram.gml = ge.getGMLText(); ge.dispose(); } // switch to two category display mode if (diagramdisplay_button.getState() && !twocatdisplay_button.getState()) { diagramdisplay_button.setState(true); twocatdisplay_button.setState(false); ini.setDiagramDisplay(false); // functorDisplay(); } // switch to diagram display mode else { diagramdisplay_button.setState(false); twocatdisplay_button.setState(true); ini.setDiagramDisplay(true); // functorDisplay(); } functorDisplay(); } public void updateDiagramCategory() /* This function creates a new diagram based on the categories A and B, and creates a new random graph for it */ { // the diagram will be a copy of category A: diagram = new Category(); diagram.copyCategory(A); // but the names of each object and arrow will be taken from category B: int i, j; for (i=0; i