/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: Category.java Description: This class contains all of the information that is needed for a category and some useful functions */ import java.awt.*; class Category { IniSettings ini = new IniSettings(); //IniSettings class that contains the lengths //of the arrays in the Category class String name; //Name of the category String[] obj = new String[ini.getMAXWORD()]; //Names of the objects in the category int numobj = 0; //Number of objects in category int[][] arr = new int[ini.getMAXARR()][2]; //domain and codomain of arrows String[] arrow = new String[ini.getMAXARR()];//Names of arrows in a category int numarr = 0; //Number of arrows in category Relation[] rel_set = new Relation[ini.getMAXARR()]; //Contains relations in category int num_rel = 0; //Number of relations in category String comment = new String(); //Comments about the category String filename = new String(); //Name of file that category was opened, //loaded, or saved in String gml = new String(); //Text version of graphical interpretation //of thecategory String originalGml = new String(); //Text version of the original graphical //interpretation of the category CategoryModified mod = new CategoryModified(); //This contains all of the information //about modifications to the original //category file public boolean isModified() //Return true if the category was not originally saved //or has been modified since it was last saved { if (mod.downloadCat || mod.functorCat || mod.createCat || mod.dualCat || mod.downloadCat) return true; else if (mod.dataAdded || mod.dataRemoved || (!gml.equals(originalGml) && !originalGml.equals("")) || mod.nameChanged || mod.madeConfluent) return true; else return false; } public void copyCategory(Category c) { if (c == null) return; int i, j, temp; name = new String(c.name); numobj = c.numobj; numarr = c.numarr; num_rel = c.num_rel; for (i=0; i path_len(path2)) { return(true); } else { if ((path_len(path1)) == (path_len(path2))) { if ((path_len(path1) == 1) && (path1[0] == ini.getIdentityCode())) return(false); j = 0; while (j < path_len(path1)) { if (path2[j] > path1[j]) { return(false); } else { if (path2[j] < path1[j]) { return(true); } } j++; } } } return(false); } public Category makeDual() /* Purpose: To dualize a category Design: Makes a dual of the category and returns it */ { char over, leave; int i, j, temp; int temp2[] = new int [ini.getMAXWORD()]; int temp3[] = new int [ini.getMAXWORD()]; boolean done; Category B = new Category(); B.name = name; // + "DUAL"; B.numobj = numobj; B.numarr = numarr; B.num_rel = num_rel; for(i=0;i=0;j--) { temp2[path_len(rel_set[i].lhs)-1-j] = rel_set[i].lhs[j]; } temp2[path_len(rel_set[i].lhs)] = -1; for(j=path_len(rel_set[i].rhs)-1;j>=0;j--) { temp3[path_len(rel_set[i].rhs)-1-j] = rel_set[i].rhs[j]; } temp3[path_len(rel_set[i].rhs)] = -1; Relation r = new Relation(); if (greater(temp2,temp3)) { r.lhs = copy_path(temp2); r.rhs = copy_path(temp3); } else { r.lhs = copy_path(temp3); r.rhs = copy_path(temp2); } B.rel_set[i] = r; } return B; } public int all_arr(int obj, int arrows[]) /* Parameters: obj: integer representing an object in the category arrows: array containing all arrows with object obj as their domain Purpose: Returns an integer whose value is the number of arrows in the category with object obj as their domain. The array is passed back containing all such arrows. */ { int j, k=0; for (j=0;j size) size = j; int[] ret = new int[j+1]; for (i=0; i