<commit_before>import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 * The Grand-Daddy of them all!
 * 
 * @author jshmtthwclrk
 *
 */
public class MainPanel extends JFrame {
	
	/**
	 * SerialVersionUID
	 */
	private static final long serialVersionUID = -7236160691262901215L;
	
	/** Bounding box for panels */
	public JFrame frame = new JFrame();
	/** Panel that contains all the separate panels */
	public JPanel main = new JPanel();
	/** Panel that displays the 2-D array */
	private JPanel grid = new JPanel();
	/** Dis Panel does da choosin */
	private JPanel radioBox = new JPanel();
	/** The Side Panel of Information!!! */
	private JPanel side = new JPanel();
	/** Background color */
	private Color GOLD = new Color(218,165,32);
	/** Grid object */
	private Grid grd = new Grid();
	/** Panel that shows the visualization */
	private JPanel swagPanel = new JPanel();
	
	/** 2-D array for grid panel */
	public JPanel[][] pArray;
	
	// ************* User Interaction Panel *************
	
	private JRadioButton union = new JRadioButton("Union Find");
	private JRadioButton qUnion = new JRadioButton("Quick Union Find");
	private JButton execute = new JButton("Execute");
	private JLabel gridSizeLabel = new JLabel("Enter size:");
	private JTextField gridSizeText = new JTextField("", 5);
	private JLabel numRunsLabel = new JLabel("Number of runs:");
	private JTextField numRunsText = new JTextField("1", 5);
	private String numRunsString;
	
	// ************* Side Panel Information *************
	private JLabel select = new JLabel("Selection: ");
	private String sizeString;
	private JLabel currSize = new JLabel("Grid Size: ");
	private int theSize = 0;
	private JLabel blank1 = new JLabel(" ");
	private JLabel blank2 = new JLabel(" ");
	private JLabel blank3 = new JLabel(" ");
	private JLabel blank4 = new JLabel(" ");
	
	/** Weighted Compression Quick Union object */
	public WeightedCompressionQuickUnion qf;
	/** Quick Find object */
	public QuickFind uf;
	
	private int randRow;
	private int randCol;

	/** Percolation object */
	public Percolation<DynamicConnectivity> perk;
	
	private JLabel percent = new JLabel("Last Percent open: 0%");
	private DecimalFormat df = new DecimalFormat("#.000");
	
	private JLabel avgPercent = new JLabel("Avg Percent open: 0%");
	private JLabel avgTime = new JLabel("Avg Run Time: ");
	private JLabel runs = new JLabel("Number of Runs: ");
	private double avgPercentNum;
	private long avgTimeNum;
	
	// Timer Stuff
	private int timerCount = 0;
	private JLabel timerLabel = new JLabel("Last Run Time: " + timerCount + " ms");
	
	//Build Percent List
	private String[] percentList;
	private JLabel percentListTitle = new JLabel("");
	private JLabel percentListLabel0 = new JLabel("");
	private JLabel percentListLabel1 = new JLabel("");
	private JLabel percentListLabel2 = new JLabel("");
	private JLabel percentListLabel3 = new JLabel("");
	private JLabel percentListLabel4 = new JLabel("");
	private JLabel percentListLabel5 = new JLabel("");
	private JLabel percentListLabel6 = new JLabel("");
	private JLabel percentListLabel7 = new JLabel("");
	private JLabel percentListLabel8 = new JLabel("");
	private JLabel percentListLabel9 = new JLabel("");
	
	/** Main method */
	public static void main(String [] args) {
		@SuppressWarnings("unused")
		MainPanel mainPanel = new MainPanel();
	} // end main method
	
	/**
	 * Constructor that sets up the Main Panel for Union Find Visualization.
	 */
	public MainPanel() {
		
		frame.setSize(800, 700);
		frame.setResizable(false);
		frame.setTitle("Union Find");
		
		main.setSize(800,700);
		main.setLayout(null);
		
		@SuppressWarnings("unused")
		RadioBox rdobx = new RadioBox();
		@SuppressWarnings("unused")
		SidePanel sdpnl = new SidePanel();
		
		main.add(grid);
		main.add(radioBox);
		main.add(side);
		
		frame.add(main);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} // end constructor
	

	private class Grid {
		
		/**
		 * Constructor that sets up the Grid Panel.
		 */
		public Grid() {
			
			GridLayout gridGrid = new GridLayout();
			grid.setSize(600, 600);
			grid.setLayout(gridGrid);
			grid.setBackground(Color.DARK_GRAY);
			grid.setLocation(0, 0);
			grid.setVisible(true);
		} // end constructor
		
