Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comments for UI #403

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public void setRules(List<? extends Rule> 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();
Expand All @@ -75,6 +75,12 @@ public void setRules(List<? extends Rule> 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) {

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down