diff --git a/src/main/java/edu/rpi/legup/app/Config.java b/src/main/java/edu/rpi/legup/app/Config.java index 1016838c7..b04ef9b88 100644 --- a/src/main/java/edu/rpi/legup/app/Config.java +++ b/src/main/java/edu/rpi/legup/app/Config.java @@ -13,9 +13,9 @@ import org.xml.sax.SAXException; /** - * The {@code Config} class manages the configuration for puzzles by loading configuration data - * from an XML file. It provides methods to access puzzle class names, display names, and their - * file creation statuses + * The {@code Config} class manages the configuration for puzzles by loading configuration data from + * an XML file. It provides methods to access puzzle class names, display names, and their file + * creation statuses */ public class Config { private static final Logger Logger = LogManager.getLogger(Config.class.getName()); @@ -80,8 +80,8 @@ public static String convertClassNameToDisplayName(String className) { } /** - * Converts the display name of the puzzle back to its corresponding class name. - * For example: convertDisplayNameToClassName("Tree Tent") returns "TreeTent" + * Converts the display name of the puzzle back to its corresponding class name. For example: + * convertDisplayNameToClassName("Tree Tent") returns "TreeTent" * * @param displayName the display name of the puzzle * @return the class name of the puzzle as a String @@ -110,8 +110,8 @@ public List getPuzzleNames() { } /** - * Returns a list of the display names of the puzzles that can have files created and edited within - * the proof editor + * Returns a list of the display names of the puzzles that can have files created and edited + * within the proof editor * * @return a List of puzzle display names as Strings with file creation enabled */ diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 835041c3c..c6f92e5b5 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -32,8 +32,9 @@ import org.xml.sax.SAXException; /** - * {@code GameBoardFacade} is a class designed to manage the game board operations within the application. - * It integrates various components such as UI elements, puzzle management, and history tracking + * {@code GameBoardFacade} is a class designed to manage the game board operations within the + * application. It integrates various components such as UI elements, puzzle management, and history + * tracking */ public class GameBoardFacade implements IHistorySubject { private static final Logger LOGGER = LogManager.getLogger(GameBoardFacade.class.getName()); @@ -76,9 +77,7 @@ public static synchronized GameBoardFacade getInstance() { return instance; } - /** - * Initializes the UI components - */ + /** Initializes the UI components */ public void initializeUI() { EventQueue.invokeLater( () -> { @@ -101,18 +100,14 @@ public void setPuzzle(Puzzle puzzle) { this.history.clear(); } - /** - * Clears the current puzzle - */ + /** Clears the current puzzle */ public void clearPuzzle() { this.puzzle = null; this.curFileName = null; this.history.clear(); } - /** - * Sets up the configuration by initializing the Config object - */ + /** Sets up the configuration by initializing the Config object */ public static void setupConfig() { Config config = null; try { @@ -203,7 +198,7 @@ public boolean validateTextInput(String game, String[] statements) throws Runtim * @param columns the number of columns on the board */ public void loadPuzzle(String game, int rows, int columns) throws RuntimeException { - if (!game.equals("")) { + if (!game.isEmpty()) { String qualifiedClassName = config.getPuzzleClassForName(game); LOGGER.debug("Loading " + qualifiedClassName); @@ -235,15 +230,14 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti } catch (IllegalArgumentException exception) { throw new IllegalArgumentException(exception.getMessage()); } catch (ClassNotFoundException - | NoSuchMethodException - | InvocationTargetException - | IllegalAccessException - | InstantiationException e) { + | NoSuchMethodException + | InvocationTargetException + | IllegalAccessException + | InstantiationException e) { LOGGER.error(e); throw new RuntimeException("Puzzle creation error"); } } - } /** @@ -297,7 +291,8 @@ public void loadPuzzle(String game, String[] statements) { * Loads a puzzle file from the specified file * * @param fileName file name of the board file - * @throws InvalidFileFormatException if the file format is invalid or if the file cannot be created + * @throws InvalidFileFormatException if the file format is invalid or if the file cannot be + * created */ public void loadPuzzle(String fileName) throws InvalidFileFormatException { try { @@ -314,7 +309,8 @@ public void loadPuzzle(String fileName) throws InvalidFileFormatException { * Loads a puzzle into the editor from the specified file name * * @param fileName the name of the file to load - * @throws InvalidFileFormatException if the file format is invalid or if the file cannot be created + * @throws InvalidFileFormatException if the file format is invalid or if the file cannot be + * created */ public void loadPuzzleEditor(String fileName) throws InvalidFileFormatException { try { @@ -331,7 +327,8 @@ public void loadPuzzleEditor(String fileName) throws InvalidFileFormatException * Loads a puzzle into the editor from the specified input stream * * @param inputStream the input stream to load the puzzle from - * @throws InvalidFileFormatException if the input stream cannot be processed or the file format is invalid + * @throws InvalidFileFormatException if the input stream cannot be processed or the file format + * is invalid */ public void loadPuzzleEditor(InputStream inputStream) throws InvalidFileFormatException { Document document; diff --git a/src/main/java/edu/rpi/legup/app/InvalidConfigException.java b/src/main/java/edu/rpi/legup/app/InvalidConfigException.java index c66b23ec2..cad80b5ce 100644 --- a/src/main/java/edu/rpi/legup/app/InvalidConfigException.java +++ b/src/main/java/edu/rpi/legup/app/InvalidConfigException.java @@ -1,7 +1,8 @@ package edu.rpi.legup.app; /** - * {@code InvalidConfigException} is a custom exception class for handling invalid configuration errors + * {@code InvalidConfigException} is a custom exception class for handling invalid configuration + * errors */ public class InvalidConfigException extends Exception { /** diff --git a/src/main/java/edu/rpi/legup/app/LegupPreferences.java b/src/main/java/edu/rpi/legup/app/LegupPreferences.java index 03b8be8d9..3d17233bd 100644 --- a/src/main/java/edu/rpi/legup/app/LegupPreferences.java +++ b/src/main/java/edu/rpi/legup/app/LegupPreferences.java @@ -5,8 +5,9 @@ import java.util.prefs.Preferences; /** - * {@code LegupPreferences} is a class responsible for managing user preferences within the application. - * It uses Java's Preferences API to store and retrieve preferences, and it provides methods for accessing and updating these preferences. + * {@code LegupPreferences} is a class responsible for managing user preferences within the + * application. It uses Java's Preferences API to store and retrieve preferences, and it provides + * methods for accessing and updating these preferences. */ public class LegupPreferences { @@ -77,8 +78,8 @@ public class LegupPreferences { } /** - * Gets the legup preferences singleton instance - * This method ensures that only one instance of LegupPreferences exists + * Gets the legup preferences singleton instance This method ensures that only one instance of + * LegupPreferences exists * * @return the singleton instance of LegupPreferences */ @@ -90,8 +91,8 @@ public static LegupPreferences getInstance() { } /** - * Private constructor to prevent instantiation from outside the class - * Use {@link #getInstance()} to access the singleton instance + * Private constructor to prevent instantiation from outside the class Use {@link + * #getInstance()} to access the singleton instance */ private LegupPreferences() {} diff --git a/src/main/java/edu/rpi/legup/controller/Controller.java b/src/main/java/edu/rpi/legup/controller/Controller.java index 47ef70e17..823bac716 100644 --- a/src/main/java/edu/rpi/legup/controller/Controller.java +++ b/src/main/java/edu/rpi/legup/controller/Controller.java @@ -6,8 +6,9 @@ import javax.swing.*; /** - * {@code Controller} is an abstract class designed to handle various mouse events and provide control functionality for a {@code ScrollView}. - * It implements several mouse event interfaces to manage interactions such as panning and zooming within a {@code ScrollView} + * {@code Controller} is an abstract class designed to handle various mouse events and provide + * control functionality for a {@code ScrollView}. It implements several mouse event interfaces to + * manage interactions such as panning and zooming within a {@code ScrollView} */ public abstract class Controller implements MouseMotionListener, MouseListener, MouseWheelListener { protected ScrollView viewer; diff --git a/src/main/java/edu/rpi/legup/controller/CursorController.java b/src/main/java/edu/rpi/legup/controller/CursorController.java index 6a3ab018d..aad7eaf46 100644 --- a/src/main/java/edu/rpi/legup/controller/CursorController.java +++ b/src/main/java/edu/rpi/legup/controller/CursorController.java @@ -7,8 +7,9 @@ import java.util.TimerTask; /** - * {@code CursorController} provides functionality for managing the cursor appearance during actions that take a certain amount of time. - * It allows for the display of a busy cursor while an action is being processed and reverts to the default cursor afterward + * {@code CursorController} provides functionality for managing the cursor appearance during actions + * that take a certain amount of time. It allows for the display of a busy cursor while an action is + * being processed and reverts to the default cursor afterward */ public class CursorController { public static final Cursor BUSY_CURSOR = new Cursor(Cursor.WAIT_CURSOR); diff --git a/src/main/java/edu/rpi/legup/controller/EditorElementController.java b/src/main/java/edu/rpi/legup/controller/EditorElementController.java index 040610137..050f5bd65 100644 --- a/src/main/java/edu/rpi/legup/controller/EditorElementController.java +++ b/src/main/java/edu/rpi/legup/controller/EditorElementController.java @@ -10,8 +10,9 @@ import javax.swing.*; /** - * {@code EditorElementController} manages actions related to UI elements within the puzzle editor environment. - * It handles button presses, updates element selection, and manages visual states of buttons + * {@code EditorElementController} manages actions related to UI elements within the puzzle editor + * environment. It handles button presses, updates element selection, and manages visual states of + * buttons */ public class EditorElementController implements ActionListener { protected Object lastSource; diff --git a/src/main/java/edu/rpi/legup/controller/RuleController.java b/src/main/java/edu/rpi/legup/controller/RuleController.java index 491e02f74..df4def59e 100644 --- a/src/main/java/edu/rpi/legup/controller/RuleController.java +++ b/src/main/java/edu/rpi/legup/controller/RuleController.java @@ -17,9 +17,9 @@ import java.util.List; /** - * The RuleController class is responsible for handling UI events related to rule buttons - * in the RulePanel of the Legup application. It implements ActionListener to process action - * events triggered by rule buttons and applies rules to the puzzle accordingly + * The RuleController class is responsible for handling UI events related to rule buttons in the + * RulePanel of the Legup application. It implements ActionListener to process action events + * triggered by rule buttons and applies rules to the puzzle accordingly */ public class RuleController implements ActionListener { protected Object lastSource; diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index 2b12268ac..6e4ce9fd9 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -12,8 +12,8 @@ import javax.swing.*; /** - * The TreeController class handles UI events from a TreePanel. - * It extends the Controller class to provide specific behavior for tree interactions + * The TreeController class handles UI events from a TreePanel. It extends the Controller class to + * provide specific behavior for tree interactions */ public class TreeController extends Controller { /** diff --git a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java index 92a887f71..421cea438 100644 --- a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java @@ -10,10 +10,9 @@ import java.util.List; import java.util.Map; - /** - * The AddTreeElementCommand class represents a command to add tree elements to the proof tree. - * It extends the PuzzleCommand class to handle the addition of tree elements and undo operation. + * The AddTreeElementCommand class represents a command to add tree elements to the proof tree. It + * extends the PuzzleCommand class to handle the addition of tree elements and undo operation. */ public class AddTreeElementCommand extends PuzzleCommand { @@ -33,8 +32,8 @@ public AddTreeElementCommand(TreeViewSelection selection) { } /** - * Executes the command to add selected tree elements to the tree. - * Updates the puzzle and tree view accordingly + * Executes the command to add selected tree elements to the tree. Updates the puzzle and tree + * view accordingly */ @Override public void executeCommand() { @@ -104,8 +103,8 @@ public String getErrorString() { } /** - * Undoes the command by removing the added tree elements. - * Updates the puzzle and tree view accordingly + * Undoes the command by removing the added tree elements. Updates the puzzle and tree view + * accordingly */ @Override public void undoCommand() { diff --git a/src/main/java/edu/rpi/legup/history/ApplyDefaultDirectRuleCommand.java b/src/main/java/edu/rpi/legup/history/ApplyDefaultDirectRuleCommand.java index ad89ab636..e3e89ddd0 100644 --- a/src/main/java/edu/rpi/legup/history/ApplyDefaultDirectRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ApplyDefaultDirectRuleCommand.java @@ -11,9 +11,9 @@ import java.util.Map; /** - * The ApplyDefaultDirectRuleCommand class represents a command to apply a default direct rule - * to selected tree nodes in the proof tree. - * It extends the PuzzleCommand class to handle rule application and undo operation. + * The ApplyDefaultDirectRuleCommand class represents a command to apply a default direct rule to + * selected tree nodes in the proof tree. It extends the PuzzleCommand class to handle rule + * application and undo operation. */ public class ApplyDefaultDirectRuleCommand extends PuzzleCommand { @@ -75,8 +75,8 @@ public String getErrorString() { } /** - * Executes the command to apply the default rule to the selected tree nodes. - * Updates the puzzle and tree view accordingly. + * Executes the command to apply the default rule to the selected tree nodes. Updates the puzzle + * and tree view accordingly. */ @Override public void executeCommand() { @@ -118,8 +118,8 @@ public void executeCommand() { } /** - * Undoes the command by removing the applied default rule from the tree nodes. - * Updates the puzzle and tree view accordingly. + * Undoes the command by removing the applied default rule from the tree nodes. Updates the + * puzzle and tree view accordingly. */ @Override public void undoCommand() { diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index b86cda6ea..4717b25ae 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -15,8 +15,8 @@ /** * The AutoCaseRuleCommand class represents a command to automatically apply a case rule to a - * selected tree node in the proof tree. - * It extends the PuzzleCommand class to handle case rule application and undo operation. + * selected tree node in the proof tree. It extends the PuzzleCommand class to handle case rule + * application and undo operation. */ public class AutoCaseRuleCommand extends PuzzleCommand { @@ -52,8 +52,8 @@ public AutoCaseRuleCommand( } /** - * Executes the command to apply the case rule to the selected tree node. - * Updates the puzzle and tree view accordingly. + * Executes the command to apply the case rule to the selected tree node. Updates the puzzle and + * tree view accordingly. */ @Override public void executeCommand() { @@ -64,10 +64,11 @@ public void executeCommand() { TreeNode node = (TreeNode) selection.getFirstSelection().getTreeElement(); if (caseTrans.isEmpty()) { - List cases = caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()); + List cases = + caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()); for (Board board : cases) { final TreeTransition transition = (TreeTransition) tree.addTreeElement(node); - //board.setModifiable(false); + // board.setModifiable(false); transition.setBoard(board); transition.setRule(caseRule); transition.setSelection(elementView.getPuzzleElement().copy()); @@ -118,11 +119,13 @@ public String getErrorString() { return "The selected data element is not pickable with this case rule."; } - if (caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size() == 0) { + if (caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size() + == 0) { return "The selection must produce at least one case"; } - int numberOfCaseRules = caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size(); + int numberOfCaseRules = + caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size(); System.out.println("Number of cases:" + numberOfCaseRules); if (numberOfCaseRules > caseRule.MAX_CASES) { return "The selection can produce a max of " + caseRule.MAX_CASES + " cases"; @@ -135,8 +138,8 @@ public String getErrorString() { } /** - * Undoes the command by removing the applied case rules from the tree node. - * Updates the puzzle and tree view accordingly + * Undoes the command by removing the applied case rules from the tree node. Updates the puzzle + * and tree view accordingly */ @Override public void undoCommand() { diff --git a/src/main/java/edu/rpi/legup/history/CommandError.java b/src/main/java/edu/rpi/legup/history/CommandError.java index 26959cccd..78027f6ab 100644 --- a/src/main/java/edu/rpi/legup/history/CommandError.java +++ b/src/main/java/edu/rpi/legup/history/CommandError.java @@ -2,15 +2,16 @@ /** * The CommandError enum represents various error conditions that can occur when executing or - * validating commands related to tree elements in the proof tree. - * Each error condition is associated with a descriptive message. + * validating commands related to tree elements in the proof tree. Each error condition is + * associated with a descriptive message. */ public enum CommandError { NO_SELECTED_VIEWS("The selection does not have any tree elements."), ONE_SELECTED_VIEW("The selection must have exactly one tree element."), UNMODIFIABLE_BOARD("The selection contains a board which is not modifiable."), UNMODIFIABLE_DATA("The selection contains a board where the data element is not modifiable."), - UNMODIFIABLE_DATA_CASE_RULE("The proof tree contains a future case rule, causing previous transitions to become unmodifiable."), + UNMODIFIABLE_DATA_CASE_RULE( + "The proof tree contains a future case rule, causing previous transitions to become unmodifiable."), CONTAINS_ROOT("The selection contains the root tree node."), ONE_CHILD("The selection contains a tree node that does not have exactly one child."), ADD_WITH_CHILD("The selection contains a tree transition that already has a child tree node."), diff --git a/src/main/java/edu/rpi/legup/history/CommandState.java b/src/main/java/edu/rpi/legup/history/CommandState.java index 326490e28..b72f15480 100644 --- a/src/main/java/edu/rpi/legup/history/CommandState.java +++ b/src/main/java/edu/rpi/legup/history/CommandState.java @@ -1,8 +1,8 @@ package edu.rpi.legup.history; /** - * The CommandState enum represents the various states that a command can be in during its lifecycle. - * Each state is associated with a descriptive name. + * The CommandState enum represents the various states that a command can be in during its + * lifecycle. Each state is associated with a descriptive name. */ public enum CommandState { CREATED("Created"), diff --git a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java index e82197898..bfd9cd7f5 100644 --- a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java @@ -8,9 +8,9 @@ import java.util.List; /** - * The DeleteTreeElementCommand class represents a command to delete tree elements from a proof tree. - * It extends PuzzleCommand and implements the functionality to remove selected tree elements and - * handle undo operations. + * The DeleteTreeElementCommand class represents a command to delete tree elements from a proof + * tree. It extends PuzzleCommand and implements the functionality to remove selected tree elements + * and handle undo operations. */ public class DeleteTreeElementCommand extends PuzzleCommand { private TreeViewSelection selection; @@ -25,9 +25,7 @@ public DeleteTreeElementCommand(TreeViewSelection selection) { this.selection = selection.copy(); } - /** - * Executes the delete command, removing the selected tree elements from the tree. - */ + /** Executes the delete command, removing the selected tree elements from the tree. */ @Override public void executeCommand() { Tree tree = GameBoardFacade.getInstance().getTree(); @@ -41,11 +39,13 @@ public void executeCommand() { TreeElementView firstSelectedView = selectedViews.get(0); TreeElementView newSelectedView; if (firstSelectedView.getType() == TreeElementType.NODE) { - //System.out.println("FIRST SELECTION NODE, total selection views: " + selectedViews.size()); + // System.out.println("FIRST SELECTION NODE, total selection views: " + + // selectedViews.size()); TreeNodeView nodeView = (TreeNodeView) firstSelectedView; newSelectedView = nodeView.getParentView(); } else { - //System.out.println("FIRST SELECTION TRANS, total selection views: " + selectedViews.size()); + // System.out.println("FIRST SELECTION TRANS, total selection views: " + + // selectedViews.size()); TreeTransitionView transitionView = (TreeTransitionView) firstSelectedView; newSelectedView = transitionView.getParentViews().get(0); } @@ -58,8 +58,10 @@ public void executeCommand() { } final TreeViewSelection newSelection = new TreeViewSelection(newSelectedView); - puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(newSelectedView.getTreeElement())); - puzzle.notifyTreeListeners((ITreeListener listener) -> listener.onTreeSelectionChanged(newSelection)); + puzzle.notifyBoardListeners( + listener -> listener.onTreeElementChanged(newSelectedView.getTreeElement())); + puzzle.notifyTreeListeners( + (ITreeListener listener) -> listener.onTreeSelectionChanged(newSelection)); } /** @@ -84,9 +86,7 @@ public String getErrorString() { return null; } - /** - * Undoes the delete command, re-adding the previously deleted tree elements. - */ + /** Undoes the delete command, re-adding the previously deleted tree elements. */ @Override public void undoCommand() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); diff --git a/src/main/java/edu/rpi/legup/history/EditDataCommand.java b/src/main/java/edu/rpi/legup/history/EditDataCommand.java index a629aa085..0d51cc717 100644 --- a/src/main/java/edu/rpi/legup/history/EditDataCommand.java +++ b/src/main/java/edu/rpi/legup/history/EditDataCommand.java @@ -11,16 +11,15 @@ import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.lookandfeel.materialdesign.MaterialColors; import edu.rpi.legup.ui.proofeditorui.treeview.*; - -import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.util.List; +import javax.swing.*; /** - * The EditDataCommand class represents a command to edit the data of a puzzle element within - * a tree transition. It extends PuzzleCommand and provides functionality to execute and undo - * changes made to puzzle elements. + * The EditDataCommand class represents a command to edit the data of a puzzle element within a tree + * transition. It extends PuzzleCommand and provides functionality to execute and undo changes made + * to puzzle elements. */ public class EditDataCommand extends PuzzleCommand { private TreeTransition transition; @@ -47,9 +46,7 @@ public EditDataCommand(ElementView elementView, TreeViewSelection selection, Mou this.transition = null; } - /** - * Executes the edit data command, modifying the puzzle element and propagating changes - */ + /** Executes the edit data command, modifying the puzzle element and propagating changes */ @SuppressWarnings("unchecked") @Override public void executeCommand() { @@ -142,9 +139,7 @@ public String getErrorString() { return null; } - /** - * Causes the TreeView background to flash red for a short duration when an error occurs. - */ + /** Causes the TreeView background to flash red for a short duration when an error occurs. */ private void flashTreeViewRed() { TreeView treeView = getInstance().getLegupUI().getTreePanel().getTreeView(); Color originalColor = treeView.getBackground(); @@ -154,9 +149,7 @@ private void flashTreeViewRed() { timer.start(); } - /** - * Undoes the edit data command, restoring the previous state of the puzzle element. - */ + /** Undoes the edit data command, restoring the previous state of the puzzle element. */ @SuppressWarnings("unchecked") @Override public void undoCommand() { diff --git a/src/main/java/edu/rpi/legup/history/History.java b/src/main/java/edu/rpi/legup/history/History.java index b244e8f88..9eaeb3e75 100644 --- a/src/main/java/edu/rpi/legup/history/History.java +++ b/src/main/java/edu/rpi/legup/history/History.java @@ -7,8 +7,9 @@ import org.apache.logging.log4j.Logger; /** - * The History class manages a stack of commands for undo and redo operations on the board and tree structure. - * It maintains a list of commands and a current index to track the position in the history stack. + * The History class manages a stack of commands for undo and redo operations on the board and tree + * structure. It maintains a list of commands and a current index to track the position in the + * history stack. */ public class History { private static final Logger LOGGER = LogManager.getLogger(History.class.getName()); @@ -18,8 +19,8 @@ public class History { private int curIndex; /** - * Constructs a History object to keep track of changes and allow undo and redo operations. - * The history is implemented as a stack, with curIndex pointing to the top of the stack. + * Constructs a History object to keep track of changes and allow undo and redo operations. The + * history is implemented as a stack, with curIndex pointing to the top of the stack. */ public History() { history = new ArrayList<>(); @@ -58,7 +59,6 @@ public void undo() { command.undo(); LOGGER.info("Undoed " + command.getClass().getSimpleName()); - GameBoardFacade.getInstance() .notifyHistoryListeners( l -> l.onUndo(curIndex < 0, curIndex == history.size() - 1)); @@ -83,9 +83,7 @@ public void redo() { } } - /** - * Clears all actions from the history stack and resets the current index - */ + /** Clears all actions from the history stack and resets the current index */ public void clear() { history.clear(); curIndex = -1; diff --git a/src/main/java/edu/rpi/legup/history/ICommand.java b/src/main/java/edu/rpi/legup/history/ICommand.java index 4f867dbab..fe10bd693 100644 --- a/src/main/java/edu/rpi/legup/history/ICommand.java +++ b/src/main/java/edu/rpi/legup/history/ICommand.java @@ -1,13 +1,11 @@ package edu.rpi.legup.history; /** - * The ICommand interface defines the structure for command objects in a command pattern. - * It provides methods to execute, undo, redo commands, and to check if a command can be executed. + * The ICommand interface defines the structure for command objects in a command pattern. It + * provides methods to execute, undo, redo commands, and to check if a command can be executed. */ public interface ICommand { - /** - * Executes the command. The specific behavior depends on the implementation - */ + /** Executes the command. The specific behavior depends on the implementation */ void execute(); /** @@ -25,13 +23,9 @@ public interface ICommand { */ String getError(); - /** - * Undoes the command. Reverts the changes made by the execute method - */ + /** Undoes the command. Reverts the changes made by the execute method */ void undo(); - /** - * Redoes the command. Re-applies the changes made by the execute method after undoing - */ + /** Redoes the command. Re-applies the changes made by the execute method after undoing */ void redo(); } diff --git a/src/main/java/edu/rpi/legup/history/IHistoryListener.java b/src/main/java/edu/rpi/legup/history/IHistoryListener.java index 48690168d..a752cd53a 100644 --- a/src/main/java/edu/rpi/legup/history/IHistoryListener.java +++ b/src/main/java/edu/rpi/legup/history/IHistoryListener.java @@ -1,9 +1,9 @@ package edu.rpi.legup.history; /** - * The IHistoryListener interface defines methods for listening to changes in the history of commands. - * Implementations of this interface can respond to events related to command history such as pushing, - * undoing, redoing commands, and clearing the history. + * The IHistoryListener interface defines methods for listening to changes in the history of + * commands. Implementations of this interface can respond to events related to command history such + * as pushing, undoing, redoing commands, and clearing the history. */ public interface IHistoryListener { @@ -30,8 +30,6 @@ public interface IHistoryListener { */ void onRedo(boolean isBottom, boolean isTop); - /** - * Called when the history stack is cleared. - */ + /** Called when the history stack is cleared. */ void onClearHistory(); } diff --git a/src/main/java/edu/rpi/legup/history/IHistorySubject.java b/src/main/java/edu/rpi/legup/history/IHistorySubject.java index 431adbb93..b526c7cf3 100644 --- a/src/main/java/edu/rpi/legup/history/IHistorySubject.java +++ b/src/main/java/edu/rpi/legup/history/IHistorySubject.java @@ -3,9 +3,9 @@ import java.util.function.Consumer; /** - * The IHistorySubject interface defines methods for managing and notifying listeners - * about changes in the command history. Implementations of this interface can add, remove, - * and notify history listeners. + * The IHistorySubject interface defines methods for managing and notifying listeners about changes + * in the command history. Implementations of this interface can add, remove, and notify history + * listeners. */ public interface IHistorySubject { @@ -17,7 +17,8 @@ public interface IHistorySubject { void addHistoryListener(IHistoryListener listener); /** - * Removes a history listener, so it no longer receives updates about changes in the command history. + * Removes a history listener, so it no longer receives updates about changes in the command + * history. * * @param listener the listener to remove */ @@ -26,7 +27,8 @@ public interface IHistorySubject { /** * Notifies all registered listeners about a change in the command history. * - * @param algorithm a Consumer function that takes an IHistoryListener and performs some action with it + * @param algorithm a Consumer function that takes an IHistoryListener and performs some action + * with it */ void notifyHistoryListeners(Consumer algorithm); } diff --git a/src/main/java/edu/rpi/legup/history/InvalidCommandStateTransition.java b/src/main/java/edu/rpi/legup/history/InvalidCommandStateTransition.java index 201babb9e..0e1ba1b0d 100644 --- a/src/main/java/edu/rpi/legup/history/InvalidCommandStateTransition.java +++ b/src/main/java/edu/rpi/legup/history/InvalidCommandStateTransition.java @@ -1,8 +1,8 @@ package edu.rpi.legup.history; /** - * The InvalidCommandStateTransition exception is thrown when an invalid state transition - * is attempted on a PuzzleCommand + * The InvalidCommandStateTransition exception is thrown when an invalid state transition is + * attempted on a PuzzleCommand */ public class InvalidCommandStateTransition extends RuntimeException { diff --git a/src/main/java/edu/rpi/legup/history/MergeCommand.java b/src/main/java/edu/rpi/legup/history/MergeCommand.java index c2851bced..2d180465b 100644 --- a/src/main/java/edu/rpi/legup/history/MergeCommand.java +++ b/src/main/java/edu/rpi/legup/history/MergeCommand.java @@ -11,8 +11,8 @@ import java.util.Set; /** - * The MergeCommand class represents a command to merge selected tree nodes into a single node - * and create a transition to represent the merge + * The MergeCommand class represents a command to merge selected tree nodes into a single node and + * create a transition to represent the merge */ public class MergeCommand extends PuzzleCommand { private TreeViewSelection selection; @@ -28,9 +28,7 @@ public MergeCommand(TreeViewSelection selection) { this.transition = null; } - /** - * Executes the merge command - */ + /** Executes the merge command */ @Override public void executeCommand() { List selectedViews = selection.getSelectedViews(); @@ -77,9 +75,7 @@ public void executeCommand() { puzzle.notifyTreeListeners(listener -> listener.onTreeSelectionChanged(newSelection)); } - /** - * Undoes the merge command - */ + /** Undoes the merge command */ @Override public void undoCommand() { Tree tree = GameBoardFacade.getInstance().getTree(); diff --git a/src/main/java/edu/rpi/legup/history/PuzzleCommand.java b/src/main/java/edu/rpi/legup/history/PuzzleCommand.java index d4385b3e8..54e58c667 100644 --- a/src/main/java/edu/rpi/legup/history/PuzzleCommand.java +++ b/src/main/java/edu/rpi/legup/history/PuzzleCommand.java @@ -1,27 +1,23 @@ package edu.rpi.legup.history; /** - * The PuzzleCommand class is an abstract base class for commands that can be executed, undone, and redone - * within the puzzle model. It implements the ICommand interface and maintains the state and error handling - * for the command. + * The PuzzleCommand class is an abstract base class for commands that can be executed, undone, and + * redone within the puzzle model. It implements the ICommand interface and maintains the state and + * error handling for the command. */ public abstract class PuzzleCommand implements ICommand { private CommandState state; private boolean isCached; private String cachedError; - /** - * Puzzle Command Constructor for creating an undoable and redoable change to the model - */ + /** Puzzle Command Constructor for creating an undoable and redoable change to the model */ protected PuzzleCommand() { this.state = CommandState.CREATED; this.isCached = false; this.cachedError = null; } - /** - * Executes the command if it can be executed - */ + /** Executes the command if it can be executed */ @Override public final void execute() { if (canExecute()) { @@ -30,9 +26,7 @@ public final void execute() { } } - /** - * Determines whether the command can be executed by checking the error state - */ + /** Determines whether the command can be executed by checking the error state */ @Override public final boolean canExecute() { cachedError = getError(); @@ -64,20 +58,18 @@ public final String getError() { public abstract String getErrorString(); /** - * Executes the command. - * This method must be implemented by subclasses to define the command's execution behavior. + * Executes the command. This method must be implemented by subclasses to define the command's + * execution behavior. */ public abstract void executeCommand(); /** - * Undoes the command. - * This method must be implemented by subclasses to define the command's undo behavior. + * Undoes the command. This method must be implemented by subclasses to define the command's + * undo behavior. */ public abstract void undoCommand(); - /** - * Redoes the command. This method is called if the command was previously undone. - */ + /** Redoes the command. This method is called if the command was previously undone. */ public void redoCommand() { if (state == CommandState.UNDOED) { executeCommand(); @@ -87,9 +79,7 @@ public void redoCommand() { } } - /** - * Undoes the command if it was executed or redone - */ + /** Undoes the command if it was executed or redone */ @Override public final void undo() { if (state == CommandState.EXECUTED || state == CommandState.REDOED) { @@ -100,9 +90,7 @@ public final void undo() { } } - /** - * Redoes the command if it was previously undone. - */ + /** Redoes the command if it was previously undone. */ public final void redo() { if (state == CommandState.UNDOED) { redoCommand(); diff --git a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java index 6827436e8..3f534bcda 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java @@ -13,8 +13,8 @@ import java.util.Map; /** - * The ValidateCaseRuleCommand class represents a command for validating a CaseRule in the tree structure. - * It extends the PuzzleCommand class and implements the ICommand interface. + * The ValidateCaseRuleCommand class represents a command for validating a CaseRule in the tree + * structure. It extends the PuzzleCommand class and implements the ICommand interface. */ public class ValidateCaseRuleCommand extends PuzzleCommand { @@ -37,9 +37,7 @@ public ValidateCaseRuleCommand(TreeViewSelection selection, CaseRule caseRule) { this.addNode = new HashMap<>(); } - /** - * Executes the command to validate the CaseRule - */ + /** Executes the command to validate the CaseRule */ @Override public void executeCommand() { Tree tree = getInstance().getTree(); @@ -111,10 +109,7 @@ public String getErrorString() { return null; } - - /** - * Undoes the validation command, restoring the previous state - */ + /** Undoes the validation command, restoring the previous state */ @Override public void undoCommand() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); diff --git a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java index b106a6072..0a8b9414f 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java @@ -11,8 +11,9 @@ import java.util.Map; /** - * The ValidateContradictionRuleCommand class represents a command for validating and applying a ContradictionRule - * within a tree structure. It extends the PuzzleCommand class and implements the ICommand interface. + * The ValidateContradictionRuleCommand class represents a command for validating and applying a + * ContradictionRule within a tree structure. It extends the PuzzleCommand class and implements the + * ICommand interface. */ public class ValidateContradictionRuleCommand extends PuzzleCommand { private TreeViewSelection selection; @@ -35,9 +36,7 @@ public ValidateContradictionRuleCommand(TreeViewSelection selection, Contradicti this.addTran = new HashMap<>(); } - /** - * Executes the command to validate and apply the ContradictionRule. - */ + /** Executes the command to validate and apply the ContradictionRule. */ @Override public void executeCommand() { Tree tree = GameBoardFacade.getInstance().getTree(); @@ -92,8 +91,7 @@ public void executeCommand() { TreeNodeView nodeView = (TreeNodeView) firstSelectedView; if (!nodeView.getChildrenViews().isEmpty()) { finalTreeElement = nodeView.getChildrenViews().get(0).getTreeElement(); - } - else { + } else { finalTreeElement = null; } } else { @@ -136,9 +134,7 @@ public String getErrorString() { return null; } - /** - * Undoes the validation command, restoring the previous state. - */ + /** Undoes the validation command, restoring the previous state. */ @Override public void undoCommand() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); diff --git a/src/main/java/edu/rpi/legup/history/ValidateDirectRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateDirectRuleCommand.java index f7694cc0a..49bf378ee 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateDirectRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateDirectRuleCommand.java @@ -6,16 +6,16 @@ import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.*; import edu.rpi.legup.ui.proofeditorui.treeview.*; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * The ValidateDirectRuleCommand class represents a command for validating and applying a DirectRule - * to a set of selected tree elements. It extends the PuzzleCommand class and implements the ICommand interface. + * to a set of selected tree elements. It extends the PuzzleCommand class and implements the + * ICommand interface. */ public class ValidateDirectRuleCommand extends PuzzleCommand { private static final Logger LOGGER = LogManager.getLogger(History.class.getName()); @@ -38,9 +38,7 @@ public ValidateDirectRuleCommand(TreeViewSelection selection, DirectRule rule) { this.addNode = new HashMap<>(); } - /** - * Executes the command to validate and apply the DirectRule. - */ + /** Executes the command to validate and apply the DirectRule. */ @Override public void executeCommand() { Tree tree = GameBoardFacade.getInstance().getTree(); @@ -116,7 +114,6 @@ public void executeCommand() { puzzle.notifyTreeListeners(listener -> listener.onTreeSelectionChanged(newSelection)); } - /** * Gets the reason why the command cannot be executed * @@ -146,9 +143,7 @@ public String getErrorString() { return null; } - /** - * Undoes the validation command, restoring the previous state. - */ + /** Undoes the validation command, restoring the previous state. */ @Override public void undoCommand() { Tree tree = GameBoardFacade.getInstance().getTree(); @@ -162,7 +157,6 @@ public void undoCommand() { transitionView = nodeView.getChildrenViews().get(0); } else { transitionView = (TreeTransitionView) selectedView; - } TreeTransition transition = transitionView.getTreeElement(); diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index 6cc92f347..8024c99ed 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -36,9 +36,9 @@ import org.xml.sax.SAXException; /** - * Abstract class representing a puzzle. - * The Puzzle class manages the core components of a puzzle game, including the board, rules, and elements. - * It also handles importing and exporting puzzle configurations and notifies listeners about changes. + * Abstract class representing a puzzle. The Puzzle class manages the core components of a puzzle + * game, including the board, rules, and elements. It also handles importing and exporting puzzle + * configurations and notifies listeners about changes. */ public abstract class Puzzle implements IBoardSubject, ITreeSubject { private static final Logger LOGGER = LogManager.getLogger(Puzzle.class.getName()); @@ -75,8 +75,8 @@ public Puzzle() { } /** - * Registers puzzle elements from the package of the derived class. - * Scans for classes annotated with {@link RegisterElement} and initializes them. + * Registers puzzle elements from the package of the derived class. Scans for classes annotated + * with {@link RegisterElement} and initializes them. */ private void registerPuzzleElements() { String packageName = this.getClass().getPackage().toString().replace("package ", ""); @@ -87,7 +87,8 @@ private void registerPuzzleElements() { for (Class c : possElements) { String classPackageName = c.getPackage().getName(); - if (!classPackageName.startsWith("edu.rpi.legup.puzzle.") || !classPackageName.endsWith(".elements")) { + if (!classPackageName.startsWith("edu.rpi.legup.puzzle.") + || !classPackageName.endsWith(".elements")) { continue; } System.out.println("possible element: " + c.getName()); @@ -122,8 +123,8 @@ private void registerPuzzleElements() { } /** - * Registers rules from the package of the derived class. - * Scans for classes annotated with {@link RegisterRule} and initializes them. + * Registers rules from the package of the derived class. Scans for classes annotated with + * {@link RegisterRule} and initializes them. */ private void registerRules() { String packageName = this.getClass().getPackage().toString().replace("package ", ""); @@ -134,7 +135,8 @@ private void registerRules() { for (Class c : possRules) { String classPackageName = c.getPackage().getName(); - if (!classPackageName.startsWith("edu.rpi.legup.puzzle.") || !classPackageName.endsWith(".rules")) { + if (!classPackageName.startsWith("edu.rpi.legup.puzzle.") + || !classPackageName.endsWith(".rules")) { continue; } System.out.println("possible rule: " + c.getName()); @@ -176,9 +178,7 @@ private void registerRules() { } } - /** - * Initializes the view. Called by the invoker of the class - */ + /** Initializes the view. Called by the invoker of the class */ public abstract void initializeView(); /** @@ -584,8 +584,8 @@ public void setFactory(ElementFactory factory) { } /** - * Adds a board listener to the list of listeners. - * This allows the puzzle to notify the listener about changes to the board. + * Adds a board listener to the list of listeners. This allows the puzzle to notify the listener + * about changes to the board. * * @param listener The IBoardListener to be added to the list of listeners. */ @@ -595,8 +595,8 @@ public void addBoardListener(IBoardListener listener) { } /** - * Removes a board listener from the list of listeners. - * This prevents the puzzle from notifying the listener about future changes to the board. + * Removes a board listener from the list of listeners. This prevents the puzzle from notifying + * the listener about future changes to the board. * * @param listener The IBoardListener to be removed from the list of listeners. */ @@ -606,10 +606,11 @@ public void removeBoardListener(IBoardListener listener) { } /** - * Notifies all registered board listeners about changes. - * The provided algorithm is applied to each listener to process the notification. + * Notifies all registered board listeners about changes. The provided algorithm is applied to + * each listener to process the notification. * - * @param algorithm A Consumer function that takes an IBoardListener and performs operations to notify the listener. + * @param algorithm A Consumer function that takes an IBoardListener and performs operations to + * notify the listener. */ @Override public void notifyBoardListeners(Consumer algorithm) { @@ -617,8 +618,8 @@ public void notifyBoardListeners(Consumer algorithm) { } /** - * Adds a tree listener to the list of listeners. - * This allows the puzzle to notify the listener about changes to the tree. + * Adds a tree listener to the list of listeners. This allows the puzzle to notify the listener + * about changes to the tree. * * @param listener The ITreeListener to be added to the list of listeners. */ @@ -628,8 +629,8 @@ public void addTreeListener(ITreeListener listener) { } /** - * Removes a tree listener from the list of listeners. - * This prevents the puzzle from notifying the listener about future changes to the tree. + * Removes a tree listener from the list of listeners. This prevents the puzzle from notifying + * the listener about future changes to the tree. * * @param listener The ITreeListener to be removed from the list of listeners. */ @@ -639,10 +640,11 @@ public void removeTreeListener(ITreeListener listener) { } /** - * Notifies all registered tree listeners about changes. - * The provided algorithm is applied to each listener to process the notification. + * Notifies all registered tree listeners about changes. The provided algorithm is applied to + * each listener to process the notification. * - * @param algorithm A Consumer function that takes an ITreeListener and performs operations to notify the listener. + * @param algorithm A Consumer function that takes an ITreeListener and performs operations to + * notify the listener. */ @Override public void notifyTreeListeners(Consumer algorithm) { @@ -650,8 +652,8 @@ public void notifyTreeListeners(Consumer algorithm) { } /** - * Checks if the puzzle is valid. - * The implementation of this method can vary based on the specific criteria for puzzle validity. + * Checks if the puzzle is valid. The implementation of this method can vary based on the + * specific criteria for puzzle validity. * * @return true if the puzzle is valid, false otherwise. */ diff --git a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java index 234d0f25c..13107bb54 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java @@ -21,9 +21,9 @@ import org.w3c.dom.Element; /** - * Abstract class for exporting puzzle data to XML format. - * This class provides functionality to export a puzzle object, including its board and tree structure, to an XML file. - * Subclasses must implement methods to create specific elements for the board and the tree. + * Abstract class for exporting puzzle data to XML format. This class provides functionality to + * export a puzzle object, including its board and tree structure, to an XML file. Subclasses must + * implement methods to create specific elements for the board and the tree. */ public abstract class PuzzleExporter { private static final Logger LOGGER = LogManager.getLogger(PuzzleExporter.class.getName()); @@ -97,8 +97,8 @@ public void exportPuzzle(String fileName) throws ExportFileException { } /** - * Creates an XML element representing the board of the puzzle. - * Subclasses must implement this method to provide the XML structure for the board. + * Creates an XML element representing the board of the puzzle. Subclasses must implement this + * method to provide the XML structure for the board. * * @param newDocument The XML document to create elements within. * @return An XML element representing the puzzle's board. @@ -107,7 +107,8 @@ public void exportPuzzle(String fileName) throws ExportFileException { /** * Creates an XML element representing the proof of the puzzle, including its tree structure. - * This method is used to generate the proof section of the XML, which contains the tree representation. + * This method is used to generate the proof section of the XML, which contains the tree + * representation. * * @param newDocument The XML document to create elements within. * @return An XML element representing the proof of the puzzle. @@ -120,8 +121,8 @@ protected Element createProofElement(Document newDocument) { } /** - * Creates an XML element representing the tree structure of the puzzle. - * This method traverses the tree nodes and transitions, and creates XML elements for each. + * Creates an XML element representing the tree structure of the puzzle. This method traverses + * the tree nodes and transitions, and creates XML elements for each. * * @param newDocument The XML document to create elements within. * @return An XML element representing the puzzle's tree structure. diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index b1e8a2dd9..9d16d94e9 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -14,10 +14,10 @@ import org.w3c.dom.NodeList; /** - * Abstract class for importing puzzle data from various sources into a puzzle object. - * This class provides methods to initialize and set up a puzzle, including its board and proof structure, - * from different input formats such as dimensions, statements, or XML files. - * Subclasses must implement methods to handle specific formats for board initialization and proof creation. + * Abstract class for importing puzzle data from various sources into a puzzle object. This class + * provides methods to initialize and set up a puzzle, including its board and proof structure, from + * different input formats such as dimensions, statements, or XML files. Subclasses must implement + * methods to handle specific formats for board initialization and proof creation. */ public abstract class PuzzleImporter { private static final Logger LOGGER = LogManager.getLogger(PuzzleImporter.class.getName()); @@ -57,7 +57,8 @@ public void initializePuzzle(int rows, int columns) throws RuntimeException { * * @param statements the statements used to initialize the puzzle * @throws InputMismatchException if the input statements are invalid - * @throws IllegalArgumentException if the statements are not suitable for initializing the puzzle + * @throws IllegalArgumentException if the statements are not suitable for initializing the + * puzzle */ public void initializePuzzle(String[] statements) throws InputMismatchException, IllegalArgumentException { @@ -145,7 +146,8 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * * @param statements the statements used to initialize the board * @throws UnsupportedOperationException if the operation is not supported - * @throws IllegalArgumentException if the statements are not suitable for initializing the board + * @throws IllegalArgumentException if the statements are not suitable for initializing the + * board */ public abstract void initializeBoard(String[] statements) throws UnsupportedOperationException, IllegalArgumentException; @@ -314,7 +316,6 @@ protected void createTree(Node node) throws InvalidFileFormatException { } } - protected void validateTreeStructure( HashMap nodes, HashMap transitions) throws InvalidFileFormatException { @@ -394,7 +395,8 @@ protected void validateTreeStructure( * * @param transition the TreeTransition object representing the transition to be updated * @param transElement the XML node containing the transition data - * @throws InvalidFileFormatException if the XML node format is incorrect or unknown nodes are encountered + * @throws InvalidFileFormatException if the XML node format is incorrect or unknown nodes are + * encountered */ protected void makeTransitionChanges(TreeTransition transition, Node transElement) throws InvalidFileFormatException { @@ -440,8 +442,8 @@ protected void makeTransitionChanges(TreeTransition transition, Node transElemen } /** - * Creates a default proof tree with a single root node. The root node is initialized with the current board state. - * The created tree is then set as the proof tree for the puzzle. + * Creates a default proof tree with a single root node. The root node is initialized with the + * current board state. The created tree is then set as the proof tree for the puzzle. */ protected void createDefaultTree() { TreeNode root = new TreeNode(puzzle.getCurrentBoard()); diff --git a/src/main/java/edu/rpi/legup/model/RegisterPuzzle.java b/src/main/java/edu/rpi/legup/model/RegisterPuzzle.java index c473e0ecd..df2a9bc5b 100644 --- a/src/main/java/edu/rpi/legup/model/RegisterPuzzle.java +++ b/src/main/java/edu/rpi/legup/model/RegisterPuzzle.java @@ -5,9 +5,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Annotation for registering puzzle classes with the puzzle framework. - */ +/** Annotation for registering puzzle classes with the puzzle framework. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface RegisterPuzzle {} diff --git a/src/main/java/edu/rpi/legup/model/elements/Element.java b/src/main/java/edu/rpi/legup/model/elements/Element.java index 0adbbaf91..ed47f6523 100644 --- a/src/main/java/edu/rpi/legup/model/elements/Element.java +++ b/src/main/java/edu/rpi/legup/model/elements/Element.java @@ -5,8 +5,8 @@ import javax.swing.*; /** - * The Element class serves as an abstract base class for various elements used in the system. - * It handles basic properties such as ID, name, description, and image associated with the element. + * The Element class serves as an abstract base class for various elements used in the system. It + * handles basic properties such as ID, name, description, and image associated with the element. */ @RegisterElement public abstract class Element { @@ -39,7 +39,8 @@ public Element(String elementID, String elementName, String description, String } /** - * Loads the image for the element and resizes it to a width of 100 pixels while maintaining aspect ratio + * Loads the image for the element and resizes it to a width of 100 pixels while maintaining + * aspect ratio */ private void loadImage() { if (imageName != null) { diff --git a/src/main/java/edu/rpi/legup/model/elements/ElementType.java b/src/main/java/edu/rpi/legup/model/elements/ElementType.java index 4fee79d4f..142427efe 100644 --- a/src/main/java/edu/rpi/legup/model/elements/ElementType.java +++ b/src/main/java/edu/rpi/legup/model/elements/ElementType.java @@ -1,9 +1,7 @@ package edu.rpi.legup.model.elements; -/** - * Enum representing the different types of elements that can be used in the system - */ +/** Enum representing the different types of elements that can be used in the system */ public enum ElementType { PLACEABLE - //NONPLACEABLE COMBINED ALL PLACEABLE AND NONPLACEABLE INTO JUST ONE CATEGORY + // NONPLACEABLE COMBINED ALL PLACEABLE AND NONPLACEABLE INTO JUST ONE CATEGORY } diff --git a/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java b/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java index 019001128..5c4e96556 100644 --- a/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java +++ b/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java @@ -1,9 +1,9 @@ -//package edu.rpi.legup.model.elements; +// package edu.rpi.legup.model.elements; // -//public abstract class NonPlaceableElement extends Element { +// public abstract class NonPlaceableElement extends Element { // public NonPlaceableElement( // String elementID, String elementName, String description, String imageName) { // super(elementID, elementName, description, imageName); // this.elementType = ElementType.PLACEABLE; // } -//} +// } diff --git a/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java b/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java index 79a0dcff8..820dc08dd 100644 --- a/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java +++ b/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java @@ -1,18 +1,18 @@ package edu.rpi.legup.model.elements; /** - * Abstract class representing elements that can be placed within the system. - * Inherits from the {@link Element} class and sets the {@link ElementType} to {@link ElementType#PLACEABLE}. + * Abstract class representing elements that can be placed within the system. Inherits from the + * {@link Element} class and sets the {@link ElementType} to {@link ElementType#PLACEABLE}. */ public abstract class PlaceableElement extends Element { /** * Constructs a PlaceableElement with the specified details * - * @param elementID Unique identifier for the element - * @param elementName Name of the element - * @param description Description of the element - * @param imageName Name of the image file representing the element + * @param elementID Unique identifier for the element + * @param elementName Name of the element + * @param description Description of the element + * @param imageName Name of the image file representing the element */ public PlaceableElement( String elementID, String elementName, String description, String imageName) { diff --git a/src/main/java/edu/rpi/legup/model/elements/RegisterElement.java b/src/main/java/edu/rpi/legup/model/elements/RegisterElement.java index 5f59ad795..916719ebc 100644 --- a/src/main/java/edu/rpi/legup/model/elements/RegisterElement.java +++ b/src/main/java/edu/rpi/legup/model/elements/RegisterElement.java @@ -4,9 +4,9 @@ import java.lang.annotation.ElementType; /** - * Annotation to mark classes as elements that should be registered. - * This annotation is used to indicate that a class is an element within the system and should be registered - * for use within the application. + * Annotation to mark classes as elements that should be registered. This annotation is used to + * indicate that a class is an element within the system and should be registered for use within the + * application. */ @Inherited @Target(ElementType.TYPE) diff --git a/src/main/java/edu/rpi/legup/model/gameboard/Board.java b/src/main/java/edu/rpi/legup/model/gameboard/Board.java index 4544caa36..9e7d93441 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/Board.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/Board.java @@ -6,9 +6,8 @@ import java.util.Set; /** - * Abstract class representing a game board. - * This class provides functionality for managing puzzle elements, tracking modifications, - * and determining if the board is modifiable. + * Abstract class representing a game board. This class provides functionality for managing puzzle + * elements, tracking modifications, and determining if the board is modifiable. */ public abstract class Board { diff --git a/src/main/java/edu/rpi/legup/model/gameboard/CaseBoard.java b/src/main/java/edu/rpi/legup/model/gameboard/CaseBoard.java index 14dcb8609..07cc2947d 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/CaseBoard.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/CaseBoard.java @@ -6,8 +6,8 @@ import java.util.Set; /** - * Represents a game board with specific rules for selecting puzzle elements. - * Extends the abstract `Board` class and adds functionality for handling pickable elements and case rules. + * Represents a game board with specific rules for selecting puzzle elements. Extends the abstract + * `Board` class and adds functionality for handling pickable elements and case rules. */ public class CaseBoard extends Board { protected Board baseBoard; @@ -100,10 +100,8 @@ public int getCount() { return pickablePuzzleElements.size(); } - /** - * Performs a deep copy of this CaseBoard. - * CURRENTLY NOT IMPLEMENTED AND RETURNS NULL + * Performs a deep copy of this CaseBoard. CURRENTLY NOT IMPLEMENTED AND RETURNS NULL * * @return a new copy of the CaseBoard */ diff --git a/src/main/java/edu/rpi/legup/model/gameboard/GridCell.java b/src/main/java/edu/rpi/legup/model/gameboard/GridCell.java index 5d6fe1ff3..671b89e9b 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/GridCell.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/GridCell.java @@ -3,9 +3,9 @@ import java.awt.*; /** - * GridCell represents a cell within a grid-based board. It holds data of type T and tracks its location - * on the board using a {@link Point}. The class extends from PuzzleElement and supports deep copying of - * the grid cell. + * GridCell represents a cell within a grid-based board. It holds data of type T and tracks its + * location on the board using a {@link Point}. The class extends from PuzzleElement and supports + * deep copying of the grid cell. * * @param the type of data held by the GridCell */ diff --git a/src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java b/src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java index b2a10a153..79027d9d1 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java @@ -4,8 +4,8 @@ import java.util.List; /** - * GridRegion represents a collection of cells within a grid. It manages a list of cells and provides - * methods to add, remove, and retrieve cells from the region. + * GridRegion represents a collection of cells within a grid. It manages a list of cells and + * provides methods to add, remove, and retrieve cells from the region. * * @param the type of cell managed by the GridRegion */ diff --git a/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java b/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java index a92b3efb0..eca6f3be4 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java @@ -5,7 +5,8 @@ /** * PuzzleElement represents a single element in a puzzle grid. It holds data and provides various - * methods to manage and retrieve its properties, including modifiability, modification status, and validity. + * methods to manage and retrieve its properties, including modifiability, modification status, and + * validity. * * @param the type of data held by the PuzzleElement */ diff --git a/src/main/java/edu/rpi/legup/model/observer/IBoardListener.java b/src/main/java/edu/rpi/legup/model/observer/IBoardListener.java index fa440369c..7ba886fd4 100644 --- a/src/main/java/edu/rpi/legup/model/observer/IBoardListener.java +++ b/src/main/java/edu/rpi/legup/model/observer/IBoardListener.java @@ -5,8 +5,8 @@ import edu.rpi.legup.model.tree.TreeElement; /** - * IBoardListener defines methods for receiving notifications about changes to the board, - * including updates to tree elements, case boards, and puzzle elements. + * IBoardListener defines methods for receiving notifications about changes to the board, including + * updates to tree elements, case boards, and puzzle elements. */ public interface IBoardListener { /** diff --git a/src/main/java/edu/rpi/legup/model/observer/IBoardSubject.java b/src/main/java/edu/rpi/legup/model/observer/IBoardSubject.java index 53bfe444b..6cdcd7dc2 100644 --- a/src/main/java/edu/rpi/legup/model/observer/IBoardSubject.java +++ b/src/main/java/edu/rpi/legup/model/observer/IBoardSubject.java @@ -3,8 +3,8 @@ import java.util.function.Consumer; /** - * IBoardSubject defines methods for managing and notifying board listeners. - * It allows for adding and removing listeners, and for notifying them using a specified algorithm. + * IBoardSubject defines methods for managing and notifying board listeners. It allows for adding + * and removing listeners, and for notifying them using a specified algorithm. */ public interface IBoardSubject { /** diff --git a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java index c5a0355ca..713b464e2 100644 --- a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java +++ b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java @@ -4,8 +4,8 @@ import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; /** - * ITreeListener defines methods for handling events related to changes in the tree. - * Implementations of this interface are notified of additions, removals, and selection changes in the tree. + * ITreeListener defines methods for handling events related to changes in the tree. Implementations + * of this interface are notified of additions, removals, and selection changes in the tree. */ public interface ITreeListener { /** diff --git a/src/main/java/edu/rpi/legup/model/observer/ITreeSubject.java b/src/main/java/edu/rpi/legup/model/observer/ITreeSubject.java index 0b0aee348..f7c033529 100644 --- a/src/main/java/edu/rpi/legup/model/observer/ITreeSubject.java +++ b/src/main/java/edu/rpi/legup/model/observer/ITreeSubject.java @@ -3,8 +3,8 @@ import java.util.function.Consumer; /** - * ITreeSubject defines methods for managing and notifying listeners about changes to the tree model. - * Implementations of this interface handle adding, removing, and notifying listeners. + * ITreeSubject defines methods for managing and notifying listeners about changes to the tree + * model. Implementations of this interface handle adding, removing, and notifying listeners. */ public interface ITreeSubject { /** diff --git a/src/main/java/edu/rpi/legup/model/rules/CaseRule.java b/src/main/java/edu/rpi/legup/model/rules/CaseRule.java index ee5c91229..aac4fd352 100644 --- a/src/main/java/edu/rpi/legup/model/rules/CaseRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/CaseRule.java @@ -12,8 +12,9 @@ import java.util.Set; /** - * CaseRule is an abstract class representing a rule that can be applied with multiple cases in a puzzle board. - * It defines methods for applying and checking the rule, as well as retrieving the necessary elements. + * CaseRule is an abstract class representing a rule that can be applied with multiple cases in a + * puzzle board. It defines methods for applying and checking the rule, as well as retrieving the + * necessary elements. */ public abstract class CaseRule extends Rule { diff --git a/src/main/java/edu/rpi/legup/model/rules/ContradictionRule.java b/src/main/java/edu/rpi/legup/model/rules/ContradictionRule.java index cd2e20081..c80a551ec 100644 --- a/src/main/java/edu/rpi/legup/model/rules/ContradictionRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/ContradictionRule.java @@ -7,8 +7,9 @@ import edu.rpi.legup.model.tree.TreeTransition; /** - * ContradictionRule is an abstract class representing a rule that identifies contradictions in a puzzle. - * It provides methods to check for contradictions both globally and at specific puzzle elements. + * ContradictionRule is an abstract class representing a rule that identifies contradictions in a + * puzzle. It provides methods to check for contradictions both globally and at specific puzzle + * elements. */ public abstract class ContradictionRule extends Rule { diff --git a/src/main/java/edu/rpi/legup/model/rules/DirectRule.java b/src/main/java/edu/rpi/legup/model/rules/DirectRule.java index 613574989..8efe119b6 100644 --- a/src/main/java/edu/rpi/legup/model/rules/DirectRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/DirectRule.java @@ -8,8 +8,8 @@ import edu.rpi.legup.model.tree.TreeTransition; /** - * DirectRule is an abstract class representing a direct rule for transitions in a puzzle. - * It provides methods for checking whether transitions and specific puzzle elements follow the rule. + * DirectRule is an abstract class representing a direct rule for transitions in a puzzle. It + * provides methods for checking whether transitions and specific puzzle elements follow the rule. */ public abstract class DirectRule extends Rule { /** diff --git a/src/main/java/edu/rpi/legup/model/rules/MergeRule.java b/src/main/java/edu/rpi/legup/model/rules/MergeRule.java index f7bd887f3..86c63fb7c 100644 --- a/src/main/java/edu/rpi/legup/model/rules/MergeRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/MergeRule.java @@ -11,8 +11,8 @@ import java.util.List; /** - * MergeRule is an implementation of a rule that merges multiple nodes into one. - * It validates if the merging of nodes is done correctly. + * MergeRule is an implementation of a rule that merges multiple nodes into one. It validates if the + * merging of nodes is done correctly. */ public class MergeRule extends Rule { /** MergeRule Constructor merges to board states together */ diff --git a/src/main/java/edu/rpi/legup/model/rules/RegisterRule.java b/src/main/java/edu/rpi/legup/model/rules/RegisterRule.java index d357e0d86..0ee2a686e 100644 --- a/src/main/java/edu/rpi/legup/model/rules/RegisterRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/RegisterRule.java @@ -3,9 +3,8 @@ import java.lang.annotation.*; /** - * Annotation to register a class as a rule in the system. - * This annotation can be applied to rule classes to indicate that they should be registered - * in the rule system. + * Annotation to register a class as a rule in the system. This annotation can be applied to rule + * classes to indicate that they should be registered in the rule system. */ @Inherited @Target(ElementType.TYPE) diff --git a/src/main/java/edu/rpi/legup/model/rules/Rule.java b/src/main/java/edu/rpi/legup/model/rules/Rule.java index 107e72712..edcab550b 100644 --- a/src/main/java/edu/rpi/legup/model/rules/Rule.java +++ b/src/main/java/edu/rpi/legup/model/rules/Rule.java @@ -9,10 +9,9 @@ import javax.swing.ImageIcon; /** - * Abstract base class for defining rules. - * This class encapsulates the common functionality and attributes of all rules, - * including rule identification, description, image handling, and validation logic. - * Subclasses must provide implementations for specific rule checking logic. + * Abstract base class for defining rules. This class encapsulates the common functionality and + * attributes of all rules, including rule identification, description, image handling, and + * validation logic. Subclasses must provide implementations for specific rule checking logic. */ @RegisterRule public abstract class Rule { diff --git a/src/main/java/edu/rpi/legup/model/rules/RuleType.java b/src/main/java/edu/rpi/legup/model/rules/RuleType.java index e72118e3c..7eee80ea3 100644 --- a/src/main/java/edu/rpi/legup/model/rules/RuleType.java +++ b/src/main/java/edu/rpi/legup/model/rules/RuleType.java @@ -1,8 +1,8 @@ package edu.rpi.legup.model.rules; /** - * Enumeration representing different types of rules in the rule-based system. - * This enum categorizes rules into various types based on their functionality and application. + * Enumeration representing different types of rules in the rule-based system. This enum categorizes + * rules into various types based on their functionality and application. */ public enum RuleType { BASIC, diff --git a/src/main/java/edu/rpi/legup/model/tree/Tree.java b/src/main/java/edu/rpi/legup/model/tree/Tree.java index 3e68015a1..545976fd1 100644 --- a/src/main/java/edu/rpi/legup/model/tree/Tree.java +++ b/src/main/java/edu/rpi/legup/model/tree/Tree.java @@ -2,18 +2,15 @@ import edu.rpi.legup.controller.TreeController; import edu.rpi.legup.model.gameboard.Board; -import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /** - * Represents a tree structure in a puzzle. - * The tree consists of {@link TreeNode}s and {@link TreeTransition}s - * and allows adding, removing, and validating elements. + * Represents a tree structure in a puzzle. The tree consists of {@link TreeNode}s and {@link + * TreeTransition}s and allows adding, removing, and validating elements. */ public class Tree { private TreeNode rootNode; diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeElement.java b/src/main/java/edu/rpi/legup/model/tree/TreeElement.java index 2f6f45e4d..8c865b89b 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeElement.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeElement.java @@ -3,7 +3,8 @@ import edu.rpi.legup.model.gameboard.Board; /** - * Represents an element in a tree structure, which can be either a {@link TreeNode} or a {@link TreeTransition}. + * Represents an element in a tree structure, which can be either a {@link TreeNode} or a {@link + * TreeTransition}. */ public abstract class TreeElement { protected TreeElementType type; diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeElementType.java b/src/main/java/edu/rpi/legup/model/tree/TreeElementType.java index 3a6dbb124..eb585329e 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeElementType.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeElementType.java @@ -1,8 +1,8 @@ package edu.rpi.legup.model.tree; /** - * Enum representing the type of a tree element. - * Tree elements can be either nodes or transitions in the tree structure. + * Enum representing the type of a tree element. Tree elements can be either nodes or transitions in + * the tree structure. */ public enum TreeElementType { NODE, diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeNode.java b/src/main/java/edu/rpi/legup/model/tree/TreeNode.java index 85a5e717b..d4095afa5 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeNode.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeNode.java @@ -5,9 +5,9 @@ import java.util.*; /** - * Represents a node in a tree structure. Extends {@link TreeElement}. - * A {@code TreeNode} contains a board, references to its parent and children transitions, and indicates - * if it is the root node of the tree. + * Represents a node in a tree structure. Extends {@link TreeElement}. A {@code TreeNode} contains a + * board, references to its parent and children transitions, and indicates if it is the root node of + * the tree. */ public class TreeNode extends TreeElement { private TreeTransition parent; @@ -332,8 +332,8 @@ public void setRoot(boolean isRoot) { } /** - * Clears all children transitions from this tree node. - * After calling this method, the node will have no child transitions. + * Clears all children transitions from this tree node. After calling this method, the node will + * have no child transitions. */ public void clearChildren() { this.children.clear(); diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeTransition.java b/src/main/java/edu/rpi/legup/model/tree/TreeTransition.java index 9e441ac55..10c8fc7a0 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeTransition.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeTransition.java @@ -9,9 +9,9 @@ import java.util.List; /** - * Represents a transition between two nodes in a tree structure within a game. - * A transition is responsible for propagating changes through the tree and managing - * and verifying the associated rules and puzzle elements. + * Represents a transition between two nodes in a tree structure within a game. A transition is + * responsible for propagating changes through the tree and managing and verifying the associated + * rules and puzzle elements. */ public class TreeTransition extends TreeElement { private ArrayList parents; @@ -355,7 +355,6 @@ public void addChild(TreeNode child) { parents.add(child); } - /** * Gets the rule associated with this transition * diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/Binary.java b/src/main/java/edu/rpi/legup/puzzle/binary/Binary.java index d2dd0b181..7b70a43a1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/Binary.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/Binary.java @@ -68,16 +68,15 @@ public boolean isBoardComplete(Board board) { @Override public void onBoardChange(Board board) {} - /** * Determines if the given dimensions are valid for Binary * - * @param rows the number of rows - * @param columns the number of columns + * @param rows the number of rows + * @param columns the number of columns * @return true if the given dimensions are valid for Binary, false otherwise */ @Override - public boolean isValidDimensions(int rows, int columns){ + public boolean isValidDimensions(int rows, int columns) { return rows >= 2 && rows % 2 == 0 && rows == columns; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryBoard.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryBoard.java index 34819410b..d5d65ed26 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryBoard.java @@ -2,7 +2,6 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; @@ -55,7 +54,7 @@ public Set getRowCells(int rowNum) { } /** - * Get all the binary cells in a column + * Get all the binary cells in a column * * @param colNum column number * @return set of all binary cells in specified colNum @@ -69,7 +68,7 @@ public Set getColCells(int colNum) { } /** - * Get all the binary types in a row + * Get all the binary types in a row * * @param rowNum row number * @return ArrayList of all binary types in specified rowNum @@ -84,7 +83,7 @@ public ArrayList getRowTypes(int rowNum) { } /** - * Get all the binary types in a column + * Get all the binary types in a column * * @param colNum column number * @return ArrayList of all binary types in specified colNum @@ -100,6 +99,7 @@ public ArrayList getColTypes(int colNum) { /** * Get a copy of the binary board + * * @return copy of current BinaryBoard */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryCell.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryCell.java index d09f7115e..0edb8444e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryCell.java @@ -5,7 +5,6 @@ import java.awt.Point; import java.awt.event.MouseEvent; - public class BinaryCell extends GridCell { /** * BinaryCell Constructor - creates a BinaryCell from the specified value and location @@ -63,24 +62,20 @@ public void setType(Element e, MouseEvent m) { if (m.getButton() == MouseEvent.BUTTON1) { if (this.data == 2) { this.data = 0; - } - else { + } else { this.data = this.data + 1; } - } - else { + } else { if (m.getButton() == MouseEvent.BUTTON3) { if (this.data > 0) { this.data = this.data - 1; - } - else { + } else { this.data = 2; } } } - } - else { // unknown tile + } else { // unknown tile this.data = 2; } } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryController.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryController.java index caf62f3fe..5ec6669a0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryController.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryController.java @@ -7,13 +7,12 @@ public class BinaryController extends ElementController { /** - * Handles cell state changes in the binary puzzle when a mouse event occurs - * If the left mouse button is clicked: - * - If the control key is held down, shows a context menu at the mouse position - * - Otherwise, toggles the cell data state between 0, 1, and 2 in a cyclic manner - * If the right mouse button is clicked, the cell state is also toggled between 2, 1, and 0 + * Handles cell state changes in the binary puzzle when a mouse event occurs If the left mouse + * button is clicked: - If the control key is held down, shows a context menu at the mouse + * position - Otherwise, toggles the cell data state between 0, 1, and 2 in a cyclic manner If + * the right mouse button is clicked, the cell state is also toggled between 2, 1, and 0 * - * @param e MouseEvent triggered by the user interaction + * @param e MouseEvent triggered by the user interaction * @param data PuzzleElement representing the cell being modified */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryElementView.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryElementView.java index f5ea33d4a..74a761e89 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryElementView.java @@ -24,7 +24,6 @@ public BinaryCell getPuzzleElement() { return (BinaryCell) super.getPuzzleElement(); } - /** * Draws the cells provided in the puzzle's .xml file with light gray background * @@ -49,7 +48,7 @@ public void drawElement(Graphics2D graphics2D) { * Helper method to handle drawing the cell based on its type and background color * * @param graphics2D The graphics object to draw on - * @param bgColor The background color for the cell + * @param bgColor The background color for the cell */ private void drawCell(Graphics2D graphics2D, Color bgColor) { BinaryCell cell = (BinaryCell) puzzleElement; @@ -86,4 +85,3 @@ private void drawCenteredText(Graphics2D graphics2D) { graphics2D.drawString(value, xText, yText); } } - diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryExporter.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryExporter.java index f12a07378..c032b63a9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryExporter.java @@ -11,8 +11,8 @@ public BinaryExporter(Binary binary) { } /** - * Generates an XML element for the binary puzzle board, including its dimensions and the - * state of each cell. Binary cells that are not in the `UNKNOWN` state are included in the XML. + * Generates an XML element for the binary puzzle board, including its dimensions and the state + * of each cell. Binary cells that are not in the `UNKNOWN` state are included in the XML. * * @param newDocument The XML document to which the board element belongs. * @return The XML element representing the board. diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryImporter.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryImporter.java index 8a4bad01e..419789060 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryImporter.java @@ -129,6 +129,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { /** * Initializes a board with text + * * @param statements the text being used * @throws UnsupportedOperationException Binary does not use text input */ diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryType.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryType.java index f03f2ee08..7e8e162e6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryType.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryType.java @@ -3,20 +3,17 @@ /** * Enum representing the possible states of a binary puzzle cell * - * The states include: - * - ZERO: Represents a cell with a value of 0 - * - ONE: Represents a cell with a value of 1 - * - UNKNOWN: Represents an empty cell - * + *

The states include: - ZERO: Represents a cell with a value of 0 - ONE: Represents a cell with + * a value of 1 - UNKNOWN: Represents an empty cell */ public enum BinaryType { - ZERO, // Enum constant 0 - ONE, // Enum constant 1 - UNKNOWN; // Enum constant 2 + ZERO, // Enum constant 0 + ONE, // Enum constant 1 + UNKNOWN; // Enum constant 2 /** - * The `toValue` method returns the ordinal value of the enum constant, - * which can be used to convert the enum to an integer representation. + * The `toValue` method returns the ordinal value of the enum constant, which can be used to + * convert the enum to an integer representation. */ public int toValue() { return this.ordinal(); diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryView.java b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryView.java index e1869de6b..b428ce32c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/BinaryView.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/BinaryView.java @@ -7,9 +7,10 @@ public class BinaryView extends GridBoardView { - /** Creates and arranges the visual components for each cell in the binary puzzle. Initializes - * the view by setting up the board controller, binary controller, and the grid dimensions. - * For each cell in the BinaryBoard, it creates a corresponding BinaryElementView, sets its index, + /** + * Creates and arranges the visual components for each cell in the binary puzzle. Initializes + * the view by setting up the board controller, binary controller, and the grid dimensions. For + * each cell in the BinaryBoard, it creates a corresponding BinaryElementView, sets its index, * size, and location, and adds it to the list of element views to be displayed. * * @param board The BinaryBoard representing the current state of the binary puzzle diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/elements/NumberTile.java b/src/main/java/edu/rpi/legup/puzzle/binary/elements/NumberTile.java index e996e246b..dc3d75e00 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/elements/NumberTile.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/elements/NumberTile.java @@ -1,4 +1,3 @@ - package edu.rpi.legup.puzzle.binary.elements; import edu.rpi.legup.model.elements.PlaceableElement; @@ -11,4 +10,4 @@ public NumberTile() { "A number tile", "edu/rpi/legup/images/binary/tiles/NumberTile.png"); } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/elements/UnknownTile.java b/src/main/java/edu/rpi/legup/puzzle/binary/elements/UnknownTile.java index 8c60ea8c3..e32a2d12f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/elements/UnknownTile.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/elements/UnknownTile.java @@ -10,4 +10,4 @@ public UnknownTile() { "A blank tile", "edu/rpi/legup/images/binary/tiles/UnknownTile.png"); } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/CompleteRowColumnDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/CompleteRowColumnDirectRule.java index 359433685..6ced37a9c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/CompleteRowColumnDirectRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/CompleteRowColumnDirectRule.java @@ -15,8 +15,8 @@ public CompleteRowColumnDirectRule() { super( "BINA-BASC-0003", "Complete Row/Column", - "If a row/column of length n contains n/2 of a single value, the remaining " + - "cells must contain the other value", + "If a row/column of length n contains n/2 of a single value, the remaining " + + "cells must contain the other value", "edu/rpi/legup/images/binary/rules/CompleteRowColumnDirectRule.png"); } diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/EliminateTheImpossibleDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/EliminateTheImpossibleDirectRule.java index 02c1c2c31..df84dd540 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/EliminateTheImpossibleDirectRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/EliminateTheImpossibleDirectRule.java @@ -1,33 +1,35 @@ -//package edu.rpi.legup.puzzle.binary.rules; -// -//import edu.rpi.legup.model.gameboard.Board; -//import edu.rpi.legup.model.gameboard.PuzzleElement; -//import edu.rpi.legup.model.rules.DirectRule; -//import edu.rpi.legup.model.tree.TreeNode; -//import edu.rpi.legup.model.tree.TreeTransition; -//import edu.rpi.legup.puzzle.binary.BinaryBoard; -//import edu.rpi.legup.puzzle.binary.BinaryCell; -//import edu.rpi.legup.puzzle.binary.BinaryType; -// -//import java.util.LinkedList; -//import java.util.Queue; -//import java.lang.Math.*; -//import java.lang.reflect.Array; -//import java.util.ArrayList; -// -//public class EliminateTheImpossibleDirectRule extends DirectRule { +// package edu.rpi.legup.puzzle.binary.rules; +// +// import edu.rpi.legup.model.gameboard.Board; +// import edu.rpi.legup.model.gameboard.PuzzleElement; +// import edu.rpi.legup.model.rules.DirectRule; +// import edu.rpi.legup.model.tree.TreeNode; +// import edu.rpi.legup.model.tree.TreeTransition; +// import edu.rpi.legup.puzzle.binary.BinaryBoard; +// import edu.rpi.legup.puzzle.binary.BinaryCell; +// import edu.rpi.legup.puzzle.binary.BinaryType; +// +// import java.util.LinkedList; +// import java.util.Queue; +// import java.lang.Math.*; +// import java.lang.reflect.Array; +// import java.util.ArrayList; +// +// public class EliminateTheImpossibleDirectRule extends DirectRule { // private final String INVALID_USE_MESSAGE = "Number at cell is incorrect"; // // public EliminateTheImpossibleDirectRule() { // super( // "BINA-BASC-0004", // "Eliminate The Impossible", -// "Out of the remaining empty cells in this row or column, this digit must go here, otherwise there will be a future contradiction", +// "Out of the remaining empty cells in this row or column, this digit must go here, +// otherwise there will be a future contradiction", // "edu/rpi/legup/images/binary/rules/EliminateTheImpossibleDirectRule.png"); // } // // // Function to generate all binary strings -// void generatePossibilitites(int spots, ArrayList possibilities, int zeroCount, int oneCount) +// void generatePossibilitites(int spots, ArrayList possibilities, int zeroCount, int +// oneCount) // // This function generates all the possible combinations of 0s and 1s for a // // certain size, it does this // // by basically just counting from 0 to the number - 1, so if you want all the @@ -122,7 +124,8 @@ // // unknown spots left, // // an ArrayList that will be populated with the possible results (in String // // form), the amount of zeros left and ones left -// generatePossibilitites((size - rowNumZeros - rowNumOnes), rowResult, size / 2 - rowNumZeros, size / 2 - rowNumOnes); +// generatePossibilitites((size - rowNumZeros - rowNumOnes), rowResult, size / 2 - +// rowNumZeros, size / 2 - rowNumOnes); // // // Create deep copies of each row // ArrayList> rowCopies = new ArrayList<>(); @@ -198,4 +201,4 @@ // public Board getDefaultBoard(TreeNode node) { // return null; // } -//} +// } diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/PreventTrioDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/PreventTrioDirectRule.java index 745e35d4e..728ec8e10 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/PreventTrioDirectRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/PreventTrioDirectRule.java @@ -35,7 +35,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem BinaryCell binaryCell = (BinaryCell) puzzleElement; BinaryBoard modified = origBoard.copy(); - // Flip the cell and check to see if there will be a trio contradiction, if so the rule is applied correctly + // Flip the cell and check to see if there will be a trio contradiction, if so the rule is + // applied correctly modified.getPuzzleElement(puzzleElement).setData(Math.abs(binaryCell.getData() - 1)); if (contraRule.checkContradictionAt(modified, binaryCell) == null) { return null; @@ -55,4 +56,4 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem public Board getDefaultBoard(TreeNode node) { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/RepeatedRowColumnContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/RepeatedRowColumnContradictionRule.java index 13eb35283..a7a4ced12 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/RepeatedRowColumnContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/RepeatedRowColumnContradictionRule.java @@ -35,7 +35,8 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { BinaryBoard binaryBoard = (BinaryBoard) board; BinaryCell cell = (BinaryCell) binaryBoard.getPuzzleElement(puzzleElement); - // Compare each row with row of current cell to see if they are equal, if so the rule is applied correctly + // Compare each row with row of current cell to see if they are equal, if so the rule is + // applied correctly ArrayList row = binaryBoard.getRowTypes(cell.getLocation().y); int size = row.size(); for (int i = 0; i < size; i++) { @@ -47,7 +48,8 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { } } - // Compare each column with column of current cell to see if they are equal, if so the rule is applied correctly + // Compare each column with column of current cell to see if they are equal, if so the rule + // is applied correctly ArrayList col = binaryBoard.getColTypes(cell.getLocation().x); for (int i = 0; i < size; i++) { if (i != cell.getLocation().x) { diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/SaveBlockerDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/SaveBlockerDirectRule.java index 5f76c4f59..6cc28446d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/SaveBlockerDirectRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/SaveBlockerDirectRule.java @@ -8,7 +8,7 @@ import edu.rpi.legup.puzzle.binary.BinaryBoard; import edu.rpi.legup.puzzle.binary.BinaryCell; -public class SaveBlockerDirectRule extends DirectRule { +public class SaveBlockerDirectRule extends DirectRule { private final String INVALID_USE_MESSAGE = "Number at cell is incorrect"; @@ -35,7 +35,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem BinaryCell binaryCell = (BinaryCell) puzzleElement; BinaryBoard modified = origBoard.copy(); - // Flip the cell and check to see if a blocker digit is wasted, if so the rule is applied correctly + // Flip the cell and check to see if a blocker digit is wasted, if so the rule is applied + // correctly modified.getPuzzleElement(puzzleElement).setData(Math.abs(binaryCell.getData() - 1)); if (contraRule.checkContradictionAt(modified, binaryCell) == null) { return null; @@ -55,6 +56,4 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem public Board getDefaultBoard(TreeNode node) { return null; } - - } diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/TrioContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/TrioContradictionRule.java index dce7fe371..fc5cd4165 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/TrioContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/TrioContradictionRule.java @@ -21,8 +21,8 @@ public TrioContradictionRule() { } /** - * This method checks the surrounding cells of a given puzzle element at a specified distance - * in both the vertical and horizontal directions + * This method checks the surrounding cells of a given puzzle element at a specified distance in + * both the vertical and horizontal directions * * @param board The board where the puzzle elements are located * @param puzzleElement The puzzle element from which the distance is calculated @@ -58,8 +58,8 @@ public BinaryCell[] getCellsNAway(Board board, PuzzleElement puzzleElement, int } /** - * Checks whether the cell and its two surrounding cells form a trio of zeros or ones; - * If a trio is found, it indicates a contradiction + * Checks whether the cell and its two surrounding cells form a trio of zeros or ones; If a trio + * is found, it indicates a contradiction * * @param board The board where the puzzle elements are located * @param puzzleElement The puzzle element to check for contradiction @@ -120,8 +120,8 @@ public boolean checkSurroundPair(Board board, PuzzleElement puzzleElement) { } /** - * Checks whether there are two of the same cell type separated by one cell that also has - * the same type in any direction. If a trio is found, it indicates a contradiction + * Checks whether there are two of the same cell type separated by one cell that also has the + * same type in any direction. If a trio is found, it indicates a contradiction * * @param board The board where the puzzle elements are located * @param puzzleElement The puzzle element to check for contradiction diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/UnbalancedRowColumnContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/UnbalancedRowColumnContradictionRule.java index 82f658013..1d00f4da9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/UnbalancedRowColumnContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/UnbalancedRowColumnContradictionRule.java @@ -6,7 +6,6 @@ import edu.rpi.legup.puzzle.binary.BinaryBoard; import edu.rpi.legup.puzzle.binary.BinaryCell; import edu.rpi.legup.puzzle.binary.BinaryType; - import java.util.Set; public class UnbalancedRowColumnContradictionRule extends ContradictionRule { @@ -56,7 +55,6 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { return null; } - Set col = binaryBoard.getColCells(cell.getLocation().x); size = col.size(); diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/UniqueRowColumnDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/UniqueRowColumnDirectRule.java index 3f90510e3..0250a4c74 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/UniqueRowColumnDirectRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/UniqueRowColumnDirectRule.java @@ -5,12 +5,9 @@ import edu.rpi.legup.model.rules.DirectRule; import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; -import edu.rpi.legup.puzzle.binary.Binary; import edu.rpi.legup.puzzle.binary.BinaryBoard; import edu.rpi.legup.puzzle.binary.BinaryCell; import edu.rpi.legup.puzzle.binary.BinaryType; - -import java.lang.reflect.Array; import java.util.ArrayList; public class UniqueRowColumnDirectRule extends DirectRule { @@ -20,8 +17,8 @@ public UniqueRowColumnDirectRule() { super( "BINA-BASC-0004", "Unique Row/Column", - "If an unfinished row/column only differs by empty cells from a finished one, " + - "fill contradicting empty cells with opposite digit to prevent a repeated row/column", + "If an unfinished row/column only differs by empty cells from a finished one, " + + "fill contradicting empty cells with opposite digit to prevent a repeated row/column", "edu/rpi/legup/images/binary/rules/UniqueRowColumnDirectRule.png"); } @@ -50,8 +47,11 @@ private int getNumEmpty(ArrayList seq) { * @param rowOrColumn Flag to indicate whether checking a row (0) or a column (1) * @return Null if a valid opposite digit is found, otherwise an error message */ - private String checkOppositeDigitDifference(ArrayList seq, BinaryBoard origBoard, - BinaryCell binaryCell, int rowOrColumn) { + private String checkOppositeDigitDifference( + ArrayList seq, + BinaryBoard origBoard, + BinaryCell binaryCell, + int rowOrColumn) { // rowOrColumn : 0 for row, 1 for column int numEmpty = getNumEmpty(seq); @@ -83,7 +83,8 @@ private String checkOppositeDigitDifference(ArrayList seq, BinaryBoa valid = false; break; } - // Count differences between the sequences, stopping if more than 1 difference is found + // Count differences between the sequences, stopping if more than 1 difference is + // found if (!seq.get(j).equals(currSeq.get(j)) && !seq.get(j).equals(BinaryType.UNKNOWN)) { if (++numDifferentCells > 1 || numEmpty != 1) { valid = false; @@ -92,17 +93,18 @@ private String checkOppositeDigitDifference(ArrayList seq, BinaryBoa } // Check if there's a contradiction with the current cell, if not mark as valid - if (currSeq.get(j).equals(BinaryType.ZERO) && seq.get(j).equals(BinaryType.UNKNOWN) + if (currSeq.get(j).equals(BinaryType.ZERO) + && seq.get(j).equals(BinaryType.UNKNOWN) && binaryCell.getType().equals(BinaryType.ONE)) { - if ((rowOrColumn == 0 && binaryCell.getLocation().x == j) || rowOrColumn == 1 - && binaryCell.getLocation().y == j) { + if ((rowOrColumn == 0 && binaryCell.getLocation().x == j) + || rowOrColumn == 1 && binaryCell.getLocation().y == j) { valid = true; } - } - else if (currSeq.get(j).equals(BinaryType.ONE) && seq.get(j).equals(BinaryType.UNKNOWN) + } else if (currSeq.get(j).equals(BinaryType.ONE) + && seq.get(j).equals(BinaryType.UNKNOWN) && binaryCell.getType().equals(BinaryType.ZERO)) { - if ((rowOrColumn == 0 && binaryCell.getLocation().x == j) || rowOrColumn == 1 - && binaryCell.getLocation().y == j) { + if ((rowOrColumn == 0 && binaryCell.getLocation().x == j) + || rowOrColumn == 1 && binaryCell.getLocation().y == j) { valid = true; } } @@ -130,8 +132,12 @@ else if (currSeq.get(j).equals(BinaryType.ONE) && seq.get(j).equals(BinaryType.U * @param zeroOrOne Flag to indicate whether checking for 0s (0) or 1s (1) * @return Null if the rule can be applied, otherwise an error message */ - private String checkRemainingOneDigitDifference(ArrayList seq, BinaryBoard origBoard, - BinaryCell binaryCell, int rowOrColumn, int zeroOrOne) { + private String checkRemainingOneDigitDifference( + ArrayList seq, + BinaryBoard origBoard, + BinaryCell binaryCell, + int rowOrColumn, + int zeroOrOne) { // zeroOrOne: zero for 0, one for 1 for (int i = 0; i < seq.size(); i++) { @@ -141,8 +147,7 @@ private String checkRemainingOneDigitDifference(ArrayList seq, Binar continue; } currSeq = origBoard.getRowTypes(i); - } - else { + } else { if (i == binaryCell.getLocation().x) { continue; } @@ -172,24 +177,27 @@ private String checkRemainingOneDigitDifference(ArrayList seq, Binar currSeqCell = currSeq.get(binaryCell.getLocation().y); } - // Check if this sequence has only one more zero remaining and current sequence fills that zero in, + // Check if this sequence has only one more zero remaining and current sequence + // fills that zero in, // if so, zero in this seq must go in another cell to prevent repetition if (zeroOrOne == 0) { - if (currSeqCell.equals(BinaryType.ZERO) && binaryCell.getType().equals(BinaryType.ONE)) { + if (currSeqCell.equals(BinaryType.ZERO) + && binaryCell.getType().equals(BinaryType.ONE)) { return null; } } - // Check if this sequence has only one more one remaining and current sequence fills that one in, + // Check if this sequence has only one more one remaining and current sequence fills + // that one in, // if so, one in this seq must go in another cell to prevent repetition else if (zeroOrOne == 1) { - if (currSeqCell.equals(BinaryType.ONE) && binaryCell.getType().equals(BinaryType.ZERO)) { + if (currSeqCell.equals(BinaryType.ONE) + && binaryCell.getType().equals(BinaryType.ZERO)) { return null; } } } } - return "There does not exist a sequence that can be prevented by a remaining digit difference"; } @@ -206,7 +214,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem BinaryBoard origBoard = (BinaryBoard) transition.getParents().get(0).getBoard(); BinaryCell binaryCell = (BinaryCell) puzzleElement; - // Check if filling the current cell with the opposite digit would prevent repetition with another row + // Check if filling the current cell with the opposite digit would prevent repetition with + // another row ArrayList row = origBoard.getRowTypes(binaryCell.getLocation().y); if (checkOppositeDigitDifference(row, origBoard, binaryCell, 0) == null) { return null; @@ -216,15 +225,14 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem for (int i = 0; i < row.size(); i++) { if (row.get(i).equals(BinaryType.ZERO)) { numZeros++; - } - else if (row.get(i).equals(BinaryType.ONE)) { + } else if (row.get(i).equals(BinaryType.ONE)) { numOnes++; } } // Check if only one more zero is needed, then see this row will be repeated by another row // if current cell is filled in with last zero as well - if (numZeros == row.size()/2 - 1) { + if (numZeros == row.size() / 2 - 1) { if (checkRemainingOneDigitDifference(row, origBoard, binaryCell, 0, 0) == null) { return null; } @@ -232,13 +240,14 @@ else if (row.get(i).equals(BinaryType.ONE)) { // Check if only one more one is needed, then see this row will be repeated by another row // if current cell is filled in with last one as well - if (numOnes == row.size()/2 - 1) { + if (numOnes == row.size() / 2 - 1) { if (checkRemainingOneDigitDifference(row, origBoard, binaryCell, 0, 1) == null) { return null; } } - // Check if filling the current cell with the opposite digit would prevent repetition with another column + // Check if filling the current cell with the opposite digit would prevent repetition with + // another column ArrayList col = origBoard.getColTypes(binaryCell.getLocation().x); if (checkOppositeDigitDifference(col, origBoard, binaryCell, 1) == null) { return null; @@ -249,29 +258,31 @@ else if (row.get(i).equals(BinaryType.ONE)) { for (int i = 0; i < col.size(); i++) { if (col.get(i).equals(BinaryType.ZERO)) { numZeros++; - } - else if (col.get(i).equals(BinaryType.ONE)) { + } else if (col.get(i).equals(BinaryType.ONE)) { numOnes++; } } - // Check if only one more zero is needed, then see this column will be repeated by another column + // Check if only one more zero is needed, then see this column will be repeated by another + // column // if current cell is filled in with last zero as well - if (numZeros == col.size()/2 - 1) { + if (numZeros == col.size() / 2 - 1) { if (checkRemainingOneDigitDifference(col, origBoard, binaryCell, 1, 0) == null) { return null; } } - // Check if only one more one is needed, then see this column will be repeated by another column + // Check if only one more one is needed, then see this column will be repeated by another + // column // if current cell is filled in with last one as well - if (numOnes == col.size()/2 - 1) { + if (numOnes == col.size() / 2 - 1) { if (checkRemainingOneDigitDifference(col, origBoard, binaryCell, 1, 1) == null) { return null; } } - return "There is no row/column that forces this cell to be a " + binaryCell.getData().toString(); + return "There is no row/column that forces this cell to be a " + + binaryCell.getData().toString(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/WastedBlockerContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/WastedBlockerContradictionRule.java index e7ab51b41..ef5fc0e7e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/WastedBlockerContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/WastedBlockerContradictionRule.java @@ -6,18 +6,18 @@ import edu.rpi.legup.puzzle.binary.BinaryBoard; import edu.rpi.legup.puzzle.binary.BinaryCell; import edu.rpi.legup.puzzle.binary.BinaryType; - import java.util.ArrayList; public class WastedBlockerContradictionRule extends ContradictionRule { - private final String NO_CONTRADICTION_MESSAGE = "Does not contain a contradiction at this index"; + private final String NO_CONTRADICTION_MESSAGE = + "Does not contain a contradiction at this index"; public WastedBlockerContradictionRule() { super( "BINA-CONT-0004", "Wasted Blocker", - "There exists a cell in this row/column that allocates a digit unnecessarily and" + - " will cause a future trio to appear", + "There exists a cell in this row/column that allocates a digit unnecessarily and" + + " will cause a future trio to appear", "edu/rpi/legup/images/binary/rules/WastedBlockerContradictionRule.png"); } @@ -29,7 +29,8 @@ public WastedBlockerContradictionRule() { neededZeros = ( n + i + j ) / 3 */ /** - * Calculates the number of zeros needed in a sequence based on the values on either side and the number of empty cells. + * Calculates the number of zeros needed in a sequence based on the values on either side and + * the number of empty cells. * * @param leftVal The value on the left side of the empty cells * @param rightVal The value on the right side of the empty cells @@ -56,7 +57,8 @@ private int calculateNeededZeros(int leftVal, int rightVal, int emptyCellsInCurS neededOnes = ( n + ( 1 - i ) + ( 1 - j ) ) / 3 */ /** - * Calculates the number of ones needed in a sequence based on the values on either side and the number of empty cells + * Calculates the number of ones needed in a sequence based on the values on either side and the + * number of empty cells * * @param leftVal The value on the left side of the empty cells * @param rightVal The value on the right side of the empty cells @@ -102,10 +104,10 @@ private String checkSequence(ArrayList seq) { int leftVal; int rightVal; // Check if left cell is out of bounds - if (i-emptyCellsInCurSec-1 < 0) { + if (i - emptyCellsInCurSec - 1 < 0) { leftVal = -1; } else { - leftVal = seq.get(i-emptyCellsInCurSec-1).toValue(); + leftVal = seq.get(i - emptyCellsInCurSec - 1).toValue(); } rightVal = seq.get(i).toValue(); neededZeros += calculateNeededZeros(leftVal, rightVal, emptyCellsInCurSec); @@ -128,10 +130,10 @@ private String checkSequence(ArrayList seq) { int leftVal; int rightVal; // Check if left cell is out of bounds - if (seq.size()-1-emptyCellsInCurSec-1 < 0) { + if (seq.size() - 1 - emptyCellsInCurSec - 1 < 0) { leftVal = -1; } else { - leftVal = seq.get(seq.size()-1-emptyCellsInCurSec).toValue(); + leftVal = seq.get(seq.size() - 1 - emptyCellsInCurSec).toValue(); } rightVal = -1; neededZeros += calculateNeededZeros(leftVal, rightVal, emptyCellsInCurSec); @@ -141,7 +143,7 @@ private String checkSequence(ArrayList seq) { // Check if the number of needed zeros or ones exceeds half the sequence length // If so, return null to indicate contradiction has occurred - if ((numZeros + neededZeros > seq.size()/2) || (numOnes + neededOnes > seq.size()/2)) { + if ((numZeros + neededZeros > seq.size() / 2) || (numOnes + neededOnes > seq.size() / 2)) { return null; } diff --git a/src/main/java/edu/rpi/legup/puzzle/binary/rules/ZeroOrOneCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/binary/rules/ZeroOrOneCaseRule.java index 3ae7a424d..f47fe55b9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/binary/rules/ZeroOrOneCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/binary/rules/ZeroOrOneCaseRule.java @@ -39,18 +39,21 @@ public String checkRuleRaw(TreeTransition transition) { TreeTransition case2 = childTransitions.get(1); if (case1.getBoard().getModifiedData().size() != 1 || case2.getBoard().getModifiedData().size() != 1) { - return super.getInvalidUseOfRuleMessage() + ": This case rule must have 1 modified cell for each case."; + return super.getInvalidUseOfRuleMessage() + + ": This case rule must have 1 modified cell for each case."; } BinaryCell mod1 = (BinaryCell) case1.getBoard().getModifiedData().iterator().next(); BinaryCell mod2 = (BinaryCell) case2.getBoard().getModifiedData().iterator().next(); if (!mod1.getLocation().equals(mod2.getLocation())) { - return super.getInvalidUseOfRuleMessage() + ": This case rule must modify the same cell for each case."; + return super.getInvalidUseOfRuleMessage() + + ": This case rule must modify the same cell for each case."; } if (!((mod1.getType() == BinaryType.ZERO && mod2.getType() == BinaryType.ONE) || (mod2.getType() == BinaryType.ZERO && mod1.getType() == BinaryType.ONE))) { - return super.getInvalidUseOfRuleMessage() + ": This case rule must modify an empty cell."; + return super.getInvalidUseOfRuleMessage() + + ": This case rule must modify an empty cell."; } return null; diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeController.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeController.java index f2fad0d50..44ead6fac 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeController.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeController.java @@ -7,13 +7,12 @@ public class NurikabeController extends ElementController { /** - * Handles cell state changes in the nurikabe puzzle when a mouse event occurs - * If the left mouse button is clicked: - * - If the control key is held down, shows a context menu at the mouse position - * - Otherwise, toggles the cell data state between 0, -1, and -2 in a cyclic manner - * If the right mouse button is clicked, the cell data state is also toggled between -2, -1, and 0 + * Handles cell state changes in the nurikabe puzzle when a mouse event occurs If the left mouse + * button is clicked: - If the control key is held down, shows a context menu at the mouse + * position - Otherwise, toggles the cell data state between 0, -1, and -2 in a cyclic manner If + * the right mouse button is clicked, the cell data state is also toggled between -2, -1, and 0 * - * @param e MouseEvent triggered by the user interaction + * @param e MouseEvent triggered by the user interaction * @param data PuzzleElement representing the cell being modified */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/FinishRoomCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/FinishRoomCaseRule.java index dd8943cdb..025212d96 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/FinishRoomCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/FinishRoomCaseRule.java @@ -17,8 +17,10 @@ import java.util.Set; public class FinishRoomCaseRule extends CaseRule { - private int legitCases = 0; // placeholder for amount of cases originally generated in case user tries to delete + private int legitCases = + 0; // placeholder for amount of cases originally generated in case user tries to delete private Set uniqueCases; // stores the unique case hashes + // cases public FinishRoomCaseRule() { @@ -84,19 +86,27 @@ public CaseBoard getCaseBoard(Board board) { DisjointSets regions = NurikabeUtilities.getNurikabeRegions(nurikabeBoard); nurikabeBoard.setModifiable(false); - for (PuzzleElement element : nurikabeBoard.getPuzzleElements()) { // loops all puzzle elements - if (((NurikabeCell) element).getType() == NurikabeType.NUMBER) { // if the tile is a white number block - Set disRow = regions.getSet(((NurikabeCell) element)); // store the row of the white region - boolean only = true; // placeholder boolean of if the element being tested is the only number block in the room or not + for (PuzzleElement element : + nurikabeBoard.getPuzzleElements()) { // loops all puzzle elements + if (((NurikabeCell) element).getType() + == NurikabeType.NUMBER) { // if the tile is a white number block + Set disRow = + regions.getSet( + ((NurikabeCell) element)); // store the row of the white region + boolean only = + true; // placeholder boolean of if the element being tested is the only + // number block in the room or not for (NurikabeCell d : disRow) { // loops through tiles in the room - // if found another number tile and it's data is different from the element we're working with + // if found another number tile and it's data is different from the element + // we're working with if ((d.getType() == NurikabeType.NUMBER) && !(d.getData().equals(((NurikabeCell) element).getData()))) { only = false; } } - // if size of region is 1 less than the number block and the number block is only number block in the region + // if size of region is 1 less than the number block and the number block is only + // number block in the region if (disRow.size() < ((NurikabeCell) element).getData() && only) { caseBoard.addPickableElement(element); // add that room as a pickable element } @@ -120,10 +130,12 @@ public ArrayList getCases(Board board, PuzzleElement puzzleElement) { } NurikabeBoard nuriBoard = (NurikabeBoard) board.copy(); // nurikabe board to edit - NurikabeCell numberCell = nuriBoard.getCell( - ((NurikabeCell) puzzleElement).getLocation().x, - ((NurikabeCell) puzzleElement).getLocation().y - ); // number cell whose room we want to fill + NurikabeCell numberCell = + nuriBoard.getCell( + ((NurikabeCell) puzzleElement).getLocation().x, + ((NurikabeCell) puzzleElement) + .getLocation() + .y); // number cell whose room we want to fill Point origPoint = new Point(numberCell.getLocation().x, numberCell.getLocation().y); int filledRoomSize = numberCell.getData(); // size of room we want afterward @@ -138,12 +150,16 @@ public ArrayList getCases(Board board, PuzzleElement puzzleElement) { directions.add(top); directions.add(bot); - Set checkedPoints = new HashSet<>(); // add all into checked points and continue at start of loop if inside - DisjointSets regions = NurikabeUtilities.getNurikabeRegions(nuriBoard); // gathers regions + Set checkedPoints = + new HashSet<>(); // add all into checked points and continue at start of loop if + // inside + DisjointSets regions = + NurikabeUtilities.getNurikabeRegions(nuriBoard); // gathers regions Set numberCellRegion = regions.getSet(numberCell); // set of white spaces for (NurikabeCell d : numberCellRegion) { // loops through white spaces - generateCases(nuriBoard, d, filledRoomSize, directions, checkedPoints, cases, origPoint); + generateCases( + nuriBoard, d, filledRoomSize, directions, checkedPoints, cases, origPoint); } legitCases = cases.size(); @@ -162,16 +178,24 @@ public ArrayList getCases(Board board, PuzzleElement puzzleElement) { * @param cases the list of valid board cases generated * @param origPoint the original point of the number cell initiating the room filling */ - private void generateCases(NurikabeBoard nuriBoard, NurikabeCell currentCell, int filledRoomSize, - Set directions, Set checkedPoints, ArrayList cases, Point origPoint) { + private void generateCases( + NurikabeBoard nuriBoard, + NurikabeCell currentCell, + int filledRoomSize, + Set directions, + Set checkedPoints, + ArrayList cases, + Point origPoint) { for (Point direction : directions) { - Point newPoint = new Point( - currentCell.getLocation().x + direction.x, - currentCell.getLocation().y + direction.y - ); + Point newPoint = + new Point( + currentCell.getLocation().x + direction.x, + currentCell.getLocation().y + direction.y); - if (newPoint.x < 0 || newPoint.y < 0 || - newPoint.x >= nuriBoard.getWidth() || newPoint.y >= nuriBoard.getHeight()) { + if (newPoint.x < 0 + || newPoint.y < 0 + || newPoint.x >= nuriBoard.getWidth() + || newPoint.y >= nuriBoard.getHeight()) { continue; // out of bounds } @@ -181,15 +205,21 @@ private void generateCases(NurikabeBoard nuriBoard, NurikabeCell currentCell, in } if (newCell.getType() == NurikabeType.UNKNOWN) { - newCell.setData(NurikabeType.WHITE.toValue()); // changes adjacent cell color to white + newCell.setData( + NurikabeType.WHITE.toValue()); // changes adjacent cell color to white newCell.setModifiable(false); checkedPoints.add(newPoint); - DisjointSets regions = NurikabeUtilities.getNurikabeRegions(nuriBoard); // update regions variable - Set newRoomSet = regions.getSet(newCell); // gets set of cells in room with new white cell added + DisjointSets regions = + NurikabeUtilities.getNurikabeRegions(nuriBoard); // update regions variable + Set newRoomSet = + regions.getSet( + newCell); // gets set of cells in room with new white cell added - if (!touchesDifferentRoom(nuriBoard, newCell, filledRoomSize, directions, origPoint)) { - if (newRoomSet.size() == filledRoomSize) { // if adding white fills the room to exact size of + if (!touchesDifferentRoom( + nuriBoard, newCell, filledRoomSize, directions, origPoint)) { + if (newRoomSet.size() + == filledRoomSize) { // if adding white fills the room to exact size of // number block and doesn't connect with another room Board caseBoard = nuriBoard.copy(); // check if case for board already exists @@ -205,7 +235,14 @@ private void generateCases(NurikabeBoard nuriBoard, NurikabeCell currentCell, in cases.add(caseBoard); } } else if (newRoomSet.size() < filledRoomSize) { - generateCases(nuriBoard, newCell, filledRoomSize, directions, checkedPoints, cases, origPoint); + generateCases( + nuriBoard, + newCell, + filledRoomSize, + directions, + checkedPoints, + cases, + origPoint); } } newCell.setData(NurikabeType.UNKNOWN.toValue()); @@ -216,7 +253,8 @@ private void generateCases(NurikabeBoard nuriBoard, NurikabeCell currentCell, in } /** - * Determines if a given cell touches a different room by checking adjacent cells in specified directions. + * Determines if a given cell touches a different room by checking adjacent cells in specified + * directions. * * @param board the current Nurikabe board state * @param cell the cell being evaluated @@ -225,20 +263,27 @@ private void generateCases(NurikabeBoard nuriBoard, NurikabeCell currentCell, in * @param origPoint the original point of the number cell initiating the room filling * @return true if the cell touches a different room, false otherwise */ - private boolean touchesDifferentRoom(NurikabeBoard board, NurikabeCell cell, int origRoomSize, Set directions, Point origPoint) { + private boolean touchesDifferentRoom( + NurikabeBoard board, + NurikabeCell cell, + int origRoomSize, + Set directions, + Point origPoint) { for (Point direction : directions) { - Point adjacentPoint = new Point( - cell.getLocation().x + direction.x, - cell.getLocation().y + direction.y - ); + Point adjacentPoint = + new Point( + cell.getLocation().x + direction.x, cell.getLocation().y + direction.y); - if (adjacentPoint.x >= 0 && adjacentPoint.y >= 0 && - adjacentPoint.x < board.getWidth() && adjacentPoint.y < board.getHeight()) { // check if out of bounds + if (adjacentPoint.x >= 0 + && adjacentPoint.y >= 0 + && adjacentPoint.x < board.getWidth() + && adjacentPoint.y < board.getHeight()) { // check if out of bounds NurikabeCell adjacentCell = board.getCell(adjacentPoint.x, adjacentPoint.y); // check if the adjacent cell is a number cell if (adjacentCell.getType() == NurikabeType.NUMBER) { // check if it's different from the original number cell - if (origRoomSize != adjacentCell.getData() || (adjacentPoint.x != origPoint.x || adjacentPoint.y != origPoint.y)) { + if (origRoomSize != adjacentCell.getData() + || (adjacentPoint.x != origPoint.x || adjacentPoint.y != origPoint.y)) { return true; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java index 0e6345ff1..cfb3388ff 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java @@ -55,13 +55,16 @@ public void drawElement(Graphics2D graphics2D) { int xText = location.x + (size.width - metrics.stringWidth(value)) / 2; int yText = location.y + ((size.height - metrics.getHeight()) / 2) + metrics.getAscent(); - // REPRESENT NO CLUE AS EMPTY STRING INSTEAD OF 0, SOLVING PUZZLES WITH NO CLUE IS CURRENTLY NOT WORKING - // IF YOU ARE IMPLEMENTING NO CLUE FUNCTIONALITY, UNCOMMENT BELOW CODE AND DELETE OTHER IF STATEMENT, - // ADDITIONALLY, GO TO SkyscrapersBoard AND EDIT LINES 220 AND 223 SO YOU CAN CYCLE FOR NO CLUE + // REPRESENT NO CLUE AS EMPTY STRING INSTEAD OF 0, SOLVING PUZZLES WITH NO CLUE IS CURRENTLY + // NOT WORKING + // IF YOU ARE IMPLEMENTING NO CLUE FUNCTIONALITY, UNCOMMENT BELOW CODE AND DELETE OTHER IF + // STATEMENT, + // ADDITIONALLY, GO TO SkyscrapersBoard AND EDIT LINES 220 AND 223 SO YOU CAN CYCLE FOR NO + // CLUE // IN THE SKYSCRAPERS PUZZLE EDITOR -// if (value.equals("0")) { -// value = ""; -// } + // if (value.equals("0")) { + // value = ""; + // } if (value.equals("0")) { value = "1"; clue.setData(1); diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java index 4e194ae2c..75e5820a0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java @@ -15,10 +15,10 @@ public class SudokuCell extends GridCell { /** * SudokuCell Constructor - creates a new Sudoku cell to hold the puzzleElement * - * @param value value of the sudoku cell - * @param location location of the cell on the board + * @param value value of the sudoku cell + * @param location location of the cell on the board * @param groupIndex index of the group the cell is in on the board - * @param size size of the sudoku cell + * @param size size of the sudoku cell */ public SudokuCell(int value, Point location, int groupIndex, int size) { super(value, location); @@ -73,23 +73,19 @@ public void setType(Element e, MouseEvent m) { if (m.getButton() == MouseEvent.BUTTON1) { if (this.data <= 0 || this.data > 8) { this.data = 1; - } - else { + } else { this.data = this.data + 1; } - } - else { + } else { if (m.getButton() == MouseEvent.BUTTON3) { if (this.data > 1) { this.data = this.data - 1; - } - else { + } else { this.data = 9; } } } - } - else if (e.getElementName().equals("Unknown Tile")) { + } else if (e.getElementName().equals("Unknown Tile")) { this.data = 0; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java index d2a8d95ab..474feb342 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java @@ -22,12 +22,12 @@ public SudokuView(SudokuBoard board) { for (int k = 0; k < gridSize.width; k++) { Point location = new Point( - k * elementSize.width + (k / minorSize) * 4 + 5,// - i * elementSize.height + (i / minorSize) * 4 + 5); -// Point location = -// new Point( -// k * elementSize.width, -// i * elementSize.height); + k * elementSize.width + (k / minorSize) * 4 + 5, // + i * elementSize.height + (i / minorSize) * 4 + 5); + // Point location = + // new Point( + // k * elementSize.width, + // i * elementSize.height); SudokuElementView element = new SudokuElementView(board.getCell(k, i)); element.setIndex(i * gridSize.width + k); element.setIndex(i * gridSize.width); diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/NumberTile.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/NumberTile.java index b8f4a596c..a94d10e64 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/NumberTile.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/NumberTile.java @@ -1,4 +1,3 @@ - package edu.rpi.legup.puzzle.sudoku.elements; import edu.rpi.legup.model.elements.PlaceableElement; @@ -11,4 +10,4 @@ public NumberTile() { "A number tile", "edu/rpi/legup/images/sudoku/tiles/NumberTile.png"); } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/UnknownTile.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/UnknownTile.java index 162ba46d1..eb9a2c103 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/UnknownTile.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/elements/UnknownTile.java @@ -10,4 +10,4 @@ public UnknownTile() { "A blank tile", "edu/rpi/legup/images/sudoku/tiles/UnknownTile.png"); } -} \ No newline at end of file +} diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java index 4b0113232..35993303a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java @@ -4,7 +4,6 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; - import java.util.List; public class TreeTent extends Puzzle { diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index b1aa24eca..bde2df3d5 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -11,8 +11,8 @@ import javax.swing.*; /** - * Provides the user interface components for creating a new puzzle in the Legup application. - * This package includes classes for displaying dialog boxes to configure and initialize puzzles. + * Provides the user interface components for creating a new puzzle in the Legup application. This + * package includes classes for displaying dialog boxes to configure and initialize puzzles. */ public class CreatePuzzleDialog extends JDialog { private HomePanel homePanel; @@ -22,11 +22,12 @@ public class CreatePuzzleDialog extends JDialog { private ActionListener gameBoxListener = new ActionListener() { /** - * An ActionListener that handles changes in the drop-down menu for selecting puzzle types. - * When a new item is selected in the drop-down menu, this listener updates the visibility of - * the text input area and the row/column input fields based on the selected puzzle type. - * If "ShortTruthTable" is selected, the text input area is shown and the row/column fields are hidden. - * For other puzzle types, the row/column fields are shown and the text input area is hidden. + * An ActionListener that handles changes in the drop-down menu for selecting puzzle + * types. When a new item is selected in the drop-down menu, this listener updates + * the visibility of the text input area and the row/column input fields based on + * the selected puzzle type. If "ShortTruthTable" is selected, the text input area + * is shown and the row/column fields are hidden. For other puzzle types, the + * row/column fields are shown and the text input area is hidden. */ @Override public void actionPerformed(ActionEvent e) { @@ -76,9 +77,7 @@ public void actionPerformed(ActionEvent ae) { return; } if (!game.equals("ShortTruthTable") - && (game.isEmpty() - || getRows().isEmpty() - || getColumns().isEmpty())) { + && (game.isEmpty() || getRows().isEmpty() || getColumns().isEmpty())) { System.out.println("Unfilled fields"); return; } @@ -200,8 +199,8 @@ public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { } /** - * Initializes the puzzle options available for selection in the dialog. - * The options are retrieved from the game board facade and sorted alphabetically. + * Initializes the puzzle options available for selection in the dialog. The options are + * retrieved from the game board facade and sorted alphabetically. */ public void initPuzzles() { this.games = @@ -213,9 +212,9 @@ public void initPuzzles() { gameBox = new JComboBox(this.games); } - /** - * Handles the action events for the dialog, including interactions with the Ok and Cancel buttons + * Handles the action events for the dialog, including interactions with the Ok and Cancel + * buttons * * @param e The action event to be processed */ @@ -235,7 +234,8 @@ public void actionPerformed(ActionEvent e) { } this.setVisible(false); } catch (IllegalArgumentException exception) { - // Do nothing. This is here to prevent the dialog from closing if the dimensions are invalid. + // Do nothing. This is here to prevent the dialog from closing if the dimensions are + // invalid. } } else { if (e.getSource() == cancel) { @@ -278,5 +278,7 @@ public String getColumns() { * * @return an array of strings, each representing as a line of text */ - public String[] getTextArea() { return textArea.getText().split("\n"); } + public String[] getTextArea() { + return textArea.getText().split("\n"); + } } diff --git a/src/main/java/edu/rpi/legup/ui/DynamicView.java b/src/main/java/edu/rpi/legup/ui/DynamicView.java index 344885783..fa0004d0b 100644 --- a/src/main/java/edu/rpi/legup/ui/DynamicView.java +++ b/src/main/java/edu/rpi/legup/ui/DynamicView.java @@ -244,16 +244,12 @@ public void updateError(String message) { status.setText(message); } - /** - * Clears the status label - */ + /** Clears the status label */ public void resetStatus() { status.setText(""); } - /** - * Resets the view to its default state and zooms the content to fit the screen - */ + /** Resets the view to its default state and zooms the content to fit the screen */ public void reset() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); Board board1 = GameBoardFacade.getInstance().getBoard(); @@ -262,9 +258,7 @@ public void reset() { this.getScrollView().zoomFit(); } - /** - * Fits the board view to the screen - */ + /** Fits the board view to the screen */ protected void fitBoardViewToScreen() { scrollView.zoomFit(); } diff --git a/src/main/java/edu/rpi/legup/ui/DynamicViewType.java b/src/main/java/edu/rpi/legup/ui/DynamicViewType.java index d161f5b9c..c4bb940e0 100644 --- a/src/main/java/edu/rpi/legup/ui/DynamicViewType.java +++ b/src/main/java/edu/rpi/legup/ui/DynamicViewType.java @@ -3,9 +3,10 @@ /** * An enumeration representing the different types of dynamic views supported by the application. * The two types of views are: + * *

    - *
  • {@code BOARD} - Represents a dynamic view of a game board
  • - *
  • {@code PROOF_TREE} - Represents a dynamic view of a proof tree
  • + *
  • {@code BOARD} - Represents a dynamic view of a game board + *
  • {@code PROOF_TREE} - Represents a dynamic view of a proof tree *
*/ public enum DynamicViewType { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index f12ffdbf0..75761c475 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -26,10 +26,9 @@ import org.xml.sax.helpers.DefaultHandler; /** - * The {@code HomePanel} class represents the home panel of the LEGUP application. - * This panel provides buttons for functionalities of opening the proof editor, - * opening the puzzle editor, and performing batch grading. It also includes a menu bar with - * options for preferences. + * The {@code HomePanel} class represents the home panel of the LEGUP application. This panel + * provides buttons for functionalities of opening the proof editor, opening the puzzle editor, and + * performing batch grading. It also includes a menu bar with options for preferences. */ public class HomePanel extends LegupPanel { private static final Logger LOGGER = LogManager.getLogger(HomePanel.class.getName()); @@ -42,9 +41,7 @@ public class HomePanel extends LegupPanel { private final int buttonSize = 100; - /** - * Initialize the proof solver to an empty panel with no puzzle - */ + /** Initialize the proof solver to an empty panel with no puzzle */ private ActionListener openProofListener = new ActionListener() { @Override @@ -101,9 +98,7 @@ public JMenuBar getMenuBar() { return this.menuBar; } - /** - * Makes the panel visible and sets the menu bar of the frame - */ + /** Makes the panel visible and sets the menu bar of the frame */ @Override public void makeVisible() { render(); @@ -124,9 +119,7 @@ private static ImageIcon resizeButtonIcon(ImageIcon icon, int width, int height) return new ImageIcon(resizedImage); } - /** - * Initializes the buttons for this panel - */ + /** Initializes the buttons for this panel */ private void initButtons() { this.buttons = new JButton[3]; @@ -188,8 +181,8 @@ public void actionPerformed(ActionEvent e) { } /** - * Opens a folder chooser dialog and grades puzzles in the selected folder. - * The results are written to a CSV file. + * Opens a folder chooser dialog and grades puzzles in the selected folder. The results are + * written to a CSV file. */ public void checkFolder() { GameBoardFacade facade = GameBoardFacade.getInstance(); @@ -276,12 +269,12 @@ public void checkFolder() { } /** - * Processes XML files within a selected directory and generates a CSV report on their "solved?" status. - * The method allows the user to select a directory, and evaluates each XML file for a "solved?" status. - * Results are saved in a "result.csv" file. + * Processes XML files within a selected directory and generates a CSV report on their "solved?" + * status. The method allows the user to select a directory, and evaluates each XML file for a + * "solved?" status. Results are saved in a "result.csv" file. * - * @effect Selects a directory, processes each XML file to check for "solved?" status, - * and writes results to "result.csv". Opens the CSV file upon completion. + * @effect Selects a directory, processes each XML file to check for "solved?" status, and + * writes results to "result.csv". Opens the CSV file upon completion. */ private void use_xml_to_check() { /* Select a folder, go through each .xml file in the subfolders, look for "isSolved" flag */ @@ -481,8 +474,8 @@ public void endDocument() throws SAXException { } /** - * Initializes the text labels for the user interface. - * Sets up labels for welcome message, led by Bram, and version information. + * Initializes the text labels for the user interface. Sets up labels for welcome message, led + * by Bram, and version information. */ private void initText() { // TODO: add version text after auto-changing version label is implemented. (text[2] = @@ -505,9 +498,7 @@ private void initText() { this.text[1] = credits; } - /** - * Renders the user interface components - */ + /** Renders the user interface components */ private void render() { this.removeAll(); @@ -536,7 +527,8 @@ private void render() { /** * Opens the puzzle editor dialog with no selected puzzle, leaving a blank panel * - * @throws IllegalArgumentException if the configuration parameters are invalid (should never happen) + * @throws IllegalArgumentException if the configuration parameters are invalid (should never + * happen) */ private void openPuzzleEditorDialog() { String game = ""; @@ -668,11 +660,10 @@ private void traverseDir(File folder, BufferedWriter writer, String path) throws */ public void openEditorWithNewPuzzle(String game, int rows, int columns) throws IllegalArgumentException { - if (game.equals("")) { + if (game.isEmpty()) { this.legupUI.displayPanel(2); this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, rows, columns); - } - else { + } else { // Validate the dimensions GameBoardFacade facade = GameBoardFacade.getInstance(); boolean isValidDimensions = facade.validateDimensions(game, rows, columns); @@ -695,7 +686,6 @@ public void openEditorWithNewPuzzle(String game, int rows, int columns) this.legupUI.displayPanel(2); this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, rows, columns); } - } /** diff --git a/src/main/java/edu/rpi/legup/ui/LegupPanel.java b/src/main/java/edu/rpi/legup/ui/LegupPanel.java index 38c44cbe4..639f21211 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupPanel.java +++ b/src/main/java/edu/rpi/legup/ui/LegupPanel.java @@ -3,17 +3,14 @@ import javax.swing.*; /** - * An abstract base class for panels in the LEGUP application. - * This class extends {@link JPanel} and defines common properties and methods - * for all panels in the LEGUP user interface - * (currently only implements toolbar scale) + * An abstract base class for panels in the LEGUP application. This class extends {@link JPanel} and + * defines common properties and methods for all panels in the LEGUP user interface (currently only + * implements toolbar scale) */ public abstract class LegupPanel extends JPanel { /** Alerts panel that it will be going visible now */ protected final int TOOLBAR_ICON_SCALE = 40; - /** - * Abstract method to make the panel visible - */ + /** Abstract method to make the panel visible */ public abstract void makeVisible(); } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 30857f05f..75f822a6c 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -15,9 +15,9 @@ import org.apache.logging.log4j.Logger; /** - * The main user interface class for the LEGUP application. - * This class extends {@link JFrame} and implements {@link WindowListener} - * to manage the overall window and provide functionality for displaying various panels. + * The main user interface class for the LEGUP application. This class extends {@link JFrame} and + * implements {@link WindowListener} to manage the overall window and provide functionality for + * displaying various panels. */ public class LegupUI extends JFrame implements WindowListener { private static final Logger LOGGER = LogManager.getLogger(LegupUI.class.getName()); @@ -96,10 +96,7 @@ public void keyTyped(KeyEvent e) { setVisible(true); } - /** - * Initializes the panels used in the UI. - * Sets up the layout and adds panels to the window. - */ + /** Initializes the panels used in the UI. Sets up the layout and adds panels to the window. */ private void initPanels() { window = new JPanel(); window.setLayout(new BorderLayout()); @@ -148,9 +145,7 @@ public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } - /** - * Repaints the tree view in the proof editor. - */ + /** Repaints the tree view in the proof editor. */ public void repaintTree() { getProofEditor().repaintTree(); } diff --git a/src/main/java/edu/rpi/legup/ui/PickGameDialog.java b/src/main/java/edu/rpi/legup/ui/PickGameDialog.java index a6501e2a0..3b66931a7 100644 --- a/src/main/java/edu/rpi/legup/ui/PickGameDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PickGameDialog.java @@ -16,9 +16,8 @@ import javax.swing.JTextField; /** - * A dialog for selecting a game. - * This class extends {@link JDialog} and implements {@link ActionListener} - * to handle user interactions for selecting a game type and puzzle file. + * A dialog for selecting a game. This class extends {@link JDialog} and implements {@link + * ActionListener} to handle user interactions for selecting a game type and puzzle file. */ public class PickGameDialog extends JDialog implements ActionListener { JLabel gameLabel = new JLabel("Game:"); @@ -112,8 +111,8 @@ public PickGameDialog(JFrame parent, boolean pickBothAtOnce) { } /** - * Initializes the available games and puzzles. - * Populates the {@link JComboBox} with game types and sets up the puzzle options. + * Initializes the available games and puzzles. Populates the {@link JComboBox} with game types + * and sets up the puzzle options. */ public void initPuzzles() { Object[] o = GameBoardFacade.getInstance().getConfig().getPuzzleClassNames().toArray(); @@ -156,9 +155,8 @@ public String getGame() { } /** - * Handles action events for the dialog components. - * Responds to user interactions such as selecting a puzzle, choosing a puzzle file, - * and pressing the 'Ok' or 'Cancel' buttons. + * Handles action events for the dialog components. Responds to user interactions such as + * selecting a puzzle, choosing a puzzle file, and pressing the 'Ok' or 'Cancel' buttons. * * @param e the action event */ diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index c8639f796..e90d06640 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -18,10 +18,10 @@ import javax.swing.*; /** - * A dialog for managing user preferences in the LEGUP application. - * This dialog allows users to configure various settings such as screen mode, - * update preferences, work directory path, and specific features related to board and tree views. - * Users can access this dialog from the home screen or proof editor. + * A dialog for managing user preferences in the LEGUP application. This dialog allows users to + * configure various settings such as screen mode, update preferences, work directory path, and + * specific features related to board and tree views. Users can access this dialog from the home + * screen or proof editor. */ public class PreferencesDialog extends JDialog { @@ -364,10 +364,9 @@ private JScrollPane createPuzzleTab(Puzzle puzzle) { } /** - * Creates a JPanel that represents a single row for a rule in the rule list. - * Each row displays the rule's name and an area for showing keyboard shortcuts - * associated with the rule. The keyboard shortcuts are dynamically updated based - * on user input. + * Creates a JPanel that represents a single row for a rule in the rule list. Each row displays + * the rule's name and an area for showing keyboard shortcuts associated with the rule. The + * keyboard shortcuts are dynamically updated based on user input. * * @param rule the rule object to be displayed * @return a JPanel representing the row for the rule @@ -425,9 +424,8 @@ public void keyPressed(KeyEvent e) { } /** - * Creates a JPanel containing a left-aligned label with the specified text. - * This label is typically used for section headings or descriptive text in the - * preferences dialog. + * Creates a JPanel containing a left-aligned label with the specified text. This label is + * typically used for section headings or descriptive text in the preferences dialog. * * @param text the text to be displayed on the label * @return a JPanel containing the left-aligned label @@ -446,8 +444,8 @@ private JPanel createLeftLabel(String text) { } /** - * Creates a JSeparator with a maximum height of 5 pixels. - * This separator is used to visually divide sections in the preferences dialog. + * Creates a JSeparator with a maximum height of 5 pixels. This separator is used to visually + * divide sections in the preferences dialog. * * @return a JSeparator with a fixed height */ @@ -458,10 +456,10 @@ private JSeparator createLineSeparator() { } /** - * Applies the current user preferences and updates the associated components. - * This method retrieves user preferences from the dialog's components and stores - * them in the {@link LegupPreferences} instance. It also updates the rule panels - * in the rules frame if it is not null. + * Applies the current user preferences and updates the associated components. This method + * retrieves user preferences from the dialog's components and stores them in the {@link + * LegupPreferences} instance. It also updates the rule panels in the rules frame if it is not + * null. */ public void applyPreferences() { LegupPreferences prefs = LegupPreferences.getInstance(); diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 88c1ee427..5ecbd5564 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -17,7 +17,6 @@ import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; -import edu.rpi.legup.ui.proofeditorui.treeview.TreeTransitionView; import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import edu.rpi.legup.user.Submission; import java.awt.*; @@ -38,12 +37,11 @@ import org.apache.logging.log4j.Logger; /** - * {@code ProofEditorPanel} is a panel that serves as the main user interface - * component for the proof editing functionality of LEGUP. It provides - * the graphical components and interactive elements necessary for editing and managing - * proofs, including toolbars, menus, and views for different aspects of proof editing. - * It also manages interactions with the rest of the application and updates the UI - * based on user actions and application state changes. + * {@code ProofEditorPanel} is a panel that serves as the main user interface component for the + * proof editing functionality of LEGUP. It provides the graphical components and interactive + * elements necessary for editing and managing proofs, including toolbars, menus, and views for + * different aspects of proof editing. It also manages interactions with the rest of the application + * and updates the UI based on user actions and application state changes. */ public class ProofEditorPanel extends LegupPanel implements IHistoryListener { private static final Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); @@ -136,8 +134,8 @@ public ProofEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { } /** - * Makes the panel visible by setting up the toolbar and content components. - * This method also sets the menu bar of the frame to the one used by this panel. + * Makes the panel visible by setting up the toolbar and content components. This method also + * sets the menu bar of the frame to the one used by this panel. */ @Override public void makeVisible() { @@ -149,20 +147,22 @@ public void makeVisible() { } /** - * Constructs and returns the {@code JMenuBar} for this panel. - * It populates it with various {@code JMenu} and {@code JMenuItem} components related - * to file operations, editing, viewing, and proof management. - * The menu bar includes: + * Constructs and returns the {@code JMenuBar} for this panel. It populates it with various + * {@code JMenu} and {@code JMenuItem} components related to file operations, editing, viewing, + * and proof management. The menu bar includes: + * *
    - *
  • {@code File} menu with options to open a new puzzle, reset the puzzle, save the proof, - * access preferences, and exit the editor.
  • - *
  • {@code Edit} menu with options for undo, redo, and fitting the board or tree to the screen.
  • - *
  • {@code Proof} menu with options for adding, deleting, merging, collapsing elements, - * and toggling settings related to rule applications and feedback.
  • - *
  • {@code About} menu with options to view information about the application and access help resources.
  • + *
  • {@code File} menu with options to open a new puzzle, reset the puzzle, save the proof, + * access preferences, and exit the editor. + *
  • {@code Edit} menu with options for undo, redo, and fitting the board or tree to the + * screen. + *
  • {@code Proof} menu with options for adding, deleting, merging, collapsing elements, and + * toggling settings related to rule applications and feedback. + *
  • {@code About} menu with options to view information about the application and access + * help resources. *
- *

- * Accelerator keys are set based on the operating system (Mac or non-Mac). + * + *

Accelerator keys are set based on the operating system (Mac or non-Mac). * * @return the {@code JMenuBar} instance containing the menus and menu items for this panel */ @@ -497,8 +497,8 @@ public void actionPerformed(ActionEvent e) { } /** - * Clears the current puzzle, resets the UI to display the initial panel, - * and nullifies the references to the tree panel and board view. + * Clears the current puzzle, resets the UI to display the initial panel, and nullifies the + * references to the tree panel and board view. */ public void exitEditor() { // Wipes the puzzle entirely as if LEGUP just started @@ -510,10 +510,11 @@ public void exitEditor() { /** * Opens a file chooser dialog allowing the user to select a directory. It uses the user's - * preferred directory or the last saved path if available. The selected directory is used - * to set the new working directory. + * preferred directory or the last saved path if available. The selected directory is used to + * set the new working directory. * - * @return an array containing the file name and the selected file, or {@code null} if the operation was canceled + * @return an array containing the file name and the selected file, or {@code null} if the + * operation was canceled */ public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); @@ -559,10 +560,10 @@ public Object[] promptPuzzle() { } /** - * Calls {@link #promptPuzzle()} to get the file information and then loads the puzzle using - * the provided file name and file object. Updates the frame title to reflect the puzzle name. - * If the file is not valid or an error occurs, an error message is shown, and the user is - * prompted to try loading another puzzle. + * Calls {@link #promptPuzzle()} to get the file information and then loads the puzzle using the + * provided file name and file object. Updates the frame title to reflect the puzzle name. If + * the file is not valid or an error occurs, an error message is shown, and the user is prompted + * to try loading another puzzle. */ public void loadPuzzle() { Object[] items = promptPuzzle(); @@ -576,16 +577,16 @@ public void loadPuzzle() { } /** - * Attempts to load a puzzle from the given file. If successful, it updates the - * UI to display the puzzle and changes the frame title to include the puzzle name. If the - * file is invalid or cannot be read, it shows an appropriate error message and prompts the - * user to try loading another puzzle. + * Attempts to load a puzzle from the given file. If successful, it updates the UI to display + * the puzzle and changes the frame title to include the puzzle name. If the file is invalid or + * cannot be read, it shows an appropriate error message and prompts the user to try loading + * another puzzle. * * @param fileName the name of the file to load * @param puzzleFile the file object representing the puzzle file */ public void loadPuzzle(String fileName, File puzzleFile) { - if (puzzleFile == null && fileName.equals("")) { + if (puzzleFile == null && fileName.isEmpty()) { legupUI.displayPanel(1); } if (puzzleFile != null && puzzleFile.exists()) { @@ -623,9 +624,9 @@ public void loadPuzzle(String fileName, File puzzleFile) { } /** - * Uses the current puzzle and its associated exporter to save the puzzle data - * to the file currently being used. If the puzzle or exporter is null, or if an error occurs - * during export, the method will catch the exception and print the stack trace. + * Uses the current puzzle and its associated exporter to save the puzzle data to the file + * currently being used. If the puzzle or exporter is null, or if an error occurs during export, + * the method will catch the exception and print the stack trace. */ private void direct_save() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); @@ -648,8 +649,8 @@ private void direct_save() { /** * Opens a file chooser dialog for the user to select a directory. The chosen directory is used - * to determine where the puzzle file will be saved. If an exporter is available, it will be used - * to export the puzzle data to the selected path. + * to determine where the puzzle file will be saved. If an exporter is available, it will be + * used to export the puzzle data to the selected path. */ private void saveProofAs() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); @@ -689,9 +690,9 @@ private void saveProofAs() { // Hyperlink for help button; links to wiki page for tutorials /** - * Opens the default web browser to a help page related to the type of puzzle currently being used. - * The URL is chosen based on the name of the puzzle. If the puzzle type is not recognized, a general - * tutorial page is opened. + * Opens the default web browser to a help page related to the type of puzzle currently being + * used. The URL is chosen based on the name of the puzzle. If the puzzle type is not + * recognized, a general tutorial page is opened. */ private void helpTutorial() { // redirecting to certain help link in wiki @@ -745,9 +746,9 @@ public void actionPerformed(ActionEvent e) { } /** - * Saves the puzzle using the current file name and shows a message dialog to - * confirm that the save operation was successful. If the puzzle or exporter is null, or if - * an error occurs during export, the method will catch the exception and print the stack trace. + * Saves the puzzle using the current file name and shows a message dialog to confirm that the + * save operation was successful. If the puzzle or exporter is null, or if an error occurs + * during export, the method will catch the exception and print the stack trace. */ private void saveProofChange() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); @@ -826,9 +827,9 @@ protected void setupContent() { } /** - * Initializes the first toolbar, configures its appearance, and adds an 'Open' button - * with an associated icon. An action listener is attached to the button to trigger the loading of - * a puzzle when clicked. + * Initializes the first toolbar, configures its appearance, and adds an 'Open' button with an + * associated icon. An action listener is attached to the button to trigger the loading of a + * puzzle when clicked. */ private void setupToolBar1() { toolBar1 = new JToolBar(); @@ -862,14 +863,15 @@ private void setupToolBar1() { } /** - * Initializes the second toolbar, configures its appearance, and adds four buttons each - * with associated icons. Action listeners are attached to each button to trigger their respective + * Initializes the second toolbar, configures its appearance, and adds four buttons each with + * associated icons. Action listeners are attached to each button to trigger their respective * actions when clicked: + * *

    - *
  • 'Directions' button triggers the `directionsToolButton` method.
  • - *
  • 'Undo' button triggers the undo action in the puzzle's history.
  • - *
  • 'Redo' button triggers the redo action in the puzzle's history.
  • - *
  • 'Check' button triggers the `checkProof` method.
  • + *
  • 'Directions' button triggers the `directionsToolButton` method. + *
  • 'Undo' button triggers the undo action in the puzzle's history. + *
  • 'Redo' button triggers the redo action in the puzzle's history. + *
  • 'Check' button triggers the `checkProof` method. *
*/ private void setupToolBar2() { @@ -933,9 +935,10 @@ private void setupToolBar2() { JButton redo = new JButton("Redo", RedoImageIcon); redo.setFocusPainted(false); - redo.addActionListener((ActionEvent) -> { - GameBoardFacade.getInstance().getHistory().redo(); - }); + redo.addActionListener( + (ActionEvent) -> { + GameBoardFacade.getInstance().getHistory().redo(); + }); getToolBar2Buttons()[2] = redo; toolBar2.add(getToolBar2Buttons()[2]); @@ -960,7 +963,6 @@ private void setupToolBar2() { getToolBar2Buttons()[3] = check; toolBar2.add(getToolBar2Buttons()[3]); - this.add(toolBar2, BorderLayout.NORTH); } @@ -1001,8 +1003,9 @@ public JButton[] getToolBar2Buttons() { } /** - * Uses the {@link GameBoardFacade} to obtain the current puzzle and board. If the puzzle is complete, - * it notifies the user of a correct proof. If not, it alerts the user that the board is not solved. + * Uses the {@link GameBoardFacade} to obtain the current puzzle and board. If the puzzle is + * complete, it notifies the user of a correct proof. If not, it alerts the user that the board + * is not solved. */ private void checkProof() { GameBoardFacade facade = GameBoardFacade.getInstance(); @@ -1031,42 +1034,49 @@ private void checkProof() { } /** - * Retrieves the puzzle name from the `GameBoardFacade` and opens a corresponding rules page in the default web browser. + * Retrieves the puzzle name from the `GameBoardFacade` and opens a corresponding rules page in + * the default web browser. * * @throws IOException if an error occurs while trying to open the web page */ private void directionsToolButton() { String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - //System.out.println(puzzleName); + // System.out.println(puzzleName); try { if (puzzleName.equals("Fillapix")) { java.awt.Desktop.getDesktop() - .browse(URI.create("https://github.com/Bram-Hub/LEGUP/wiki/Fill-a-pix-rules")); - } - else if (puzzleName.equals("LightUp")) { + .browse( + URI.create( + "https://github.com/Bram-Hub/LEGUP/wiki/Fill-a-pix-rules")); + } else if (puzzleName.equals("LightUp")) { java.awt.Desktop.getDesktop() - .browse(URI.create("https://github.com/Bram-Hub/LEGUP/wiki/Light-up-rules")); - } - else if (puzzleName.equals("TreeTent")) { + .browse( + URI.create( + "https://github.com/Bram-Hub/LEGUP/wiki/Light-up-rules")); + } else if (puzzleName.equals("TreeTent")) { java.awt.Desktop.getDesktop() - .browse(URI.create("https://github.com/Bram-Hub/LEGUP/wiki/Tree-tent-rules")); - } - else if (puzzleName.equals("ShortTruthTables")) { + .browse( + URI.create( + "https://github.com/Bram-Hub/LEGUP/wiki/Tree-tent-rules")); + } else if (puzzleName.equals("ShortTruthTables")) { java.awt.Desktop.getDesktop() - .browse(URI.create("https://github.com/Bram-Hub/LEGUP/wiki/Short-truth-table-rules")); - } - else { + .browse( + URI.create( + "https://github.com/Bram-Hub/LEGUP/wiki/Short-truth-table-rules")); + } else { java.awt.Desktop.getDesktop() - .browse(URI.create("https://github.com/Bram-Hub/LEGUP/wiki/" + puzzleName + "-rules")); + .browse( + URI.create( + "https://github.com/Bram-Hub/LEGUP/wiki/" + + puzzleName + + "-rules")); } } catch (IOException e) { LOGGER.error("Can't open web page"); } } - /** - * Repaints the board view and tree panel - */ + /** Repaints the board view and tree panel */ private void repaintAll() { boardView.repaint(); treePanel.repaint(); @@ -1081,7 +1091,6 @@ private void repaintAll() { public void setPuzzleView(Puzzle puzzle) { this.boardView = puzzle.getBoardView(); - dynamicBoardView = new DynamicView(boardView, DynamicViewType.BOARD); this.topHalfPanel.setRightComponent(dynamicBoardView); this.topHalfPanel.setVisible(true); @@ -1107,12 +1116,11 @@ public void setPuzzleView(Puzzle puzzle) { reloadGui(); } - /** - * Calls {@code repaintTree()} to refresh the tree view. - */ + /** Calls {@code repaintTree()} to refresh the tree view. */ public void reloadGui() { repaintTree(); } + /** * Updates the tree view displayed in the tree panel to reflect the current state of the tree. */ @@ -1242,7 +1250,6 @@ public BoardView getBoardView() { return boardView; } - /** * Returns the current dynamic board view. * @@ -1278,12 +1285,11 @@ public void onPushChange(ICommand command) { } /** - * Updates the state of the undo and redo buttons to reflect that there are no actions - * available to undo or redo. It disables both buttons when the history is cleared. + * Updates the state of the undo and redo buttons to reflect that there are no actions available + * to undo or redo. It disables both buttons when the history is cleared. */ @Override - public void onClearHistory() { - } + public void onClearHistory() {} /** * Called when an action is redone @@ -1359,10 +1365,7 @@ public void showStatus(String status, boolean error, int timer) { // TODO: implement } - - /** - * Zooms the tree view to fit within the available screen space - */ + /** Zooms the tree view to fit within the available screen space */ protected void fitTreeViewToScreen() { this.treePanel.getTreeView().zoomFit(); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 2f3c16eac..7c2ba06ff 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -10,14 +10,9 @@ import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.PuzzleExporter; -import edu.rpi.legup.model.tree.Tree; -import edu.rpi.legup.model.tree.TreeNode; -import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.save.ExportFileException; import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.HomePanel; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import java.awt.*; import java.awt.event.ActionEvent; @@ -27,7 +22,6 @@ import java.io.IOException; import java.net.URI; import java.net.URL; -import java.util.List; import java.util.Objects; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -35,9 +29,9 @@ import org.apache.logging.log4j.Logger; /** - * Represents the panel used for puzzle editor in the LEGUP. - * This panel includes a variety of UI components such as toolbars, menus, and split panes. - * It handles puzzle file operations, including creating and editing puzzles. + * Represents the panel used for puzzle editor in the LEGUP. This panel includes a variety of UI + * components such as toolbars, menus, and split panes. It handles puzzle file operations, including + * creating and editing puzzles. */ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { @@ -71,7 +65,8 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private File puzzleFile; /** - * Constructs a {@code PuzzleEditorPanel} with the specified file dialog, frame, and Legup UI instance + * Constructs a {@code PuzzleEditorPanel} with the specified file dialog, frame, and Legup UI + * instance * * @param fileDialog the file dialog used for file operations * @param frame the main application frame @@ -86,8 +81,8 @@ public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { } /** - * Sets up the content of the panel, including the layout and UI components. - * Initializes and configures the {@code DynamicView} and {@code ElementFrame}, and adds them to the panel. + * Sets up the content of the panel, including the layout and UI components. Initializes and + * configures the {@code DynamicView} and {@code ElementFrame}, and adds them to the panel. */ protected void setupContent() { JSplitPane splitPanel; @@ -121,9 +116,8 @@ protected void setupContent() { } /** - * Configures the menu bar with menus and menu items for the application. - * Adds actions for opening, creating, and exiting puzzles. - * Also sets up help and about menu items. + * Configures the menu bar with menus and menu items for the application. Adds actions for + * opening, creating, and exiting puzzles. Also sets up help and about menu items. */ public void setMenuBar() { String os = LegupUI.getOS(); @@ -147,13 +141,14 @@ public void setMenuBar() { } // file>create JMenuItem createPuzzle = new JMenuItem("Create"); - createPuzzle.addActionListener((ActionEvent) -> { - hp = new HomePanel(this.frame, this.legupUI); - cpd = new CreatePuzzleDialog(this.frame, hp); - cpd.setLocationRelativeTo(null); - cpd.setVisible(true); - existingPuzzle = false; - }); + createPuzzle.addActionListener( + (ActionEvent) -> { + hp = new HomePanel(this.frame, this.legupUI); + cpd = new CreatePuzzleDialog(this.frame, hp); + cpd.setLocationRelativeTo(null); + cpd.setVisible(true); + existingPuzzle = false; + }); if (os.equals("mac")) { createPuzzle.setAccelerator( KeyStroke.getKeyStroke( @@ -162,7 +157,6 @@ public void setMenuBar() { createPuzzle.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK)); } - JMenuItem exit = new JMenuItem("Exit"); exit.addActionListener((ActionEvent) -> exitEditor()); if (os.equals("mac")) { @@ -174,7 +168,7 @@ public void setMenuBar() { } menus[0].add(openPuzzle); menus[0].add(createPuzzle); - //menus[0].add(directSavePuzzle); + // menus[0].add(directSavePuzzle); menus[0].add(exit); // EDIT @@ -186,7 +180,7 @@ public void setMenuBar() { fitBoardToScreen = new JMenuItem("Fit Board to Screen"); // TODO: Undo operation currently does not get updated correctly in history - //menus[1].add(undo); + // menus[1].add(undo); undo.addActionListener((ActionEvent) -> GameBoardFacade.getInstance().getHistory().undo()); if (os.equals("mac")) { undo.setAccelerator( @@ -197,7 +191,7 @@ public void setMenuBar() { } // TODO: Redo operation currently does not get updated correctly in history - //menus[1].add(redo); + // menus[1].add(redo); // Created action to support two keybinds (CTRL-SHIFT-Z, CTRL-Y) Action redoAction = new AbstractAction() { @@ -272,10 +266,9 @@ public void actionPerformed(ActionEvent e) { } /** - * Exits the puzzle editor and resets the application state to its initial condition. - * This method clears the current puzzle from the {@code GameBoardFacade}, - * resets the display to the initial panel, and nullifies references to the - * tree panel and board view. + * Exits the puzzle editor and resets the application state to its initial condition. This + * method clears the current puzzle from the {@code GameBoardFacade}, resets the display to the + * initial panel, and nullifies references to the tree panel and board view. */ public void exitEditor() { // Wipes the puzzle entirely as if LEGUP just started @@ -286,8 +279,8 @@ public void exitEditor() { } /** - * Makes the panel visible by setting up the toolbar, content, and menu bar. - * This method is called to refresh the panel's user interface. + * Makes the panel visible by setting up the toolbar, content, and menu bar. This method is + * called to refresh the panel's user interface. */ @Override public void makeVisible() { @@ -298,8 +291,8 @@ public void makeVisible() { } /** - * Sets up the first toolbar with buttons for opening and creating puzzles. - * This method initializes the toolbar buttons with their icons and actions. + * Sets up the first toolbar with buttons for opening and creating puzzles. This method + * initializes the toolbar buttons with their icons and actions. */ private void setupToolBar1() { setToolBar1Buttons(new JButton[2]); @@ -341,13 +334,14 @@ private void setupToolBar1() { JButton create = new JButton("Create", CreateImageIcon); create.setFocusPainted(false); - create.addActionListener((ActionEvent) -> { - hp = new HomePanel(this.frame, this.legupUI); - cpd = new CreatePuzzleDialog(this.frame, hp); - cpd.setLocationRelativeTo(null); - cpd.setVisible(true); - existingPuzzle = false; - }); + create.addActionListener( + (ActionEvent) -> { + hp = new HomePanel(this.frame, this.legupUI); + cpd = new CreatePuzzleDialog(this.frame, hp); + cpd.setLocationRelativeTo(null); + cpd.setVisible(true); + existingPuzzle = false; + }); getToolBar1Buttons()[1] = create; toolBar1.setFloatable(false); @@ -383,19 +377,22 @@ private void setupToolBar2() { resetButton.setFocusPainted(false); resetButton.addActionListener( - a -> { - if (existingPuzzle) { - legupUI.getPuzzleEditor().loadPuzzle(fileName, puzzleFile); - } - else { - if (cpd.getGame().equals("ShortTruthTable")) { - GameBoardFacade.getInstance().loadPuzzle(cpd.getGame(), cpd.getTextArea()); - } - else { - GameBoardFacade.getInstance().loadPuzzle(cpd.getGame(), Integer.valueOf(cpd.getRows()), Integer.valueOf(cpd.getColumns())); + a -> { + if (existingPuzzle) { + legupUI.getPuzzleEditor().loadPuzzle(fileName, puzzleFile); + } else { + if (cpd.getGame().equals("ShortTruthTable")) { + GameBoardFacade.getInstance() + .loadPuzzle(cpd.getGame(), cpd.getTextArea()); + } else { + GameBoardFacade.getInstance() + .loadPuzzle( + cpd.getGame(), + Integer.valueOf(cpd.getRows()), + Integer.valueOf(cpd.getColumns())); + } } - } - }); + }); getToolBar2Buttons()[0] = resetButton; toolBar2.add(getToolBar2Buttons()[0]); @@ -500,11 +497,12 @@ public void loadPuzzleFromHome(String game, String[] statements) { } /** - * Prompts the user to select a puzzle file to open. - * Opens a file chooser dialog and returns the selected file's name and file object. - * If a puzzle is currently loaded, prompts the user to confirm if they want to open a new puzzle. + * Prompts the user to select a puzzle file to open. Opens a file chooser dialog and returns the + * selected file's name and file object. If a puzzle is currently loaded, prompts the user to + * confirm if they want to open a new puzzle. * - * @return an array containing the selected file name and file object, or null if the operation was canceled + * @return an array containing the selected file name and file object, or null if the operation + * was canceled */ public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); @@ -548,9 +546,9 @@ public Object[] promptPuzzle() { } /** - * Loads a puzzle by prompting the user to select a puzzle file. - * If the user cancels the operation, no action is taken. If a puzzle file is selected, - * it will be loaded using the file name and file object. + * Loads a puzzle by prompting the user to select a puzzle file. If the user cancels the + * operation, no action is taken. If a puzzle file is selected, it will be loaded using the file + * name and file object. */ public void loadPuzzle() { Object[] items = promptPuzzle(); @@ -564,9 +562,8 @@ public void loadPuzzle() { } /** - * Loads a puzzle from the specified file. - * If the puzzle file is valid and exists, it loads the puzzle and updates the UI. - * If the file format is invalid, an error message is displayed. + * Loads a puzzle from the specified file. If the puzzle file is valid and exists, it loads the + * puzzle and updates the UI. If the file format is invalid, an error message is displayed. * * @param fileName the name of the puzzle file * @param puzzleFile the file object representing the puzzle file @@ -595,9 +592,8 @@ public void loadPuzzle(String fileName, File puzzleFile) { } /** - * Displays a confirmation dialog with the given instruction message. - * The method returns true if the user selected "No" or cancelled the dialog, - * and false if the user selected "Yes". + * Displays a confirmation dialog with the given instruction message. The method returns true if + * the user selected "No" or cancelled the dialog, and false if the user selected "Yes". * * @param instr the instruction message to display in the confirmation dialog * @return true if the user selected "No" or canceled; false if the user selected "Yes" @@ -607,31 +603,21 @@ public boolean noQuit(String instr) { return n != JOptionPane.YES_OPTION; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public void onPushChange(ICommand command) {} - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public void onUndo(boolean isBottom, boolean isTop) {} - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public void onRedo(boolean isBottom, boolean isTop) {} - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override - public void onClearHistory() { - } - + public void onClearHistory() {} /** * Returns the current board view @@ -678,16 +664,14 @@ public void setToolBar2Buttons(JButton[] toolBar2Buttons) { this.toolBar2Buttons = toolBar2Buttons; } - /** - * Repaints the current board view - */ + /** Repaints the current board view */ private void repaintAll() { boardView.repaint(); } /** - * Sets the puzzle view based on the provided puzzle object. - * Updates the UI components to display the new puzzle. + * Sets the puzzle view based on the provided puzzle object. Updates the UI components to + * display the new puzzle. * * @param puzzle the puzzle object to display */ @@ -734,11 +718,11 @@ private void direct_save() { } /** - * Saves the current puzzle to a user-selected directory. - * Prompts the user to select a directory and saves the puzzle to that directory. - * Returns the path where the puzzle was saved. + * Saves the current puzzle to a user-selected directory. Prompts the user to select a directory + * and saves the puzzle to that directory. Returns the path where the puzzle was saved. * - * @return the path where the puzzle was saved, or an empty string if the save operation was canceled + * @return the path where the puzzle was saved, or an empty string if the save operation was + * canceled */ private String savePuzzle() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); diff --git a/src/main/java/edu/rpi/legup/ui/ScrollView.java b/src/main/java/edu/rpi/legup/ui/ScrollView.java index 18aff4d1c..589573154 100644 --- a/src/main/java/edu/rpi/legup/ui/ScrollView.java +++ b/src/main/java/edu/rpi/legup/ui/ScrollView.java @@ -7,8 +7,9 @@ import javax.swing.*; /** - * ScrollView extends {@link JScrollPane} to provide a customizable view with zoom and scroll capabilities. - * It uses a {@link ZoomablePane} as the canvas and allows for zooming and scrolling with respect to the canvas content. + * ScrollView extends {@link JScrollPane} to provide a customizable view with zoom and scroll + * capabilities. It uses a {@link ZoomablePane} as the canvas and allows for zooming and scrolling + * with respect to the canvas content. */ public class ScrollView extends JScrollPane { private static final Logger LOGGER = Logger.getLogger(ScrollView.class.getName()); @@ -170,7 +171,8 @@ public void zoom(int n, Point point) { } /** - * Adjusts the zoom level to the given scale and centers the viewport on the current center point + * Adjusts the zoom level to the given scale and centers the viewport on the current center + * point * * @param newScale the new scale to set */ diff --git a/src/main/java/edu/rpi/legup/ui/ToolbarName.java b/src/main/java/edu/rpi/legup/ui/ToolbarName.java index 53936a141..622d16d8d 100644 --- a/src/main/java/edu/rpi/legup/ui/ToolbarName.java +++ b/src/main/java/edu/rpi/legup/ui/ToolbarName.java @@ -1,8 +1,8 @@ package edu.rpi.legup.ui; /** - * This enum defines constants for toolbar names used in the user interface. - * Each represents a specific toolbar action. + * This enum defines constants for toolbar names used in the user interface. Each represents a + * specific toolbar action. */ public enum ToolbarName { DIRECTIONS, diff --git a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java index 34e828250..40f36113f 100644 --- a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java +++ b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java @@ -36,17 +36,13 @@ public ZoomWidget(ScrollView parent) { addMouseListener(open); } - /** - * A {@code JPopupMenu} subclass that contains a vertical slider for adjusting zoom level. - */ + /** A {@code JPopupMenu} subclass that contains a vertical slider for adjusting zoom level. */ private class PopupSlider extends JPopupMenu implements ChangeListener { private static final long serialVersionUID = 8225019381200459814L; private JSlider slider; - /** - * Constructs a {@code PopupSlider} with a vertical slider - */ + /** Constructs a {@code PopupSlider} with a vertical slider */ public PopupSlider() { slider = new JSlider(SwingConstants.VERTICAL, 0, 400, 200); slider.setMajorTickSpacing(25); diff --git a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java index fa3ec70b7..18b47d98b 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java @@ -12,8 +12,8 @@ import java.util.ArrayList; /** - * An abstract class representing a view for a board in the puzzle game. - * It handles the visual representation and user interactions with the board elements. + * An abstract class representing a view for a board in the puzzle game. It handles the visual + * representation and user interactions with the board elements. */ public abstract class BoardView extends ScrollView implements IBoardListener { protected TreeElement treeElement; @@ -129,9 +129,7 @@ public void setBoard(Board board) { } } - /** - * Configures the view to handle case interactions - */ + /** Configures the view to handle case interactions */ protected void setCasePickable() { CaseBoard caseBoard = (CaseBoard) board; Board baseBoard = caseBoard.getBaseBoard(); @@ -199,7 +197,6 @@ public ElementController getElementController() { return elementController; } - @Override public void draw(Graphics2D graphics2D) { drawBoard(graphics2D); diff --git a/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java b/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java index a3d82b461..bc40e3d58 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java @@ -6,8 +6,8 @@ import javax.swing.border.BevelBorder; /** - * DataSelectionView is a popup menu used for selecting data elements. - * It extends JPopupMenu and is styled with a gray background and a raised bevel border. + * DataSelectionView is a popup menu used for selecting data elements. It extends JPopupMenu and is + * styled with a gray background and a raised bevel border. */ public class DataSelectionView extends JPopupMenu { diff --git a/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java b/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java index 9ad4132d6..eaa85082d 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java @@ -4,8 +4,8 @@ import java.util.ArrayList; /** - * ElementSelection manages the selection and hover states of ElementViews. - * It maintains a list of selected elements, the currently hovered element, and the mouse point location. + * ElementSelection manages the selection and hover states of ElementViews. It maintains a list of + * selected elements, the currently hovered element, and the mouse point location. */ public class ElementSelection { private ArrayList selection; @@ -40,8 +40,8 @@ public ElementView getFirstSelection() { } /** - * Toggles the selection state of an ElementView. - * If the ElementView is currently selected, it is deselected. Otherwise, it is selected. + * Toggles the selection state of an ElementView. If the ElementView is currently selected, it + * is deselected. Otherwise, it is selected. * * @param elementView the ElementView to toggle */ @@ -56,7 +56,8 @@ public void toggleSelection(ElementView elementView) { } /** - * Sets a new selection, clearing the previous selection and selecting the specified ElementView. + * Sets a new selection, clearing the previous selection and selecting the specified + * ElementView. * * @param elementView the ElementView to select */ @@ -66,9 +67,7 @@ public void newSelection(ElementView elementView) { elementView.setSelected(true); } - /** - * Clears the selection and deselects all ElementViews - */ + /** Clears the selection and deselects all ElementViews */ public void clearSelection() { for (ElementView elementView : selection) { elementView.setSelected(false); @@ -98,9 +97,7 @@ public void newHover(ElementView newHovered) { hover = newHovered; } - /** - * Clears the current hover state if there exists one - */ + /** Clears the current hover state if there exists one */ public void clearHover() { if (hover != null) { hover.setHover(false); diff --git a/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java b/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java index ad6cd3d3f..eab13cc1d 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java @@ -10,8 +10,8 @@ import javax.swing.*; /** - * ElementView represents a visual representation of a PuzzleElement. - * It handles drawing, selection, hover states, and interaction with the PuzzleElement. + * ElementView represents a visual representation of a PuzzleElement. It handles drawing, selection, + * hover states, and interaction with the PuzzleElement. */ public abstract class ElementView implements Shape { protected int index; @@ -78,7 +78,8 @@ public void draw(Graphics2D graphics2D) { } /** - * Draws the basic element representation (e.g., border, text) on the provided Graphics2D context. + * Draws the basic element representation (e.g., border, text) on the provided Graphics2D + * context. * * @param graphics2D the Graphics2D context to use for drawing */ @@ -331,7 +332,8 @@ public JMenuItem getSelectionMenuItem() { * * @param x the x-coordinate of the point to check * @param y the y-coordinate of the point to check - * @return {@code true} if the point is within the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this ElementView; {@code false} + * otherwise */ @Override public boolean contains(double x, double y) { @@ -345,7 +347,8 @@ public boolean contains(double x, double y) { * Determines if the specified Point2D object is within the bounds of this ElementView * * @param point the Point2D object representing the point to check - * @return {@code true} if the point is within the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this ElementView; {@code false} + * otherwise */ @Override public boolean contains(Point2D point) { @@ -353,13 +356,15 @@ public boolean contains(Point2D point) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) intersects with the bounds of this ElementView. + * Determines if the specified rectangle defined by (x, y, width, height) intersects with the + * bounds of this ElementView. * * @param x The x-coordinate of the rectangle to check * @param y The y-coordinate of the rectangle to check * @param width The width of the rectangle to check * @param height The height of the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this ElementView; {@code + * false} otherwise */ @Override public boolean intersects(double x, double y, double width, double height) { @@ -368,10 +373,12 @@ public boolean intersects(double x, double y, double width, double height) { } /** - * Determines if the specified Rectangle2D object intersects with the bounds of this ElementView. + * Determines if the specified Rectangle2D object intersects with the bounds of this + * ElementView. * * @param rectangle2D the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this ElementView; {@code + * false} otherwise */ @Override public boolean intersects(Rectangle2D rectangle2D) { @@ -383,13 +390,15 @@ public boolean intersects(Rectangle2D rectangle2D) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained within the bounds of this ElementView + * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained + * within the bounds of this ElementView * * @param x the x-coordinate of the rectangle to check * @param y the y-coordinate of the rectangle to check * @param width the width of the rectangle to check * @param height the height of the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * ElementView; {@code false} otherwise */ @Override public boolean contains(double x, double y, double width, double height) { @@ -398,10 +407,12 @@ public boolean contains(double x, double y, double width, double height) { } /** - * Determines if the specified Rectangle2D object is entirely contained within the bounds of this ElementView. + * Determines if the specified Rectangle2D object is entirely contained within the bounds of + * this ElementView. * * @param rectangle2D the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this ElementView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * ElementView; {@code false} otherwise */ @Override public boolean contains(Rectangle2D rectangle2D) { @@ -412,10 +423,9 @@ public boolean contains(Rectangle2D rectangle2D) { rectangle2D.getHeight()); } - /** - * Returns an iterator over the path geometry of this ElementView. The iterator provides access to the path's - * segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this ElementView. The iterator provides access + * to the path's segments and their coordinates, which can be used for rendering or hit testing. * * @param at the AffineTransform to apply to the path geometry * @return a PathIterator that iterates over the path geometry of this ElementView @@ -426,8 +436,9 @@ public PathIterator getPathIterator(AffineTransform at) { } /** - * Returns an iterator over the path geometry of this ElementView with the specified flatness. The iterator provides - * access to the path's segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this ElementView with the specified flatness. + * The iterator provides access to the path's segments and their coordinates, which can be used + * for rendering or hit testing. * * @param at the AffineTransform to apply to the path geometry * @param flatness the maximum distance that the line segments can deviate from the true path diff --git a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java index 1baa34b3a..e2b8bbc12 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java @@ -6,9 +6,8 @@ import java.awt.Dimension; /** - * A view class for a grid-based board that displays elements in a grid layout. - * This class extends BoardView and is responsible for managing and rendering - * grid-based elements. + * A view class for a grid-based board that displays elements in a grid layout. This class extends + * BoardView and is responsible for managing and rendering grid-based elements. */ public class GridBoardView extends BoardView { protected Dimension gridSize; @@ -57,8 +56,8 @@ public GridElementView getElement(int index) { } /** - * Retrieves the GridElementView at the specified grid coordinates (xIndex, yIndex). - * Returns null if the coordinates are out of bounds. + * Retrieves the GridElementView at the specified grid coordinates (xIndex, yIndex). Returns + * null if the coordinates are out of bounds. * * @param xIndex the x-coordinate (column) of the element view to retrieve * @param yIndex the y-coordinate (row) of the element view to retrieve @@ -72,8 +71,8 @@ public GridElementView getElement(int xIndex, int yIndex) { } /** - * Initializes the initial dimension of the viewport for the GridBoardView. - * Sets the size of the board view and adjusts the zoom to fit. + * Initializes the initial dimension of the viewport for the GridBoardView. Sets the size of the + * board view and adjusts the zoom to fit. */ @Override public void initSize() { @@ -94,8 +93,8 @@ protected Dimension getProperSize() { } /** - * Retrieves the selection popup menu for data selection. - * Currently returns null as there is no implementation. + * Retrieves the selection popup menu for data selection. Currently returns null as there is no + * implementation. * * @return null */ diff --git a/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java b/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java index 31e8fcd6c..587ba9efb 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java @@ -3,9 +3,8 @@ import edu.rpi.legup.model.gameboard.GridCell; /** - * A view class for a grid cell element in the board. - * This class extends ElementView and represents a specific type of element view - * associated with a GridCell. + * A view class for a grid cell element in the board. This class extends ElementView and represents + * a specific type of element view associated with a GridCell. */ public class GridElementView extends ElementView { public GridElementView(GridCell cell) { diff --git a/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java b/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java index 15deb86d1..6a1429a61 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java @@ -4,17 +4,16 @@ import javax.swing.*; /** - * A menu item view class that represents a selectable item in a menu, associated with a PuzzleElement. - * This class extends JMenuItem and provides additional functionality to - * handle PuzzleElement data. + * A menu item view class that represents a selectable item in a menu, associated with a + * PuzzleElement. This class extends JMenuItem and provides additional functionality to handle + * PuzzleElement data. */ public class SelectionItemView extends JMenuItem { private PuzzleElement data; /** - * Constructs a SelectionItemView with the specified PuzzleElement and icon. - * Initializes the menu item with the given icon and associates it with the - * provided PuzzleElement. + * Constructs a SelectionItemView with the specified PuzzleElement and icon. Initializes the + * menu item with the given icon and associates it with the provided PuzzleElement. * * @param data the PuzzleElement associated with this menu item * @param icon the icon to be displayed on the menu item @@ -25,9 +24,8 @@ public SelectionItemView(PuzzleElement data, Icon icon) { } /** - * Constructs a SelectionItemView with the specified PuzzleElement and display text. - * Initializes the menu item with the given display text and associates it with the - * provided PuzzleElement. + * Constructs a SelectionItemView with the specified PuzzleElement and display text. Initializes + * the menu item with the given display text and associates it with the provided PuzzleElement. * * @param data the PuzzleElement associated with this menu item * @param display the text to be displayed on the menu item @@ -39,8 +37,8 @@ public SelectionItemView(PuzzleElement data, String display) { /** * Constructs a SelectionItemView with the specified PuzzleElement and display integer. - * Initializes the menu item with the integer converted to a string and associates it with - * the provided PuzzleElement. + * Initializes the menu item with the integer converted to a string and associates it with the + * provided PuzzleElement. * * @param data the PuzzleElement associated with this menu item * @param display the integer to be displayed on the menu item @@ -51,8 +49,8 @@ public SelectionItemView(PuzzleElement data, int display) { } /** - * Constructs a SelectionItemView with the specified PuzzleElement. - * Initializes the menu item with the data's integer representation as display text. + * Constructs a SelectionItemView with the specified PuzzleElement. Initializes the menu item + * with the data's integer representation as display text. * * @param data the PuzzleElement associated with this menu item */ diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java index 849c5c145..4d7bb378d 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java @@ -3,10 +3,10 @@ import javax.swing.ImageIcon; /** - * The {@code CaseRulePanel} class is a specialized panel that represents case rules - * within a {@link RuleFrame}. It extends the {@link RulePanel} and provides - * specific functionality and UI components related to case rules. - * This class initializes with an icon and name that are specific to case rules. + * The {@code CaseRulePanel} class is a specialized panel that represents case rules within a {@link + * RuleFrame}. It extends the {@link RulePanel} and provides specific functionality and UI + * components related to case rules. This class initializes with an icon and name that are specific + * to case rules. */ public class CaseRulePanel extends RulePanel { /** diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java index 5bed7e17d..92e747305 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java @@ -3,13 +3,12 @@ import javax.swing.*; /** - * The {@code ContradictionRulePanel} class is a specialized panel that represents contradiction rules - * within a {@link RuleFrame}. It extends the {@link RulePanel} and provides - * specific functionality and UI components related to contradiction rules. - * This class initializes with an icon and name that are specific to contradiction rules. + * The {@code ContradictionRulePanel} class is a specialized panel that represents contradiction + * rules within a {@link RuleFrame}. It extends the {@link RulePanel} and provides specific + * functionality and UI components related to contradiction rules. This class initializes with an + * icon and name that are specific to contradiction rules. */ - - public class ContradictionRulePanel extends RulePanel { +public class ContradictionRulePanel extends RulePanel { /** * ContradictionRulePanel Constructor creates a ContradictionRulePanel * diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/DirectRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/DirectRulePanel.java index c1562eb70..17fcac5bb 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/DirectRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/DirectRulePanel.java @@ -5,12 +5,12 @@ import org.apache.logging.log4j.Logger; /** - * The {@code DirectRulePanel} class is a specialized panel that represents direct rules - * within a {@link RuleFrame}. It extends the {@link RulePanel} and provides - * specific functionality and UI components related to direct rules. - * This class initializes with an icon and name that are specific to direct rules. + * The {@code DirectRulePanel} class is a specialized panel that represents direct rules within a + * {@link RuleFrame}. It extends the {@link RulePanel} and provides specific functionality and UI + * components related to direct rules. This class initializes with an icon and name that are + * specific to direct rules. */ - public class DirectRulePanel extends RulePanel { +public class DirectRulePanel extends RulePanel { private static final Logger LOGGER = LogManager.getLogger(DirectRulePanel.class.getName()); /** 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 7222603bc..929f211d0 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 @@ -4,9 +4,9 @@ import javax.swing.*; /** - * The {@code RuleButton} class is a custom button that represents a rule in the user interface. - * It extends {@link JButton} and is designed to display a rule's name and icon. - * The button is initialized with a {@link Rule} object, which provides the name and icon for the button. + * The {@code RuleButton} class is a custom button that represents a rule in the user interface. It + * extends {@link JButton} and is designed to display a rule's name and icon. The button is + * initialized with a {@link Rule} object, which provides the name and icon for the button. */ public class RuleButton extends JButton { private Rule rule; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java index 3131f474d..b14091351 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java @@ -12,10 +12,10 @@ /** * The {@code RuleFrame} class is a panel that contains and manages multiple rule-related panels - * within a tabbed interface. It extends {@link JPanel} and organizes the display of various rule types - * such as direct rules, contradiction rules, and case rules. - * The frame uses a {@link JTabbedPane} to allow users to switch between different rule panels. - * It also includes a search bar panel and a status label for displaying additional information. + * within a tabbed interface. It extends {@link JPanel} and organizes the display of various rule + * types such as direct rules, contradiction rules, and case rules. The frame uses a {@link + * JTabbedPane} to allow users to switch between different rule panels. It also includes a search + * bar panel and a status label for displaying additional information. */ public class RuleFrame extends JPanel { private static final String checkBox = " \u2714 "; @@ -36,8 +36,8 @@ public class RuleFrame extends JPanel { private RuleController controller; /** - * Constructs a new {@code RuleFrame} instance. - * Initializes the frame with tabs for the different rule panels, a search bar panel, and a status label. + * Constructs a new {@code RuleFrame} instance. Initializes the frame with tabs for the + * different rule panels, a search bar panel, and a status label. * * @param controller the {@link RuleController} instance that manages the rules for this frame */ 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 4c9ebf882..85ddf82b5 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 @@ -10,8 +10,8 @@ import javax.swing.*; /** - * Abstract base class for panels displaying rules. Each subclass will represent a specific type - * of rule panel (e.g., DirectRulePanel, CaseRulePanel). + * Abstract base class for panels displaying rules. Each subclass will represent a specific type of + * rule panel (e.g., DirectRulePanel, CaseRulePanel). */ public abstract class RulePanel extends JPanel { protected ImageIcon icon; @@ -59,7 +59,8 @@ public void setRules(List rules) { Rule rule = rules.get(i); ruleButtons[i] = new RuleButton(rule); - ruleButtons[i].setPreferredSize(new Dimension(150, 150)); // adjust the size of each RuleButton + ruleButtons[i].setPreferredSize( + new Dimension(150, 150)); // adjust the size of each RuleButton if (rule.getRuleName().length() > 18) { ruleButtons[i].setFont(new Font("Segoe UI", Font.PLAIN, 11)); @@ -73,16 +74,15 @@ public void setRules(List rules) { ruleButtons[i].setVerticalTextPosition(JButton.BOTTOM); ruleFrame.getButtonGroup().add(ruleButtons[i]); - ruleButtons[i].setToolTipText(rule.getRuleName() + ": " + rule.getDescription()); // showing description + ruleButtons[i].setToolTipText( + rule.getRuleName() + ": " + rule.getDescription()); // showing description ruleButtons[i].addActionListener(ruleFrame.getController()); add(ruleButtons[i]); } revalidate(); } - /** - * Updates the rules displayed by reloading images and setting the rules again. - */ + /** Updates the rules displayed by reloading images and setting the rules again. */ public void updateRules() { for (Rule rule : rules) { rule.loadImage(); 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 842859ce2..60e24b986 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 @@ -2,10 +2,10 @@ import javax.swing.*; - /** - * The {@code SearchBarPanel} class creates a panel that allows users to search for rules within the rule frame. - * This panel provides a search bar for entering rule names and finding corresponding rules. + * The {@code SearchBarPanel} class creates a panel that allows users to search for rules within the + * rule frame. This panel provides a search bar for entering rule names and finding corresponding + * rules. */ public class SearchBarPanel extends RulePanel { /** diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java index 228e69950..e5e523e11 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java @@ -5,10 +5,9 @@ import java.awt.*; /** - * Abstract base class for views of tree elements in the tree structure. - * This class implements the Shape interface to support custom drawing and interaction - * with tree elements. - * It holds properties for rendering, interaction, and layout of the tree elements. + * Abstract base class for views of tree elements in the tree structure. This class implements the + * Shape interface to support custom drawing and interaction with tree elements. It holds properties + * for rendering, interaction, and layout of the tree elements. */ public abstract class TreeElementView implements Shape { protected TreeElement treeElement; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java index 0e2a31bbf..c9aedaef3 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java @@ -8,10 +8,10 @@ import java.util.ArrayList; /** - * Represents a view of a tree node in the tree structure. - * This class extends {@link TreeElementView} and provides specific rendering and interaction - * functionality for tree nodes. It includes visual properties and methods to manage the - * node's appearance, location, and its relationships with other nodes. + * Represents a view of a tree node in the tree structure. This class extends {@link + * TreeElementView} and provides specific rendering and interaction functionality for tree nodes. It + * includes visual properties and methods to manage the node's appearance, location, and its + * relationships with other nodes. */ public class TreeNodeView extends TreeElementView { static final int RADIUS = 25; @@ -291,7 +291,8 @@ public Rectangle2D getBounds2D() { * * @param x the x-coordinate of the point to check * @param y the y-coordinate of the point to check - * @return {@code true} if the point is within the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this TreeNodeView; {@code false} + * otherwise */ @Override public boolean contains(double x, double y) { @@ -302,7 +303,8 @@ public boolean contains(double x, double y) { * Determines if the specified Point2D object is within the bounds of this TreeNodeView * * @param p the Point2D object representing the point to check - * @return {@code true} if the point is within the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this TreeNodeView; {@code false} + * otherwise */ @Override public boolean contains(Point2D p) { @@ -310,13 +312,15 @@ public boolean contains(Point2D p) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) intersects with the bounds of this TreeNodeView. + * Determines if the specified rectangle defined by (x, y, width, height) intersects with the + * bounds of this TreeNodeView. * * @param x The x-coordinate of the rectangle to check * @param y The y-coordinate of the rectangle to check * @param w The width of the rectangle to check * @param h The height of the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this TreeNodeView; {@code + * false} otherwise */ @Override public boolean intersects(double x, double y, double w, double h) { @@ -324,10 +328,12 @@ public boolean intersects(double x, double y, double w, double h) { } /** - * Determines if the specified Rectangle2D object intersects with the bounds of this TreeNodeView. + * Determines if the specified Rectangle2D object intersects with the bounds of this + * TreeNodeView. * * @param r the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this TreeNodeView; {@code + * false} otherwise */ @Override public boolean intersects(Rectangle2D r) { @@ -335,13 +341,15 @@ public boolean intersects(Rectangle2D r) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained within the bounds of this TreeNodeView + * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained + * within the bounds of this TreeNodeView * * @param x the x-coordinate of the rectangle to check * @param y the y-coordinate of the rectangle to check * @param w the width of the rectangle to check * @param h the height of the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * TreeNodeView; {@code false} otherwise */ @Override public boolean contains(double x, double y, double w, double h) { @@ -349,10 +357,12 @@ public boolean contains(double x, double y, double w, double h) { } /** - * Determines if the specified Rectangle2D object is entirely contained within the bounds of this TreeNodeView. + * Determines if the specified Rectangle2D object is entirely contained within the bounds of + * this TreeNodeView. * * @param r the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this TreeNodeView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * TreeNodeView; {@code false} otherwise */ @Override public boolean contains(Rectangle2D r) { @@ -360,8 +370,8 @@ public boolean contains(Rectangle2D r) { } /** - * Returns an iterator over the path geometry of this TreeNodeView. The iterator provides access to the path's - * segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this TreeNodeView. The iterator provides access + * to the path's segments and their coordinates, which can be used for rendering or hit testing. * * @param at the AffineTransform to apply to the path geometry * @return a PathIterator that iterates over the path geometry of this TreeNodeView @@ -372,8 +382,9 @@ public PathIterator getPathIterator(AffineTransform at) { } /** - * Returns an iterator over the path geometry of this TreeNodeView with the specified flatness. The iterator provides - * access to the path's segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this TreeNodeView with the specified flatness. + * The iterator provides access to the path's segments and their coordinates, which can be used + * for rendering or hit testing. * * @param at the AffineTransform to apply to the path geometry * @param flatness the maximum distance that the line segments can deviate from the true path diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java index 4bef664bd..936b0de95 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java @@ -17,11 +17,10 @@ import javax.swing.JPanel; import javax.swing.border.TitledBorder; - /** - * {@code TreePanel} is a JPanel that manages and displays a tree view with associated toolbar and status information. - * It provides methods to interact with the tree view, such as adding, deleting, and merging tree elements, - * and updating the status based on actions performed. + * {@code TreePanel} is a JPanel that manages and displays a tree view with associated toolbar and + * status information. It provides methods to interact with the tree view, such as adding, deleting, + * and merging tree elements, and updating the status based on actions performed. */ public class TreePanel extends JPanel { public boolean modifiedSinceSave = false; @@ -35,9 +34,7 @@ public class TreePanel extends JPanel { private JLabel status; - /** - * Constructs a {@code TreePanel} and initializes the UI components. - */ + /** Constructs a {@code TreePanel} and initializes the UI components. */ public TreePanel(/*LegupUI legupUI*/ ) { // this.legupUI = legupUI; @@ -91,9 +88,8 @@ public void boardDataChanged(Board board) { } /** - * Updates the status display based on the status timer. - * If the timer is greater than 0, the status will not be updated. - * Otherwise, it clears the status text. + * Updates the status display based on the status timer. If the timer is greater than 0, the + * status will not be updated. Otherwise, it clears the status text. */ public void updateStatus() { updateStatusTimer = ((updateStatusTimer - 1) > 0) ? (updateStatusTimer - 1) : 0; @@ -135,8 +131,8 @@ public TreeView getTreeView() { } /** - * Adds a new tree element by executing an {@link AddTreeElementCommand}. - * If the command cannot be executed, it updates the status display with an error and error message. + * Adds a new tree element by executing an {@link AddTreeElementCommand}. If the command cannot + * be executed, it updates the status display with an error and error message. */ public void add() { TreeViewSelection selection = treeView.getSelection(); @@ -151,8 +147,8 @@ public void add() { } /** - * Deletes the selected tree element by executing a {@link DeleteTreeElementCommand}. - * If the command cannot be executed, it updates the status display with an error and an error message. + * Deletes the selected tree element by executing a {@link DeleteTreeElementCommand}. If the + * command cannot be executed, it updates the status display with an error and an error message. */ public void delete() { TreeViewSelection selection = treeView.getSelection(); @@ -167,8 +163,8 @@ public void delete() { } /** - * Merges selected tree elements by executing a {@link MergeCommand}. - * If the command cannot be executed, it updates the status display with an error and an error message. + * Merges selected tree elements by executing a {@link MergeCommand}. If the command cannot be + * executed, it updates the status display with an error and an error message. */ public void merge() { TreeViewSelection selection = treeView.getSelection(); @@ -183,8 +179,8 @@ public void merge() { } /** - * Toggles the collapsed state of the selected tree elements. - * If an element is collapsed, it will be expanded, and vice versa. + * Toggles the collapsed state of the selected tree elements. If an element is collapsed, it + * will be expanded, and vice versa. */ public void collapse() { TreeViewSelection selection = treeView.getSelection(); diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java index 214c735df..232498723 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java @@ -3,9 +3,7 @@ import java.awt.Dimension; import javax.swing.*; -/** - * {@code TreeToolBarButton} is a JButton that represents a button in the tree toolbar. - */ +/** {@code TreeToolBarButton} is a JButton that represents a button in the tree toolbar. */ public class TreeToolBarButton extends JButton { private TreeToolBarName name; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java index 500ed29c5..06af84c57 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java @@ -3,10 +3,9 @@ import java.awt.*; import javax.swing.*; - /** - * {@code TreeToolbarPanel} is a JPanel that provides a toolbar for managing tree elements in the tree view. - * It includes buttons for adding, deleting, merging, and collapsing nodes. + * {@code TreeToolbarPanel} is a JPanel that provides a toolbar for managing tree elements in the + * tree view. It includes buttons for adding, deleting, merging, and collapsing nodes. */ public class TreeToolbarPanel extends JPanel { private TreePanel treePanel; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java index 25c67bb5a..5a3aa7d5c 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java @@ -11,8 +11,8 @@ import java.util.List; /** - * {@code TreeTransitionView} is a visual representation of a tree transition in the tree view. - * It extends TreeElementView and displays a transition arrow between tree nodes and handles various + * {@code TreeTransitionView} is a visual representation of a tree transition in the tree view. It + * extends TreeElementView and displays a transition arrow between tree nodes and handles various * visual states such as selection, hover, and correctness. */ public class TreeTransitionView extends TreeElementView { @@ -342,7 +342,8 @@ public Rectangle2D getBounds2D() { * * @param x the x-coordinate of the point to check * @param y the y-coordinate of the point to check - * @return {@code true} if the point is within the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this TreeTransitionView; {@code + * false} otherwise */ @Override public boolean contains(double x, double y) { @@ -353,7 +354,8 @@ public boolean contains(double x, double y) { * Determines if the specified Point2D object is within the bounds of this TreeTransitionView * * @param p the Point2D object representing the point to check - * @return {@code true} if the point is within the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the point is within the bounds of this TreeTransitionView; {@code + * false} otherwise */ @Override public boolean contains(Point2D p) { @@ -361,13 +363,15 @@ public boolean contains(Point2D p) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) intersects with the bounds of this TreeTransitionView. + * Determines if the specified rectangle defined by (x, y, width, height) intersects with the + * bounds of this TreeTransitionView. * * @param x The x-coordinate of the rectangle to check * @param y The y-coordinate of the rectangle to check * @param w The width of the rectangle to check * @param h The height of the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this TreeTransitionView; + * {@code false} otherwise */ @Override public boolean intersects(double x, double y, double w, double h) { @@ -375,10 +379,12 @@ public boolean intersects(double x, double y, double w, double h) { } /** - * Determines if the specified Rectangle2D object intersects with the bounds of this TreeTransitionView. + * Determines if the specified Rectangle2D object intersects with the bounds of this + * TreeTransitionView. * * @param r the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle intersects with the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the rectangle intersects with the bounds of this TreeTransitionView; + * {@code false} otherwise */ @Override public boolean intersects(Rectangle2D r) { @@ -386,13 +392,15 @@ public boolean intersects(Rectangle2D r) { } /** - * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained within the bounds of this TreeTransitionView + * Determines if the specified rectangle defined by (x, y, width, height) is entirely contained + * within the bounds of this TreeTransitionView * * @param x the x-coordinate of the rectangle to check * @param y the y-coordinate of the rectangle to check * @param w the width of the rectangle to check * @param h the height of the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * TreeTransitionView; {@code false} otherwise */ @Override public boolean contains(double x, double y, double w, double h) { @@ -400,10 +408,12 @@ public boolean contains(double x, double y, double w, double h) { } /** - * Determines if the specified Rectangle2D object is entirely contained within the bounds of this TreeTransitionView. + * Determines if the specified Rectangle2D object is entirely contained within the bounds of + * this TreeTransitionView. * * @param r the Rectangle2D object representing the rectangle to check - * @return {@code true} if the rectangle is entirely contained within the bounds of this TreeTransitionView; {@code false} otherwise + * @return {@code true} if the rectangle is entirely contained within the bounds of this + * TreeTransitionView; {@code false} otherwise */ @Override public boolean contains(Rectangle2D r) { @@ -411,8 +421,9 @@ public boolean contains(Rectangle2D r) { } /** - * Returns an iterator over the path geometry of this TreeTransitionView. The iterator provides access to the path's - * segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this TreeTransitionView. The iterator provides + * access to the path's segments and their coordinates, which can be used for rendering or hit + * testing. * * @param at the AffineTransform to apply to the path geometry * @return a PathIterator that iterates over the path geometry of this TreeTransitionView @@ -423,8 +434,9 @@ public PathIterator getPathIterator(AffineTransform at) { } /** - * Returns an iterator over the path geometry of this TreeTransitionView with the specified flatness. The iterator provides - * access to the path's segments and their coordinates, which can be used for rendering or hit testing. + * Returns an iterator over the path geometry of this TreeTransitionView with the specified + * flatness. The iterator provides access to the path's segments and their coordinates, which + * can be used for rendering or hit testing. * * @param at the AffineTransform to apply to the path geometry * @param flatness the maximum distance that the line segments can deviate from the true path diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java index 490cf1480..65f49ff0a 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java @@ -28,9 +28,9 @@ /** * The {@code TreeView} class provides a graphical representation of a {@code Tree} structure, - * allowing interaction and visualization of tree elements, transitions, and selections. - * It extends {@code ScrollView} and implements {@code ITreeListener} to respond to updates - * in the tree structure. + * allowing interaction and visualization of tree elements, transitions, and selections. It extends + * {@code ScrollView} and implements {@code ITreeListener} to respond to updates in the tree + * structure. */ public class TreeView extends ScrollView implements ITreeListener { private static final Logger LOGGER = LogManager.getLogger(TreeView.class.getName()); @@ -169,9 +169,7 @@ public void setTree(Tree tree) { this.tree = tree; } - /** - * Updates the size of the tree view based on the bounds of its tree - */ + /** Updates the size of the tree view based on the bounds of its tree */ public void updateTreeSize() { if (GameBoardFacade.getInstance().getTree() == null) { return; @@ -179,9 +177,7 @@ public void updateTreeSize() { setSize(bounds.getSize()); } - /** - * Resets the view if the tree bounds have been modified - */ + /** Resets the view if the tree bounds have been modified */ public void reset() { if (bounds.x != 0 || bounds.y != 0) { updateTreeSize(); @@ -189,8 +185,8 @@ public void reset() { } /** - * Adjusts the zoom level to fit the entire tree within the viewport when - * the Resize Proof button is selected + * Adjusts the zoom level to fit the entire tree within the viewport when the Resize Proof + * button is selected */ public void zoomFit() { final int MIN_HEIGHT = 200; @@ -272,7 +268,8 @@ public void draw(Graphics2D graphics2D) { } /** - * Resets the zoom level to its default state and positions the viewport from the top-left corner + * Resets the zoom level to its default state and positions the viewport from the top-left + * corner */ public void zoomReset() { zoomTo(1.0); @@ -333,9 +330,7 @@ public void drawMouseOver(Graphics2D g) { } } - /** - * Resets the view by clearing the current tree, root node view, and selection - */ + /** Resets the view by clearing the current tree, root node view, and selection */ public void resetView() { this.tree = null; this.rootNodeView = null; @@ -538,7 +533,8 @@ public void removeTreeTransition(TreeTransition trans) { // Update transition modifiability if removing a case rule List parents = trans.getParents(); for (TreeNode parent : parents) { - // if transition is a case rule, unlock ancestor elements up until latest case rule or root node + // if transition is a case rule, unlock ancestor elements up until latest case rule or + // root node boolean nextAncestorIsCaseRule = false; Rule rule = trans.getRule(); if (rule instanceof CaseRule) { @@ -551,7 +547,8 @@ public void removeTreeTransition(TreeTransition trans) { break; } for (PuzzleElement element : parent.getBoard().getPuzzleElements()) { - PuzzleElement curElement = ancestors.get(i).getParent().getBoard().getPuzzleElement(element); + PuzzleElement curElement = + ancestors.get(i).getParent().getBoard().getPuzzleElement(element); if (!curElement.isModifiableCaseRule()) { curElement.setModifiableCaseRule(true); } @@ -593,7 +590,8 @@ private void addTreeNode(TreeNode node) { continue; } for (PuzzleElement element : - caseRule.dependentElements(node.getBoard(), node.getChildren().get(0).getSelection())) { + caseRule.dependentElements( + node.getBoard(), node.getChildren().get(0).getSelection())) { // increment and lock PuzzleElement oldElement = ancestor.getParent().getBoard().getPuzzleElement(element); @@ -634,7 +632,8 @@ private void addTreeTransition(TreeTransition trans) { } for (PuzzleElement element : parent.getBoard().getPuzzleElements()) { - PuzzleElement curElement = ancestor.getParent().getBoard().getPuzzleElement(element); + PuzzleElement curElement = + ancestor.getParent().getBoard().getPuzzleElement(element); curElement.setModifiableCaseRule(false); } } @@ -715,9 +714,9 @@ public void createViews(TreeNodeView nodeView) { } /** - * Calculates the layout locations (x and y coordinates) of the nodes in the tree. - * This method recursively traverses the tree and updates the positions of - * nodes and transitions based on their depth and parent relationships. + * Calculates the layout locations (x and y coordinates) of the nodes in the tree. This method + * recursively traverses the tree and updates the positions of nodes and transitions based on + * their depth and parent relationships. * * @param nodeView the node view to calculate the positions for * @param depth the depth of the node in the tree, used to calculate its x-coordinate @@ -828,9 +827,9 @@ public void calculateViewLocations(TreeNodeView nodeView, int depth) { } /** - * Calculates the span (height) required for the given view, including its children. - * This method recursively determines the span for nodes and transitions based on their - * children and the merging branches they belong to. + * Calculates the span (height) required for the given view, including its children. This method + * recursively determines the span for nodes and transitions based on their children and the + * merging branches they belong to. * * @param view the view whose span is to be calculated */ @@ -902,12 +901,12 @@ public void calcSpan(TreeElementView view) { } /** - * Calculates the span of a subtree rooted at the specified view, stopping at the given - * stop view. The stop view is not included in the span calculation. + * Calculates the span of a subtree rooted at the specified view, stopping at the given stop + * view. The stop view is not included in the span calculation. * * @param view the root view of the subtree to calculate the span for - * @param stop the view at which to stop the span calculation. The stop view itself is - * not included in the span calculation + * @param stop the view at which to stop the span calculation. The stop view itself is not + * included in the span calculation */ private void subCalcSpan(TreeElementView view, TreeElementView stop) { // safe-guard for infinite loop @@ -982,14 +981,14 @@ private void subCalcSpan(TreeElementView view, TreeElementView stop) { } /** - * Reorders the branches of a given node such that branches that merge are grouped together sequentially. - * Transitions are kept in their relative order based on their original positions in the list of child transitions - * of the specified node. This ensures that the visual representation of the branches and transitions maintains - * a logical and readable structure. + * Reorders the branches of a given node such that branches that merge are grouped together + * sequentially. Transitions are kept in their relative order based on their original positions + * in the list of child transitions of the specified node. This ensures that the visual + * representation of the branches and transitions maintains a logical and readable structure. * * @param node the root node whose branches are to be reordered - * @param branches a DisjointSets structure representing the merging relationships of the child branches of the - * specified node. This determines which branches should be grouped together + * @param branches a DisjointSets structure representing the merging relationships of the child + * branches of the specified node. This determines which branches should be grouped together */ private void reorderBranches(TreeNode node, DisjointSets branches) { List children = node.getChildren(); diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java index c7893b168..c509b6cb9 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.List; - /** - * {@code TreeViewSelection} manages the selection and hover state of tree element views in a tree view. - * It maintains a list of selected views, tracks the currently hovered view, and manages the mouse position. + * {@code TreeViewSelection} manages the selection and hover state of tree element views in a tree + * view. It maintains a list of selected views, tracks the currently hovered view, and manages the + * mouse position. */ public class TreeViewSelection { private ArrayList selectedViews; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index 97c76919e..1619ecbaa 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -2,7 +2,6 @@ import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.ui.lookandfeel.components.MaterialTabbedPaneUI; import java.awt.*; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -14,7 +13,7 @@ public class ElementFrame extends JPanel { private static final String htmlTail = ""; private PlaceableElementPanel placeableElementPanel; - //private JTabbedPane tabbedPane; + // private JTabbedPane tabbedPane; private ButtonGroup buttonGroup; private EditorElementController controller; @@ -53,12 +52,12 @@ public ButtonGroup getButtonGroup() { return buttonGroup; } -// public void resetSize() { -// int buttonWidth = -// ((ElementPanel) tabbedPane.getSelectedComponent()) -// .getElementButtons()[0].getWidth(); -// this.setMinimumSize(new Dimension(2 * buttonWidth + 64, this.getHeight())); -// } + // public void resetSize() { + // int buttonWidth = + // ((ElementPanel) tabbedPane.getSelectedComponent()) + // .getElementButtons()[0].getWidth(); + // this.setMinimumSize(new Dimension(2 * buttonWidth + 64, this.getHeight())); + // } public void setElements(Puzzle puzzle) { if (puzzle != null) { @@ -70,9 +69,9 @@ public EditorElementController getController() { return controller; } -// public JTabbedPane getTabbedPane() { -// return tabbedPane; -// } + // public JTabbedPane getTabbedPane() { + // return tabbedPane; + // } public PlaceableElementPanel getPlaceableElementPanel() { return placeableElementPanel; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java index 796d1ae68..91e8d2e49 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java @@ -1,8 +1,8 @@ -//package edu.rpi.legup.ui.puzzleeditorui.elementsview; +// package edu.rpi.legup.ui.puzzleeditorui.elementsview; // -//import javax.swing.*; +// import javax.swing.*; // -//public class NonPlaceableElementPanel extends ElementPanel { +// public class NonPlaceableElementPanel extends ElementPanel { // public NonPlaceableElementPanel(ElementFrame elementFrame) { // super(elementFrame); // this.icon = @@ -12,4 +12,4 @@ // this.name = "Non-Placeable Elements"; // this.toolTip = "Non-Placeable Elements"; // } -//} +// } diff --git a/src/test/java/legup/TestUtilities.java b/src/test/java/legup/TestUtilities.java index d48d648d7..cd9f4a935 100644 --- a/src/test/java/legup/TestUtilities.java +++ b/src/test/java/legup/TestUtilities.java @@ -6,7 +6,6 @@ import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.save.InvalidFileFormatException; - import java.io.InputStream; public final class TestUtilities { @@ -15,7 +14,8 @@ public static void importTestBoard(String fileName, Puzzle puzzle) InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName); if (inputStream == null) { - throw new IllegalArgumentException("InputStream cannot be null. File not found: " + fileName); + throw new IllegalArgumentException( + "InputStream cannot be null. File not found: " + fileName); } puzzle.importPuzzle(inputStream); diff --git a/src/test/java/puzzles/nurikabe/rules/FinishRoomCaseRuleTest.java b/src/test/java/puzzles/nurikabe/rules/FinishRoomCaseRuleTest.java index a29a1c934..32a440d13 100644 --- a/src/test/java/puzzles/nurikabe/rules/FinishRoomCaseRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/FinishRoomCaseRuleTest.java @@ -27,13 +27,11 @@ public static void setUp() { nurikabe = new Nurikabe(); } - /** - * Tests the Finish Room case rule by ensuring it produces the correct number of children - */ - + /** Tests the Finish Room case rule by ensuring it produces the correct number of children */ @Test public void FinishRoomCaseRule_FinishRoomCaseRuleBaseTest() throws InvalidFileFormatException { - TestUtilities.importTestBoard("puzzles/nurikabe/rules/FinishRoomCaseRule/FinishRoomCaseRuleBase", nurikabe); + TestUtilities.importTestBoard( + "puzzles/nurikabe/rules/FinishRoomCaseRule/FinishRoomCaseRuleBase", nurikabe); TreeNode rootNode = nurikabe.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE);