/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 Created: May 8th, 2003 (J. Tweedle) File: PushoutFrame.java Description: This class implements a frame which allows the user to run the category tool "Pushout" on the current category. The algorithms used to test the category for sums were removed and put into the file Pullback.java */ //import statements import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.beans.*; public class PushoutFrame extends JInternalFrame { private CategoryInternalFrame categoryInternalFrame_; private Category cat = new Category(); private Pullback pushout; private int obj; private String objchr; //Objects in the Graphical User Interface(GUI) private JLabel objectLabel = new JLabel(); private JLabel alphaLabel = new JLabel(); private JLabel betaLabel = new JLabel(); private JLabel lambdaLabel = new JLabel(); private JLabel rhoLabel = new JLabel(); private JButton okButton = new JButton(); private JButton pushoutButton = new JButton(); private JComboBox objectChoice = new JComboBox(); private JCheckBox lambdarhoChoice = new JCheckBox(); private JTextField alphaField = new JTextField(13); private JTextField betaField = new JTextField(13); private JTextField lambdaField = new JTextField(13); private JTextField rhoField = new JTextField(13); public PushoutFrame(CategoryInternalFrame categoryInternalFrame) //Default Constructor with the parent frame as a parameter { super(categoryInternalFrame.getTitle() + ": Pushout", true, true, false, false); categoryInternalFrame_ = categoryInternalFrame; cat = categoryInternalFrame_.getCategory(); pushout = new Pullback(cat.makeDual(), "pushout"); okButton.setText("Close"); objectLabel.setText("Pushout Object:"); alphaLabel.setText("Alpha:"); betaLabel.setText("Beta:"); lambdaLabel.setText("Lambda:"); lambdaLabel.setEnabled(false); rhoLabel.setText("Rho:"); rhoLabel.setEnabled(false); lambdarhoChoice.setText("Specify lambda/rho"); objectChoice.setBackground(Color.white); pushoutButton.setText("Pushout?"); alphaField.setBackground(Color.white); betaField.setBackground(Color.white); lambdaField.setBackground(Color.white); lambdaField.setEnabled(false); rhoField.setBackground(Color.white); rhoField.setEnabled(false); pushoutButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { pushoutButton_actionPerformed(); } }); objectChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { objectChoice_itemStateChanged(e); } }); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okButton_actionPerformed(e); } }); lambdarhoChoice.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { lambda_rho_action(); } }); Container contentPane = getContentPane(); contentPane.setLayout(new GridBagLayout()); contentPane.add(pushoutButton, new GridBagConstraints(0, 6, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(okButton, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(lambdaLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(rhoLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(alphaLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(betaLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(objectLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(objectChoice, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(lambdaField, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(rhoField, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(alphaField, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(betaField, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0)); contentPane.add(lambdarhoChoice, new GridBagConstraints(0, 5, 2, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 3, 3), 0, 0)); objectChoice.addItem("Check all objects"); for (int i = 0; i < cat.num_objects; i++) objectChoice.addItem(cat.obj[i]); objectChoice.setSelectedIndex(1); } private void pushoutButton_actionPerformed() { pushout.setNumPullbacks(0); pushout.setOutput(""); String viewbox = ""; pushout.setEndoPassed(false); objchr = (String)objectChoice.getSelectedItem(); if (objchr.equals("Check all objects")) { if (!cat.check_obj(lambdaField.getText())) { JOptionPane.showInternalMessageDialog(this, lambdaField.getText() + " is not an object of " + cat.name + ".\n", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (!cat.check_obj(rhoField.getText())) { JOptionPane.showInternalMessageDialog(this, rhoField.getText() + " is not an object of " + cat.name + ".\n", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (!cat.check_obj(alphaField.getText())) { JOptionPane.showInternalMessageDialog(this, alphaField.getText() + " is not an object of " + cat.name + ".\n", "Error", JOptionPane.ERROR_MESSAGE); return; } else { for (int i=0; i