		private void initalizeGrid(int size) {
			
			pArray = new JPanel[size][size];
			
			grid.removeAll();
			grid.updateUI();
			swagPanel.removeAll();
			swagPanel.updateUI();
			grid.setLayout(new GridLayout());
			swagPanel.setBackground(GOLD);
			swagPanel.setSize(600, 600);
			GridLayout tileGrid = new GridLayout(size, size, 1, 1);
			tileGrid.minimumLayoutSize(swagPanel);
			swagPanel.setLayout(tileGrid);
			swagPanel.setVisible(true);
			
			percentListLabel0.setText("");
			percentListLabel1.setText("");
			percentListLabel2.setText("");
			percentListLabel3.setText("");
			percentListLabel4.setText("");
			percentListLabel5.setText("");
			percentListLabel6.setText("");
			percentListLabel7.setText("");
			percentListLabel8.setText("");
			percentListLabel9.setText("");
			
			for (int row = 0; row < size; row++) {
				for (int col = 0; col < size; col++) {
					JPanel panel = new JPanel(/*new GridBagLayout()*/);
					panel.setBackground(Color.DARK_GRAY);
					//panel.setSize(new Dimension((600/size), (600/size)));
					panel.setVisible(true);
					swagPanel.add(panel);
					pArray[row][col] = panel;
				} // end nested for loop
			} // end for loop
			grid.add(swagPanel);
		} // end method initalizeGrid(int)
		
		private void updateGrid() {
			// random number stuff
			randRow = (int)(Math.random() * ((theSize - 1) + 1));
			randCol = (int)(Math.random() * ((theSize - 1) + 1));
			
			if(perk.isOpen(randRow, randCol) == false) {
				perk.open(randRow, randCol);
				pArray[randRow][randCol].setBackground(Color.BLUE);
			} // end if statement
		} // end method updateGrid
	} // end inner class Grid
	
	/**
	 * Private Inner Class for User Interaction Panel
	 * @author <NAME>
	 *
	 */
	private class RadioBox {<commit_msg>Revert 667308c..99b6266<commit_after>import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 * The Grand-Daddy of them all!
 * 
 * @author jshmtthwclrk
 *
 */
public class MainPanel extends JFrame {
	
	/**
	 * SerialVersionUID
	 */
	private static final long serialVersionUID = -7236160691262901215L;
	/** Panel that contains all the separate panels */
	public JFrame frame = new JFrame();
	public JPanel main = new JPanel();
	/** Panel that displays the 2-D array */
	private JPanel grid = new JPanel();
	/** Dis Panel does da choosin */
	private JPanel radioBox = new JPanel();
	/** The Side Panel of Information!!! */
	private JPanel side = new JPanel();
	/** Background color */
	private Color GOLD = new Color(218,165,32);
	private Grid grd = new Grid();
	private JPanel swagPanel = new JPanel();
	
	public JPanel[][] pArray;
	
	// User Interaction Panel
	private JRadioButton union = new JRadioButton("Union Find");
	private JRadioButton qUnion = new JRadioButton("Quick Union Find");
	private JButton execute = new JButton("Execute");
	private JLabel gridSizeLabel = new JLabel("Enter size:");
	private JTextField gridSizeText = new JTextField("", 5);
	private JLabel numRunsLabel = new JLabel("Number of runs:");
	private JTextField numRunsText = new JTextField("1", 5);
	private String numRunsString;
	
	// Side Panel Information
	private JLabel select = new JLabel("Selection: ");
	private String sizeString;
	private JLabel currSize = new JLabel("Grid Size: ");
	private int theSize = 0;
	private JLabel blank1 = new JLabel(" ");
	private JLabel blank2 = new JLabel(" ");
	private JLabel blank3 = new JLabel(" ");
	private JLabel blank4 = new JLabel(" ");
	
	public WeightedCompressionQuickUnion qf;
	public QuickFind uf;
	
	private int randRow;
	private int randCol;

	public Percolation<DynamicConnectivity> perk;
	
	private JLabel percent = new JLabel("Last Percent open: 0%");
	private DecimalFormat df = new DecimalFormat("#.000");
	
	private JLabel avgPercent = new JLabel("Avg Percent open: 0%");
	private JLabel avgTime = new JLabel("Avg Run Time: ");
	private JLabel runs = new JLabel("Number of Runs: ");
	private double avgPercentNum;
	private long avgTimeNum;
	
