diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 4aa8d60d2..e661a4336 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -118,10 +118,10 @@ public JMenuBar getMenuBar() { newPuzzle = new JMenuItem("Open"); resetPuzzle = new JMenuItem("Reset Puzzle"); // genPuzzle = new JMenuItem("Puzzle Generators"); - saveProofAs = new JMenuItem("Save Proof As"); - saveProofChange = new JMenuItem("Save Proof Change"); + saveProofAs = new JMenuItem("Save Proof As"); // create a new file to save + saveProofChange = new JMenuItem("Save Proof Change"); // save to the current file preferences = new JMenuItem("Preferences"); - helpTutorial = new JMenuItem("Help"); + helpTutorial = new JMenuItem("Help"); // jump to web page exit = new JMenuItem("Exit"); edit = new JMenu("Edit"); @@ -432,7 +432,7 @@ private void direct_save(){ } } /** - * Saves a proof + * Create a new file and save proof to it */ private void saveProofAs() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); @@ -475,7 +475,7 @@ private void saveProofAs() { private void helpTutorial() { Runtime rt = Runtime.getRuntime(); - String url = "https://github.com/Bram-Hub/Legup/wiki/LEGUP-Tutorial"; // empty page, Oct 17th + String url = "https://github.com/Bram-Hub/Legup/wiki/LEGUP-Tutorial"; // empty page 2022 Fall semester try{ //rt.exec("rundll32 url.dll,FileProtocolHandler "+url); java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); @@ -499,11 +499,11 @@ public void actionPerformed(ActionEvent e) { panel.add(moveing_buttom); } - - - - - // Quick save, does not prompt user for name change + + + + + // Quick save proof to the current file with a pop window to show "successfully saved" private void saveProofChange(){ Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); if (puzzle == null) { diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java index bf1a143ae..7e2e30bf5 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java @@ -13,7 +13,7 @@ public class RuleButton extends JButton { * @param rule rule to create the button */ RuleButton(Rule rule) { - super(rule.getRuleName(), rule.getImageIcon()); + super(rule.getRuleName(), rule.getImageIcon()); // display rules' name under rule when load the icon this.rule = rule; } diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java index 89c9e5dd6..78a07cdda 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java @@ -57,14 +57,14 @@ public void setRules(List rules) { Rule rule = rules.get(i); ruleButtons[i] = new RuleButton(rule); - ruleButtons[i].setPreferredSize(new Dimension(150,150)); + ruleButtons[i].setPreferredSize(new Dimension(150,150));// adjust the size of each RuleButton ruleButtons[i].setHorizontalTextPosition(JButton.CENTER); ruleButtons[i].setVerticalTextPosition(JButton.BOTTOM); + ruleFrame.getButtonGroup().add(ruleButtons[i]); - ruleButtons[i].setToolTipText(rule.getRuleName() + ": " + rule.getDescription()); + ruleButtons[i].setToolTipText(rule.getRuleName() + ": " + rule.getDescription()); // showing description ruleButtons[i].addActionListener(ruleFrame.getController()); add(ruleButtons[i]); - //add(new JButton(rule.getRuleName())); // add name under relative rule } revalidate(); @@ -75,6 +75,12 @@ public void setRules(List rules) { * Search a certain rule in all the puzzles and set it for the searchBarPanel * * @param puzzle, ruleName + * + * This function is the searching algorithm for "public void setSearchBar(Puzzle allPuzzle)" (below) + * + * It takes two param Puzzle puzzle and String ruleName + * puzzle contains rules, this function will compare each rule of puzzle with ruleName, + * to find exact same, similar rules, or all the rules with same start letter (if input is a signal letter) */ public void searchForRule(Puzzle puzzle, String ruleName) { @@ -132,6 +138,11 @@ else if((ruleName.charAt(0)) == (rule.getRuleName().toUpperCase()).charAt(0)){ /** * Calculates the similarity (a number within 0 and 1) between two strings. + * This funtion will take two para String s1 and String s2, which s1 is the user's input + * and s2 is the compared really rule name + * + * similarityCheck will use a helper function to calculate a similarity degree(from 0 to 1). + * closer to 0 means less similar, and closer to 1 means more similar. */ public static double similarityCheck(String s1, String s2) { String longer = s1, shorter = s2; @@ -177,10 +188,10 @@ public static int editDistance(String s1, String s2) { } /** - * UnFinished - * * Sets the search bar for SearchBarPanel - * + * search bar allows user to input a name to get relative rules + * once a name is entered and click ok will load (a/several) rule icon, + * which has all the functions just as other rule icons. */ public void setSearchBar(Puzzle allPuzzle){ diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/SearchBarPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/SearchBarPanel.java index 3832fd8d7..2c32b6e88 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/SearchBarPanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/SearchBarPanel.java @@ -4,9 +4,11 @@ public class SearchBarPanel extends RulePanel { /** - * ContradictionRulePanel Constructor creates a ContradictionRulePanel + * SearchBarPanel Constructor creates a SearchBarPanel * - * @param ruleFrame rule frame that this ContradictionRulePanel is contained in + * @param ruleFrame rule frame that this SearchBarPanel is contained in + * + * This class is used to create a panel named "search bar" */ SearchBarPanel(RuleFrame ruleFrame) { super(ruleFrame);