Skip to content

Commit

Permalink
Merge pull request #860 from Bram-Hub/auto-format-code-1727468924
Browse files Browse the repository at this point in the history
Automated Java code formatting changes
  • Loading branch information
jadeandtea authored Sep 27, 2024
2 parents 1cc1c45 + e0d3b3a commit d3965f5
Show file tree
Hide file tree
Showing 124 changed files with 1,013 additions and 1,037 deletions.
14 changes: 7 additions & 7 deletions src/main/java/edu/rpi/legup/app/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -110,8 +110,8 @@ public List<String> 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
*/
Expand Down
37 changes: 17 additions & 20 deletions src/main/java/edu/rpi/legup/app/GameBoardFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -76,9 +77,7 @@ public static synchronized GameBoardFacade getInstance() {
return instance;
}

/**
* Initializes the UI components
*/
/** Initializes the UI components */
public void initializeUI() {
EventQueue.invokeLater(
() -> {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);

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

}

/**
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/rpi/legup/app/InvalidConfigException.java
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/edu/rpi/legup/app/LegupPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
*/
Expand All @@ -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() {}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/rpi/legup/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/rpi/legup/controller/CursorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/edu/rpi/legup/controller/RuleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/rpi/legup/controller/TreeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

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

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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() {
Expand All @@ -64,10 +64,11 @@ public void executeCommand() {

TreeNode node = (TreeNode) selection.getFirstSelection().getTreeElement();
if (caseTrans.isEmpty()) {
List<Board> cases = caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement());
List<Board> 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());
Expand Down Expand Up @@ -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";
Expand All @@ -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() {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/edu/rpi/legup/history/CommandError.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
Loading

0 comments on commit d3965f5

Please sign in to comment.