	// Timer Stuff
	//private javax.swing.Timer timer = new Timer(1, this);
	private int timerCount = 0;
	private JLabel timerLabel = new JLabel("Last Run Time: " + timerCount + " ms");
	
	//Build Percent List
	private String[] percentList;
	private JLabel percentListTitle = new JLabel("");
	private JLabel percentListLabel0 = new JLabel("");
	private JLabel percentListLabel1 = new JLabel("");
	private JLabel percentListLabel2 = new JLabel("");
	private JLabel percentListLabel3 = new JLabel("");
	private JLabel percentListLabel4 = new JLabel("");
	private JLabel percentListLabel5 = new JLabel("");
	private JLabel percentListLabel6 = new JLabel("");
	private JLabel percentListLabel7 = new JLabel("");
	private JLabel percentListLabel8 = new JLabel("");
	private JLabel percentListLabel9 = new JLabel("");
	
	/** Main method */
	public static void main(String [] args) {
		@SuppressWarnings("unused")
		MainPanel mainPanel = new MainPanel();
	} // end main method
	
	/**
	 * Constructor that sets up the Main Panel for Union Find Visualization.
	 */
	public MainPanel() {
		frame.setSize(800, 700);
		frame.setResizable(false);
		frame.setTitle("Union Find");
		
		main.setSize(800,700);
		main.setLayout(null);
		
		@SuppressWarnings("unused")
		RadioBox rdobx = new RadioBox();
		@SuppressWarnings("unused")
		SidePanel sdpnl = new SidePanel();
		
		main.add(grid);
		main.add(radioBox);
		main.add(side);
		
		frame.add(main);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} // end constructor
	

	private class Grid {
		
		/**
		 * Constructor that sets up the Grid Panel.
		 */
		public Grid() {
			
			GridLayout gridGrid = new GridLayout();
			grid.setSize(600, 600);
			grid.setLayout(gridGrid);
			grid.setBackground(Color.DARK_GRAY);
			grid.setLocation(0, 0);
			
			grid.setVisible(true);
		} // end constructor
		
		private void initalizeGrid(int size) {
			
			pArray = new JPanel[size][size];
			
			grid.removeAll();
			grid.updateUI();
			swagPanel.removeAll();
			swagPanel.updateUI();
			grid.setLayout(new GridLayout());
			swagPanel.setBackground(GOLD);
			swagPanel.setSize(600, 600);
			GridLayout tileGrid = new GridLayout(size, size, 1, 1);
			tileGrid.minimumLayoutSize(swagPanel);
			swagPanel.setLayout(tileGrid);
			swagPanel.setVisible(true);
			
			percentListLabel0.setText("");
			percentListLabel1.setText("");
			percentListLabel2.setText("");
			percentListLabel3.setText("");
			percentListLabel4.setText("");
			percentListLabel5.setText("");
			percentListLabel6.setText("");
			percentListLabel7.setText("");
			percentListLabel8.setText("");
			percentListLabel9.setText("");
			
			for (int row = 0; row < size; row++) {
				for (int col = 0; col < size; col++) {
					JPanel panel = new JPanel(/*new GridBagLayout()*/);
					panel.setBackground(Color.DARK_GRAY);
					//panel.setSize(new Dimension((600/size), (600/size)));
					panel.setVisible(true);
					swagPanel.add(panel);
					pArray[row][col] = panel;
				} // end nested for loop
			} // end for loop
			grid.add(swagPanel);
		} // end method initalizeGrid(int)
		
		private void updateGrid() {
			// random number stuff
			randRow = (int)(Math.random() * ((theSize - 1) + 1));
			randCol = (int)(Math.random() * ((theSize - 1) + 1));
			
			// if(! .isOpen) .open; else updateGrid();
			if(perk.isOpen(randRow, randCol) == false) {
				perk.open(randRow, randCol);
				pArray[randRow][randCol].setBackground(Color.BLUE);
			}
			
		}
		
	} // end inner class Grid
	
	/**
	 * Private Inner Class for User Interaction Panel
	 * @author <NAME>
	 *
	 */
	private class RadioBox {
{'fraction_non_alphanumeric': 0.1324822915855842, 'fraction_numerical': 0.016968942165486105, 'mean_word_length': 4.072246348203711, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7608496', 'n_tokens_mistral': 4505, 'n_tokens_neox': 3979, 'n_words': 1118}