From f476dd003d7009cabc2c7ce3d8e4b42fa2e49d1e Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 10 Mar 2026 14:55:25 -0400 Subject: [PATCH 01/13] add jetbrains to some LightUp files --- .../edu/rpi/legup/puzzle/lightup/LightUp.java | 12 +++++++----- .../rpi/legup/puzzle/lightup/LightUpBoard.java | 18 ++++++++++-------- .../rpi/legup/puzzle/lightup/LightUpCell.java | 12 +++++++----- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java index 605fad136..5de436ff3 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java @@ -7,6 +7,8 @@ import edu.rpi.legup.model.rules.ContradictionRule; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @RegisterPuzzle public class LightUp extends Puzzle { @@ -37,7 +39,7 @@ public void initializeView() { * @return board of the random edu.rpi.legup.puzzle */ @Override - public Board generatePuzzle(int difficulty) { + public @Nullable Board generatePuzzle(int difficulty) { return null; } @@ -60,7 +62,7 @@ public boolean isValidDimensions(int rows, int columns) { * @return true if board is valid, false otherwise */ @Override - public boolean isBoardComplete(Board board) { + public boolean isBoardComplete(@NotNull Board board) { LightUpBoard lightUpBoard = (LightUpBoard) board; lightUpBoard.fillWithLight(); @@ -75,7 +77,7 @@ public boolean isBoardComplete(Board board) { for (PuzzleElement data : lightUpBoard.getPuzzleElements()) { LightUpCell cell = (LightUpCell) data; if ((cell.getType() == LightUpCellType.UNKNOWN - || cell.getType() == LightUpCellType.EMPTY) + || cell.getType() == LightUpCellType.EMPTY) && !cell.isLite()) { return false; } @@ -89,5 +91,5 @@ public boolean isBoardComplete(Board board) { * @param board the board that has changed */ @Override - public void onBoardChange(Board board) {} -} + public void onBoardChange(@NotNull Board board) {} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpBoard.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpBoard.java index 21084b8c7..55cb10ce0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpBoard.java @@ -5,6 +5,8 @@ import java.awt.*; import java.util.HashSet; import java.util.Set; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class LightUpBoard extends GridBoard { public LightUpBoard(int width, int height) { @@ -74,7 +76,7 @@ public void fillWithLight() { * @param cell LightUpCell * @return Set of adjacent LightUpCells */ - public Set getAdj(LightUpCell cell) { + public @NotNull Set getAdj(@NotNull LightUpCell cell) { Set adjCells = new HashSet<>(); cell = (LightUpCell) getPuzzleElement(cell); @@ -105,7 +107,7 @@ public Set getAdj(LightUpCell cell) { * @param type specified type * @return the number of adjacent cells */ - public int getNumAdj(LightUpCell cell, LightUpCellType type) { + public int getNumAdj(@NotNull LightUpCell cell, @NotNull LightUpCellType type) { int num = 0; Set adjCells = getAdj(cell); for (LightUpCell c : adjCells) { @@ -122,7 +124,7 @@ public int getNumAdj(LightUpCell cell, LightUpCellType type) { * @param cell LightUpCell * @return number of adjacent cells */ - public int getNumAdjLite(LightUpCell cell) { + public int getNumAdjLite(@NotNull LightUpCell cell) { int num = 0; Set adjCells = getAdj(cell); for (LightUpCell c : adjCells) { @@ -139,7 +141,7 @@ public int getNumAdjLite(LightUpCell cell) { * @param cell specified cell * @return number of adjacent cells that are placeable */ - public int getNumPlaceable(LightUpCell cell) { + public int getNumPlaceable(@NotNull LightUpCell cell) { int num = 0; Set adjCells = getAdj(cell); for (LightUpCell c : adjCells) { @@ -151,18 +153,18 @@ public int getNumPlaceable(LightUpCell cell) { } @Override - public LightUpCell getCell(int x, int y) { + public @Nullable LightUpCell getCell(int x, int y) { return (LightUpCell) super.getCell(x, y); } @Override - public void notifyChange(PuzzleElement puzzleElement) { + public void notifyChange(@NotNull PuzzleElement puzzleElement) { super.notifyChange(puzzleElement); fillWithLight(); } @Override - public LightUpBoard copy() { + public @NotNull LightUpBoard copy() { LightUpBoard copy = new LightUpBoard(dimension.width, dimension.height); for (int x = 0; x < this.dimension.width; x++) { for (int y = 0; y < this.dimension.height; y++) { @@ -175,4 +177,4 @@ public LightUpBoard copy() { copy.fillWithLight(); return copy; } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java index 6d890e67b..a4b96ea6e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java @@ -4,17 +4,19 @@ import edu.rpi.legup.model.gameboard.GridCell; import java.awt.*; import java.awt.event.MouseEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class LightUpCell extends GridCell { private boolean isLite; - public LightUpCell(int valueInt, Point location) { + public LightUpCell(int valueInt, @NotNull Point location) { super(valueInt, location); this.isLite = false; } @Override - public void setType(Element e, MouseEvent m) { + public void setType(@NotNull Element e, @NotNull MouseEvent m) { switch (e.getElementID()) { case "LTUP-ELEM-0002": this.data = -4; @@ -46,7 +48,7 @@ public void setType(Element e, MouseEvent m) { } } - public LightUpCellType getType() { + public @Nullable LightUpCellType getType() { switch (data) { case -4: return LightUpCellType.BULB; @@ -73,11 +75,11 @@ public void setLite(boolean isLite) { } @Override - public LightUpCell copy() { + public @NotNull LightUpCell copy() { LightUpCell copy = new LightUpCell(data, (Point) location.clone()); copy.setIndex(index); copy.setModifiable(isModifiable); copy.setGiven(isGiven); return copy; } -} +} \ No newline at end of file From a6e61d5d203cdd5e9358154def18e95eac7a2c2c Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 10 Mar 2026 15:31:53 -0400 Subject: [PATCH 02/13] add jetbrains to more lightup files --- .../rpi/legup/puzzle/lightup/LightUpCellController.java | 5 +++-- .../edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java | 9 ++++++--- .../edu/rpi/legup/puzzle/lightup/LightUpElementView.java | 9 +++++---- .../edu/rpi/legup/puzzle/lightup/LightUpExporter.java | 3 ++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellController.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellController.java index d4049897d..b8f14053d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellController.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellController.java @@ -3,10 +3,11 @@ import edu.rpi.legup.controller.ElementController; import edu.rpi.legup.model.gameboard.PuzzleElement; import java.awt.event.MouseEvent; +import org.jetbrains.annotations.NotNull; public class LightUpCellController extends ElementController { @Override - public void changeCell(MouseEvent e, PuzzleElement data) { + public void changeCell(@NotNull MouseEvent e, @NotNull PuzzleElement data) { LightUpCell cell = (LightUpCell) data; if (e.getButton() == MouseEvent.BUTTON1) { if (e.isControlDown()) { @@ -41,4 +42,4 @@ public void changeCell(MouseEvent e, PuzzleElement data) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java index 2f83e9c0e..ba9837e02 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java @@ -8,6 +8,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import org.jetbrains.annotations.NotNull; public class LightUpCellFactory extends ElementFactory { /** @@ -19,7 +20,8 @@ public class LightUpCellFactory extends ElementFactory { * @throws InvalidFileFormatException if file is invalid */ @Override - public LightUpCell importCell(Node node, Board board) throws InvalidFileFormatException { + public @NotNull LightUpCell importCell(@NotNull Node node, @NotNull Board board) + throws InvalidFileFormatException { try { if (!node.getNodeName().equalsIgnoreCase("cell")) { throw new InvalidFileFormatException( @@ -60,7 +62,8 @@ public LightUpCell importCell(Node node, Board board) throws InvalidFileFormatEx * @param puzzleElement PuzzleElement cell * @return xml PuzzleElement */ - public org.w3c.dom.Element exportCell(Document document, PuzzleElement puzzleElement) { + public @NotNull org.w3c.dom.Element exportCell( + @NotNull Document document, @NotNull PuzzleElement puzzleElement) { org.w3c.dom.Element cellElement = document.createElement("cell"); LightUpCell cell = (LightUpCell) puzzleElement; @@ -72,4 +75,4 @@ public org.w3c.dom.Element exportCell(Document document, PuzzleElement puzzleEle return cellElement; } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java index 1b00b007d..c07a42144 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java @@ -2,6 +2,7 @@ import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; +import org.jetbrains.annotations.NotNull; public class LightUpElementView extends GridElementView { private static final Color LITE = new Color(0xFFF176); @@ -11,7 +12,7 @@ public class LightUpElementView extends GridElementView { private static final Color WHITE_COLOR = new Color(0xF5F5F5); private static final Color GRAY_COLOR = new Color(0x9E9E9E); - public LightUpElementView(LightUpCell cell) { + public LightUpElementView(@NotNull LightUpCell cell) { super(cell); } @@ -21,12 +22,12 @@ public LightUpElementView(LightUpCell cell) { * @return PuzzleElement associated with this view */ @Override - public LightUpCell getPuzzleElement() { + public @NotNull LightUpCell getPuzzleElement() { return (LightUpCell) super.getPuzzleElement(); } @Override - public void drawElement(Graphics2D graphics2D) { + public void drawElement(@NotNull Graphics2D graphics2D) { LightUpCell cell = (LightUpCell) puzzleElement; LightUpCellType type = cell.getType(); if (type == LightUpCellType.NUMBER) { @@ -86,4 +87,4 @@ public void drawElement(Graphics2D graphics2D) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java index 0e8987020..a92503afb 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java @@ -3,10 +3,11 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; import org.w3c.dom.Document; +import org.jetbrains.annotations.NotNull; public class LightUpExporter extends PuzzleExporter { - public LightUpExporter(LightUp lightUp) { + public LightUpExporter(@NotNull LightUp lightUp) { super(lightUp); } From 78110a758812d602e9c54fb00992c9ee3fe795d4 Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 10 Mar 2026 15:42:34 -0400 Subject: [PATCH 03/13] add jetbrains to common parent classes --- .../edu/rpi/legup/model/gameboard/ElementFactory.java | 8 +++++--- .../java/edu/rpi/legup/model/gameboard/GridBoard.java | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/gameboard/ElementFactory.java b/src/main/java/edu/rpi/legup/model/gameboard/ElementFactory.java index 131feb122..968ee03c7 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/ElementFactory.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/ElementFactory.java @@ -4,6 +4,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.jetbrains.annotations.NotNull; /** * ElementFactory is an abstract class for importing and exporting {@link PuzzleElement} instances. @@ -19,7 +20,7 @@ public abstract class ElementFactory { * @throws InvalidFileFormatException thrown if the xml node is invalid for the specific puzzle * element */ - public abstract PuzzleElement importCell(Node node, Board board) + public abstract @NotNull PuzzleElement importCell(@NotNull Node node, @NotNull Board board) throws InvalidFileFormatException; /** @@ -29,5 +30,6 @@ public abstract PuzzleElement importCell(Node node, Board board) * @param puzzleElement PuzzleElement cell * @return xml PuzzleElement */ - public abstract Element exportCell(Document document, PuzzleElement puzzleElement); -} + public abstract @NotNull Element exportCell( + @NotNull Document document, @NotNull PuzzleElement puzzleElement); +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/model/gameboard/GridBoard.java b/src/main/java/edu/rpi/legup/model/gameboard/GridBoard.java index 7338132f8..c684db2fd 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/GridBoard.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/GridBoard.java @@ -5,6 +5,8 @@ import edu.rpi.legup.puzzle.treetent.TreeTentClue; import java.awt.*; import java.awt.event.MouseEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * GridBoard represents a grid-based board where each cell can be manipulated based on its @@ -45,6 +47,7 @@ public GridBoard(int size) { * @param y y location of the cell * @return grid cell at location (x, y) */ + @Nullable public GridCell getCell(int x, int y) { if (y * dimension.width + x >= puzzleElements.size() || x >= dimension.width @@ -66,7 +69,7 @@ public GridCell getCell(int x, int y) { * @param y y location of the cell * @param cell grid cell to set at location (x,y) */ - public void setCell(int x, int y, GridCell cell) { + public void setCell(int x, int y, @NotNull GridCell cell) { if (y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || y >= dimension.height @@ -77,7 +80,7 @@ public void setCell(int x, int y, GridCell cell) { puzzleElements.set(y * dimension.width + x, cell); } - public void setCell(int x, int y, Element e, MouseEvent m) { + public void setCell(int x, int y, @Nullable Element e, @NotNull MouseEvent m) { if (this instanceof TreeTentBoard && ((y == dimension.height && 0 <= x && x < dimension.width) || (x == dimension.width && 0 <= y && y < dimension.height))) { @@ -153,6 +156,7 @@ public int getHeight() { * * @return the dimension of the grid board */ + @NotNull public Dimension getDimension() { return dimension; } @@ -162,6 +166,7 @@ public Dimension getDimension() { * * @return a new copy of the board that is independent of this one */ + @NotNull public GridBoard copy() { GridBoard newGridBoard = new GridBoard(this.dimension.width, this.dimension.height); for (int x = 0; x < this.dimension.width; x++) { From fedc66ddf7af11f26b94550b855571ea77886af3 Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 10 Mar 2026 16:56:16 -0400 Subject: [PATCH 04/13] test new yaml for publish javadoc --- .github/workflows/publish-javadoc.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index 2deed2b6e..a7ca5804a 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -1,18 +1,23 @@ -# modified from https://github.com/MathieuSoysal/Javadoc-publisher.yml - name: Publish Javadoc on: push: branches: - dev + - Fix-JavaDoc + workflow_dispatch: + permissions: contents: write jobs: publish: runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Publish JavaDoc uses: MathieuSoysal/Javadoc-publisher.yml@v2.4.0 with: From b6413d4a710b542059b7783622a334a75cce2e31 Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 17 Mar 2026 16:49:18 -0400 Subject: [PATCH 05/13] trying to fix error code in publish javadoc --- .github/workflows/publish-javadoc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index a7ca5804a..99c814b74 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -26,4 +26,5 @@ jobs: java-version: 21 java-distribution: temurin target-folder: docs - project: gradle \ No newline at end of file + project: gradle + gradle-command: ./gradlew javadoc \ No newline at end of file From 914c1a9e0a6af61755d0da58827520b66d1e1810 Mon Sep 17 00:00:00 2001 From: busabj Date: Fri, 20 Mar 2026 16:14:17 -0400 Subject: [PATCH 06/13] add conditional in build.gradle and command in yaml --- .github/workflows/publish-javadoc.yml | 2 +- build.gradle | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index 99c814b74..29ee900ea 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -27,4 +27,4 @@ jobs: java-distribution: temurin target-folder: docs project: gradle - gradle-command: ./gradlew javadoc \ No newline at end of file + gradle-command: ./gradlew javadoc -Pci \ No newline at end of file diff --git a/build.gradle b/build.gradle index c47be439b..24bff8fe4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,10 @@ plugins { id 'com.diffplug.spotless' version '6.25.0' } +if (!project.hasProperty("ci")) { + id 'edu.sc.seis.launch4j' version '2.5.3' +} + def versionFile = file('legup-update/src/main/resources/edu.rpi.legupupdate/VERSION') def appVersion = versionFile.exists() ? versionFile.text.trim() : 'VERSION_NOT_FOUND' version = appVersion From e1c630441a49b23cba81a2ebf9305dd7e78ebf1f Mon Sep 17 00:00:00 2001 From: busabj Date: Fri, 20 Mar 2026 17:27:35 -0400 Subject: [PATCH 07/13] fix conditional, silence warnings --- .github/workflows/publish-javadoc.yml | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index 29ee900ea..d4c91cdcc 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -27,4 +27,4 @@ jobs: java-distribution: temurin target-folder: docs project: gradle - gradle-command: ./gradlew javadoc -Pci \ No newline at end of file + custom-command: ./gradlew javadoc -Pci \ No newline at end of file diff --git a/build.gradle b/build.gradle index 24bff8fe4..e21b80795 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'edu.sc.seis.launch4j' version '2.5.3' + id 'edu.sc.seis.launch4j' version '2.5.3' apply false id 'kr.motd.sphinx' version '2.10.0' id 'com.diffplug.spotless' version '6.25.0' } From 128fef9b763c77e9d1f82072691d133c83e39ef3 Mon Sep 17 00:00:00 2001 From: busabj Date: Tue, 24 Mar 2026 16:40:24 -0400 Subject: [PATCH 08/13] add comment from old version --- .github/workflows/publish-javadoc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index d4c91cdcc..4ad5945ec 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -1,3 +1,5 @@ +# modified from https://github.com/MathieuSoysal/Javadoc-publisher.yml + name: Publish Javadoc on: From 1c59e44663202af553712fa6b6606723892051a7 Mon Sep 17 00:00:00 2001 From: busabj Date: Fri, 10 Apr 2026 20:35:10 -0400 Subject: [PATCH 09/13] add jetbrains and some javadoc comments to main files --- .../edu/rpi/legup/model/PuzzleImporter.java | 35 ++++++++++----- .../rpi/legup/puzzle/lightup/LightUpView.java | 14 ++++-- .../edu/rpi/legup/ui/boardview/BoardView.java | 44 +++++++++++++------ 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index adc510b79..9927a3c47 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -9,6 +9,8 @@ import java.util.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -29,7 +31,7 @@ public abstract class PuzzleImporter { * * @param puzzle puzzle that is imported */ - public PuzzleImporter(Puzzle puzzle) { + public PuzzleImporter(@NotNull Puzzle puzzle) { this.puzzle = puzzle; } @@ -60,7 +62,7 @@ public void initializePuzzle(int rows, int columns) throws RuntimeException { * @throws IllegalArgumentException if the statements are not suitable for initializing the * puzzle */ - public void initializePuzzle(String[] statements) + public void initializePuzzle(@NotNull String[] statements) throws InputMismatchException, IllegalArgumentException { // Note: Error checking for the statements will be left up to the puzzles that support // text input. For example, some puzzles may be okay with "blank" statements (Strings with @@ -74,7 +76,7 @@ public void initializePuzzle(String[] statements) * @param node the XML document node representing the puzzle * @throws InvalidFileFormatException if the file format is invalid */ - public void initializePuzzle(Node node) throws InvalidFileFormatException { + public void initializePuzzle(@NotNull Node node) throws InvalidFileFormatException { if (node.getNodeName().equalsIgnoreCase("puzzle")) { org.w3c.dom.Element puzzleElement = (org.w3c.dom.Element) node; @@ -143,7 +145,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * @param node the XML document node representing the board * @throws InvalidFileFormatException if the file format is invalid */ - public abstract void initializeBoard(Node node) throws InvalidFileFormatException; + public abstract void initializeBoard(@NotNull Node node) throws InvalidFileFormatException; /** * Initializes the board using an array of statements. @@ -153,7 +155,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * @throws IllegalArgumentException if the statements are not suitable for initializing the * board */ - public abstract void initializeBoard(String[] statements) + public abstract void initializeBoard(@NotNull String[] statements) throws UnsupportedOperationException, IllegalArgumentException; /** @@ -164,6 +166,7 @@ public abstract void initializeBoard(String[] statements) * @return A list of elements that will change when solving the puzzle * e.g. {"cell"}, {"cell", * "line"} */ + @NotNull public List getImporterElements() { List elements = new ArrayList<>(); elements.add("cell"); @@ -176,7 +179,7 @@ public List getImporterElements() { * @param node xml document node * @throws InvalidFileFormatException if file is invalid */ - public void initializeProof(Node node) throws InvalidFileFormatException { + public void initializeProof(@NotNull Node node) throws InvalidFileFormatException { if (node.getNodeName().equalsIgnoreCase("proof")) { org.w3c.dom.Element proofElement = (org.w3c.dom.Element) node; NodeList treeList = proofElement.getElementsByTagName("tree"); @@ -211,7 +214,7 @@ public void initializeProof(Node node) throws InvalidFileFormatException { * @param node xml document node * @throws InvalidFileFormatException if file is invalid */ - protected void setCells(Node node) throws InvalidFileFormatException { + protected void setCells(@NotNull Node node) throws InvalidFileFormatException { NodeList dataList = ((org.w3c.dom.Element) node).getElementsByTagName("cell"); Board board = puzzle.getCurrentBoard(); for (int i = 0; i < dataList.getLength(); i++) { @@ -227,7 +230,7 @@ protected void setCells(Node node) throws InvalidFileFormatException { * @param node xml document node * @throws InvalidFileFormatException if file is invalid */ - protected void createTree(Node node) throws InvalidFileFormatException { + protected void createTree(@NotNull Node node) throws InvalidFileFormatException { Element treeElement = (org.w3c.dom.Element) node; Tree tree = new Tree(); @@ -320,8 +323,16 @@ protected void createTree(Node node) throws InvalidFileFormatException { } } + /** + * Validates the structure of the proof tree, checking for disjoint or cyclic elements. + * + * @param nodes the map of node IDs to TreeNode objects + * @param transitions the map of transition IDs to TreeTransition objects + * @throws InvalidFileFormatException if the tree structure is invalid + */ protected void validateTreeStructure( - HashMap nodes, HashMap transitions) + @NotNull HashMap nodes, + @NotNull HashMap transitions) throws InvalidFileFormatException { Tree tree = puzzle.getTree(); @@ -402,7 +413,8 @@ protected void validateTreeStructure( * @throws InvalidFileFormatException if the XML node format is incorrect or unknown nodes are * encountered */ - protected void makeTransitionChanges(TreeTransition transition, Node transElement) + protected void makeTransitionChanges( + @NotNull TreeTransition transition, @NotNull Node transElement) throws InvalidFileFormatException { if (transition.getRule() instanceof MergeRule) { List mergingNodes = transition.getParents(); @@ -462,7 +474,8 @@ protected void createDefaultTree() { * * @return puzzle */ + @NotNull public Puzzle getPuzzle() { return puzzle; } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java index ebce6a682..00b116245 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java @@ -13,6 +13,7 @@ import javax.swing.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; public class LightUpView extends GridBoardView { private static final Logger LOGGER = LogManager.getLogger(LightUpView.class.getName()); @@ -29,7 +30,7 @@ public class LightUpView extends GridBoardView { } } - public LightUpView(LightUpBoard board) { + public LightUpView(@NotNull LightUpBoard board) { super(new BoardController(), new LightUpCellController(), board.getDimension()); for (PuzzleElement puzzleElement : board.getPuzzleElements()) { @@ -50,7 +51,7 @@ public LightUpView(LightUpBoard board) { * @param treeElement tree element */ @Override - public void onTreeElementChanged(TreeElement treeElement) { + public void onTreeElementChanged(@NotNull TreeElement treeElement) { super.onTreeElementChanged(treeElement); LightUpBoard lightUpBoard = board instanceof CaseBoard @@ -60,7 +61,12 @@ public void onTreeElementChanged(TreeElement treeElement) { repaint(); } - /** Returns a DataSelectionView popup menu */ + /** + * Returns a DataSelectionView popup menu + * + * @return a fully constructed DataSelectionView popup menu + */ + @NotNull public DataSelectionView getSelectionPopupMenu() { DataSelectionView selectionView = new DataSelectionView(elementController); GridLayout layout = new GridLayout(3, 1); @@ -101,4 +107,4 @@ public DataSelectionView getSelectionPopupMenu() { return selectionView; } -} +} \ No newline at end of file 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 18b47d98b..b1e269362 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java @@ -10,6 +10,8 @@ import edu.rpi.legup.ui.ScrollView; import java.awt.*; import java.util.ArrayList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An abstract class representing a view for a board in the puzzle game. It handles the visual @@ -29,7 +31,7 @@ public abstract class BoardView extends ScrollView implements IBoardListener { * @param boardController controller that handles the ui events * @param elementController controller that handles the ui events */ - public BoardView(BoardController boardController, ElementController elementController) { + public BoardView(@NotNull BoardController boardController, @NotNull ElementController elementController) { super(boardController); this.treeElement = null; this.board = null; @@ -51,6 +53,7 @@ public BoardView(BoardController boardController, ElementController elementContr * * @return dimension of the board view */ + @NotNull protected abstract Dimension getProperSize(); /** @@ -59,6 +62,7 @@ public BoardView(BoardController boardController, ElementController elementContr * @param index index of the ElementView * @return ElementView at the specified index */ + @Nullable public abstract ElementView getElement(int index); /** @@ -66,18 +70,19 @@ public BoardView(BoardController boardController, ElementController elementContr * * @param elements ElementView list */ - public void setElementViews(ArrayList elements) { + public void setElementViews(@NotNull ArrayList elements) { elementViews = elements; } /** - * Gets the ElementView from the location specified or null if one does not exists at that + * Gets the ElementView from the location specified or null if one does not exist at that * location * * @param point location on the viewport - * @return ElementView at the specified location + * @return ElementView at the specified location, or null if none exists */ - public ElementView getElement(Point point) { + @Nullable + public ElementView getElement(@NotNull Point point) { Point scaledPoint = new Point( (int) Math.round(point.x / getScale()), @@ -95,6 +100,7 @@ public ElementView getElement(Point point) { * * @return the ElementSelection */ + @NotNull public ElementSelection getSelection() { return selection; } @@ -104,6 +110,7 @@ public ElementSelection getSelection() { * * @return board */ + @Nullable public Board getBoard() { return board; } @@ -113,7 +120,7 @@ public Board getBoard() { * * @param board board */ - public void setBoard(Board board) { + public void setBoard(@NotNull Board board) { if (this.board != board) { this.board = board; @@ -149,7 +156,7 @@ protected void setCasePickable() { * @param treeElement tree element */ @Override - public void onTreeElementChanged(TreeElement treeElement) { + public void onTreeElementChanged(@NotNull TreeElement treeElement) { this.treeElement = treeElement; setBoard(treeElement.getBoard()); repaint(); @@ -161,11 +168,17 @@ public void onTreeElementChanged(TreeElement treeElement) { * @param caseBoard case board to be added */ @Override - public void onCaseBoardAdded(CaseBoard caseBoard) { + public void onCaseBoardAdded(@NotNull CaseBoard caseBoard) { setBoard(caseBoard); repaint(); } + /** + * Gets the current tree element + * + * @return the current TreeElement, or null if none is set + */ + @Nullable public TreeElement getTreeElement() { return this.treeElement; } @@ -180,10 +193,11 @@ public int getElementCount() { } /** - * Gets the PuzzleElements associated with the BoardView + * Gets the ElementViews associated with the BoardView * - * @return list of PuzzleElements + * @return list of ElementViews */ + @NotNull public ArrayList getElementViews() { return elementViews; } @@ -193,12 +207,13 @@ public ArrayList getElementViews() { * * @return the ElementController */ + @NotNull public ElementController getElementController() { return elementController; } @Override - public void draw(Graphics2D graphics2D) { + public void draw(@NotNull Graphics2D graphics2D) { drawBoard(graphics2D); } @@ -207,7 +222,7 @@ public void draw(Graphics2D graphics2D) { * * @param graphics2D the Graphics2D context used for drawing */ - public void drawBoard(Graphics2D graphics2D) { + public void drawBoard(@NotNull Graphics2D graphics2D) { for (ElementView element : elementViews) { element.draw(graphics2D); } @@ -219,7 +234,7 @@ public void drawBoard(Graphics2D graphics2D) { * @param puzzleElement puzzleElement of the puzzleElement that changed */ @Override - public void onBoardDataChanged(PuzzleElement puzzleElement) { + public void onBoardDataChanged(@NotNull PuzzleElement puzzleElement) { repaint(); } @@ -228,5 +243,6 @@ public void onBoardDataChanged(PuzzleElement puzzleElement) { * * @return the DataSelectionView associated with this view */ + @NotNull public abstract DataSelectionView getSelectionPopupMenu(); -} +} \ No newline at end of file From 4f9a6923d59cb2d51fea451dbfd45d46edb1980d Mon Sep 17 00:00:00 2001 From: busabj Date: Fri, 17 Apr 2026 17:10:12 -0400 Subject: [PATCH 10/13] attempt to fix errored-checks --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e21b80795..808bf1720 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } if (!project.hasProperty("ci")) { - id 'edu.sc.seis.launch4j' version '2.5.3' + apply plugin: 'edu.sc.seis.launch4j' } def versionFile = file('legup-update/src/main/resources/edu.rpi.legupupdate/VERSION') From efc7c4e2df231bc8a4f6faec5f3d0a333aadcd66 Mon Sep 17 00:00:00 2001 From: busabj Date: Mon, 20 Apr 2026 17:57:28 -0400 Subject: [PATCH 11/13] add Jetbrains Javadoc comments to UI files --- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 19 +++--- .../java/edu/rpi/legup/ui/DynamicView.java | 32 +++++----- src/main/java/edu/rpi/legup/ui/HomePanel.java | 63 +++++++++++-------- src/main/java/edu/rpi/legup/ui/LegupUI.java | 33 ++++++---- 4 files changed, 88 insertions(+), 59 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 97f166af7..873023048 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -11,6 +11,7 @@ import javax.swing.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * Provides the user interface components for creating a new puzzle in the Legup application. This @@ -34,7 +35,7 @@ public class CreatePuzzleDialog extends JDialog { * row/column fields are shown and the text input area is hidden. */ @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); String puzzleName = (String) comboBox.getSelectedItem(); if (puzzleName.equals("ShortTruthTable")) { @@ -72,7 +73,7 @@ public void actionPerformed(ActionEvent e) { * @param ae the event to be processed */ @Override - public void actionPerformed(ActionEvent ae) { + public void actionPerformed(@NotNull ActionEvent ae) { String game = getGame(); // Check if all 3 TextFields are filled @@ -113,7 +114,7 @@ public void actionPerformed(ActionEvent ae) { * @param e the event to be processed */ @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { dispose(); } }; @@ -124,7 +125,7 @@ public void actionPerformed(ActionEvent e) { * @param parent the parent frame of the dialog * @param homePanel the home panel where the created puzzle will be added */ - public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { + public CreatePuzzleDialog(@NotNull JFrame parent, @NotNull HomePanel homePanel) { super(parent, true); this.homePanel = homePanel; @@ -222,7 +223,7 @@ public void initPuzzles() { * * @param e The action event to be processed */ - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { if (e.getSource() == ok) { String game = Config.convertDisplayNameToClassName((String) gameBox.getSelectedItem()); @@ -255,6 +256,7 @@ public void actionPerformed(ActionEvent e) { * * @return the class name of the selected game */ + @NotNull public String getGame() { return Config.convertDisplayNameToClassName((String) gameBox.getSelectedItem()); } @@ -264,6 +266,7 @@ public String getGame() { * * @return the number of rows as a string */ + @NotNull public String getRows() { return rows.getText(); } @@ -273,6 +276,7 @@ public String getRows() { * * @return the number of columns as a string */ + @NotNull public String getColumns() { return columns.getText(); } @@ -280,9 +284,10 @@ public String getColumns() { /** * Retrieves the text entered in the text area, split by new lines. * - * @return an array of strings, each representing as a line of text + * @return an array of strings, each representing a line of text */ + @NotNull public String[] getTextArea() { return textArea.getText().split("\n"); } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/DynamicView.java b/src/main/java/edu/rpi/legup/ui/DynamicView.java index b92b4db04..1d8afbd68 100644 --- a/src/main/java/edu/rpi/legup/ui/DynamicView.java +++ b/src/main/java/edu/rpi/legup/ui/DynamicView.java @@ -14,6 +14,8 @@ import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.event.ChangeEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A JPanel that provides a dynamic view with zooming capabilities for different types of content. @@ -40,7 +42,7 @@ public class DynamicView extends JPanel { * @param scrollView the ScrollView that provides the content to be displayed and zoomed * @param type the type of dynamic view to set up (e.g., BOARD or PROOF_TREE) */ - public DynamicView(ScrollView scrollView, DynamicViewType type) { + public DynamicView(@NotNull ScrollView scrollView, @NotNull DynamicViewType type) { this.scrollView = scrollView; setLayout(new BorderLayout()); @@ -54,9 +56,10 @@ public DynamicView(ScrollView scrollView, DynamicViewType type) { * * @param type The DynamicView that we are setting up the zoomer for (so the zoomer for the * board view or the zoomer for the proof tree view) - * @return A JPanel containing the zoomer + * @return A JPanel containing the zoomer, or null if the type is unrecognized */ - private JPanel setUpZoomer(DynamicViewType type) { + @Nullable + private JPanel setUpZoomer(@NotNull DynamicViewType type) { if (type == DynamicViewType.BOARD) { return setUpBoardZoomer(); } else { @@ -74,6 +77,7 @@ private JPanel setUpZoomer(DynamicViewType type) { * * @return A JPanel containing the zoomer */ + @NotNull private JPanel setUpBoardZoomer() { final String label = "Resize Board"; ActionListener listener = (ActionListener) -> this.fitBoardViewToScreen(); @@ -85,6 +89,7 @@ private JPanel setUpBoardZoomer() { * * @return A JPanel containing the zoomer */ + @NotNull private JPanel setUpProofTreeZoomer() { final String label = "Resize Proof"; ActionListener listener = @@ -103,7 +108,8 @@ private JPanel setUpProofTreeZoomer() { * @param listener A listener that determines what the resize button will do * @return A JPanel containing the zoomer */ - private JPanel setUpZoomerHelper(final String label, ActionListener listener) { + @NotNull + private JPanel setUpZoomerHelper(@NotNull final String label, @NotNull ActionListener listener) { zoomWrapper = new JPanel(); try { zoomer = new JPanel(); @@ -166,7 +172,7 @@ private JPanel setUpZoomerHelper(final String label, ActionListener listener) { scrollView.addComponentListener( new ComponentAdapter() { @Override - public void componentResized(ComponentEvent e) { + public void componentResized(@NotNull ComponentEvent e) { zoomSlider.setValue((int) (scrollView.getZoom() / SLIDER_PRECISION)); zoomLabel.setText( (int) (zoomSlider.getValue() * SLIDER_PRECISION + 0.5) + "%"); @@ -184,13 +190,6 @@ public void componentResized(ComponentEvent e) { zoomSlider.setMinorTickSpacing((int) (25f / SLIDER_PRECISION)); zoomSlider.setPaintTicks(true); - // Hashtable labelTable = new Hashtable<>(); - // labelTable.put((int)(25f/SLIDER_PRECISION), new JLabel("25%")); - // labelTable.put((int)(100f/SLIDER_PRECISION), new JLabel("100%")); - // labelTable.put((int)(400f/SLIDER_PRECISION), new JLabel("400%")); - // zoomSlider.setLabelTable(labelTable); - // zoomSlider.setPaintLabels(true); - zoomer.setLayout(new FlowLayout()); zoomer.add(minus); @@ -214,6 +213,7 @@ public void componentResized(ComponentEvent e) { * * @return the ScrollView component */ + @NotNull public ScrollView getScrollView() { return this.scrollView; } @@ -223,6 +223,7 @@ public ScrollView getScrollView() { * * @return the zoom wrapper with zooming controls */ + @Nullable public JPanel getZoomWrapper() { return this.zoomWrapper; } @@ -232,6 +233,7 @@ public JPanel getZoomWrapper() { * * @return the zoomer with the zoomer component */ + @Nullable public JPanel getZoomer() { return this.zoomer; } @@ -241,7 +243,7 @@ public JPanel getZoomer() { * * @param message the informational message to display */ - public void updateInfo(String message) { + public void updateInfo(@NotNull String message) { status.setFont(INFO_FONT); status.setForeground(INFO_COLOR); status.setText(message); @@ -252,7 +254,7 @@ public void updateInfo(String message) { * * @param message the error message to display */ - public void updateError(String message) { + public void updateError(@NotNull String message) { status.setFont(ERROR_FONT); status.setForeground(ERROR_COLOR); status.setText(message); @@ -276,4 +278,4 @@ public void reset() { protected void fitBoardViewToScreen() { scrollView.zoomFit(); } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index dcaff3bdd..76a59dba5 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -25,6 +25,8 @@ import javax.xml.transform.stream.StreamResult; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -51,7 +53,7 @@ public class HomePanel extends LegupPanel { private ActionListener openProofListener = new ActionListener() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { legupUI.getProofEditor().loadPuzzle("", null); } }; @@ -62,7 +64,7 @@ public void actionPerformed(ActionEvent e) { * @param frame the main application frame * @param legupUI the LEGUP user interface */ - public HomePanel(JFrame frame, LegupUI legupUI) { + public HomePanel(@NotNull JFrame frame, @NotNull LegupUI legupUI) { this.legupUI = legupUI; this.frame = frame; setLayout(new GridLayout(1, 2)); @@ -76,6 +78,7 @@ public HomePanel(JFrame frame, LegupUI legupUI) { * * @return the menu bar */ + @NotNull public JMenuBar getMenuBar() { this.menuBar = new JMenuBar(); JMenu settings = new JMenu("Settings"); @@ -121,7 +124,8 @@ public void makeVisible() { * @param height the target height * @return the resized icon */ - private static ImageIcon resizeButtonIcon(ImageIcon icon, int width, int height) { + @NotNull + private static ImageIcon resizeButtonIcon(@NotNull ImageIcon icon, int width, int height) { Image image = icon.getImage(); Image resizedImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); return new ImageIcon(resizedImage); @@ -306,10 +310,11 @@ public void openBatchGraderMenu() { * 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. * + * @param folder the directory to process * @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(File folder) { + private void use_xml_to_check(@NotNull File folder) { /* Select a folder, go through each .xml file in the subfolders, look for "isSolved" flag */ File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { @@ -337,10 +342,13 @@ private void use_xml_to_check(File folder) { } /** - * @param file - the input file - * @return Parsed document of file if possible, null otherwise + * Attempts to parse the given file as an XML document. + * + * @param file the input file + * @return parsed Document of file if possible, null otherwise */ - public Document isxmlfile(File file) { + @Nullable + public Document isxmlfile(@NotNull File file) { Document doc = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -353,13 +361,14 @@ public Document isxmlfile(File file) { } /** - * reads the puzzle name and type, and outputs to .csv file + * Reads the puzzle name and type, and outputs to .csv file * - * @param doc - the parsed file currently being graded - * @param writer - write to .csv - * @throws IOException + * @param doc the parsed file currently being graded + * @param writer write to .csv + * @throws IOException if an I/O error occurs */ - private void parsePuzzle(Document doc, BufferedWriter writer) throws IOException { + private void parsePuzzle(@NotNull Document doc, @NotNull BufferedWriter writer) + throws IOException { NodeList puzzleNodes = doc.getElementsByTagName("puzzle"); if (puzzleNodes.getLength() <= 0) { writer.write("not a LEGUP puzzle!"); @@ -379,11 +388,12 @@ private void parsePuzzle(Document doc, BufferedWriter writer) throws IOException * Reads the hashed solved state and export timestamp, unhashes information and prints out to * csv * - * @param doc - the parsed file currently being graded - * @param writer - write to .csv - * @throws IOException + * @param doc the parsed file currently being graded + * @param writer write to .csv + * @throws IOException if an I/O error occurs */ - private void parseSolvedState(Document doc, BufferedWriter writer) throws IOException { + private void parseSolvedState(@NotNull Document doc, @NotNull BufferedWriter writer) + throws IOException { NodeList solvedNodes = doc.getElementsByTagName("solved"); if (solvedNodes.getLength() <= 0) { writer.write(",missing flag!"); @@ -418,12 +428,15 @@ private void parseSolvedState(Document doc, BufferedWriter writer) throws IOExce } /** - * @param folder - the input folder - * @param writer - write to .csv - * @param path - the current path - * @throws IOException + * Recursively parses a folder and writes puzzle grading results to a CSV file. + * + * @param folder the input folder + * @param writer write to .csv + * @param path the current path + * @throws IOException if an I/O error occurs */ - private void recursive_parser(File folder, BufferedWriter writer, String path) + private void recursive_parser( + @NotNull File folder, @NotNull BufferedWriter writer, @NotNull String path) throws IOException { // Empty folder if (Objects.requireNonNull(folder.listFiles()).length == 0) { @@ -503,7 +516,7 @@ private void recursive_parser(File folder, BufferedWriter writer, String path) * * @param folder Folder to update all files, and recurse for all subdirectories */ - private void recursiveUpdater(File folder) { + private void recursiveUpdater(@NotNull File folder) { if (Objects.requireNonNull(folder.listFiles()).length == 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Empty directory"); @@ -639,7 +652,7 @@ private void openPuzzleEditorDialog() { * @param columns the number of columns in the puzzle * @throws IllegalArgumentException if the dimensions are invalid */ - public void openEditorWithNewPuzzle(String game, int rows, int columns) + public void openEditorWithNewPuzzle(@NotNull String game, int rows, int columns) throws IllegalArgumentException { if (game.isEmpty()) { this.legupUI.displayPanel(2); @@ -675,7 +688,7 @@ public void openEditorWithNewPuzzle(String game, int rows, int columns) * @param game a String containing the name of the game * @param statements an array of statements */ - public void openEditorWithNewPuzzle(String game, String[] statements) { + public void openEditorWithNewPuzzle(@NotNull String game, @NotNull String[] statements) { // Validate the text input GameBoardFacade facade = GameBoardFacade.getInstance(); boolean isValidTextInput = facade.validateTextInput(game, statements); @@ -693,4 +706,4 @@ public void openEditorWithNewPuzzle(String game, String[] statements) { this.legupUI.displayPanel(2); this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, statements); } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 3bf3be198..167384f8b 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -13,6 +13,7 @@ import javax.swing.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * The main user interface class for the LEGUP application. This class extends {@link JFrame} and @@ -29,8 +30,9 @@ public class LegupUI extends JFrame implements WindowListener { /** * Identifies operating system * - * @return operating system, either mac or win + * @return operating system, either "mac" or "win" */ + @NotNull public static String getOS() { String os = System.getProperty("os.name").toLowerCase(); if (os.contains("mac")) { @@ -65,11 +67,11 @@ public LegupUI() { setIconImage( new ImageIcon( - Objects.requireNonNull( - ClassLoader.getSystemClassLoader() - .getResource( - "edu/rpi/legup/images/Legup/Direct" - + " Rules.gif"))) + Objects.requireNonNull( + ClassLoader.getSystemClassLoader() + .getResource( + "edu/rpi/legup/images/Legup/Direct" + + " Rules.gif"))) .getImage()); if (LegupPreferences.getInstance() @@ -88,7 +90,7 @@ public LegupUI() { * @param e */ @Override - public void keyTyped(KeyEvent e) { + public void keyTyped(@NotNull KeyEvent e) { System.err.println(e.getKeyChar()); super.keyTyped(e); } @@ -133,6 +135,7 @@ protected void displayPanel(int option) { * * @return the ProofEditorPanel */ + @NotNull public ProofEditorPanel getProofEditor() { return (ProofEditorPanel) panels[1]; } @@ -142,6 +145,7 @@ public ProofEditorPanel getProofEditor() { * * @return the PuzzleEditorPanel */ + @NotNull public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } @@ -151,15 +155,15 @@ public void repaintTree() { getProofEditor().repaintTree(); } - public void showStatus(String status, boolean error) { + public void showStatus(@NotNull String status, boolean error) { showStatus(status, error, 1); } - public void errorEncountered(String error) { + public void errorEncountered(@NotNull String error) { JOptionPane.showMessageDialog(null, error); } - public void showStatus(String status, boolean error, int timer) { + public void showStatus(@NotNull String status, boolean error, int timer) { // TODO: implement } @@ -169,7 +173,7 @@ public void showStatus(String status, boolean error, int timer) { * @param instr the prompt message * @return true if the user chooses not to quit, false otherwise */ - public boolean exit(String instr) { + public boolean exit(@NotNull String instr) { int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_OPTION); return n != JOptionPane.YES_OPTION; } @@ -206,6 +210,7 @@ public void windowDeactivated(WindowEvent e) {} * * @return the BoardView */ + @NotNull public BoardView getBoardView() { return getProofEditor().getBoardView(); } @@ -215,6 +220,7 @@ public BoardView getBoardView() { * * @return the BoardView */ + @NotNull public BoardView getEditorBoardView() { return getPuzzleEditor().getBoardView(); } @@ -224,6 +230,7 @@ public BoardView getEditorBoardView() { * * @return the DynamicView */ + @NotNull public DynamicView getDynamicBoardView() { return getProofEditor().getDynamicBoardView(); } @@ -233,6 +240,7 @@ public DynamicView getDynamicBoardView() { * * @return the DynamicView */ + @NotNull public DynamicView getEditorDynamicBoardView() { return getPuzzleEditor().getDynamicBoardView(); } @@ -242,7 +250,8 @@ public DynamicView getEditorDynamicBoardView() { * * @return the TreePanel */ + @NotNull public TreePanel getTreePanel() { return getProofEditor().getTreePanel(); } -} +} \ No newline at end of file From f26b2f6fd653100dc8dd9893e3125e725c264e99 Mon Sep 17 00:00:00 2001 From: busabj Date: Mon, 20 Apr 2026 22:37:02 -0400 Subject: [PATCH 12/13] add jetbrains and javadoc to ui files --- .../java/edu/rpi/legup/ui/PickGameDialog.java | 12 ++-- .../edu/rpi/legup/ui/PreferencesDialog.java | 32 +++++++--- .../edu/rpi/legup/ui/ProofEditorPanel.java | 58 +++++++++++-------- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 28 +++++---- 4 files changed, 83 insertions(+), 47 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PickGameDialog.java b/src/main/java/edu/rpi/legup/ui/PickGameDialog.java index 3b66931a7..b6bf398a3 100644 --- a/src/main/java/edu/rpi/legup/ui/PickGameDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PickGameDialog.java @@ -14,6 +14,8 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A dialog for selecting a game. This class extends {@link JDialog} and implements {@link @@ -50,7 +52,7 @@ public class PickGameDialog extends JDialog implements ActionListener { * @param pickBothAtOnce if true they can pick a game type and a specific edu.rpi.legup.puzzle, * if false they can only pick a game type */ - public PickGameDialog(JFrame parent, boolean pickBothAtOnce) { + public PickGameDialog(@NotNull JFrame parent, boolean pickBothAtOnce) { super(parent, true); pickBoth = pickBothAtOnce; @@ -141,6 +143,7 @@ public void initPuzzles() { * * @return the puzzle file path as a String */ + @NotNull public String getPuzzle() { return puzzleBox.getText(); } @@ -148,8 +151,9 @@ public String getPuzzle() { /** * Returns the selected puzzle * - * @return the selected puzzle as a String + * @return the selected puzzle as a String, or null if none is selected */ + @Nullable public String getGame() { return (String) gameBox.getSelectedItem(); } @@ -160,7 +164,7 @@ public String getGame() { * * @param e the action event */ - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { if (e.getSource() == gameBox) { int index = gameBox.getSelectedIndex(); } else { @@ -192,4 +196,4 @@ public void actionPerformed(ActionEvent e) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index e90d06640..586bc9b60 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -16,6 +16,8 @@ import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A dialog for managing user preferences in the LEGUP application. This dialog allows users to @@ -60,7 +62,8 @@ public class PreferencesDialog extends JDialog { * @param rules the RuleFrame associated with the proof editor * @return a new instance of PreferencesDialog */ - public static PreferencesDialog CreateDialogForProofEditor(Frame frame, RuleFrame rules) { + @NotNull + public static PreferencesDialog CreateDialogForProofEditor(@NotNull Frame frame, @NotNull RuleFrame rules) { PreferencesDialog p = new PreferencesDialog(frame); p.rulesFrame = rules; return p; @@ -71,7 +74,7 @@ public static PreferencesDialog CreateDialogForProofEditor(Frame frame, RuleFram * * @param frame the parent frame */ - public PreferencesDialog(Frame frame) { + public PreferencesDialog(@NotNull Frame frame) { super(frame); setTitle("Preferences"); @@ -125,7 +128,7 @@ public PreferencesDialog(Frame frame) { * * @param prefs the LegupPreferences instance holding user preferences */ - private void toggleDarkMode(LegupPreferences prefs) { + private void toggleDarkMode(@NotNull LegupPreferences prefs) { try { if (Boolean.valueOf(prefs.getUserPref(LegupPreferences.DARK_MODE))) { UIManager.setLookAndFeel(new FlatDarkLaf()); @@ -143,6 +146,7 @@ private void toggleDarkMode(LegupPreferences prefs) { * * @return a JScrollPane containing the general preferences panel */ + @NotNull private JScrollPane createGeneralTab() { LegupPreferences prefs = LegupPreferences.getInstance(); JScrollPane scrollPane = new JScrollPane(); @@ -322,7 +326,14 @@ private JScrollPane createGeneralTab() { return scrollPane; } - private JScrollPane createPuzzleTab(Puzzle puzzle) { + /** + * Creates the puzzle preferences tab for the given puzzle + * + * @param puzzle the puzzle whose rules will be displayed + * @return a JScrollPane containing the puzzle preferences panel + */ + @NotNull + private JScrollPane createPuzzleTab(@NotNull Puzzle puzzle) { JScrollPane scrollPane = new JScrollPane(); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); @@ -371,7 +382,8 @@ private JScrollPane createPuzzleTab(Puzzle puzzle) { * @param rule the rule object to be displayed * @return a JPanel representing the row for the rule */ - private JPanel createRuleRow(Rule rule) { + @NotNull + private JPanel createRuleRow(@NotNull Rule rule) { JPanel ruleRow = new JPanel(); ruleRow.setLayout(new BorderLayout()); @@ -385,7 +397,7 @@ private JPanel createRuleRow(Rule rule) { ruleAcc.addMouseListener( new MouseAdapter() { @Override - public void mouseEntered(MouseEvent e) { + public void mouseEntered(@NotNull MouseEvent e) { ruleAcc.requestFocusInWindow(); } }); @@ -393,7 +405,7 @@ public void mouseEntered(MouseEvent e) { ruleAcc.addKeyListener( new KeyAdapter() { @Override - public void keyPressed(KeyEvent e) { + public void keyPressed(@NotNull KeyEvent e) { int keyCode = e.getKeyCode(); String combo = ""; if (e.isControlDown()) { @@ -430,7 +442,8 @@ public void keyPressed(KeyEvent e) { * @param text the text to be displayed on the label * @return a JPanel containing the left-aligned label */ - private JPanel createLeftLabel(String text) { + @NotNull + private JPanel createLeftLabel(@NotNull String text) { JPanel labelRow = new JPanel(); labelRow.setLayout(new BorderLayout()); JLabel label = new JLabel(text); @@ -449,6 +462,7 @@ private JPanel createLeftLabel(String text) { * * @return a JSeparator with a fixed height */ + @NotNull private JSeparator createLineSeparator() { JSeparator separator = new JSeparator(); separator.setMaximumSize(new Dimension(Integer.MAX_VALUE, 5)); @@ -489,4 +503,4 @@ public void applyPreferences() { // toggle dark mode based on updated NIGHT_MODE variable toggleDarkMode(prefs); } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index b478d2e58..46019da66 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -36,6 +36,8 @@ import javax.swing.border.TitledBorder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * {@code ProofEditorPanel} is a panel that serves as the main user interface component for the @@ -91,22 +93,22 @@ public class ProofEditorPanel extends LegupPanel implements IHistoryListener { public static final int INTERN_RO = 64; public static final int AUTO_JUST = 128; private static final String[] PROFILES = { - "No Assistance", - "Rigorous Proof", - "Casual Proof", - "Assisted Proof", - "Guided Proof", - "Training-Wheels Proof", - "No Restrictions" + "No Assistance", + "Rigorous Proof", + "Casual Proof", + "Assisted Proof", + "Guided Proof", + "Training-Wheels Proof", + "No Restrictions" }; private static final int[] PROF_FLAGS = { - 0, - ALLOW_JUST | REQ_STEP_JUST, - ALLOW_JUST, - ALLOW_HINTS | ALLOW_JUST | AUTO_JUST, - ALLOW_HINTS | ALLOW_JUST | REQ_STEP_JUST, - ALLOW_HINTS | ALLOW_DEFAPP | ALLOW_JUST | IMD_FEEDBACK | INTERN_RO, - ALLOW_HINTS | ALLOW_DEFAPP | ALLOW_FULLAI | ALLOW_JUST + 0, + ALLOW_JUST | REQ_STEP_JUST, + ALLOW_JUST, + ALLOW_HINTS | ALLOW_JUST | AUTO_JUST, + ALLOW_HINTS | ALLOW_JUST | REQ_STEP_JUST, + ALLOW_HINTS | ALLOW_DEFAPP | ALLOW_JUST | IMD_FEEDBACK | INTERN_RO, + ALLOW_HINTS | ALLOW_DEFAPP | ALLOW_FULLAI | ALLOW_JUST }; private JMenu proofMode = new JMenu("Proof Mode"); private JCheckBoxMenuItem[] proofModeItems = new JCheckBoxMenuItem[PROF_FLAGS.length]; @@ -126,7 +128,7 @@ public class ProofEditorPanel extends LegupPanel implements IHistoryListener { * @param frame the {@code JFrame} that contains this panel * @param legupUI the {@code LegupUI} instance managing the user interface */ - public ProofEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { + public ProofEditorPanel(@NotNull FileDialog fileDialog, @NotNull JFrame frame, @NotNull LegupUI legupUI) { this.fileDialog = fileDialog; this.frame = frame; this.legupUI = legupUI; @@ -167,6 +169,7 @@ public void makeVisible() { * * @return the {@code JMenuBar} instance containing the menus and menu items for this panel */ + @NotNull public JMenuBar getMenuBar() { if (mBar != null) return mBar; mBar = new JMenuBar(); @@ -517,6 +520,7 @@ public void exitEditor() { * @return an array containing the file name and the selected file, or {@code null} if the * operation was canceled */ + @Nullable public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { @@ -590,7 +594,7 @@ public void loadPuzzle() { * @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) { + public void loadPuzzle(@NotNull String fileName, @Nullable File puzzleFile) { if (puzzleFile == null && fileName.isEmpty()) { legupUI.displayPanel(1); } @@ -784,7 +788,7 @@ private void saveProofChange() { * @param instr the message to display in the confirmation dialog * @return {@code true} if the user chooses not to quit, {@code false} otherwise */ - public boolean noquit(String instr) { + public boolean noquit(@NotNull String instr) { int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_OPTION); return n != JOptionPane.YES_OPTION; } @@ -976,7 +980,7 @@ private void setupToolBar2() { * * @param toolBar1Buttons toolbar buttons */ - public void setToolBar1Buttons(JButton[] toolBar1Buttons) { + public void setToolBar1Buttons(@NotNull JButton[] toolBar1Buttons) { this.toolBar1Buttons = toolBar1Buttons; } @@ -985,7 +989,7 @@ public void setToolBar1Buttons(JButton[] toolBar1Buttons) { * * @param toolBar2Buttons toolbar buttons */ - public void setToolBar2Buttons(JButton[] toolBar2Buttons) { + public void setToolBar2Buttons(@NotNull JButton[] toolBar2Buttons) { this.toolBar2Buttons = toolBar2Buttons; } @@ -994,6 +998,7 @@ public void setToolBar2Buttons(JButton[] toolBar2Buttons) { * * @return toolbar1 buttons */ + @Nullable public JButton[] getToolBar1Buttons() { return toolBar1Buttons; } @@ -1003,6 +1008,7 @@ public JButton[] getToolBar1Buttons() { * * @return toolbar2 buttons */ + @Nullable public JButton[] getToolBar2Buttons() { return toolBar2Buttons; } @@ -1095,7 +1101,7 @@ private void repaintAll() { * * @param puzzle the puzzle to be displayed */ - public void setPuzzleView(Puzzle puzzle) { + public void setPuzzleView(@NotNull Puzzle puzzle) { this.boardView = puzzle.getBoardView(); dynamicBoardView = new DynamicView(boardView, DynamicViewType.BOARD); @@ -1194,7 +1200,8 @@ private boolean basicCheckProof(int[][] origCells) { * @param path the current path in the directory traversal * @throws IOException if an error occurs while writing to the CSV file */ - private void traverseDir(File folder, BufferedWriter writer, String path) throws IOException { + private void traverseDir(@NotNull File folder, @NotNull BufferedWriter writer, @NotNull String path) + throws IOException { // Recursively traverse directory GameBoardFacade facade = GameBoardFacade.getInstance(); @@ -1255,6 +1262,7 @@ private void traverseDir(File folder, BufferedWriter writer, String path) throws * * @return the current {@link BoardView} */ + @Nullable public BoardView getBoardView() { return boardView; } @@ -1264,6 +1272,7 @@ public BoardView getBoardView() { * * @return the current {@link DynamicView} */ + @Nullable public DynamicView getDynamicBoardView() { return dynamicBoardView; } @@ -1273,6 +1282,7 @@ public DynamicView getDynamicBoardView() { * * @return the current {@link TreePanel} */ + @Nullable public TreePanel getTreePanel() { return treePanel; } @@ -1283,7 +1293,7 @@ public TreePanel getTreePanel() { * @param command action to push onto the stack */ @Override - public void onPushChange(ICommand command) { + public void onPushChange(@NotNull ICommand command) { LOGGER.info("Pushing " + command.getClass().getSimpleName() + " to stack."); undo.setEnabled(true); redo.setEnabled(false); @@ -1370,7 +1380,7 @@ private void submit() { } } - public void showStatus(String status, boolean error, int timer) { + public void showStatus(@NotNull String status, boolean error, int timer) { // TODO: implement } @@ -1378,4 +1388,4 @@ public void showStatus(String status, boolean error, int timer) { protected void fitTreeViewToScreen() { this.treePanel.getTreeView().zoomFit(); } -} +} \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 21402f42c..af3d37479 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -28,6 +28,8 @@ import javax.swing.border.TitledBorder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents the panel used for puzzle editor in the LEGUP. This panel includes a variety of UI @@ -73,7 +75,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { * @param frame the main application frame * @param legupUI the Legup UI instance */ - public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { + public PuzzleEditorPanel(@NotNull FileDialog fileDialog, @NotNull JFrame frame, @NotNull LegupUI legupUI) { this.fileDialog = fileDialog; this.frame = frame; this.legupUI = legupUI; @@ -467,7 +469,7 @@ public void actionPerformed(ActionEvent e) { * @param columns the number of columns in the puzzle * @throws IllegalArgumentException if the provided arguments are invalid */ - public void loadPuzzleFromHome(String game, int rows, int columns) + public void loadPuzzleFromHome(@NotNull String game, int rows, int columns) throws IllegalArgumentException { GameBoardFacade facade = GameBoardFacade.getInstance(); try { @@ -487,7 +489,7 @@ public void loadPuzzleFromHome(String game, int rows, int columns) * @param statements an array of statements to initialize the puzzle * @throws IllegalArgumentException if the provided arguments are invalid */ - public void loadPuzzleFromHome(String game, String[] statements) { + public void loadPuzzleFromHome(@NotNull String game, @NotNull String[] statements) { GameBoardFacade facade = GameBoardFacade.getInstance(); try { facade.loadPuzzle(game, statements); @@ -507,6 +509,7 @@ public void loadPuzzleFromHome(String game, String[] statements) { * @return an array containing the selected file name and file object, or null if the operation * was canceled */ + @Nullable public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { @@ -571,7 +574,7 @@ public void loadPuzzle() { * @param fileName the name of the puzzle file * @param puzzleFile the file object representing the puzzle file */ - public void loadPuzzle(String fileName, File puzzleFile) { + public void loadPuzzle(@NotNull String fileName, @Nullable File puzzleFile) { if (puzzleFile != null && puzzleFile.exists()) { try { legupUI.displayPanel(2); @@ -601,14 +604,14 @@ public void loadPuzzle(String fileName, File puzzleFile) { * @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" */ - public boolean noQuit(String instr) { + public boolean noQuit(@NotNull String instr) { int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_OPTION); return n != JOptionPane.YES_OPTION; } /** {@inheritDoc} */ @Override - public void onPushChange(ICommand command) {} + public void onPushChange(@NotNull ICommand command) {} /** {@inheritDoc} */ @Override @@ -627,6 +630,7 @@ public void onClearHistory() {} * * @return the board view */ + @Nullable public BoardView getBoardView() { return boardView; } @@ -636,6 +640,7 @@ public BoardView getBoardView() { * * @return the array of toolbar1 buttons */ + @Nullable public JButton[] getToolBar1Buttons() { return toolBar1Buttons; } @@ -645,7 +650,7 @@ public JButton[] getToolBar1Buttons() { * * @param toolBar1Buttons the array of toolbar1 buttons */ - public void setToolBar1Buttons(JButton[] toolBar1Buttons) { + public void setToolBar1Buttons(@NotNull JButton[] toolBar1Buttons) { this.toolBar1Buttons = toolBar1Buttons; } @@ -654,6 +659,7 @@ public void setToolBar1Buttons(JButton[] toolBar1Buttons) { * * @return the array of toolbar2 buttons */ + @Nullable public JButton[] getToolBar2Buttons() { return toolBar2Buttons; } @@ -663,7 +669,7 @@ public JButton[] getToolBar2Buttons() { * * @param toolBar2Buttons the array of toolbar2 buttons */ - public void setToolBar2Buttons(JButton[] toolBar2Buttons) { + public void setToolBar2Buttons(@NotNull JButton[] toolBar2Buttons) { this.toolBar2Buttons = toolBar2Buttons; } @@ -678,7 +684,7 @@ private void repaintAll() { * * @param puzzle the puzzle object to display */ - public void setPuzzleView(Puzzle puzzle) { + public void setPuzzleView(@NotNull Puzzle puzzle) { this.boardView = puzzle.getBoardView(); editorElementController.setElementController(boardView.getElementController()); dynamicBoardView = new DynamicView(boardView, DynamicViewType.BOARD); @@ -727,6 +733,7 @@ private void direct_save() { * @return the path where the puzzle was saved, or an empty string if the save operation was * canceled */ + @NotNull private String savePuzzle() { Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); if (puzzle == null) { @@ -784,7 +791,8 @@ private String savePuzzle() { * * @return the dynamic board view */ + @Nullable public DynamicView getDynamicBoardView() { return dynamicBoardView; } -} +} \ No newline at end of file From 9cdbce5b2247816b422f8683f0fda2addb670b61 Mon Sep 17 00:00:00 2001 From: busabj Date: Mon, 20 Apr 2026 23:41:40 -0400 Subject: [PATCH 13/13] add jetbrains and javadoc to ui files --- src/main/java/edu/rpi/legup/ui/WrapLayout.java | 9 +++++---- src/main/java/edu/rpi/legup/ui/ZoomWidget.java | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/WrapLayout.java b/src/main/java/edu/rpi/legup/ui/WrapLayout.java index 1e25b36d2..548b32a2d 100644 --- a/src/main/java/edu/rpi/legup/ui/WrapLayout.java +++ b/src/main/java/edu/rpi/legup/ui/WrapLayout.java @@ -3,6 +3,7 @@ import java.awt.*; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; +import org.jetbrains.annotations.NotNull; /** FlowLayout subclass that fully supports wrapping of components. */ public class WrapLayout extends FlowLayout { @@ -51,7 +52,7 @@ public WrapLayout(int align, int hgap, int vgap) { * @return the preferred dimensions to lay out the subcomponents of the specified container */ @Override - public Dimension preferredLayoutSize(Container target) { + public @NotNull Dimension preferredLayoutSize(@NotNull Container target) { return layoutSize(target, true); } @@ -63,7 +64,7 @@ public Dimension preferredLayoutSize(Container target) { * @return the minimum dimensions to lay out the subcomponents of the specified container */ @Override - public Dimension minimumLayoutSize(Container target) { + public @NotNull Dimension minimumLayoutSize(@NotNull Container target) { Dimension minimum = layoutSize(target, false); minimum.width -= (getHgap() + 1); return minimum; @@ -76,7 +77,7 @@ public Dimension minimumLayoutSize(Container target) { * @param preferred should preferred dimension be calculated * @return the dimension to layout the target container */ - private Dimension layoutSize(Container target, boolean preferred) { + private @NotNull Dimension layoutSize(@NotNull Container target, boolean preferred) { synchronized (target.getTreeLock()) { // Each row must fit with the width allocated to the containter. // When the container width = 0, the preferred width of the container @@ -155,7 +156,7 @@ private Dimension layoutSize(Container target, boolean preferred) { * @param rowWidth the width of the row to add * @param rowHeight the height of the row to add */ - private void addRow(Dimension dim, int rowWidth, int rowHeight) { + private void addRow(@NotNull Dimension dim, int rowWidth, int rowHeight) { dim.width = Math.max(dim.width, rowWidth); if (dim.height > 0) { diff --git a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java index 83587f4d8..bc97bfe7f 100644 --- a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java +++ b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java @@ -9,17 +9,18 @@ import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import org.jetbrains.annotations.NotNull; /** * The {@code ZoomWidget} displays a zoom icon that, when clicked, shows a popup slider to adjust * the zoom level of the associated {@code ScrollView}. */ public class ZoomWidget extends JLabel { - private ScrollView parent; + private @NotNull ScrollView parent; private PopupSlider palette = new PopupSlider(); private MouseAdapter open = new MouseAdapter() { - public void mouseClicked(MouseEvent e) { + public void mouseClicked(@NotNull MouseEvent e) { palette.slider.setValue((int) parent.getZoom()); palette.show(e.getComponent(), 0, 0); } @@ -30,7 +31,7 @@ public void mouseClicked(MouseEvent e) { * * @param parent dynamicView to which to the ZoomWidget is applied to */ - public ZoomWidget(ScrollView parent) { + public ZoomWidget(@NotNull ScrollView parent) { super(new ImageIcon("zoom.png")); this.parent = parent; addMouseListener(open); @@ -57,10 +58,10 @@ public PopupSlider() { * * @param e the {@code ChangeEvent} indicating that the slider's state has changed */ - public void stateChanged(ChangeEvent e) { + public void stateChanged(@NotNull ChangeEvent e) { if (slider.getValueIsAdjusting()) { parent.zoomTo((double) slider.getValue() / 100.0); } } } -} +} \ No newline at end of file