From baf1dfe8e2296fe3a32918c164fae1b0eba5c619 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 9 Jun 2022 11:07:14 -0400 Subject: [PATCH 01/86] Delete PuzzleCreatorView.java --- .../edu/rpi/legup/ui/PuzzleCreatorView.java | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/main/java/edu/rpi/legup/ui/PuzzleCreatorView.java diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleCreatorView.java b/src/main/java/edu/rpi/legup/ui/PuzzleCreatorView.java deleted file mode 100644 index 3e5877890..000000000 --- a/src/main/java/edu/rpi/legup/ui/PuzzleCreatorView.java +++ /dev/null @@ -1,17 +0,0 @@ -package edu.rpi.legup.ui; - -import edu.rpi.legup.ui.boardview.BoardView; - -import javax.swing.*; - -public class PuzzleCreatorView extends JFrame { - - private BoardView boardView; - - public PuzzleCreatorView(BoardView boardView) { - this.boardView = boardView; - - setContentPane(new DynamicView(boardView)); - } - -} From 3ca1a1734bd8c0b5ddf98f99b4eda89bb0c59355 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 9 Jun 2022 15:31:46 -0400 Subject: [PATCH 02/86] Created new packages for puzzle editor and proof editor --- .../edu/rpi/legup/app/PuzzleKeyAccelerator.java | 7 ++----- .../edu/rpi/legup/controller/ElementController.java | 10 +++++----- .../edu/rpi/legup/controller/RuleController.java | 6 +++--- .../edu/rpi/legup/controller/TreeController.java | 4 ++-- .../rpi/legup/history/AddTreeElementCommand.java | 7 +++---- .../legup/history/ApplyDefaultBasicRuleCommand.java | 2 +- .../edu/rpi/legup/history/AutoCaseRuleCommand.java | 4 ++-- .../rpi/legup/history/DeleteTreeElementCommand.java | 2 +- .../java/edu/rpi/legup/history/EditDataCommand.java | 6 +++--- .../java/edu/rpi/legup/history/MergeCommand.java | 2 +- .../rpi/legup/history/ValidateBasicRuleCommand.java | 3 +-- .../rpi/legup/history/ValidateCaseRuleCommand.java | 3 +-- .../history/ValidateContradictionRuleCommand.java | 3 +-- src/main/java/edu/rpi/legup/model/Puzzle.java | 2 +- .../edu/rpi/legup/model/observer/ITreeListener.java | 2 +- .../legup/puzzle/battleship/BattleShipClueView.java | 2 +- .../puzzle/battleship/BattleShipElementView.java | 2 +- .../rpi/legup/puzzle/battleship/BattleShipView.java | 2 +- .../legup/puzzle/fillapix/FillapixElementView.java | 2 +- .../edu/rpi/legup/puzzle/fillapix/FillapixView.java | 2 +- .../legup/puzzle/heyawake/HeyawakeElementView.java | 2 +- .../edu/rpi/legup/puzzle/heyawake/HeyawakeView.java | 4 ++-- .../legup/puzzle/lightup/LightUpElementView.java | 2 +- .../edu/rpi/legup/puzzle/lightup/LightUpView.java | 6 +++--- .../edu/rpi/legup/puzzle/masyu/EditLineCommand.java | 6 +++--- .../edu/rpi/legup/puzzle/masyu/MasyuController.java | 2 +- .../rpi/legup/puzzle/masyu/MasyuElementView.java | 2 +- .../edu/rpi/legup/puzzle/masyu/MasyuLineView.java | 2 +- .../java/edu/rpi/legup/puzzle/masyu/MasyuView.java | 2 +- .../legup/puzzle/nurikabe/NurikabeElementView.java | 2 +- .../edu/rpi/legup/puzzle/nurikabe/NurikabeView.java | 2 +- .../shorttruthtable/ShortTruthTableElementView.java | 2 +- .../puzzle/shorttruthtable/ShortTruthTableView.java | 2 +- .../rpi/legup/puzzle/skyscrapers/ClueCommand.java | 13 ++++--------- .../puzzle/skyscrapers/SkyscrapersClueView.java | 2 +- .../puzzle/skyscrapers/SkyscrapersController.java | 10 +++++----- .../puzzle/skyscrapers/SkyscrapersElementView.java | 5 +---- .../puzzle/skyscrapers/SkyscrapersLineView.java | 2 +- .../legup/puzzle/skyscrapers/SkyscrapersView.java | 4 ++-- .../java/edu/rpi/legup/puzzle/sudoku/Sudoku.java | 2 +- .../rpi/legup/puzzle/sudoku/SudokuElementView.java | 2 +- .../edu/rpi/legup/puzzle/sudoku/SudokuView.java | 9 ++++----- .../edu/rpi/legup/puzzle/treetent/ClueCommand.java | 6 +++--- .../rpi/legup/puzzle/treetent/EditLineCommand.java | 8 ++++---- .../rpi/legup/puzzle/treetent/TreeTentClueView.java | 2 +- .../legup/puzzle/treetent/TreeTentController.java | 10 +++++----- .../legup/puzzle/treetent/TreeTentElementView.java | 2 +- .../rpi/legup/puzzle/treetent/TreeTentLineView.java | 2 +- .../edu/rpi/legup/puzzle/treetent/TreeTentView.java | 4 ++-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 9 ++++----- .../{ => puzzleeditorui}/boardview/BoardView.java | 2 +- .../boardview/DataSelectionView.java | 2 +- .../boardview/ElementSelection.java | 2 +- .../{ => puzzleeditorui}/boardview/ElementView.java | 2 +- .../boardview/GridBoardView.java | 3 +-- .../boardview/GridElementView.java | 2 +- .../boardview/SelectionItemView.java | 2 +- .../rulesview/BasicRulePanel.java | 2 +- .../rulesview/CaseRulePanel.java | 2 +- .../rulesview/CaseRuleSelectionView.java | 2 +- .../rulesview/ContradictionRulePanel.java | 2 +- .../{ => puzzleeditorui}/rulesview/RuleButton.java | 2 +- .../{ => puzzleeditorui}/rulesview/RuleFrame.java | 2 +- .../{ => puzzleeditorui}/rulesview/RulePanel.java | 2 +- .../treeview/TreeElementView.java | 2 +- .../{ => puzzleeditorui}/treeview/TreeNodeView.java | 2 +- .../ui/{ => puzzleeditorui}/treeview/TreePanel.java | 3 +-- .../treeview/TreeToolBarButton.java | 2 +- .../treeview/TreeToolBarName.java | 2 +- .../treeview/TreeToolbarPanel.java | 2 +- .../treeview/TreeTransitionView.java | 2 +- .../ui/{ => puzzleeditorui}/treeview/TreeView.java | 6 +++--- .../treeview/TreeViewSelection.java | 2 +- 73 files changed, 117 insertions(+), 136 deletions(-) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/BoardView.java (99%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/DataSelectionView.java (87%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/ElementSelection.java (97%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/ElementView.java (99%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/GridBoardView.java (97%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/GridElementView.java (77%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/boardview/SelectionItemView.java (93%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/BasicRulePanel.java (93%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/CaseRulePanel.java (90%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/CaseRuleSelectionView.java (90%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/ContradictionRulePanel.java (91%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/RuleButton.java (92%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/RuleFrame.java (98%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/rulesview/RulePanel.java (98%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeElementView.java (98%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeNodeView.java (99%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreePanel.java (98%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeToolBarButton.java (87%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeToolBarName.java (60%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeToolbarPanel.java (97%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeTransitionView.java (99%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeView.java (99%) rename src/main/java/edu/rpi/legup/ui/{ => puzzleeditorui}/treeview/TreeViewSelection.java (98%) diff --git a/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java b/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java index 6711e3035..67837c460 100644 --- a/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java +++ b/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java @@ -7,8 +7,8 @@ import edu.rpi.legup.model.rules.ContradictionRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.rules.RuleType; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import javax.swing.*; import java.awt.event.KeyEvent; @@ -16,9 +16,6 @@ import java.util.HashMap; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import static edu.rpi.legup.app.GameBoardFacade.getInstance; public class PuzzleKeyAccelerator implements KeyListener { diff --git a/src/main/java/edu/rpi/legup/controller/ElementController.java b/src/main/java/edu/rpi/legup/controller/ElementController.java index a92cf0d2e..49f87cd4e 100644 --- a/src/main/java/edu/rpi/legup/controller/ElementController.java +++ b/src/main/java/edu/rpi/legup/controller/ElementController.java @@ -11,11 +11,11 @@ import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.ui.DynamicView; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.boardview.ElementSelection; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.boardview.SelectionItemView; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementSelection; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.EditDataCommand; diff --git a/src/main/java/edu/rpi/legup/controller/RuleController.java b/src/main/java/edu/rpi/legup/controller/RuleController.java index 84a32715f..2189cc84a 100644 --- a/src/main/java/edu/rpi/legup/controller/RuleController.java +++ b/src/main/java/edu/rpi/legup/controller/RuleController.java @@ -7,9 +7,9 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.rules.*; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.rulesview.RuleButton; -import edu.rpi.legup.ui.rulesview.RulePanel; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.rulesview.RuleButton; +import edu.rpi.legup.ui.puzzleeditorui.rulesview.RulePanel; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index 462cbe142..ed1bc9cb6 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -2,8 +2,8 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java index 099af9afa..2302d1f99 100644 --- a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java @@ -2,11 +2,10 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.TreeElementView; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java b/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java index 7284b8db2..6d244af83 100644 --- a/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.BasicRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index 95b644102..6b1480d68 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -6,8 +6,8 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; import java.util.*; diff --git a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java index 9755d9002..e7f0294cd 100644 --- a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java @@ -4,7 +4,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.observer.ITreeListener; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/EditDataCommand.java b/src/main/java/edu/rpi/legup/history/EditDataCommand.java index 67e199934..6ed7d804b 100644 --- a/src/main/java/edu/rpi/legup/history/EditDataCommand.java +++ b/src/main/java/edu/rpi/legup/history/EditDataCommand.java @@ -5,9 +5,9 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.observer.ITreeListener; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/MergeCommand.java b/src/main/java/edu/rpi/legup/history/MergeCommand.java index 0634906b7..9e8e6aeea 100644 --- a/src/main/java/edu/rpi/legup/history/MergeCommand.java +++ b/src/main/java/edu/rpi/legup/history/MergeCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.MergeRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java index d3d1eafb8..cb910e898 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java @@ -2,11 +2,10 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.BasicRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java index 3697c2f2e..f0dd4fe70 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java @@ -2,11 +2,10 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java index 258bb01c6..79b8a6870 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java @@ -2,10 +2,9 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.ContradictionRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index 24fa967e1..2cccc7ccc 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -16,7 +16,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; diff --git a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java index 89c48e25f..69c681055 100644 --- a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java +++ b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java @@ -1,7 +1,7 @@ package edu.rpi.legup.model.observer; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; public interface ITreeListener { /** diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java index 06e4901d7..d4a4cfd3c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.battleship; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java index a1ba0f9b8..84a169fb8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.battleship; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java index 7c4353888..2fcfd2331 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java index 00d0a6807..500aa5959 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.fillapix; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java index 7e6453f58..7434730b2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java index 5efec44ff..f29df74c5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.heyawake; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java index c60ca2d88..d48888463 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java @@ -2,8 +2,8 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; import java.awt.geom.Area; 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 a57f22706..4715cf5d6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.lightup; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; 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 f4c762124..bcd5782d4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java @@ -4,9 +4,9 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.boardview.DataSelectionView; -import edu.rpi.legup.ui.boardview.GridBoardView; -import edu.rpi.legup.ui.boardview.SelectionItemView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.DataSelectionView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; import javax.imageio.ImageIO; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java index 493d5e1ad..c02af0165 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java @@ -9,9 +9,9 @@ import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.*; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java index 554b8d898..9cd8c5445 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java @@ -4,7 +4,7 @@ import edu.rpi.legup.controller.ElementController; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; import java.awt.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java index 6a13d7155..45a20641e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.masyu; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java index d527ca414..b914232a4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.masyu; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java index ac60dbe66..cabada597 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; import java.util.ArrayList; diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java index 09f976dc9..460fe84ce 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.nurikabe; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java index cef287b92..84492c0ff 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java index 7b0cd1b06..f4bf33af2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.shorttruthtable; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java index 64e9fda75..0a906b632 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java index 6e350c6aa..212a38412 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java @@ -2,23 +2,18 @@ import edu.rpi.legup.history.CommandError; import edu.rpi.legup.history.PuzzleCommand; -import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.gameboard.Board; -import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.TreeElementView; -import edu.rpi.legup.ui.treeview.TreeNodeView; -import edu.rpi.legup.ui.treeview.TreeTransitionView; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeTransitionView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import static edu.rpi.legup.app.GameBoardFacade.getInstance; - public class ClueCommand extends PuzzleCommand { private TreeViewSelection selection; private SkyscrapersClueView clueView; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java index 22799ed05..a2316dcd0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java index 45b8a3f0b..75e282973 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java @@ -8,11 +8,11 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.TreePanel; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java index 1207845a8..82dca87c5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java @@ -1,11 +1,8 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.app.LegupPreferences; -import edu.rpi.legup.puzzle.sudoku.SudokuCell; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; -import java.awt.geom.Rectangle2D; public class SkyscrapersElementView extends GridElementView { private static final Font FONT = new Font("TimesRoman", Font.BOLD, 16); diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java index a66c6d7b2..3e5e8de43 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java index 98d3545d2..0fc461368 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java @@ -4,8 +4,8 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import javax.imageio.ImageIO; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java index 2704ce314..440776142 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java @@ -4,7 +4,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; -import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; public class Sudoku extends Puzzle { private SudokuView boardView; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java index bc114c3c5..b7ef0ebc9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.app.LegupPreferences; import edu.rpi.legup.model.gameboard.GridCell; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java index 4625c6c24..01dff235d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java @@ -1,11 +1,10 @@ package edu.rpi.legup.puzzle.sudoku; import edu.rpi.legup.controller.BoardController; -import edu.rpi.legup.controller.ElementController; -import edu.rpi.legup.ui.boardview.DataSelectionView; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.boardview.GridBoardView; -import edu.rpi.legup.ui.boardview.SelectionItemView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.DataSelectionView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java index 0ddf9ac29..f68e165d9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java @@ -4,9 +4,9 @@ import edu.rpi.legup.history.PuzzleCommand; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.treeview.TreeElementView; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java index 3a42f12da..aa011534a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java @@ -4,10 +4,10 @@ import edu.rpi.legup.history.PuzzleCommand; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.TreeElementView; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.awt.*; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java index 4e7b24b13..49e6760e8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java index 833180ee3..3d6ff3f57 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java @@ -8,11 +8,11 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.treeview.TreePanel; -import edu.rpi.legup.ui.treeview.TreeView; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java index 91d2c29b1..6ef214db1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.boardview.GridElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; import java.awt.*; import java.awt.geom.Rectangle2D; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java index 833dcb5b5..4d2a969f4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java index 5a2127fc7..0fb69ba4b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java @@ -4,8 +4,8 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; import javax.imageio.ImageIO; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 2321c9992..caa0864b9 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -28,14 +28,13 @@ import edu.rpi.legup.model.tree.Tree; import edu.rpi.legup.save.ExportFileException; import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.rulesview.RuleFrame; -import edu.rpi.legup.ui.treeview.TreePanel; -import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.puzzleeditorui.rulesview.RuleFrame; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; import edu.rpi.legup.user.Submission; import edu.rpi.legupupdate.Update; import edu.rpi.legupupdate.UpdateProgress; -import io.grpc.internal.KeepAliveManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/boardview/BoardView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java index 31cec590b..a39c1872c 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.ElementController; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java similarity index 87% rename from src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java index 8257fd47c..562ad1f74 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.controller.ElementController; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java similarity index 97% rename from src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java index 8e6f2cb18..6a403b26b 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import java.awt.*; import java.util.ArrayList; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/boardview/ElementView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java index 008c1a5f5..c8053fe8a 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.model.gameboard.PuzzleElement; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java similarity index 97% rename from src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java index 6b352370f..1a20d318b 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java @@ -1,11 +1,10 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.ElementController; import java.awt.Color; import java.awt.Dimension; -import java.awt.Point; public class GridBoardView extends BoardView { protected Dimension gridSize; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java similarity index 77% rename from src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java index 440b3a693..ac3fb8ae1 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.model.gameboard.GridCell; diff --git a/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java similarity index 93% rename from src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java index 1ce5033c7..c24854635 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.boardview; +package edu.rpi.legup.ui.puzzleeditorui.boardview; import edu.rpi.legup.model.gameboard.PuzzleElement; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/BasicRulePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java similarity index 93% rename from src/main/java/edu/rpi/legup/ui/rulesview/BasicRulePanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java index 6307b81d5..590526a86 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/BasicRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/CaseRulePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java similarity index 90% rename from src/main/java/edu/rpi/legup/ui/rulesview/CaseRulePanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java index 534825dc7..0740de253 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/CaseRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import javax.swing.ImageIcon; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/CaseRuleSelectionView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java similarity index 90% rename from src/main/java/edu/rpi/legup/ui/rulesview/CaseRuleSelectionView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java index eda8e0cb9..b95527cd4 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/CaseRuleSelectionView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import edu.rpi.legup.ui.WrapLayout; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/ContradictionRulePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java similarity index 91% rename from src/main/java/edu/rpi/legup/ui/rulesview/ContradictionRulePanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java index 4b81b6ade..000117849 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/ContradictionRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/RuleButton.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java similarity index 92% rename from src/main/java/edu/rpi/legup/ui/rulesview/RuleButton.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java index ca898a25c..e0d7fcad7 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/RuleButton.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import edu.rpi.legup.model.rules.Rule; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java index ca0c4ba0b..d4c3ea027 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.model.Puzzle; diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/RulePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/rulesview/RulePanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java index de01f3916..c37b5fa73 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/RulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.rulesview; +package edu.rpi.legup.ui.puzzleeditorui.rulesview; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.ui.WrapLayout; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeElementView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeElementView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java index 3c46c5241..c471c964c 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeElementView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import edu.rpi.legup.model.tree.TreeElement; import edu.rpi.legup.model.tree.TreeElementType; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeNodeView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeNodeView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java index 55d586f4d..425691858 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeNodeView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import edu.rpi.legup.model.rules.RuleType; import edu.rpi.legup.model.tree.TreeElementType; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java index 4f49d7639..8fae3a108 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.controller.TreeController; @@ -7,7 +7,6 @@ import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.MergeCommand; import edu.rpi.legup.model.gameboard.Board; -import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.Tree; import edu.rpi.legup.ui.DynamicView; import edu.rpi.legup.ui.LegupUI; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarButton.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java similarity index 87% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarButton.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java index ab63bab81..75cba9d4f 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarButton.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarName.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java similarity index 60% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarName.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java index 309fa3048..d5fb62ca3 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolBarName.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; public enum TreeToolBarName { ADD_CHILD, DEL_CHILD, MERGE, COLLAPSE diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolbarPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java similarity index 97% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeToolbarPanel.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java index 50b31d74c..17e0b44da 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeToolbarPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeTransitionView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeTransitionView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java index a71f92800..37b99bcc0 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeTransitionView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeTransition; diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeView.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeView.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java index 01ec07d32..3e7c41e2e 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeView.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.controller.TreeController; @@ -21,8 +21,8 @@ import static edu.rpi.legup.model.tree.TreeElementType.NODE; import static edu.rpi.legup.model.tree.TreeElementType.TRANSITION; -import static edu.rpi.legup.ui.treeview.TreeNodeView.DIAMETER; -import static edu.rpi.legup.ui.treeview.TreeNodeView.RADIUS; +import static edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView.DIAMETER; +import static edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView.RADIUS; public class TreeView extends ScrollView implements ITreeListener { private final static Logger LOGGER = LogManager.getLogger(TreeView.class.getName()); diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreeViewSelection.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/treeview/TreeViewSelection.java rename to src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java index 0c76aa5e0..11b63e9ab 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreeViewSelection.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.treeview; +package edu.rpi.legup.ui.puzzleeditorui.treeview; import java.awt.*; import java.util.List; From 592b0200d8dc0d129c046ec2ad140747d82391f7 Mon Sep 17 00:00:00 2001 From: Chris Reed <55092742+cjreed121@users.noreply.github.com> Date: Thu, 9 Jun 2022 23:14:16 -0400 Subject: [PATCH 03/86] Add multiple windows --- .../edu/rpi/legup/app/GameBoardFacade.java | 8 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 40 + .../java/edu/rpi/legup/ui/LegupPanel.java | 10 + src/main/java/edu/rpi/legup/ui/LegupUI.java | 725 +----------------- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 18 + .../edu/rpi/legup/ui/PuzzleSolverPanel.java | 699 +++++++++++++++++ .../edu/rpi/legup/ui/treeview/TreePanel.java | 4 +- 7 files changed, 807 insertions(+), 697 deletions(-) create mode 100644 src/main/java/edu/rpi/legup/ui/HomePanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/LegupPanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index fcae4df3d..47f50e722 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -6,6 +6,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; +import edu.rpi.legup.ui.PuzzleSolverPanel; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -42,6 +43,8 @@ public class GameBoardFacade implements IHistorySubject { private LegupUI legupUI; + private PuzzleSolverPanel puzzleSolver; + private String curFileName; private History history; @@ -73,13 +76,14 @@ public synchronized static GameBoardFacade getInstance() { public void initializeUI() { EventQueue.invokeLater(() ->{ legupUI = new LegupUI(); - addHistoryListener(legupUI); + puzzleSolver = legupUI.getPuzzleSolver(); + addHistoryListener(legupUI.getPuzzleSolver()); }); } public void setPuzzle(Puzzle puzzle) { this.puzzle = puzzle; - this.legupUI.setPuzzleView(puzzle); + this.puzzleSolver.setPuzzleView(puzzle); this.history.clear(); } diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java new file mode 100644 index 000000000..7e0ca93e3 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -0,0 +1,40 @@ +package edu.rpi.legup.ui; + +import javax.swing.*; +import java.awt.*; + +public class HomePanel extends LegupPanel { + private LegupUI legupUI; + + private JButton[] buttons; + + private JPanel buttonPanel; + + public HomePanel(LegupUI legupUI) { + this.legupUI = legupUI; + setLayout(new GridLayout(2, 1)); + initButtons(); + } + + @Override + public void makeVisible() { + render(); + } + + private void initButtons() { + this.buttons = new JButton[2]; + this.buttons[0] = new JButton("Solve a puzzle!"); + this.buttons[0].addActionListener(l -> this.legupUI.displayPanel(1)); + this.buttons[1] = new JButton("Create/Edit a puzzle!"); + this.buttons[1].addActionListener(l -> this.legupUI.displayPanel(2)); + this.buttonPanel = new JPanel(); + for (JButton button : this.buttons) { + this.buttonPanel.add(button); + } + } + + private void render() { + add(new JLabel("Welcome to LEGUP! What would you like to do?")); + add(this.buttonPanel); + } +} diff --git a/src/main/java/edu/rpi/legup/ui/LegupPanel.java b/src/main/java/edu/rpi/legup/ui/LegupPanel.java new file mode 100644 index 000000000..de5f70f76 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/LegupPanel.java @@ -0,0 +1,10 @@ +package edu.rpi.legup.ui; + +import javax.swing.*; + +public abstract class LegupPanel extends JPanel { + /** + * Alerts panel that it will be going visible now + */ + public abstract void makeVisible(); +} diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 2321c9992..03ef20ef5 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -3,46 +3,23 @@ import java.awt.*; import java.awt.event.*; import java.io.*; -import java.net.URI; -import java.net.URL; -import java.io.FileWriter; -import java.io.BufferedWriter; +import java.security.InvalidParameterException; import javax.swing.*; -import java.util.List; - import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.app.LegupPreferences; -import edu.rpi.legup.controller.BoardController; -import edu.rpi.legup.controller.RuleController; -import edu.rpi.legup.history.ICommand; -import edu.rpi.legup.history.IHistoryListener; -import edu.rpi.legup.model.tree.TreeNode; -import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.ui.lookandfeel.LegupLookAndFeel; -import edu.rpi.legup.model.Puzzle; -import edu.rpi.legup.model.PuzzleExporter; -import edu.rpi.legup.model.gameboard.Board; -import edu.rpi.legup.model.tree.Tree; -import edu.rpi.legup.save.ExportFileException; -import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.rulesview.RuleFrame; import edu.rpi.legup.ui.treeview.TreePanel; -import edu.rpi.legup.ui.treeview.TreeViewSelection; -import edu.rpi.legup.user.Submission; import edu.rpi.legupupdate.Update; import edu.rpi.legupupdate.UpdateProgress; -import io.grpc.internal.KeepAliveManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import javax.swing.border.TitledBorder; - -public class LegupUI extends JFrame implements WindowListener, IHistoryListener { +public class LegupUI extends JFrame implements WindowListener { private final static Logger LOGGER = LogManager.getLogger(LegupUI.class.getName()); public static final int ALLOW_HINTS = 1; @@ -60,30 +37,9 @@ public class LegupUI extends JFrame implements WindowListener, IHistoryListener private static int CONFIG_INDEX = 0; - protected JPanel contentPane; protected FileDialog fileDialog; protected JFileChooser folderBrowser; - protected PickGameDialog pickGameDialog; - protected JButton[] toolBarButtons; - - protected JMenuBar mBar; - - protected JMenu file; - protected JMenuItem newPuzzle, resetPuzzle, saveProof, preferences, exit; - - protected JMenu edit; - protected JMenuItem undo, redo; - - protected JMenu view; - - protected JMenu proof; - protected JMenuItem add, delete, merge, collapse; - protected JCheckBoxMenuItem allowDefault, caseRuleGen, imdFeedback; - - protected JMenu about; - protected JMenuItem checkUpdates, helpLegup, aboutLegup; - protected JMenu proofMode = new JMenu("Proof Mode"); protected JCheckBoxMenuItem[] proofModeItems = new JCheckBoxMenuItem[PROF_FLAGS.length]; @@ -93,23 +49,14 @@ public class LegupUI extends JFrame implements WindowListener, IHistoryListener protected JMenuItem testAI = new JMenuItem("Test AI!"); protected JMenuItem hintAI = new JMenuItem("Hint"); - protected JMenu help; - - protected JToolBar toolBar; - - protected BoardView boardView; - protected DynamicView dynamicBoardView; - private RuleFrame ruleFrame; - private TreePanel treePanel; + protected JPanel window; - protected TitledBorder boardBorder; - - protected JSplitPane topHalfPanel, mainPanel; + protected LegupPanel[] panels; /** * Identifies operating system */ - public String getOS() { + public static String getOS() { String os = System.getProperty("os.name").toLowerCase(); if(os.contains("mac")) os = "mac"; else os = "win"; @@ -129,9 +76,10 @@ public LegupUI() { System.err.println("Not supported ui look and fel"); } - this.contentPane = new JPanel(); - contentPane.setLayout(new BorderLayout()); - setContentPane(contentPane); + fileDialog = new FileDialog(this); + + initPanels(); + displayPanel(0); setIconImage(new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Basic Rules.gif")).getImage()); @@ -154,9 +102,6 @@ public LegupUI() { } } - setupMenu(); - setupToolBar(); - setupContent(); if (LegupPreferences.getInstance().getUserPref(LegupPreferences.START_FULL_SCREEN).equals(Boolean.toString(true))) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } @@ -181,495 +126,43 @@ public void keyTyped(KeyEvent e) { setMinimumSize(getPreferredSize()); } - public static boolean profFlag(int flag) { - return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); + private void initPanels() { + window = new JPanel(); + add(window); + panels = new LegupPanel[3]; + panels[0] = new HomePanel(this); + panels[1] = new PuzzleSolverPanel(this.fileDialog, this); + panels[2] = new PuzzleEditorPanel(); } - public void repaintTree() { - treePanel.repaintTreeView(GameBoardFacade.getInstance().getTree()); - } - - /** - * Sets up the menu bar - */ - private void setupMenu() { - mBar = new JMenuBar(); - fileDialog = new FileDialog(this); - - file = new JMenu("File"); - newPuzzle = new JMenuItem("Open"); - resetPuzzle = new JMenuItem("Reset Puzzle"); -// genPuzzle = new JMenuItem("Puzzle Generators"); - saveProof = new JMenuItem("Save Proof"); - preferences = new JMenuItem("Preferences"); - exit = new JMenuItem("Exit"); - - edit = new JMenu("Edit"); - undo = new JMenuItem("Undo"); - redo = new JMenuItem("Redo"); - - view = new JMenu("View"); - - proof = new JMenu("Proof"); - - String os = getOS(); - - add = new JMenuItem("Add"); - add.addActionListener(a -> treePanel.add()); - if(os == "mac") add.setAccelerator(KeyStroke.getKeyStroke('A', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else add.setAccelerator(KeyStroke.getKeyStroke('A', InputEvent.CTRL_DOWN_MASK)); - proof.add(add); - - delete = new JMenuItem("Delete"); - delete.addActionListener(a -> treePanel.delete()); - if(os == "mac") delete.setAccelerator(KeyStroke.getKeyStroke('D', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else delete.setAccelerator(KeyStroke.getKeyStroke('D', InputEvent.CTRL_DOWN_MASK)); - proof.add(delete); - - merge = new JMenuItem("Merge"); - merge.addActionListener(a -> treePanel.merge()); - if(os == "mac") merge.setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else merge.setAccelerator(KeyStroke.getKeyStroke('M', InputEvent.CTRL_DOWN_MASK)); - proof.add(merge); - - collapse = new JMenuItem("Collapse"); - collapse.addActionListener(a -> treePanel.collapse()); - if(os == "mac") collapse.setAccelerator(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else collapse.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK)); - collapse.setEnabled(false); - proof.add(collapse); - - allowDefault = new JCheckBoxMenuItem("Allow Default Rule Applications", - LegupPreferences.getInstance().getUserPref(LegupPreferences.ALLOW_DEFAULT_RULES).equalsIgnoreCase(Boolean.toString(true))); - allowDefault.addChangeListener(e -> { - LegupPreferences.getInstance().setUserPref(LegupPreferences.ALLOW_DEFAULT_RULES, Boolean.toString(allowDefault.isSelected())); - }); - proof.add(allowDefault); - - caseRuleGen = new JCheckBoxMenuItem("Automatically generate cases for CaseRule", - LegupPreferences.getInstance().getUserPref(LegupPreferences.AUTO_GENERATE_CASES).equalsIgnoreCase(Boolean.toString(true))); - caseRuleGen.addChangeListener(e -> { - LegupPreferences.getInstance().setUserPref(LegupPreferences.AUTO_GENERATE_CASES, Boolean.toString(caseRuleGen.isSelected())); - }); - proof.add(caseRuleGen); - - imdFeedback = new JCheckBoxMenuItem("Provide immediate feedback", - LegupPreferences.getInstance().getUserPref(LegupPreferences.IMMEDIATE_FEEDBACK).equalsIgnoreCase(Boolean.toString(true))); - imdFeedback.addChangeListener(e -> { - LegupPreferences.getInstance().setUserPref(LegupPreferences.IMMEDIATE_FEEDBACK, Boolean.toString(imdFeedback.isSelected())); - }); - proof.add(imdFeedback); - - about = new JMenu("About"); - checkUpdates = new JMenuItem("Check for Updates..."); - helpLegup = new JMenuItem("Help Legup"); - aboutLegup = new JMenuItem("About Legup"); - - // unused - // help = new JMenu("Help"); - - mBar.add(file); - file.add(newPuzzle); - newPuzzle.addActionListener((ActionEvent) -> promptPuzzle()); - if(os == "mac") newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK)); - -// file.add(genPuzzle); -//// genPuzzle.addActionListener((ActionEvent) -> -//// { -//// pickGameDialog = new PickGameDialog(this, true); -//// pickGameDialog.setVisible(true); -//// }); - file.add(resetPuzzle); - resetPuzzle.addActionListener(a -> { - Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); - if (puzzle != null) { - Tree tree = GameBoardFacade.getInstance().getTree(); - TreeNode rootNode = tree.getRootNode(); - if (rootNode != null) { - int confirmReset = JOptionPane.showConfirmDialog(this, "Reset Puzzle to Root Node?", "Confirm Reset", JOptionPane.YES_NO_CANCEL_OPTION); - if (confirmReset == JOptionPane.YES_OPTION) { - List children = rootNode.getChildren(); - children.forEach(t -> puzzle.notifyTreeListeners(l -> l.onTreeElementRemoved(t))); - final TreeViewSelection selection = new TreeViewSelection(treePanel.getTreeView().getElementView(rootNode)); - puzzle.notifyTreeListeners(l -> l.onTreeSelectionChanged(selection)); - GameBoardFacade.getInstance().getHistory().clear(); - } - } - } - }); - if(os == "mac") resetPuzzle.setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else resetPuzzle.setAccelerator(KeyStroke.getKeyStroke('R', InputEvent.CTRL_DOWN_MASK)); - file.addSeparator(); - - file.add(saveProof); - saveProof.addActionListener((ActionEvent) -> saveProof()); - if(os == "mac") saveProof.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else saveProof.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_DOWN_MASK)); - - file.add(preferences); - preferences.addActionListener(a -> { - PreferencesDialog preferencesDialog = new PreferencesDialog(this); - }); - file.addSeparator(); - - file.add(exit); - exit.addActionListener((ActionEvent) -> System.exit(0)); - if(os == "mac") exit.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else exit.setAccelerator(KeyStroke.getKeyStroke('Q', InputEvent.CTRL_DOWN_MASK)); - mBar.add(edit); - - - edit.add(undo); - undo.addActionListener((ActionEvent) -> - { - GameBoardFacade.getInstance().getHistory().undo(); - }); - if(os == "mac") undo.setAccelerator(KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else undo.setAccelerator(KeyStroke.getKeyStroke('Z', InputEvent.CTRL_DOWN_MASK)); - - edit.add(redo); - redo.addActionListener((ActionEvent) -> - { - GameBoardFacade.getInstance().getHistory().redo(); - }); - if(os == "mac") redo.setAccelerator(KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else redo.setAccelerator(KeyStroke.getKeyStroke('Y', InputEvent.CTRL_DOWN_MASK)); - - mBar.add(proof); - - about.add(checkUpdates); - checkUpdates.addActionListener(l -> { - checkUpdates(); - }); - checkUpdates.setEnabled(false); - - about.add(aboutLegup); - aboutLegup.addActionListener(l -> { - JOptionPane.showMessageDialog(null, "Version: 2.0.0"); - }); - - about.add(helpLegup); - helpLegup.addActionListener(l -> { - try { - java.awt.Desktop.getDesktop().browse(URI.create("https://github.com/jpoegs/Legup2.0")); - } catch (IOException e) { - LOGGER.error("Can't open web page"); - } - }); - - mBar.add(about); - - setJMenuBar(mBar); - } - - // contains all the code to setup the toolbar - private void setupToolBar() { - setToolBarButtons(new JButton[ToolbarName.values().length]); - for (int i = 0; i < ToolbarName.values().length; i++) { - String toolBarName = ToolbarName.values()[i].toString(); - URL resourceLocation = ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/" + toolBarName + ".png"); - JButton button = new JButton(toolBarName, new ImageIcon(resourceLocation)); - button.setFocusPainted(false); - getToolBarButtons()[i] = button; - } - - toolBar = new JToolBar(); - toolBar.setFloatable(false); - toolBar.setRollover(true); - - for (int i = 0; i < getToolBarButtons().length; i++) { - for (int s = 0; s < TOOLBAR_SEPARATOR_BEFORE.length; s++) { - if (i == TOOLBAR_SEPARATOR_BEFORE[s]) { - toolBar.addSeparator(); - } - } - String toolBarName = ToolbarName.values()[i].toString(); - - toolBar.add(getToolBarButtons()[i]); - getToolBarButtons()[i].setToolTipText(toolBarName); - - getToolBarButtons()[i].setVerticalTextPosition(SwingConstants.BOTTOM); - getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER); + protected void displayPanel(int option) { + if (option > panels.length) { + throw new InvalidParameterException("Invalid option"); } - - toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); - toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); - toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); - toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); - toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> { - }); - toolBarButtons[ToolbarName.CHECK.ordinal()].addActionListener((ActionEvent e) -> checkProof()); - toolBarButtons[ToolbarName.SUBMIT.ordinal()].addActionListener((ActionEvent e) -> { - }); - toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].addActionListener((ActionEvent e) -> { - }); - - toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].addActionListener((ActionEvent e) -> checkProofAll()); - - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].setEnabled(true); - - contentPane.add(toolBar, BorderLayout.NORTH); - } - - /** - * Sets the main content for the edu.rpi.legup.user interface - */ - protected void setupContent() { -// JPanel consoleBox = new JPanel(new BorderLayout()); - JPanel treeBox = new JPanel(new BorderLayout()); - JPanel ruleBox = new JPanel(new BorderLayout()); - - RuleController ruleController = new RuleController(); - ruleFrame = new RuleFrame(ruleController); - ruleBox.add(ruleFrame, BorderLayout.WEST); - - treePanel = new TreePanel(this); - - dynamicBoardView = new DynamicView(new ScrollView(new BoardController())); - TitledBorder titleBoard = BorderFactory.createTitledBorder("Board"); - titleBoard.setTitleJustification(TitledBorder.CENTER); - dynamicBoardView.setBorder(titleBoard); - - JPanel boardPanel = new JPanel(new BorderLayout()); - topHalfPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, ruleFrame, dynamicBoardView); - mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topHalfPanel, treePanel); - topHalfPanel.setPreferredSize(new Dimension(600, 400)); - mainPanel.setPreferredSize(new Dimension(600, 600)); - - boardPanel.add(mainPanel); - boardBorder = BorderFactory.createTitledBorder("Board"); - boardBorder.setTitleJustification(TitledBorder.CENTER); - - ruleBox.add(boardPanel); - treeBox.add(ruleBox); - contentPane.add(treeBox); -// consoleBox.add(treeBox); -// -// getContentPane().add(consoleBox); - -// JPopupPanel popupPanel = new JPopupPanel(); -// setGlassPane(popupPanel); -// popupPanel.setVisible(true); - - mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation() + 100); + this.window.removeAll(); + panels[option].makeVisible(); + this.window.add(panels[option]); pack(); revalidate(); + repaint(); } - /** - * Saves a proof - */ - private void saveProof() { - Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); - if (puzzle == null) { - return; - } - - fileDialog.setMode(FileDialog.SAVE); - fileDialog.setTitle("Save Proof"); - String curFileName = GameBoardFacade.getInstance().getCurFileName(); - if (curFileName == null) { - fileDialog.setDirectory(LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); - } else { - File curFile = new File(curFileName); - fileDialog.setDirectory(curFile.getParent()); - } - fileDialog.setVisible(true); - - String fileName = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); - } - - if (fileName != null) { - try { - PuzzleExporter exporter = puzzle.getExporter(); - if (exporter == null) { - throw new ExportFileException("Puzzle exporter null"); - } - exporter.exportPuzzle(fileName); - } catch (ExportFileException e) { - e.printStackTrace(); - } - } + public PuzzleSolverPanel getPuzzleSolver() { + return (PuzzleSolverPanel) panels[1]; } - /** - * Checks the proof for correctness - */ - private void checkProof() { - GameBoardFacade facade = GameBoardFacade.getInstance(); - Tree tree = GameBoardFacade.getInstance().getTree(); - Board board = facade.getBoard(); - Board finalBoard = null; - boolean delayStatus = true; //board.evalDelayStatus(); - - repaintAll(); - - Puzzle puzzle = facade.getPuzzleModule(); - - if (puzzle.isPuzzleComplete()) { - // This is for submission which is not integrated yet - /*int confirm = JOptionPane.showConfirmDialog(null, "Congratulations! Your proof is correct. Would you like to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); - if (confirm == JOptionPane.YES_OPTION) { - Submission submission = new Submission(board); - submission.submit(); - }*/ - JOptionPane.showMessageDialog(null, "Congratulations! Your proof is correct."); - showStatus("Your proof is correct.", false); - } else { - String message = "\nThe game board is not solved."; - JOptionPane.showMessageDialog(null, message, "Invalid proof.", JOptionPane.ERROR_MESSAGE); - - showStatus(message, true); - } - } - - private void traverseDir(File folder, BufferedWriter writer, String path) throws IOException { - // Recursively traverse directory - GameBoardFacade facade = GameBoardFacade.getInstance(); - - // Folder is empty - if(folder.listFiles().length == 0) { - writer.append(path + ",Empty folder,0,Ungradeable\n"); - return; - } - - // Travese directory, recurse if sub-directory found - for(final File f : folder.listFiles()) { - // Recurse - if(f.isDirectory()) { - traverseDir(f, writer, path + "/" + f.getName()); - continue; - } - - // Set path name - writer.append(path + ","); - - // Load puzzle, run checker - // If wrong file type, ungradeable - String fName = f.getName(); - String fPath = f.getAbsolutePath(); - File puzzleFile = new File(fPath); - if(puzzleFile != null && puzzleFile.exists()) { - // Try to load file. If invalid, note in csv - try { - // Load puzzle, run checker - GameBoardFacade.getInstance().loadPuzzle(fPath); - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - setTitle(puzzleName + " - " + puzzleFile.getName()); - facade = GameBoardFacade.getInstance(); - Puzzle puzzle = facade.getPuzzleModule(); - - // Write data - writer.append(fName + ","); - if(puzzle.isPuzzleComplete()) writer.append("1,Solved\n"); - else writer.append("0,Unsolved\n"); - } catch (InvalidFileFormatException e) { - writer.append(fName + " - invalid type,0,Ungradeable\n"); - } - } else { - LOGGER.debug("Failed to run sim"); - } - } - } - - /** - * Checks the proof for all files - */ - private void checkProofAll() { - GameBoardFacade facade = GameBoardFacade.getInstance(); - - /** - * Select dir to grade; recursively grade sub-dirs using traverseDir() - * Selected dir must have sub-dirs for each student: - * GradeThis - * | - * | -> Student 1 - * | | - * | | -> Proofs - **/ - folderBrowser = new JFileChooser(); - folderBrowser.setCurrentDirectory(new java.io.File(".")); - folderBrowser.setDialogTitle("Select Directory"); - folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - folderBrowser.setAcceptAllFileFilterUsed(false); - folderBrowser.showOpenDialog(this); - File folder = folderBrowser.getSelectedFile(); - - // Write csv file (Path,File-Name,Score,Solved?) - File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { - writer.append("Name,File Name,Score,Solved?\n"); - - // Go through student folders - for (final File folderEntry : folder.listFiles(File::isDirectory)) { - // Write path - String path = folderEntry.getName(); - traverseDir(folderEntry, writer, path); - } - }catch (IOException ex){ - //LOGGER.error(ex.getMessage()); - } - JOptionPane.showMessageDialog(null, "Batch grading complete."); - } - - private boolean basicCheckProof(int[][] origCells) { - return false; + public static boolean profFlag(int flag) { + return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } - /** - * Submits the proof file - */ - private void submit() { - GameBoardFacade facade = GameBoardFacade.getInstance(); - Board board = facade.getBoard(); - boolean delayStatus = true; //board.evalDelayStatus(); - repaintAll(); - - Puzzle pm = facade.getPuzzleModule(); - if (pm.isPuzzleComplete() && delayStatus) { - // 0 means yes, 1 means no (Java's fault...) - int confirm = JOptionPane.showConfirmDialog(null, "Are you sure you wish to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); - if (confirm == 0) { - Submission submission = new Submission(board); - submission.submit(); - } - } else { - JOptionPane.showConfirmDialog(null, "Your proof is incorrect! Are you sure you wish to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); - Submission submit = new Submission(board); - } + public void repaintTree() { + getPuzzleSolver().repaintTree(); } private void directions() { JOptionPane.showMessageDialog(null, "For every move you make, you must provide a rules for it (located in the Rules panel).\n" + "While working on the edu.rpi.legup.puzzle, you may click on the \"Check\" button to test your proof for correctness.", "Directions", JOptionPane.PLAIN_MESSAGE); } - private void showAll() { - getToolBarButtons()[ToolbarName.SAVE.ordinal()].setEnabled(true); - getToolBarButtons()[ToolbarName.UNDO.ordinal()].setEnabled(false); - getToolBarButtons()[ToolbarName.REDO.ordinal()].setEnabled(false); - getToolBarButtons()[ToolbarName.HINT.ordinal()].setEnabled(true); - getToolBarButtons()[ToolbarName.CHECK.ordinal()].setEnabled(true); - getToolBarButtons()[ToolbarName.SUBMIT.ordinal()].setEnabled(true); - getToolBarButtons()[ToolbarName.DIRECTIONS.ordinal()].setEnabled(true); - - pack(); - } - - private void repaintAll() { - boardView.repaint(); - treePanel.repaint(); - } - public void showStatus(String status, boolean error) { showStatus(status, error, 1); } @@ -678,40 +171,6 @@ public void errorEncountered(String error) { JOptionPane.showMessageDialog(null, error); } - public void reloadGui() { - repaintTree(); - } - - public void promptPuzzle() { - GameBoardFacade facade = GameBoardFacade.getInstance(); - if (facade.getBoard() != null) { - if (noquit("Opening a new puzzle?")) // !noquit or noquit? - { - return; - } - } - - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setTitle("Select Puzzle"); - fileDialog.setVisible(true); - String fileName = null; - File puzzleFile = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); - puzzleFile = new File(fileName); - } - - if (puzzleFile != null && puzzleFile.exists()) { - try { - GameBoardFacade.getInstance().loadPuzzle(fileName); - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - setTitle(puzzleName + " - " + puzzleFile.getName()); - } catch (InvalidFileFormatException e) { - LOGGER.error(e.getMessage()); - } - } - } - public void showStatus(String status, boolean error, int timer) { } @@ -839,135 +298,15 @@ public void windowDeactivated(WindowEvent e) { } - /** - * Gets the toolbar buttons - * - * @return toolbar buttons - */ - public JButton[] getToolBarButtons() { - return toolBarButtons; - } - - /** - * Sets the toolbar buttons - * - * @param toolBarButtons toolbar buttons - */ - public void setToolBarButtons(JButton[] toolBarButtons) { - this.toolBarButtons = toolBarButtons; - } - - public void setPuzzleView(Puzzle puzzle) { - this.boardView = puzzle.getBoardView(); - - dynamicBoardView = new DynamicView(boardView); - this.topHalfPanel.setRightComponent(dynamicBoardView); - this.topHalfPanel.setVisible(true); - - TitledBorder titleBoard = BorderFactory.createTitledBorder(boardView.getClass().getSimpleName()); - titleBoard.setTitleJustification(TitledBorder.CENTER); - dynamicBoardView.setBorder(titleBoard); - - this.treePanel.getTreeView().resetView(); - this.treePanel.getTreeView().setTree(puzzle.getTree()); - - puzzle.addTreeListener(treePanel.getTreeView()); - puzzle.addBoardListener(puzzle.getBoardView()); - - ruleFrame.getBasicRulePanel().setRules(puzzle.getBasicRules()); - ruleFrame.getCasePanel().setRules(puzzle.getCaseRules()); - ruleFrame.getContradictionPanel().setRules(puzzle.getContradictionRules()); - - toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true); - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); - - reloadGui(); - } - public BoardView getBoardView() { - return boardView; + return getPuzzleSolver().getBoardView(); } public DynamicView getDynamicBoardView() { - return dynamicBoardView; + return getPuzzleSolver().getDynamicBoardView(); } public TreePanel getTreePanel() { - return treePanel; - } - - /** - * Called when a action is pushed onto the edu.rpi.legup.history stack - * - * @param command action to push onto the stack - */ - @Override - public void onPushChange(ICommand command) { - LOGGER.info("Pushing " + command.getClass().getSimpleName() + " to stack."); - undo.setEnabled(true); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true); - redo.setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); - - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); - setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); - } - - /** - * Called when an action is undone - * - * @param isBottom true if there are no more actions to undo, false otherwise - * @param isTop true if there are no more changes to redo, false otherwise - */ - @Override - public void onUndo(boolean isBottom, boolean isTop) { - undo.setEnabled(!isBottom); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); - redo.setEnabled(!isTop); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); - if (isBottom) { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); - setTitle(puzzleName + " - " + puzzleFile.getName()); - } else { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); - setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); - } - } - - /** - * Called when an action is redone - * - * @param isBottom true if there are no more actions to undo, false otherwise - * @param isTop true if there are no more changes to redo, false otherwise - */ - @Override - public void onRedo(boolean isBottom, boolean isTop) { - undo.setEnabled(!isBottom); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); - redo.setEnabled(!isTop); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); - if (isBottom) { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); - setTitle(puzzleName + " - " + puzzleFile.getName()); - } else { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); - setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); - } - } - - /** - * Called when the history is cleared - */ - @Override - public void onClearHistory() { - undo.setEnabled(false); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); - redo.setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); + return getPuzzleSolver().getTreePanel(); } } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java new file mode 100644 index 000000000..44f0b0f3f --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -0,0 +1,18 @@ +package edu.rpi.legup.ui; + +import javax.swing.*; + +public class PuzzleEditorPanel extends LegupPanel { + public PuzzleEditorPanel() { + + } + + @Override + public void makeVisible() { + render(); + } + + private void render() { + add(new JLabel("Puzzle Editor goes here")); + } +} diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java new file mode 100644 index 000000000..036d9f3b7 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java @@ -0,0 +1,699 @@ +package edu.rpi.legup.ui; + +import edu.rpi.legup.app.GameBoardFacade; +import edu.rpi.legup.app.LegupPreferences; +import edu.rpi.legup.controller.BoardController; +import edu.rpi.legup.controller.RuleController; +import edu.rpi.legup.history.ICommand; +import edu.rpi.legup.history.IHistoryListener; +import edu.rpi.legup.model.Puzzle; +import edu.rpi.legup.model.PuzzleExporter; +import edu.rpi.legup.model.gameboard.Board; +import edu.rpi.legup.model.tree.Tree; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.save.ExportFileException; +import edu.rpi.legup.save.InvalidFileFormatException; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.rulesview.RuleFrame; +import edu.rpi.legup.ui.treeview.TreePanel; +import edu.rpi.legup.ui.treeview.TreeViewSelection; +import edu.rpi.legup.user.Submission; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.List; + +public class PuzzleSolverPanel extends LegupPanel implements IHistoryListener { + private final static Logger LOGGER = LogManager.getLogger(PuzzleSolverPanel.class.getName()); + private JMenuBar mBar; + private TreePanel treePanel; + private FileDialog fileDialog; + private JFrame frame; + private RuleFrame ruleFrame; + private DynamicView dynamicBoardView; + private JSplitPane topHalfPanel, mainPanel; + private TitledBorder boardBorder; + private JButton[] toolBarButtons; + private JToolBar toolBar; + private BoardView boardView; + private JFileChooser folderBrowser; + private JMenuItem undo, redo; + + final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; + + public PuzzleSolverPanel(FileDialog fileDialog, JFrame frame) { + this.fileDialog = fileDialog; + this.frame = frame; + setLayout(new BorderLayout()); + } + + @Override + public void makeVisible() { + setupToolBar(); + setupContent(); + frame.setJMenuBar(getMenuBar()); + } + + public JMenuBar getMenuBar() { + mBar = new JMenuBar(); + + JMenu file = new JMenu("File"); + JMenuItem newPuzzle = new JMenuItem("Open"); + JMenuItem resetPuzzle = new JMenuItem("Reset Puzzle"); +// genPuzzle = new JMenuItem("Puzzle Generators"); + JMenuItem saveProof = new JMenuItem("Save Proof"); + JMenuItem preferences = new JMenuItem("Preferences"); + JMenuItem exit = new JMenuItem("Exit"); + + JMenu edit = new JMenu("Edit"); + undo = new JMenuItem("Undo"); + redo = new JMenuItem("Redo"); + + JMenu view = new JMenu("View"); + + JMenu proof = new JMenu("Proof"); + + String os = LegupUI.getOS(); + + JMenuItem add = new JMenuItem("Add"); + add.addActionListener(a -> treePanel.add()); + if(os.equals("mac")) add.setAccelerator(KeyStroke.getKeyStroke('A', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else add.setAccelerator(KeyStroke.getKeyStroke('A', InputEvent.CTRL_DOWN_MASK)); + proof.add(add); + + JMenuItem delete = new JMenuItem("Delete"); + delete.addActionListener(a -> treePanel.delete()); + if(os.equals("mac")) delete.setAccelerator(KeyStroke.getKeyStroke('D', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else delete.setAccelerator(KeyStroke.getKeyStroke('D', InputEvent.CTRL_DOWN_MASK)); + proof.add(delete); + + JMenuItem merge = new JMenuItem("Merge"); + merge.addActionListener(a -> treePanel.merge()); + if(os.equals("mac")) merge.setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else merge.setAccelerator(KeyStroke.getKeyStroke('M', InputEvent.CTRL_DOWN_MASK)); + proof.add(merge); + + JMenuItem collapse = new JMenuItem("Collapse"); + collapse.addActionListener(a -> treePanel.collapse()); + if(os.equals("mac")) collapse.setAccelerator(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else collapse.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK)); + collapse.setEnabled(false); + proof.add(collapse); + + JCheckBoxMenuItem allowDefault = new JCheckBoxMenuItem("Allow Default Rule Applications", + LegupPreferences.getInstance().getUserPref(LegupPreferences.ALLOW_DEFAULT_RULES).equalsIgnoreCase(Boolean.toString(true))); + allowDefault.addChangeListener(e -> { + LegupPreferences.getInstance().setUserPref(LegupPreferences.ALLOW_DEFAULT_RULES, Boolean.toString(allowDefault.isSelected())); + }); + proof.add(allowDefault); + + JCheckBoxMenuItem caseRuleGen = new JCheckBoxMenuItem("Automatically generate cases for CaseRule", + LegupPreferences.getInstance().getUserPref(LegupPreferences.AUTO_GENERATE_CASES).equalsIgnoreCase(Boolean.toString(true))); + caseRuleGen.addChangeListener(e -> { + LegupPreferences.getInstance().setUserPref(LegupPreferences.AUTO_GENERATE_CASES, Boolean.toString(caseRuleGen.isSelected())); + }); + proof.add(caseRuleGen); + + JCheckBoxMenuItem imdFeedback = new JCheckBoxMenuItem("Provide immediate feedback", + LegupPreferences.getInstance().getUserPref(LegupPreferences.IMMEDIATE_FEEDBACK).equalsIgnoreCase(Boolean.toString(true))); + imdFeedback.addChangeListener(e -> { + LegupPreferences.getInstance().setUserPref(LegupPreferences.IMMEDIATE_FEEDBACK, Boolean.toString(imdFeedback.isSelected())); + }); + proof.add(imdFeedback); + + JMenu about = new JMenu("About"); + JMenuItem checkUpdates = new JMenuItem("Check for Updates..."); + JMenuItem helpLegup = new JMenuItem("Help Legup"); + JMenuItem aboutLegup = new JMenuItem("About Legup"); + + // unused + // help = new JMenu("Help"); + + mBar.add(file); + file.add(newPuzzle); + newPuzzle.addActionListener((ActionEvent) -> promptPuzzle()); + if(os.equals("mac")) newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK)); + +// file.add(genPuzzle); +//// genPuzzle.addActionListener((ActionEvent) -> +//// { +//// pickGameDialog = new PickGameDialog(this, true); +//// pickGameDialog.setVisible(true); +//// }); + file.add(resetPuzzle); + resetPuzzle.addActionListener(a -> { + Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); + if (puzzle != null) { + Tree tree = GameBoardFacade.getInstance().getTree(); + TreeNode rootNode = tree.getRootNode(); + if (rootNode != null) { + int confirmReset = JOptionPane.showConfirmDialog(this, "Reset Puzzle to Root Node?", "Confirm Reset", JOptionPane.YES_NO_CANCEL_OPTION); + if (confirmReset == JOptionPane.YES_OPTION) { + List children = rootNode.getChildren(); + children.forEach(t -> puzzle.notifyTreeListeners(l -> l.onTreeElementRemoved(t))); + final TreeViewSelection selection = new TreeViewSelection(treePanel.getTreeView().getElementView(rootNode)); + puzzle.notifyTreeListeners(l -> l.onTreeSelectionChanged(selection)); + GameBoardFacade.getInstance().getHistory().clear(); + } + } + } + }); + if(os.equals("mac")) resetPuzzle.setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else resetPuzzle.setAccelerator(KeyStroke.getKeyStroke('R', InputEvent.CTRL_DOWN_MASK)); + file.addSeparator(); + + file.add(saveProof); + saveProof.addActionListener((ActionEvent) -> saveProof()); + if(os.equals("mac")) saveProof.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else saveProof.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_DOWN_MASK)); + + file.add(preferences); +// preferences.addActionListener(a -> { +// PreferencesDialog preferencesDialog = new PreferencesDialog(this); +// }); + file.addSeparator(); + + file.add(exit); + exit.addActionListener((ActionEvent) -> System.exit(0)); + if(os.equals("mac")) exit.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else exit.setAccelerator(KeyStroke.getKeyStroke('Q', InputEvent.CTRL_DOWN_MASK)); + mBar.add(edit); + + + edit.add(undo); + undo.addActionListener((ActionEvent) -> + { + GameBoardFacade.getInstance().getHistory().undo(); + }); + if(os.equals("mac")) undo.setAccelerator(KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else undo.setAccelerator(KeyStroke.getKeyStroke('Z', InputEvent.CTRL_DOWN_MASK)); + + edit.add(redo); + redo.addActionListener((ActionEvent) -> + { + GameBoardFacade.getInstance().getHistory().redo(); + }); + if(os.equals("mac")) redo.setAccelerator(KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else redo.setAccelerator(KeyStroke.getKeyStroke('Y', InputEvent.CTRL_DOWN_MASK)); + + mBar.add(proof); + + about.add(checkUpdates); + checkUpdates.addActionListener(l -> { + //checkUpdates(); + }); + checkUpdates.setEnabled(false); + + about.add(aboutLegup); + aboutLegup.addActionListener(l -> { + JOptionPane.showMessageDialog(null, "Version: 2.0.0"); + }); + + about.add(helpLegup); + helpLegup.addActionListener(l -> { + try { + java.awt.Desktop.getDesktop().browse(URI.create("https://github.com/jpoegs/Legup2.0")); + } catch (IOException e) { + LOGGER.error("Can't open web page"); + } + }); + + mBar.add(about); + + return mBar; + } + + public void promptPuzzle() { + GameBoardFacade facade = GameBoardFacade.getInstance(); + if (facade.getBoard() != null) { + if (noquit("Opening a new puzzle?")) // !noquit or noquit? + { + return; + } + } + + fileDialog.setMode(FileDialog.LOAD); + fileDialog.setTitle("Select Puzzle"); + fileDialog.setVisible(true); + String fileName = null; + File puzzleFile = null; + if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { + fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + puzzleFile = new File(fileName); + } + + if (puzzleFile != null && puzzleFile.exists()) { + try { + GameBoardFacade.getInstance().loadPuzzle(fileName); + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + frame.setTitle(puzzleName + " - " + puzzleFile.getName()); + } catch (InvalidFileFormatException e) { + LOGGER.error(e.getMessage()); + } + } + } + + /** + * Saves a proof + */ + private void saveProof() { + Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule(); + if (puzzle == null) { + return; + } + + fileDialog.setMode(FileDialog.SAVE); + fileDialog.setTitle("Save Proof"); + String curFileName = GameBoardFacade.getInstance().getCurFileName(); + if (curFileName == null) { + fileDialog.setDirectory(LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); + } else { + File curFile = new File(curFileName); + fileDialog.setDirectory(curFile.getParent()); + } + fileDialog.setVisible(true); + + String fileName = null; + if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { + fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + } + + if (fileName != null) { + try { + PuzzleExporter exporter = puzzle.getExporter(); + if (exporter == null) { + throw new ExportFileException("Puzzle exporter null"); + } + exporter.exportPuzzle(fileName); + } catch (ExportFileException e) { + e.printStackTrace(); + } + } + } + + public boolean noquit(String instr) { + int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_CANCEL_OPTION); + if (n == JOptionPane.YES_OPTION) { + return false; + } + return true; + } + + /** + * Sets the main content for the edu.rpi.legup.user interface + */ + protected void setupContent() { +// JPanel consoleBox = new JPanel(new BorderLayout()); + JPanel treeBox = new JPanel(new BorderLayout()); + JPanel ruleBox = new JPanel(new BorderLayout()); + + RuleController ruleController = new RuleController(); + ruleFrame = new RuleFrame(ruleController); + ruleBox.add(ruleFrame, BorderLayout.WEST); + + treePanel = new TreePanel(); + + dynamicBoardView = new DynamicView(new ScrollView(new BoardController())); + TitledBorder titleBoard = BorderFactory.createTitledBorder("Board"); + titleBoard.setTitleJustification(TitledBorder.CENTER); + dynamicBoardView.setBorder(titleBoard); + + JPanel boardPanel = new JPanel(new BorderLayout()); + topHalfPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, ruleFrame, dynamicBoardView); + mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topHalfPanel, treePanel); + topHalfPanel.setPreferredSize(new Dimension(600, 400)); + mainPanel.setPreferredSize(new Dimension(600, 600)); + + boardPanel.add(mainPanel); + boardBorder = BorderFactory.createTitledBorder("Board"); + boardBorder.setTitleJustification(TitledBorder.CENTER); + + ruleBox.add(boardPanel); + treeBox.add(ruleBox); + this.add(treeBox); +// consoleBox.add(treeBox); +// +// getContentPane().add(consoleBox); + +// JPopupPanel popupPanel = new JPopupPanel(); +// setGlassPane(popupPanel); +// popupPanel.setVisible(true); + + mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation() + 100); + //frame.pack(); + revalidate(); + } + + private void setupToolBar() { + setToolBarButtons(new JButton[ToolbarName.values().length]); + for (int i = 0; i < ToolbarName.values().length; i++) { + String toolBarName = ToolbarName.values()[i].toString(); + URL resourceLocation = ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/" + toolBarName + ".png"); + JButton button = new JButton(toolBarName, new ImageIcon(resourceLocation)); + button.setFocusPainted(false); + getToolBarButtons()[i] = button; + } + + toolBar = new JToolBar(); + toolBar.setFloatable(false); + toolBar.setRollover(true); + + for (int i = 0; i < getToolBarButtons().length; i++) { + for (int s = 0; s < TOOLBAR_SEPARATOR_BEFORE.length; s++) { + if (i == TOOLBAR_SEPARATOR_BEFORE[s]) { + toolBar.addSeparator(); + } + } + String toolBarName = ToolbarName.values()[i].toString(); + + toolBar.add(getToolBarButtons()[i]); + getToolBarButtons()[i].setToolTipText(toolBarName); + + getToolBarButtons()[i].setVerticalTextPosition(SwingConstants.BOTTOM); + getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER); + } + + toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); + //toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); + toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); + toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); + toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> { + }); + toolBarButtons[ToolbarName.CHECK.ordinal()].addActionListener((ActionEvent e) -> checkProof()); + toolBarButtons[ToolbarName.SUBMIT.ordinal()].addActionListener((ActionEvent e) -> { + }); + toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].addActionListener((ActionEvent e) -> { + }); + + toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].addActionListener((ActionEvent e) -> checkProofAll()); + + toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].setEnabled(true); + + this.add(toolBar, BorderLayout.NORTH); + } + + /** + * Sets the toolbar buttons + * + * @param toolBarButtons toolbar buttons + */ + public void setToolBarButtons(JButton[] toolBarButtons) { + this.toolBarButtons = toolBarButtons; + } + + /** + * Gets the toolbar buttons + * + * @return toolbar buttons + */ + public JButton[] getToolBarButtons() { + return toolBarButtons; + } + + /** + * Checks the proof for correctness + */ + private void checkProof() { + GameBoardFacade facade = GameBoardFacade.getInstance(); + Tree tree = GameBoardFacade.getInstance().getTree(); + Board board = facade.getBoard(); + Board finalBoard = null; + boolean delayStatus = true; //board.evalDelayStatus(); + + repaintAll(); + + Puzzle puzzle = facade.getPuzzleModule(); + + if (puzzle.isPuzzleComplete()) { + // This is for submission which is not integrated yet + /*int confirm = JOptionPane.showConfirmDialog(null, "Congratulations! Your proof is correct. Would you like to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); + if (confirm == JOptionPane.YES_OPTION) { + Submission submission = new Submission(board); + submission.submit(); + }*/ + JOptionPane.showMessageDialog(null, "Congratulations! Your proof is correct."); + } else { + String message = "\nThe game board is not solved."; + JOptionPane.showMessageDialog(null, message, "Invalid proof.", JOptionPane.ERROR_MESSAGE); + } + } + + private void repaintAll() { + boardView.repaint(); + treePanel.repaint(); + } + + public void setPuzzleView(Puzzle puzzle) { + this.boardView = puzzle.getBoardView(); + + dynamicBoardView = new DynamicView(boardView); + this.topHalfPanel.setRightComponent(dynamicBoardView); + this.topHalfPanel.setVisible(true); + + TitledBorder titleBoard = BorderFactory.createTitledBorder(boardView.getClass().getSimpleName()); + titleBoard.setTitleJustification(TitledBorder.CENTER); + dynamicBoardView.setBorder(titleBoard); + + this.treePanel.getTreeView().resetView(); + this.treePanel.getTreeView().setTree(puzzle.getTree()); + + puzzle.addTreeListener(treePanel.getTreeView()); + puzzle.addBoardListener(puzzle.getBoardView()); + + ruleFrame.getBasicRulePanel().setRules(puzzle.getBasicRules()); + ruleFrame.getCasePanel().setRules(puzzle.getCaseRules()); + ruleFrame.getContradictionPanel().setRules(puzzle.getContradictionRules()); + + toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true); + toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); + + reloadGui(); + } + + public void reloadGui() { + repaintTree(); + } + + public void repaintTree() { + treePanel.repaintTreeView(GameBoardFacade.getInstance().getTree()); + } + + /** + * Checks the proof for all files + */ + private void checkProofAll() { + GameBoardFacade facade = GameBoardFacade.getInstance(); + + /** + * Select dir to grade; recursively grade sub-dirs using traverseDir() + * Selected dir must have sub-dirs for each student: + * GradeThis + * | + * | -> Student 1 + * | | + * | | -> Proofs + **/ + folderBrowser = new JFileChooser(); + folderBrowser.setCurrentDirectory(new java.io.File(".")); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + folderBrowser.setAcceptAllFileFilterUsed(false); + folderBrowser.showOpenDialog(this); + File folder = folderBrowser.getSelectedFile(); + + // Write csv file (Path,File-Name,Score,Solved?) + File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { + writer.append("Name,File Name,Score,Solved?\n"); + + // Go through student folders + for (final File folderEntry : folder.listFiles(File::isDirectory)) { + // Write path + String path = folderEntry.getName(); + traverseDir(folderEntry, writer, path); + } + }catch (IOException ex){ + //LOGGER.error(ex.getMessage()); + } + JOptionPane.showMessageDialog(null, "Batch grading complete."); + } + + private void traverseDir(File folder, BufferedWriter writer, String path) throws IOException { + // Recursively traverse directory + GameBoardFacade facade = GameBoardFacade.getInstance(); + + // Folder is empty + if(folder.listFiles().length == 0) { + writer.append(path + ",Empty folder,0,Ungradeable\n"); + return; + } + + // Travese directory, recurse if sub-directory found + for(final File f : folder.listFiles()) { + // Recurse + if(f.isDirectory()) { + traverseDir(f, writer, path + "/" + f.getName()); + continue; + } + + // Set path name + writer.append(path + ","); + + // Load puzzle, run checker + // If wrong file type, ungradeable + String fName = f.getName(); + String fPath = f.getAbsolutePath(); + File puzzleFile = new File(fPath); + if(puzzleFile != null && puzzleFile.exists()) { + // Try to load file. If invalid, note in csv + try { + // Load puzzle, run checker + GameBoardFacade.getInstance().loadPuzzle(fPath); + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + frame.setTitle(puzzleName + " - " + puzzleFile.getName()); + facade = GameBoardFacade.getInstance(); + Puzzle puzzle = facade.getPuzzleModule(); + + // Write data + writer.append(fName + ","); + if(puzzle.isPuzzleComplete()) writer.append("1,Solved\n"); + else writer.append("0,Unsolved\n"); + } catch (InvalidFileFormatException e) { + writer.append(fName + " - invalid type,0,Ungradeable\n"); + } + } else { + LOGGER.debug("Failed to run sim"); + } + } + } + + public BoardView getBoardView() { + return boardView; + } + + public DynamicView getDynamicBoardView() { + return dynamicBoardView; + } + + public TreePanel getTreePanel() { + return treePanel; + } + + /** + * Called when a action is pushed onto the edu.rpi.legup.history stack + * + * @param command action to push onto the stack + */ + @Override + public void onPushChange(ICommand command) { + LOGGER.info("Pushing " + command.getClass().getSimpleName() + " to stack."); + undo.setEnabled(true); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true); + redo.setEnabled(false); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); + + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); + frame.setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); + } + + /** + * Called when the history is cleared + */ + @Override + public void onClearHistory() { + undo.setEnabled(false); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); + redo.setEnabled(false); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); + } + + /** + * Called when an action is redone + * + * @param isBottom true if there are no more actions to undo, false otherwise + * @param isTop true if there are no more changes to redo, false otherwise + */ + @Override + public void onRedo(boolean isBottom, boolean isTop) { + undo.setEnabled(!isBottom); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); + redo.setEnabled(!isTop); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); + if (isBottom) { + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); + frame.setTitle(puzzleName + " - " + puzzleFile.getName()); + } else { + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); + frame.setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); + } + } + + /** + * Called when an action is undone + * + * @param isBottom true if there are no more actions to undo, false otherwise + * @param isTop true if there are no more changes to redo, false otherwise + */ + @Override + public void onUndo(boolean isBottom, boolean isTop) { + undo.setEnabled(!isBottom); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); + redo.setEnabled(!isTop); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); + if (isBottom) { + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); + frame.setTitle(puzzleName + " - " + puzzleFile.getName()); + } else { + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); + frame.setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); + } + } + + /** + * Submits the proof file + */ + private void submit() { + GameBoardFacade facade = GameBoardFacade.getInstance(); + Board board = facade.getBoard(); + boolean delayStatus = true; //board.evalDelayStatus(); + repaintAll(); + + Puzzle pm = facade.getPuzzleModule(); + if (pm.isPuzzleComplete() && delayStatus) { + // 0 means yes, 1 means no (Java's fault...) + int confirm = JOptionPane.showConfirmDialog(null, "Are you sure you wish to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); + if (confirm == 0) { + Submission submission = new Submission(board); + submission.submit(); + } + } else { + JOptionPane.showConfirmDialog(null, "Your proof is incorrect! Are you sure you wish to submit?", "Proof Submission", JOptionPane.YES_NO_OPTION); + Submission submit = new Submission(board); + } + } +} diff --git a/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java b/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java index 4f49d7639..b0688f993 100644 --- a/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java +++ b/src/main/java/edu/rpi/legup/ui/treeview/TreePanel.java @@ -33,8 +33,8 @@ public class TreePanel extends JPanel { private JLabel status; - public TreePanel(LegupUI legupUI) { - this.legupUI = legupUI; + public TreePanel(/*LegupUI legupUI*/) { + //this.legupUI = legupUI; main = new JPanel(); From c388cf1bfbfaf3854bdfd415ed343757a5f9de76 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 10 Jun 2022 13:40:24 -0400 Subject: [PATCH 04/86] More adjustments to package structure --- .../java/edu/rpi/legup/controller/ElementController.java | 8 ++++---- .../java/edu/rpi/legup/controller/TreeController.java | 2 +- .../java/edu/rpi/legup/history/AutoCaseRuleCommand.java | 2 +- src/main/java/edu/rpi/legup/history/EditDataCommand.java | 4 ++-- src/main/java/edu/rpi/legup/model/Puzzle.java | 2 +- .../rpi/legup/puzzle/battleship/BattleShipClueView.java | 2 +- .../legup/puzzle/battleship/BattleShipElementView.java | 2 +- .../edu/rpi/legup/puzzle/battleship/BattleShipView.java | 2 +- .../rpi/legup/puzzle/fillapix/FillapixElementView.java | 2 +- .../java/edu/rpi/legup/puzzle/fillapix/FillapixView.java | 2 +- .../rpi/legup/puzzle/heyawake/HeyawakeElementView.java | 2 +- .../java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java | 4 ++-- .../edu/rpi/legup/puzzle/lightup/LightUpElementView.java | 2 +- .../java/edu/rpi/legup/puzzle/lightup/LightUpView.java | 6 +++--- .../java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java | 4 ++-- .../java/edu/rpi/legup/puzzle/masyu/MasyuController.java | 2 +- .../java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java | 2 +- .../java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java | 2 +- src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java | 2 +- .../rpi/legup/puzzle/nurikabe/NurikabeElementView.java | 2 +- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java | 2 +- .../shorttruthtable/ShortTruthTableElementView.java | 2 +- .../legup/puzzle/shorttruthtable/ShortTruthTableView.java | 2 +- .../rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java | 2 +- .../legup/puzzle/skyscrapers/SkyscrapersController.java | 4 ++-- .../legup/puzzle/skyscrapers/SkyscrapersElementView.java | 2 +- .../rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java | 2 +- .../edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java | 4 ++-- src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java | 2 +- .../edu/rpi/legup/puzzle/sudoku/SudokuElementView.java | 2 +- src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java | 8 ++++---- .../edu/rpi/legup/puzzle/treetent/EditLineCommand.java | 2 +- .../edu/rpi/legup/puzzle/treetent/TreeTentClueView.java | 2 +- .../edu/rpi/legup/puzzle/treetent/TreeTentController.java | 4 ++-- .../rpi/legup/puzzle/treetent/TreeTentElementView.java | 2 +- .../edu/rpi/legup/puzzle/treetent/TreeTentLineView.java | 2 +- .../java/edu/rpi/legup/puzzle/treetent/TreeTentView.java | 4 ++-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 +- src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java | 2 +- .../ui/{puzzleeditorui => }/boardview/BoardView.java | 2 +- .../{puzzleeditorui => }/boardview/DataSelectionView.java | 2 +- .../{puzzleeditorui => }/boardview/ElementSelection.java | 2 +- .../ui/{puzzleeditorui => }/boardview/ElementView.java | 2 +- .../ui/{puzzleeditorui => }/boardview/GridBoardView.java | 2 +- .../{puzzleeditorui => }/boardview/GridElementView.java | 2 +- .../{puzzleeditorui => }/boardview/SelectionItemView.java | 2 +- .../legup/ui/proofeditorui/elementsview/ElementPanel.java | 4 ++++ .../legup/ui/proofeditorui/resizeview/ResizePanel.java | 4 ++++ 48 files changed, 69 insertions(+), 61 deletions(-) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/BoardView.java (99%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/DataSelectionView.java (87%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/ElementSelection.java (97%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/ElementView.java (99%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/GridBoardView.java (98%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/GridElementView.java (77%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => }/boardview/SelectionItemView.java (93%) create mode 100644 src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java diff --git a/src/main/java/edu/rpi/legup/controller/ElementController.java b/src/main/java/edu/rpi/legup/controller/ElementController.java index 49f87cd4e..60a2803b8 100644 --- a/src/main/java/edu/rpi/legup/controller/ElementController.java +++ b/src/main/java/edu/rpi/legup/controller/ElementController.java @@ -11,10 +11,10 @@ import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.ui.DynamicView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementSelection; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.ElementSelection; +import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.SelectionItemView; import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.EditDataCommand; diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index ed1bc9cb6..d15efd599 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -2,7 +2,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index 6b1480d68..9f260a363 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -6,7 +6,7 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/history/EditDataCommand.java b/src/main/java/edu/rpi/legup/history/EditDataCommand.java index 6ed7d804b..eb4d09a54 100644 --- a/src/main/java/edu/rpi/legup/history/EditDataCommand.java +++ b/src/main/java/edu/rpi/legup/history/EditDataCommand.java @@ -5,8 +5,8 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.observer.ITreeListener; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index 2cccc7ccc..24fa967e1 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -16,7 +16,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java index d4a4cfd3c..06e4901d7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.battleship; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java index 84a169fb8..a1ba0f9b8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.battleship; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java index 2fcfd2331..7c4353888 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java index 500aa5959..00d0a6807 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.fillapix; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java index 7434730b2..7e6453f58 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java index f29df74c5..5efec44ff 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.heyawake; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java index d48888463..c60ca2d88 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeView.java @@ -2,8 +2,8 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; import java.awt.geom.Area; 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 4715cf5d6..a57f22706 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.lightup; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; 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 bcd5782d4..f4c762124 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpView.java @@ -4,9 +4,9 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.DataSelectionView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; +import edu.rpi.legup.ui.boardview.DataSelectionView; +import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.SelectionItemView; import javax.imageio.ImageIO; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java index c02af0165..49eadc181 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java @@ -9,8 +9,8 @@ import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java index 9cd8c5445..554b8d898 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuController.java @@ -4,7 +4,7 @@ import edu.rpi.legup.controller.ElementController; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; import java.awt.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java index 45a20641e..6a13d7155 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.masyu; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java index b914232a4..d527ca414 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.masyu; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java index cabada597..ac60dbe66 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; import java.util.ArrayList; diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java index 460fe84ce..09f976dc9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.nurikabe; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java index 84492c0ff..cef287b92 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java index f4bf33af2..7b0cd1b06 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.shorttruthtable; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java index 0a906b632..64e9fda75 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.GridBoardView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java index a2316dcd0..22799ed05 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java index 75e282973..9aeb686c4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java @@ -8,8 +8,8 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java index 82dca87c5..727d9957e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java index 3e5e8de43..a66c6d7b2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.skyscrapers; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java index 0fc461368..98d3545d2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersView.java @@ -4,8 +4,8 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.GridBoardView; import javax.imageio.ImageIO; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java index 440776142..2704ce314 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java @@ -4,7 +4,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; public class Sudoku extends Puzzle { private SudokuView boardView; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java index b7ef0ebc9..bc114c3c5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuElementView.java @@ -2,7 +2,7 @@ import edu.rpi.legup.app.LegupPreferences; import edu.rpi.legup.model.gameboard.GridCell; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java index 01dff235d..e0e099038 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuView.java @@ -1,10 +1,10 @@ package edu.rpi.legup.puzzle.sudoku; import edu.rpi.legup.controller.BoardController; -import edu.rpi.legup.ui.puzzleeditorui.boardview.DataSelectionView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.SelectionItemView; +import edu.rpi.legup.ui.boardview.DataSelectionView; +import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.SelectionItemView; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java index aa011534a..7ef7639d6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java @@ -4,7 +4,7 @@ import edu.rpi.legup.history.PuzzleCommand; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java index 49e6760e8..4e7b24b13 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentClueView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java index 3d6ff3f57..ca7f684d7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java @@ -8,8 +8,8 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java index 6ef214db1..91d2c29b1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentElementView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridElementView; +import edu.rpi.legup.ui.boardview.GridElementView; import java.awt.*; import java.awt.geom.Rectangle2D; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java index 4d2a969f4..833dcb5b5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentLineView.java @@ -1,6 +1,6 @@ package edu.rpi.legup.puzzle.treetent; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.ElementView; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java index 0fb69ba4b..5a2127fc7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentView.java @@ -4,8 +4,8 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.puzzleeditorui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.boardview.GridBoardView; +import edu.rpi.legup.ui.boardview.ElementView; +import edu.rpi.legup.ui.boardview.GridBoardView; import javax.imageio.ImageIO; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index af6d58bc7..0d8375f44 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -11,7 +11,7 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.app.LegupPreferences; import edu.rpi.legup.ui.lookandfeel.LegupLookAndFeel; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; import edu.rpi.legupupdate.Update; import edu.rpi.legupupdate.UpdateProgress; diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java index 3b012d856..f365738a3 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java @@ -14,7 +14,7 @@ import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.save.ExportFileException; import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.puzzleeditorui.boardview.BoardView; +import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.puzzleeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java rename to src/main/java/edu/rpi/legup/ui/boardview/BoardView.java index a39c1872c..31cec590b 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/BoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.ElementController; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java b/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java similarity index 87% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java rename to src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java index 562ad1f74..8257fd47c 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/DataSelectionView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/DataSelectionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.controller.ElementController; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java b/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java similarity index 97% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java rename to src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java index 6a403b26b..8e6f2cb18 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementSelection.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/ElementSelection.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import java.awt.*; import java.util.ArrayList; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java b/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java rename to src/main/java/edu/rpi/legup/ui/boardview/ElementView.java index c8053fe8a..008c1a5f5 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/ElementView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/ElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.model.gameboard.PuzzleElement; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java rename to src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java index 1a20d318b..e851d14d7 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridBoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.ElementController; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java b/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java similarity index 77% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java rename to src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java index ac3fb8ae1..440b3a693 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/GridElementView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/GridElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.model.gameboard.GridCell; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java b/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java similarity index 93% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java rename to src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java index c24854635..1ce5033c7 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/boardview/SelectionItemView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/SelectionItemView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.boardview; +package edu.rpi.legup.ui.boardview; import edu.rpi.legup.model.gameboard.PuzzleElement; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java new file mode 100644 index 000000000..fda0b3aee --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java @@ -0,0 +1,4 @@ +package edu.rpi.legup.ui.proofeditorui.elementsview; + +public class ElementPanel { +} diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java new file mode 100644 index 000000000..1afaa087e --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java @@ -0,0 +1,4 @@ +package edu.rpi.legup.ui.proofeditorui.resizeview; + +public class ResizePanel { +} From b1c8b3f2fea8a152de492d0bebe0d29fdc1959eb Mon Sep 17 00:00:00 2001 From: Hiimadd Date: Fri, 10 Jun 2022 14:46:06 -0400 Subject: [PATCH 05/86] Fix 3 Rules Fixed EmptyField, LastCampingSpot, and TouchingTents rules --- .../treetent/rules/EmptyFieldBasicRule.java | 4 +- .../rules/LastCampingSpotBasicRule.java | 40 +++++++++++++++---- .../rules/TouchingTentsContradictionRule.java | 4 +- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/EmptyFieldBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/EmptyFieldBasicRule.java index 9c32f020d..acf85c74b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/EmptyFieldBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/EmptyFieldBasicRule.java @@ -37,8 +37,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem TreeTentCell initCell = (TreeTentCell) initialBoard.getPuzzleElement(puzzleElement); TreeTentBoard finalBoard = (TreeTentBoard) transition.getBoard(); TreeTentCell finalCell = (TreeTentCell) finalBoard.getPuzzleElement(puzzleElement); - if (finalCell.getType() == TreeTentType.GRASS && initCell.getType() == TreeTentType.UNKNOWN) { - return null; + if (!(finalCell.getType() == TreeTentType.GRASS && initCell.getType() == TreeTentType.UNKNOWN)) { + return super.getInvalidUseOfRuleMessage() + ": This cell must be grass"; } if (isForced(finalBoard, finalCell)) { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java index e95f45e9d..6aac4e93b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java @@ -43,20 +43,46 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem return super.getInvalidUseOfRuleMessage() + ": This cell must be a tent."; } - if (isForced(initialBoard, initCell)) { + if (isForced(finalBoard, finalCell)) { return null; } else { return super.getInvalidUseOfRuleMessage() + ": This cell is not forced to be tent."; } } + // private boolean isForced(TreeTentBoard board, TreeTentCell cell) { + // List adjTents = board.getAdjacent(cell, TreeTentType.TREE); + // for (TreeTentCell c : adjTents) { + // Point loc = c.getLocation(); + // for (TreeTentLine line : board.getLines()) { + // if (line.getC1().getLocation().equals(loc) || line.getC2().getLocation().equals(loc)) { + // return false; + // } + // } + // } + // return false; + // } + private boolean isForced(TreeTentBoard board, TreeTentCell cell) { - List adjTents = board.getAdjacent(cell, TreeTentType.TREE); - for (TreeTentCell c : adjTents) { - Point loc = c.getLocation(); - for (TreeTentLine line : board.getLines()) { - if (line.getC1().getLocation().equals(loc) || line.getC2().getLocation().equals(loc)) { - return false; + List adjTrees = board.getAdjacent(cell, TreeTentType.TREE); + for (TreeTentCell c : adjTrees) { + List unkAroundTree = board.getAdjacent(c, TreeTentType.UNKNOWN); + List tntAroundTree = board.getAdjacent(c, TreeTentType.TENT); + if(unkAroundTree.size() == 0) + { + if(tntAroundTree.size() == 1) + { + return true; + } + else + { + for(TreeTentCell t : tntAroundTree) + { + if(t == cell) {continue;} + List treesAroundTents = board.getAdjacent(t, TreeTentType.TREE); + if(treesAroundTents.size() == 1) {return false;} + } + return true; } } } diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java index 3c56c12f0..23c3e4f43 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java @@ -27,10 +27,10 @@ public TouchingTentsContradictionRule() { public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { TreeTentBoard treeTentBoard = (TreeTentBoard) board; TreeTentCell cell = (TreeTentCell) puzzleElement; - if (cell.getType() != TreeTentType.TREE) { + if (cell.getType() != TreeTentType.TENT) { return super.getNoContradictionMessage(); } - int adjTree = treeTentBoard.getAdjacent(cell, TreeTentType.TREE).size(); + int adjTree = treeTentBoard.getAdjacent(cell, TreeTentType.TENT).size(); if (adjTree > 0) { return null; } else { From bfd9e02fe991269703e72f51417b6a02b2d16453 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 10 Jun 2022 14:46:09 -0400 Subject: [PATCH 06/86] Renamed PuzzleSolver to ProofEditor Renamed class to keep naming consistent --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 4 ++-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 6 +++--- .../ui/{PuzzleSolverPanel.java => ProofEditorPanel.java} | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/edu/rpi/legup/ui/{PuzzleSolverPanel.java => ProofEditorPanel.java} (99%) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 47f50e722..c695139fa 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -6,7 +6,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; -import edu.rpi.legup.ui.PuzzleSolverPanel; +import edu.rpi.legup.ui.ProofEditorPanel; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -43,7 +43,7 @@ public class GameBoardFacade implements IHistorySubject { private LegupUI legupUI; - private PuzzleSolverPanel puzzleSolver; + private ProofEditorPanel puzzleSolver; private String curFileName; diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 0d8375f44..ff5b273bc 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -131,7 +131,7 @@ private void initPanels() { add(window); panels = new LegupPanel[3]; panels[0] = new HomePanel(this); - panels[1] = new PuzzleSolverPanel(this.fileDialog, this); + panels[1] = new ProofEditorPanel(this.fileDialog, this); panels[2] = new PuzzleEditorPanel(); } @@ -147,8 +147,8 @@ protected void displayPanel(int option) { repaint(); } - public PuzzleSolverPanel getPuzzleSolver() { - return (PuzzleSolverPanel) panels[1]; + public ProofEditorPanel getPuzzleSolver() { + return (ProofEditorPanel) panels[1]; } public static boolean profFlag(int flag) { diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java rename to src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index f365738a3..014b9580a 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleSolverPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -35,8 +35,8 @@ import java.net.URL; import java.util.List; -public class PuzzleSolverPanel extends LegupPanel implements IHistoryListener { - private final static Logger LOGGER = LogManager.getLogger(PuzzleSolverPanel.class.getName()); +public class ProofEditorPanel extends LegupPanel implements IHistoryListener { + private final static Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); private JMenuBar mBar; private TreePanel treePanel; private FileDialog fileDialog; @@ -53,7 +53,7 @@ public class PuzzleSolverPanel extends LegupPanel implements IHistoryListener { final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; - public PuzzleSolverPanel(FileDialog fileDialog, JFrame frame) { + public ProofEditorPanel(FileDialog fileDialog, JFrame frame) { this.fileDialog = fileDialog; this.frame = frame; setLayout(new BorderLayout()); From 5c1c10cc8d31063c5c65085e408e76f91eb2e9a2 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 10 Jun 2022 14:48:40 -0400 Subject: [PATCH 07/86] Edited Home Panel to display image buttons --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 22 +++++++++--------- .../edu/rpi/legup/homepanel/edit.png | Bin 0 -> 2039 bytes .../edu/rpi/legup/homepanel/newpuzzle.png | Bin 0 -> 1014 bytes .../edu/rpi/legup/homepanel/openproof.png | Bin 0 -> 1615 bytes 4 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/edu/rpi/legup/homepanel/edit.png create mode 100644 src/main/resources/edu/rpi/legup/homepanel/newpuzzle.png create mode 100644 src/main/resources/edu/rpi/legup/homepanel/openproof.png diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 7e0ca93e3..a564e53b1 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -8,11 +8,9 @@ public class HomePanel extends LegupPanel { private JButton[] buttons; - private JPanel buttonPanel; - public HomePanel(LegupUI legupUI) { this.legupUI = legupUI; - setLayout(new GridLayout(2, 1)); + setLayout(new GridLayout(1, 2)); initButtons(); } @@ -23,18 +21,20 @@ public void makeVisible() { private void initButtons() { this.buttons = new JButton[2]; - this.buttons[0] = new JButton("Solve a puzzle!"); + this.buttons[0] = new JButton("Open Proof"); + this.buttons[0].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/openproof.png")); + this.buttons[0].setHorizontalTextPosition(AbstractButton.CENTER); + this.buttons[0].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[0].addActionListener(l -> this.legupUI.displayPanel(1)); - this.buttons[1] = new JButton("Create/Edit a puzzle!"); + this.buttons[1] = new JButton("Create/Edit Puzzle"); + this.buttons[1].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); + this.buttons[1].setHorizontalTextPosition(AbstractButton.CENTER); + this.buttons[1].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[1].addActionListener(l -> this.legupUI.displayPanel(2)); - this.buttonPanel = new JPanel(); - for (JButton button : this.buttons) { - this.buttonPanel.add(button); - } } private void render() { - add(new JLabel("Welcome to LEGUP! What would you like to do?")); - add(this.buttonPanel); + add(this.buttons[0]); + add(this.buttons[1]); } } diff --git a/src/main/resources/edu/rpi/legup/homepanel/edit.png b/src/main/resources/edu/rpi/legup/homepanel/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..af7cb9d4ab2f8193a7b7770056b72efa07ed97eb GIT binary patch literal 2039 zcmb_ddo-JA8jlEq(v(Of?t+>TH13y-x<+%PTDM3lO!6hJ)fSyPrnRjoZTVu2T{TLL zZVfssMYO_JTN1utj#AYs)4Ii0*D7UtT-s9mWoCQ!|K0uLd7txpp7(t&zw^G&TXZx$ zR8NPfgFqnk=!b$MVLhM{G!kB|eY^)@rFJ?pG!W4|Y`O>oRC2)K00cr(s=Lk8fU$PQ zA@*qm0%xldHF~7YDgvP;q6Y^==OipY8O^Wz5*s}Fez*3AYOvZoMdC};^+C?vj;7c9KQ08%>}_`9`>1)8Q=Xlcoa}vOD_ZFJ!KDFk8b8B{)^+#{LS8r`euYPI1KSftUs~IEWD^LVk*2v#nWhkOccf(YMx5{H_ zf>ZMn;x&Waa#fmXc?}jlJpbMd(ECJERlV~^-7hd4C@%Yo#@5AxvPy8>u=yr!gD@RK zGMwG3DxGQa{ZUevQOj`UbV8hCMKNdZ!q2a|!>IRH5IVCD|Gxj171VQpOK+C*fGG z4P}{s5-o~3VuV+akP95gfg`n)k|I|udO><#Vhr^WbWme)t*n>+3OB6uVUVdT5>mdy zqXT(M?rmP&N-8fwlr#Yk@o-HrFtjUBC?@V2&9?a&q9X!G=YJ4PyL3c5=}6Pit?!5krF zfq-ez=YGZwW}|aIiBcKY|Ki_zoeKe2!(@AmIA!BbraECP&&yxPjfk=+H5sVX>{HW0 zEmdt6sG25be@%+}<;Tl^*K}zZZT*OpsSo8uJ6Z9GdR@*KYVS9VuMBih`&#F5OsXPS zYe6$j@H-eJC;tZwVfz;}bx;AVi)PBuDhZ2mkvpc5pKS8psPi(Bje65b+sNtlLv3c{ zg}mck&|(Sxj9q#$@<^I)p1yx#T)cZ5{5s_We&g#=S?362zN-r2WGSnP(q5|PfU8rbQsS5b#oCxX~&GSuqs&Rom zvA5%Dc8huKRo$V=4SBaYzh)|J2Y9gB4>#7e?u4s*xb@ZyFl05dwq*orD$)T9#@6<~ zv%@@O-QP4w;30(|WOA?vWLPFha^QiJjw~yN9FDPgV^<=`=6*fa)$}}IO#nOm?%=`x zG=YcYClGSgKvpNb1s)vO(QDF0;beKh1B@v@Uf7dw93{rL;h0!7S^s@aM2VTwOoskyPveat({2coIHC3{;U!7knrH< IKyLoO0FR!HdH?_b literal 0 HcmV?d00001 diff --git a/src/main/resources/edu/rpi/legup/homepanel/newpuzzle.png b/src/main/resources/edu/rpi/legup/homepanel/newpuzzle.png new file mode 100644 index 0000000000000000000000000000000000000000..24ebfd346f1fb65207ea17759fee1ace388a6a26 GIT binary patch literal 1014 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k2}mkgS)K$^jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX_q19P{hi(^Pd+}leB6J;C)m<^xK|MK&&fX~)G zW|a+d-v0XO(70iRfSBl^MNSbR9Nk=rfr>g>Ev~Ip7u;vPX8!vrUoW?mD!g9K`P$){ zzwoujHS^WhFh|<^MzC+Ho3(*2<*!Mi?1^8QhpZ+HPKCGr*QeCU)d%%mQD3wDiAU|B zD(_JymT>r99iMgL{x7p36t&>ww?$p<+6<&FEZc#d4A%YY0Y9r`?G?6cb>P2 zZ}_!)$J6DH!Yf$g*KMuR+U@sv*Zh{V_mAqXUNif6UG0wV>XWo{SW1P3He*hX&BXiCA_)g_H7RPtac*8Kw;!vmf$B%q(`41(zTNLu% zmwD)NjQ8N8?|OMR7ycED$ZY@i`bS-RnZu`7%3q!pTo>E>JbAuuRq>AO?zrtY_F9|# zDtO;;Z1TpFVte`S>~LKl`s|YOm#D(84abZ(9v0hccW1Zj`tzIr=jX{^s8A5QvFLj5 z?d>m2U)Eclm$`5v;aJ15%O8F*_VT3hWSDfacV`Jr=DNzj#^MGv)J;#wtTLup);%&7%ng7 zy%)M--JvV_ZO7+6j#;=%Y%}*&OSadt`96PsrSz9U1#)M9Si#uaDlrFW>sP6Lnjzd* zx6X)NaW3^zE8Nv_cr_6^Zj}|SwTv+=pOE7GZ9NFko(MaHT%ai z`zc&ktv@t5l{!5)vRM@n+q%+wkKxDHlm9O?U$9Z;G51x@xj-L*LZr^v=AF!QkXwP? z`FSHDF!#{X^$$+(e^>(bI#A&{#$KCeycs4BFLD2PU}UEqay_YRp_Te?_JFg=aSLy? zSD!C@S6XAgU?W#ByU8!@q!*!65zx?a^gT_{9JeTx8xCAlP=k@(YcD{@h zgJg%tffZGdh;>e3pJ%z?V()EslX-2|`7=}uGaVK;AN-{kk>H@*EXge8EB9x5F);ao zlUm-LeXi?0Kb(KCH~P!6!n@E!2}yvj68?67+r1;T{oCP~>GXC#%df#kdnQCc0zjf(@WB$jt-Q8jPvaP=3>Aj=6_MEfJ9~|3r`=7d4Eo=P0 zkUw1SA59D0cXa>JSMC-I5551ywJ+v${kwx4=YSdg_;4)L;3f5g@9*mwEU!g>cX62q QsxlZnUHx3vIVCg!0LJeEMgRZ+ literal 0 HcmV?d00001 From 705932896a30a540faeeebf2951c5f99e3537862 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Fri, 10 Jun 2022 15:17:28 -0400 Subject: [PATCH 08/86] created draft of PuzzleEditorPanel --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 +- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 36 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 0d8375f44..cffca45e8 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -132,7 +132,7 @@ private void initPanels() { panels = new LegupPanel[3]; panels[0] = new HomePanel(this); panels[1] = new PuzzleSolverPanel(this.fileDialog, this); - panels[2] = new PuzzleEditorPanel(); + panels[2] = new PuzzleEditorPanel(this); } protected void displayPanel(int option) { diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 44f0b0f3f..0fd49c8e0 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -1,10 +1,40 @@ package edu.rpi.legup.ui; import javax.swing.*; +import java.awt.*; public class PuzzleEditorPanel extends LegupPanel { - public PuzzleEditorPanel() { + private JMenu[] menus; + private JMenuBar menuBar; + private LegupUI legupUI; + private JButton[] buttons; + private JPanel mainPanel; + public PuzzleEditorPanel(LegupUI legupUI) { + this.legupUI = legupUI; + setLayout(new GridLayout(2, 1)); + setup(); + } + + private void setup() { + mainPanel = new JPanel(); + buttons = new JButton[3]; + buttons[0] = new JButton("element 0"); + buttons[1] = new JButton("element 1"); + buttons[2] = new JButton("element 2"); + for (int i = 0; i < buttons.length; i++) { + mainPanel.add(buttons[i]); + } + mainPanel.setSize(100,300); + menuBar = new JMenuBar(); + menus = new JMenu[3]; + menus[0] = new JMenu("File"); + menus[1] = new JMenu("Edit"); + menus[2] = new JMenu("Help"); + for (JMenu menu : menus) { + menuBar.add(menu); + } + mainPanel.add(menuBar); } @Override @@ -13,6 +43,8 @@ public void makeVisible() { } private void render() { - add(new JLabel("Puzzle Editor goes here")); + + add(new JLabel("Welcome to the puzzle editor!")); + add(mainPanel); } } From bc229f1aefbb5f075920ff11736055f3eb9e7364 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 10 Jun 2022 20:08:32 -0400 Subject: [PATCH 09/86] Prototype menu bar for home panel --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 30 +++++++++++++++---- src/main/java/edu/rpi/legup/ui/LegupUI.java | 4 +-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index a564e53b1..aaafca375 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -5,18 +5,38 @@ public class HomePanel extends LegupPanel { private LegupUI legupUI; - + private JFrame frame; private JButton[] buttons; + private JMenuBar menuBar; - public HomePanel(LegupUI legupUI) { + public HomePanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.legupUI = legupUI; + this.frame = frame; setLayout(new GridLayout(1, 2)); initButtons(); } + public JMenuBar getMenuBar() + { + this.menuBar = new JMenuBar(); + JMenu settings = new JMenu("Settings"); + menuBar.add(settings); + JMenuItem about = new JMenuItem("About"); + JMenuItem preferences = new JMenuItem("Preferences"); + settings.add(about); + about.addActionListener(a -> {System.out.println("About clicked");}); + // settings.addSeparator(); + settings.add(preferences); + preferences.addActionListener(a -> {System.out.println("Preferences clicked");}); + return this.menuBar; + } + @Override - public void makeVisible() { + public void makeVisible() + { render(); + this.frame.setVisible(true); + this.frame.setJMenuBar(this.getMenuBar()); } private void initButtons() { @@ -34,7 +54,7 @@ private void initButtons() { } private void render() { - add(this.buttons[0]); - add(this.buttons[1]); + this.add(this.buttons[0]); + this.add(this.buttons[1]); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index ff5b273bc..201a3abb7 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -73,7 +73,7 @@ public LegupUI() { try { UIManager.setLookAndFeel(new LegupLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { - System.err.println("Not supported ui look and fel"); + System.err.println("Not supported ui look and feel"); } fileDialog = new FileDialog(this); @@ -130,7 +130,7 @@ private void initPanels() { window = new JPanel(); add(window); panels = new LegupPanel[3]; - panels[0] = new HomePanel(this); + panels[0] = new HomePanel(this.fileDialog, this, this); panels[1] = new ProofEditorPanel(this.fileDialog, this); panels[2] = new PuzzleEditorPanel(); } From f1e7c44d98e1478c4984162c1e62d39dfa3e1c72 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:19:40 -0400 Subject: [PATCH 10/86] created draft of PuzzleEditorPanel added menu bars, mostly non-functional, but file>new opens up the file dialog --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 +- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 96 +++++++++++++++++-- 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index f0408cb33..31b6ef414 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -133,7 +133,7 @@ private void initPanels() { panels[0] = new HomePanel(this.fileDialog, this, this); panels[1] = new ProofEditorPanel(this.fileDialog, this); - panels[2] = new PuzzleEditorPanel(); + panels[2] = new PuzzleEditorPanel(this.fileDialog, this); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 0fd49c8e0..46593bf59 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -1,50 +1,128 @@ package edu.rpi.legup.ui; +import edu.rpi.legup.app.GameBoardFacade; +import edu.rpi.legup.save.InvalidFileFormatException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import javax.swing.*; import java.awt.*; +import java.awt.event.InputEvent; +import java.io.File; public class PuzzleEditorPanel extends LegupPanel { + private final static Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); private JMenu[] menus; private JMenuBar menuBar; - private LegupUI legupUI; + private JFrame frame; private JButton[] buttons; private JPanel mainPanel; - public PuzzleEditorPanel(LegupUI legupUI) { - this.legupUI = legupUI; + private FileDialog fileDialog; + private JMenuItem undo, redo; + public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame) { + this.fileDialog = fileDialog; + this.frame = frame; setLayout(new GridLayout(2, 1)); setup(); } private void setup() { mainPanel = new JPanel(); + mainPanel.setSize(100,300); + // menu bar + + + // buttons buttons = new JButton[3]; buttons[0] = new JButton("element 0"); buttons[1] = new JButton("element 1"); buttons[2] = new JButton("element 2"); - for (int i = 0; i < buttons.length; i++) { - mainPanel.add(buttons[i]); + for (JButton button : buttons) { + mainPanel.add(button); } - mainPanel.setSize(100,300); + setMenuBar(); + } + + public void setMenuBar() { + String os = LegupUI.getOS(); menuBar = new JMenuBar(); menus = new JMenu[3]; + + // create menus + // FILE menus[0] = new JMenu("File"); + // file>new + JMenuItem newPuzzle = new JMenuItem("New"); + newPuzzle.addActionListener((ActionEvent) -> promptPuzzle()); + if(os.equals("mac")) newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK)); + // file>open + JMenuItem openPuzzle = new JMenuItem("Open"); + + menus[0].add(newPuzzle); + menus[0].add(openPuzzle); + + // EDIT menus[1] = new JMenu("Edit"); + // edit>undo + undo = new JMenuItem("Undo"); + // edit>redo + redo = new JMenuItem("Redo"); + + menus[1].add(undo); + menus[1].add(redo); + + // HELP menus[2] = new JMenu("Help"); + + // add menus to menubar for (JMenu menu : menus) { menuBar.add(menu); } - mainPanel.add(menuBar); } @Override public void makeVisible() { render(); + frame.setJMenuBar(menuBar); } - private void render() { + public void promptPuzzle() { + GameBoardFacade facade = GameBoardFacade.getInstance(); + if (facade.getBoard() != null) { + if (noQuit("Opening a new puzzle to edit?")) // !noquit or noquit? + { + return; + } + } - add(new JLabel("Welcome to the puzzle editor!")); + fileDialog.setMode(FileDialog.LOAD); + fileDialog.setTitle("Select Puzzle"); + fileDialog.setVisible(true); + String fileName = null; + File puzzleFile = null; + if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { + fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + puzzleFile = new File(fileName); + } + + if (puzzleFile != null && puzzleFile.exists()) { + try { + GameBoardFacade.getInstance().loadPuzzle(fileName); + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + frame.setTitle(puzzleName + " - " + puzzleFile.getName()); + } catch (InvalidFileFormatException e) { + LOGGER.error(e.getMessage()); + } + } + } + public boolean noQuit(String instr) { + int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_CANCEL_OPTION); + return n != JOptionPane.YES_OPTION; + } + private void render() { add(mainPanel); + add(new JLabel("Welcome to the puzzle editor!")); } } From 4c4ee5d77840d105751ddc4aa1509cd56270c5ac Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 14 Jun 2022 14:49:36 -0400 Subject: [PATCH 11/86] Renamed directories --- src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java | 4 ++-- .../java/edu/rpi/legup/controller/ElementController.java | 2 +- .../java/edu/rpi/legup/controller/RuleController.java | 6 +++--- .../java/edu/rpi/legup/controller/TreeController.java | 2 +- .../java/edu/rpi/legup/history/AddTreeElementCommand.java | 6 +++--- .../rpi/legup/history/ApplyDefaultBasicRuleCommand.java | 2 +- .../java/edu/rpi/legup/history/AutoCaseRuleCommand.java | 2 +- .../edu/rpi/legup/history/DeleteTreeElementCommand.java | 2 +- src/main/java/edu/rpi/legup/history/EditDataCommand.java | 2 +- src/main/java/edu/rpi/legup/history/MergeCommand.java | 2 +- .../edu/rpi/legup/history/ValidateBasicRuleCommand.java | 2 +- .../edu/rpi/legup/history/ValidateCaseRuleCommand.java | 2 +- .../legup/history/ValidateContradictionRuleCommand.java | 2 +- .../java/edu/rpi/legup/model/observer/ITreeListener.java | 2 +- .../java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java | 2 +- .../edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java | 8 ++++---- .../legup/puzzle/skyscrapers/SkyscrapersController.java | 6 +++--- .../java/edu/rpi/legup/puzzle/treetent/ClueCommand.java | 6 +++--- .../edu/rpi/legup/puzzle/treetent/EditLineCommand.java | 6 +++--- .../edu/rpi/legup/puzzle/treetent/TreeTentController.java | 6 +++--- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 +- src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java | 6 +++--- .../legup/ui/proofeditorui/elementsview/ElementPanel.java | 4 ---- .../legup/ui/proofeditorui/resizeview/ResizePanel.java | 4 ---- .../rulesview/BasicRulePanel.java | 2 +- .../rulesview/CaseRulePanel.java | 2 +- .../rulesview/CaseRuleSelectionView.java | 2 +- .../rulesview/ContradictionRulePanel.java | 2 +- .../rulesview/RuleButton.java | 2 +- .../rulesview/RuleFrame.java | 2 +- .../rulesview/RulePanel.java | 2 +- .../treeview/TreeElementView.java | 2 +- .../treeview/TreeNodeView.java | 2 +- .../treeview/TreePanel.java | 2 +- .../treeview/TreeToolBarButton.java | 2 +- .../treeview/TreeToolBarName.java | 2 +- .../treeview/TreeToolbarPanel.java | 2 +- .../treeview/TreeTransitionView.java | 2 +- .../treeview/TreeView.java | 6 +++--- .../treeview/TreeViewSelection.java | 2 +- .../ui/puzzleeditorui/elementsview/ElementPanel.java | 4 ++++ .../legup/ui/puzzleeditorui/resizeview/ResizePanel.java | 4 ++++ 42 files changed, 66 insertions(+), 66 deletions(-) delete mode 100644 src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java delete mode 100644 src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/BasicRulePanel.java (93%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/CaseRulePanel.java (90%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/CaseRuleSelectionView.java (90%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/ContradictionRulePanel.java (91%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/RuleButton.java (92%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/RuleFrame.java (98%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/rulesview/RulePanel.java (98%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeElementView.java (98%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeNodeView.java (99%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreePanel.java (98%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeToolBarButton.java (87%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeToolBarName.java (60%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeToolbarPanel.java (97%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeTransitionView.java (99%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeView.java (99%) rename src/main/java/edu/rpi/legup/ui/{puzzleeditorui => proofeditorui}/treeview/TreeViewSelection.java (98%) create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/resizeview/ResizePanel.java diff --git a/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java b/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java index 67837c460..e1a769610 100644 --- a/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java +++ b/src/main/java/edu/rpi/legup/app/PuzzleKeyAccelerator.java @@ -7,8 +7,8 @@ import edu.rpi.legup.model.rules.ContradictionRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.rules.RuleType; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import javax.swing.*; import java.awt.event.KeyEvent; diff --git a/src/main/java/edu/rpi/legup/controller/ElementController.java b/src/main/java/edu/rpi/legup/controller/ElementController.java index 60a2803b8..80f80db3e 100644 --- a/src/main/java/edu/rpi/legup/controller/ElementController.java +++ b/src/main/java/edu/rpi/legup/controller/ElementController.java @@ -15,7 +15,7 @@ import edu.rpi.legup.ui.boardview.ElementSelection; import edu.rpi.legup.ui.boardview.ElementView; import edu.rpi.legup.ui.boardview.SelectionItemView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.EditDataCommand; diff --git a/src/main/java/edu/rpi/legup/controller/RuleController.java b/src/main/java/edu/rpi/legup/controller/RuleController.java index 2189cc84a..12fef9b77 100644 --- a/src/main/java/edu/rpi/legup/controller/RuleController.java +++ b/src/main/java/edu/rpi/legup/controller/RuleController.java @@ -7,9 +7,9 @@ import edu.rpi.legup.model.gameboard.CaseBoard; import edu.rpi.legup.model.rules.*; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.rulesview.RuleButton; -import edu.rpi.legup.ui.puzzleeditorui.rulesview.RulePanel; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleButton; +import edu.rpi.legup.ui.proofeditorui.rulesview.RulePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index d15efd599..9bb5d8377 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -3,7 +3,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.awt.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java index 2302d1f99..2f4733a55 100644 --- a/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/AddTreeElementCommand.java @@ -3,9 +3,9 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java b/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java index 6d244af83..a212ec602 100644 --- a/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ApplyDefaultBasicRuleCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.BasicRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index 9f260a363..c61875b74 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -7,7 +7,7 @@ import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.tree.*; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.awt.event.MouseEvent; import java.util.*; diff --git a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java index e7f0294cd..4d78564de 100644 --- a/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java +++ b/src/main/java/edu/rpi/legup/history/DeleteTreeElementCommand.java @@ -4,7 +4,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.observer.ITreeListener; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/EditDataCommand.java b/src/main/java/edu/rpi/legup/history/EditDataCommand.java index eb4d09a54..f4c582220 100644 --- a/src/main/java/edu/rpi/legup/history/EditDataCommand.java +++ b/src/main/java/edu/rpi/legup/history/EditDataCommand.java @@ -7,7 +7,7 @@ import edu.rpi.legup.model.tree.*; import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.awt.event.MouseEvent; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/MergeCommand.java b/src/main/java/edu/rpi/legup/history/MergeCommand.java index 9e8e6aeea..e6ddf6dfb 100644 --- a/src/main/java/edu/rpi/legup/history/MergeCommand.java +++ b/src/main/java/edu/rpi/legup/history/MergeCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.rules.MergeRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java index cb910e898..55c3421db 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateBasicRuleCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.rules.BasicRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java index f0dd4fe70..38672a555 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java @@ -5,7 +5,7 @@ import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java index 79b8a6870..7033bbc3f 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java @@ -4,7 +4,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.rules.ContradictionRule; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java index 69c681055..d8fa24166 100644 --- a/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java +++ b/src/main/java/edu/rpi/legup/model/observer/ITreeListener.java @@ -1,7 +1,7 @@ package edu.rpi.legup.model.observer; import edu.rpi.legup.model.tree.TreeElement; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; public interface ITreeListener { /** diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java index 49eadc181..8ff001d71 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/EditLineCommand.java @@ -11,7 +11,7 @@ import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.*; +import edu.rpi.legup.ui.proofeditorui.treeview.*; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java index 212a38412..d45d82c54 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/ClueCommand.java @@ -4,10 +4,10 @@ import edu.rpi.legup.history.PuzzleCommand; import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeTransitionView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeNodeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeTransitionView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java index 9aeb686c4..1a5664f94 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersController.java @@ -10,9 +10,9 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java index f68e165d9..5722774ef 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/ClueCommand.java @@ -4,9 +4,9 @@ import edu.rpi.legup.history.PuzzleCommand; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java index 7ef7639d6..ea03fc6f5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java @@ -5,9 +5,9 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.*; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.awt.*; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java index ca7f684d7..1440ced35 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java @@ -10,9 +10,9 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.boardview.ElementView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import java.awt.event.MouseEvent; diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 31b6ef414..005422d86 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -12,7 +12,7 @@ import edu.rpi.legup.app.LegupPreferences; import edu.rpi.legup.ui.lookandfeel.LegupLookAndFeel; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; import edu.rpi.legupupdate.Update; import edu.rpi.legupupdate.UpdateProgress; diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 014b9580a..48080d7d1 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -15,9 +15,9 @@ import edu.rpi.legup.save.ExportFileException; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.puzzleeditorui.rulesview.RuleFrame; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreePanel; -import edu.rpi.legup.ui.puzzleeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; +import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; import edu.rpi.legup.user.Submission; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java deleted file mode 100644 index fda0b3aee..000000000 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/elementsview/ElementPanel.java +++ /dev/null @@ -1,4 +0,0 @@ -package edu.rpi.legup.ui.proofeditorui.elementsview; - -public class ElementPanel { -} diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java deleted file mode 100644 index 1afaa087e..000000000 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/resizeview/ResizePanel.java +++ /dev/null @@ -1,4 +0,0 @@ -package edu.rpi.legup.ui.proofeditorui.resizeview; - -public class ResizePanel { -} diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/BasicRulePanel.java similarity index 93% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/BasicRulePanel.java index 590526a86..4e9bbd62a 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/BasicRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/BasicRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java similarity index 90% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java index 0740de253..5f22ac62c 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import javax.swing.ImageIcon; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRuleSelectionView.java similarity index 90% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRuleSelectionView.java index b95527cd4..276583a99 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/CaseRuleSelectionView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/CaseRuleSelectionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import edu.rpi.legup.ui.WrapLayout; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java similarity index 91% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java index 000117849..908ffc49b 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/ContradictionRulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/ContradictionRulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java similarity index 92% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java index e0d7fcad7..12cae7de1 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleButton.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleButton.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import edu.rpi.legup.model.rules.Rule; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java index d4c3ea027..7a5ddcee8 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RuleFrame.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.model.Puzzle; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java index c37b5fa73..c6bc2ee0a 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/rulesview/RulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.rulesview; +package edu.rpi.legup.ui.proofeditorui.rulesview; import edu.rpi.legup.model.rules.Rule; import edu.rpi.legup.ui.WrapLayout; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java index c471c964c..676992654 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeElementView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeElementView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import edu.rpi.legup.model.tree.TreeElement; import edu.rpi.legup.model.tree.TreeElementType; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java index 425691858..f60ffe300 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeNodeView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeNodeView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import edu.rpi.legup.model.rules.RuleType; import edu.rpi.legup.model.tree.TreeElementType; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java index ed626c7f0..6fc56b127 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreePanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.controller.TreeController; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java similarity index 87% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java index 75cba9d4f..85c1c73c8 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarButton.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarButton.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarName.java similarity index 60% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarName.java index d5fb62ca3..dd8a37c15 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolBarName.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolBarName.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; public enum TreeToolBarName { ADD_CHILD, DEL_CHILD, MERGE, COLLAPSE diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java similarity index 97% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java index 17e0b44da..97ea419e6 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeToolbarPanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java index 37b99bcc0..3f1f59ba5 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeTransitionView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeTransitionView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeTransition; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java similarity index 99% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java index 3e7c41e2e..79367216a 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeView.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeView.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.controller.TreeController; @@ -21,8 +21,8 @@ import static edu.rpi.legup.model.tree.TreeElementType.NODE; import static edu.rpi.legup.model.tree.TreeElementType.TRANSITION; -import static edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView.DIAMETER; -import static edu.rpi.legup.ui.puzzleeditorui.treeview.TreeNodeView.RADIUS; +import static edu.rpi.legup.ui.proofeditorui.treeview.TreeNodeView.DIAMETER; +import static edu.rpi.legup.ui.proofeditorui.treeview.TreeNodeView.RADIUS; public class TreeView extends ScrollView implements ITreeListener { private final static Logger LOGGER = LogManager.getLogger(TreeView.class.getName()); diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java similarity index 98% rename from src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java rename to src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java index 11b63e9ab..575d19f19 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/treeview/TreeViewSelection.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeViewSelection.java @@ -1,4 +1,4 @@ -package edu.rpi.legup.ui.puzzleeditorui.treeview; +package edu.rpi.legup.ui.proofeditorui.treeview; import java.awt.*; import java.util.List; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java new file mode 100644 index 000000000..ee6d119e0 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java @@ -0,0 +1,4 @@ +package edu.rpi.legup.ui.puzzleeditorui.elementsview; + +public class ElementPanel { +} diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/resizeview/ResizePanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/resizeview/ResizePanel.java new file mode 100644 index 000000000..7cb7856e7 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/resizeview/ResizePanel.java @@ -0,0 +1,4 @@ +package edu.rpi.legup.ui.puzzleeditorui.resizeview; + +public class ResizePanel { +} From 98e5e099f7cf5dfbbe9f04ce36c39921db49acde Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:49:45 -0400 Subject: [PATCH 12/86] `BattleShipCell` uses `BattleShipType` as casted type instead of `Integer`. Also fixed any dependencies. --- .../legup/puzzle/battleship/BattleShip.java | 28 +++++++++++++++++-- .../puzzle/battleship/BattleShipCell.java | 8 +++--- .../battleship/BattleShipCellController.java | 12 ++++---- .../battleship/BattleShipCellFactory.java | 10 +++---- .../puzzle/battleship/BattleShipClue.java | 8 +++--- .../battleship/BattleShipElementView.java | 2 +- .../puzzle/battleship/BattleShipImporter.java | 11 ++++---- ...eShipCellType.java => BattleShipType.java} | 13 ++++++--- 8 files changed, 61 insertions(+), 31 deletions(-) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipCellType.java => BattleShipType.java} (61%) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java index b89c448dd..a59bfd548 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java @@ -2,6 +2,8 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.gameboard.Board; +import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.model.rules.ContradictionRule; public class BattleShip extends Puzzle { public BattleShip() { @@ -15,9 +17,13 @@ public BattleShip() { this.factory = new BattleShipCellFactory(); } + /** + * Initializes the game board. Called by the invoker of the class + */ @Override public void initializeView() { boardView = new BattleShipView((BattleShipBoard) currentBoard); + addBoardListener(boardView); } @Override @@ -33,9 +39,27 @@ public Board generatePuzzle(int difficulty) { */ @Override public boolean isBoardComplete(Board board) { - return false; + BattleShipBoard battleShipBoard = (BattleShipBoard) board; + + for (ContradictionRule rule : contradictionRules) { + if (rule.checkContradiction(battleShipBoard) == null) { + return false; + } + } + for (PuzzleElement data : battleShipBoard.getPuzzleElements()) { + BattleShipCell cell = (BattleShipCell) data; + if (cell.getType() == BattleShipType.UNKNOWN) { + return false; + } + } + return true; } + /** + * Callback for when the board puzzleElement changes + * + * @param board the board that has changed + */ @Override public void onBoardChange(Board board) { @@ -98,7 +122,7 @@ public void importPuzzle(String fileName) { // int y = Integer.valueOf(cells.item(i).getAttributes().getNamedItem("y").getNodeValue()); // String value = cells.item(i).getAttributes().getNamedItem("value").getNodeValue().toUpperCase(); // -// BattleShipCell cell = new BattleShipCell(BattleShipCellType.valueOf(value).ordinal(), new Point(x, y)); +// BattleShipCell cell = new BattleShipCell(BattleShipType.valueOf(value).ordinal(), new Point(x, y)); // battleShipBoard.setCell(x, y, cell); // cell.setModifiable(false); // cell.setGiven(true); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java index 93607d708..db48adece 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java @@ -4,7 +4,7 @@ import java.awt.*; -public class BattleShipCell extends GridCell { +public class BattleShipCell extends GridCell { /** * BattleShipCell Constructor - creates a BattleShipCell from the specified value and location @@ -12,7 +12,7 @@ public class BattleShipCell extends GridCell { * @param value value of the BattleShipCell * @param location position of the BattleShipCell */ - public BattleShipCell(int value, Point location) { + public BattleShipCell(BattleShipType value, Point location) { super(value, location); } @@ -21,8 +21,8 @@ public BattleShipCell(int value, Point location) { * * @return type of BattleShipCell */ - public BattleShipCellType getType() { - return BattleShipCellType.getType(getData()); + public BattleShipType getType() { + return data; } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java index b47149b8a..2df1bc110 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java @@ -13,17 +13,17 @@ public void changeCell(MouseEvent e, PuzzleElement data) { if (e.isControlDown()) { this.boardView.getSelectionPopupMenu().show(boardView, this.boardView.getCanvas().getX() + e.getX(), this.boardView.getCanvas().getY() + e.getY()); } else { - if (cell.getData() == BattleShipCellType.SHIP_SEGMENT_MIDDLE.value) { - cell.setData(BattleShipCellType.UNKNOWN.value); + if (cell.getData() == BattleShipType.SHIP_SEGMENT_MIDDLE) { + cell.setData(BattleShipType.UNKNOWN); } else { - cell.setData(cell.getData() + 1); + cell.setData(BattleShipType.getType(cell.getData().value + 1)); } } } else if (e.getButton() == MouseEvent.BUTTON3) { - if (cell.getData() == BattleShipCellType.UNKNOWN.value) { - cell.setData(BattleShipCellType.SHIP_SEGMENT_MIDDLE.value); + if (cell.getData() == BattleShipType.UNKNOWN) { + cell.setData(BattleShipType.SHIP_SEGMENT_MIDDLE); } else { - cell.setData(cell.getData() - 1); + cell.setData(BattleShipType.getType(cell.getData().value - 1)); } } } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java index f884ec6b1..9f401580c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java @@ -20,7 +20,7 @@ public class BattleShipCellFactory extends ElementFactory { * @throws InvalidFileFormatException */ @Override - public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { + public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { try { BattleShipBoard battleShipBoard = (BattleShipBoard) board; int width = battleShipBoard.getWidth(); @@ -28,9 +28,9 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat NamedNodeMap attributeList = node.getAttributes(); if (node.getNodeName().equalsIgnoreCase("cell")) { - int value = Integer.valueOf(attributeList.getNamedItem("value").getNodeValue()); - int x = Integer.valueOf(attributeList.getNamedItem("x").getNodeValue()); - int y = Integer.valueOf(attributeList.getNamedItem("y").getNodeValue()); + int value = Integer.parseInt(attributeList.getNamedItem("value").getNodeValue()); + int x = Integer.parseInt(attributeList.getNamedItem("x").getNodeValue()); + int y = Integer.parseInt(attributeList.getNamedItem("y").getNodeValue()); if (x >= width || y >= height) { throw new InvalidFileFormatException("BattleShip Factory: cell location out of bounds"); } @@ -38,7 +38,7 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat throw new InvalidFileFormatException("BattleShip Factory: cell unknown value"); } - BattleShipCell cell = new BattleShipCell(value, new Point(x, y)); + BattleShipCell cell = new BattleShipCell(BattleShipType.getType(value), new Point(x, y)); cell.setIndex(y * height + x); return cell; } else { diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java index fca600d2d..20fa2a7a2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java @@ -4,9 +4,9 @@ public class BattleShipClue extends PuzzleElement { - private BattleShipCellType type; + private BattleShipType type; - public BattleShipClue(int value, int index, BattleShipCellType type) { + public BattleShipClue(int value, int index, BattleShipType type) { super(value); this.index = index; this.type = type; @@ -42,11 +42,11 @@ public Integer getData() { return (Integer) super.getData(); } - public BattleShipCellType getType() { + public BattleShipType getType() { return type; } - public void setType(BattleShipCellType type) { + public void setType(BattleShipType type) { this.type = type; } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java index a1ba0f9b8..964bd3aba 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java @@ -22,7 +22,7 @@ public BattleShipElementView(BattleShipCell cell) { @Override public void drawElement(Graphics2D graphics2D) { BattleShipCell cell = (BattleShipCell) puzzleElement; - BattleShipCellType type = cell.getType(); + BattleShipType type = cell.getType(); switch (type) { case UNKNOWN: diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java index 04a884085..d588b8eb8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java @@ -50,9 +50,10 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { int height = battleShipBoard.getHeight(); for (int i = 0; i < elementDataList.getLength(); i++) { - BattleShipCell cell = (BattleShipCell) puzzle.getFactory().importCell(elementDataList.item(i), battleShipBoard); + BattleShipCell cell = (BattleShipCell) puzzle.getFactory().importCell( + elementDataList.item(i), battleShipBoard); Point loc = cell.getLocation(); - if (cell.getData() != 0) { + if (cell.getData() != BattleShipType.getType(0)) { cell.setModifiable(false); cell.setGiven(true); } @@ -62,7 +63,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (battleShipBoard.getCell(x, y) == null) { - BattleShipCell cell = new BattleShipCell(BattleShipCellType.UNKNOWN.value, new Point(x, y)); + BattleShipCell cell = new BattleShipCell(BattleShipType.UNKNOWN, new Point(x, y)); cell.setIndex(y * height + x); cell.setModifiable(true); battleShipBoard.setCell(x, y, cell); @@ -106,7 +107,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { if (battleShipBoard.getEast().get(index - 1) != null) { throw new InvalidFileFormatException("BattleShip Importer: duplicate clue index"); } - battleShipBoard.getEast().set(index - 1, new BattleShipClue(value, index, BattleShipCellType.CLUE_EAST)); + battleShipBoard.getEast().set(index - 1, new BattleShipClue(value, index, BattleShipType.CLUE_EAST)); } for (int i = 0; i < southClues.getLength(); i++) { @@ -121,7 +122,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { if (battleShipBoard.getSouth().get(index - 1) != null) { throw new InvalidFileFormatException("BattleShip Importer: duplicate clue index"); } - battleShipBoard.getSouth().set(index - 1, new BattleShipClue(value, index, BattleShipCellType.CLUE_SOUTH)); + battleShipBoard.getSouth().set(index - 1, new BattleShipClue(value, index, BattleShipType.CLUE_SOUTH)); } puzzle.setCurrentBoard(battleShipBoard); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellType.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java similarity index 61% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellType.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java index ac6ed1dcc..a8ed1dcb4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellType.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java @@ -1,18 +1,23 @@ package edu.rpi.legup.puzzle.battleship; -public enum BattleShipCellType { +public enum BattleShipType { UNKNOWN, WATER, SHIP_SEGMENT_UNKNOWN, SHIP_SIZE_1, SHIP_SEGMENT_TOP, SHIP_SEGMENT_RIGHT, SHIP_SEGMENT_BOTTOM, SHIP_SEGMENT_LEFT, SHIP_SEGMENT_MIDDLE, CLUE_NORTH, CLUE_EAST, CLUE_SOUTH, CLUE_WEST; public int value; - BattleShipCellType() { + BattleShipType() { this.value = this.ordinal(); } - public static BattleShipCellType getType(int value) { - BattleShipCellType[] vals = values(); + /** + * Gets the enum of this BattleShipType + * + * @return enum equivalent BattleShipType of integer value + */ + public static BattleShipType getType(int value) { + BattleShipType[] vals = values(); if (value >= 0 && value < vals.length) { return vals[value]; } From ca938cfb9da4ae7df7d8159bab0707195eaf3f9e Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:50:39 -0400 Subject: [PATCH 13/86] `BattleShipCell` uses `BattleShipType` as casted type instead of `Integer`. Also fixed any dependencies. --- .../legup/puzzle/nurikabe/NurikabeCell.java | 20 +++++++++++++++++-- .../legup/puzzle/treetent/TreeTentType.java | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java index c7903a1f1..7667c2c45 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java @@ -6,10 +6,21 @@ public class NurikabeCell extends GridCell { - public NurikabeCell(int valueInt, Point location) { - super(valueInt, location); +/** + * NurikabeCell Constructor - creates a NurikabeCell from the specified value and location + * + * @param value value of the NurikabeCell + * @param location position of the NurikabeCell + */ + public NurikabeCell(int value, Point location) { + super(value, location); } + /** + * Gets the type of this NurikabeCell + * + * @return type of NurikabeCell + */ public NurikabeType getType() { switch (data) { case -2: @@ -26,6 +37,11 @@ public NurikabeType getType() { return null; } + /** + * Performs a deep copy on the NurikabeCell + * + * @return a new copy of the NurikabeCell that is independent of this one + */ @Override public NurikabeCell copy() { NurikabeCell copy = new NurikabeCell(data, (Point) location.clone()); diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java index 99d04c2e9..5faa88c59 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java @@ -1,7 +1,8 @@ package edu.rpi.legup.puzzle.treetent; public enum TreeTentType { - UNKNOWN(0), TREE(1), GRASS(2), TENT(3), CLUE_NORTH(-1), CLUE_EAST(-2), CLUE_SOUTH(-3), CLUE_WEST(-4); + UNKNOWN(0), TREE(1), GRASS(2), TENT(3), + CLUE_NORTH(-1), CLUE_EAST(-2), CLUE_SOUTH(-3), CLUE_WEST(-4); public int value; From 2589930623c142bc65773abc22c27bb3a92464b8 Mon Sep 17 00:00:00 2001 From: Weijun Li <83390795+wei-jun7@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:56:08 -0400 Subject: [PATCH 14/86] Update LegupUI.java --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index a7d738c51..c68df7905 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -694,6 +694,7 @@ public void promptPuzzle() { setTitle(puzzleName + " - " + puzzleFile.getName()); } catch (InvalidFileFormatException e) { LOGGER.error(e.getMessage()); + JOptionPane.showMessageDialog(null, "File does not exist or it cannot be read", "Error", JOptionPane.ERROR_MESSAGE); } } } From 3599b95c3456091aa14a16e07c398eaa72d73c61 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 14 Jun 2022 15:05:57 -0400 Subject: [PATCH 15/86] Update LegupUI.java Added special error message for old Legup files --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index c68df7905..a35d11584 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -694,7 +694,10 @@ public void promptPuzzle() { setTitle(puzzleName + " - " + puzzleFile.getName()); } catch (InvalidFileFormatException e) { LOGGER.error(e.getMessage()); - JOptionPane.showMessageDialog(null, "File does not exist or it cannot be read", "Error", JOptionPane.ERROR_MESSAGE); + if (e.getMessage().contains("Proof Tree construction error: could not find rule by ID")) // TO DO: make error message not hardcoded + JOptionPane.showMessageDialog(null, "This file runs on an outdated version of Legup\nand is not compatible with the current version.", "Error", JOptionPane.ERROR_MESSAGE); + else + JOptionPane.showMessageDialog(null, "File does not exist or it cannot be read", "Error", JOptionPane.ERROR_MESSAGE); } } } From b1aacb07bd416aefd5b87c2c450079efb169edb2 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 14 Jun 2022 15:14:38 -0400 Subject: [PATCH 16/86] Update HomePanel.java Saving some changes --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 69 ++++++++++++++++--- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index aaafca375..0323c9ce5 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -9,6 +9,8 @@ public class HomePanel extends LegupPanel { private JButton[] buttons; private JMenuBar menuBar; + private final int buttonSize = 23; + public HomePanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.legupUI = legupUI; this.frame = frame; @@ -21,13 +23,22 @@ public JMenuBar getMenuBar() this.menuBar = new JMenuBar(); JMenu settings = new JMenu("Settings"); menuBar.add(settings); - JMenuItem about = new JMenuItem("About"); JMenuItem preferences = new JMenuItem("Preferences"); - settings.add(about); - about.addActionListener(a -> {System.out.println("About clicked");}); - // settings.addSeparator(); + preferences.addActionListener(a -> { System.out.println("Preferences clicked"); }); settings.add(preferences); - preferences.addActionListener(a -> {System.out.println("Preferences clicked");}); + + JMenuItem about = new JMenuItem("About"); + about.addActionListener(a -> { System.out.println("About clicked"); }); + settings.add(about); + + JMenuItem help = new JMenuItem("Help"); + about.addActionListener(a -> { System.out.println("Help clicked"); }); + settings.add(help); + + JMenuItem contribute = new JMenuItem("Contribute to Legup"); + contribute.addActionListener(a -> { System.out.println("Contribute to Legup clicked"); }); + settings.add(contribute); + return this.menuBar; } @@ -40,21 +51,57 @@ public void makeVisible() } private void initButtons() { - this.buttons = new JButton[2]; - this.buttons[0] = new JButton("Open Proof"); + this.buttons = new JButton[3]; + + this.buttons[0] = new JButton("Open Proof") + { + { + setSize(buttonSize, buttonSize); + setMaximumSize(getSize()); + } + }; this.buttons[0].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/openproof.png")); this.buttons[0].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[0].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[0].addActionListener(l -> this.legupUI.displayPanel(1)); - this.buttons[1] = new JButton("Create/Edit Puzzle"); + + this.buttons[1] = new JButton("Create New Puzzle") + { + { + setSize(buttonSize, buttonSize); + setMaximumSize(getSize()); + } + }; this.buttons[1].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); this.buttons[1].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[1].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[1].addActionListener(l -> this.legupUI.displayPanel(2)); + + this.buttons[2] = new JButton("Edit Puzzle") + { + { + setSize(buttonSize, buttonSize); + setMaximumSize(getSize()); + } + }; + this.buttons[2].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); // PLACEHOLDER + this.buttons[2].setHorizontalTextPosition(AbstractButton.CENTER); + this.buttons[2].setVerticalTextPosition(AbstractButton.BOTTOM); + this.buttons[2].addActionListener(l -> this.legupUI.displayPanel(2)); // PLACEHOLDER } - private void render() { - this.add(this.buttons[0]); - this.add(this.buttons[1]); + private void render() + { + this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + JLabel welcome = new JLabel("Welcome to Legup"); + welcome.setAlignmentX(Component.CENTER_ALIGNMENT); + JPanel buttons = new JPanel(); + buttons.add(this.buttons[0]); + buttons.add(Box.createRigidArea(new Dimension(5, 0))); + buttons.add(this.buttons[1]); + buttons.add(Box.createRigidArea(new Dimension(5, 0))); + buttons.add(this.buttons[2]); + this.add(welcome); + this.add(buttons); } } From dd3d4b3e01158b31d050fdd7033486b523c27161 Mon Sep 17 00:00:00 2001 From: littlebizaizi Date: Tue, 14 Jun 2022 15:24:52 -0400 Subject: [PATCH 17/86] Update PreferencesDialog.java --- .../java/edu/rpi/legup/ui/PreferencesDialog.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index 3e511f1da..e090d6487 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -44,12 +44,7 @@ public PreferencesDialog(LegupUI legupUI) { JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); - JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); - JScrollPane generalTab = createGeneralTab(); - - tabbedPane.addTab("General", generalTab); - - mainPanel.add(tabbedPane, BorderLayout.CENTER); + mainPanel.add(createGeneralTab()); JPanel bottomPanel = new JPanel(); bottomPanel.setBorder(null); @@ -182,6 +177,15 @@ private JScrollPane createGeneralTab() { immFeedbackRow.setMaximumSize(new Dimension(Integer.MAX_VALUE, immFeedbackRow.getPreferredSize().height)); contentPane.add(immFeedbackRow); + contentPane.add(createLeftLabel("Instructor Mode")); + contentPane.add(createLineSeparator()); + immFeedback = new JCheckBox("Instructor Mode", Boolean.valueOf(prefs.getUserPref(LegupPreferences.IMMEDIATE_FEEDBACK))); + immFeedback.setToolTipText("If checked this will update the colors of the tree view elements immediately"); + immFeedbackRow.setLayout(new BorderLayout()); + immFeedbackRow.add(immFeedback, BorderLayout.WEST); + immFeedbackRow.setMaximumSize(new Dimension(Integer.MAX_VALUE, immFeedbackRow.getPreferredSize().height)); + contentPane.add(immFeedbackRow); + scrollPane.setViewportView(contentPane); return scrollPane; } From 6c2d91d4d089e6b66838589d1cc205952a3b4fdd Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 14 Jun 2022 15:28:26 -0400 Subject: [PATCH 18/86] Adjusted title font Adjusted font --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 0323c9ce5..48ff2dd7b 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -94,7 +94,9 @@ private void render() { this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JLabel welcome = new JLabel("Welcome to Legup"); + welcome.setFont(new Font("Roboto", Font.BOLD, 23)); welcome.setAlignmentX(Component.CENTER_ALIGNMENT); + JPanel buttons = new JPanel(); buttons.add(this.buttons[0]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); From 1a01de59f1c1c1317e0ba055d83ecf0c263ad094 Mon Sep 17 00:00:00 2001 From: RPIFisherman <91505581+RPIFisherman@users.noreply.github.com> Date: Tue, 14 Jun 2022 15:29:39 -0400 Subject: [PATCH 19/86] Optimize the code The println function is redundant. --- src/main/java/edu/rpi/legup/controller/Controller.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/controller/Controller.java b/src/main/java/edu/rpi/legup/controller/Controller.java index 97a0bef92..61c8108cb 100644 --- a/src/main/java/edu/rpi/legup/controller/Controller.java +++ b/src/main/java/edu/rpi/legup/controller/Controller.java @@ -117,7 +117,6 @@ public void mouseMoved(MouseEvent e) { */ @Override public void mouseWheelMoved(MouseWheelEvent e) { - System.out.println(e.getWheelRotation()); if (e.isControlDown()) { if (e.getWheelRotation() != 0){ viewer.zoom(e.getWheelRotation() * 2, e.getPoint()); From 13aaff19fc1c44683c579c282b3228cce4593eae Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 14 Jun 2022 15:31:29 -0400 Subject: [PATCH 20/86] Update PreferencesDialog.java --- src/main/java/edu/rpi/legup/ui/PreferencesDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index e090d6487..6fa8e9a67 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -177,10 +177,10 @@ private JScrollPane createGeneralTab() { immFeedbackRow.setMaximumSize(new Dimension(Integer.MAX_VALUE, immFeedbackRow.getPreferredSize().height)); contentPane.add(immFeedbackRow); - contentPane.add(createLeftLabel("Instructor Mode")); + contentPane.add(createLeftLabel("Instructor Preferences")); contentPane.add(createLineSeparator()); immFeedback = new JCheckBox("Instructor Mode", Boolean.valueOf(prefs.getUserPref(LegupPreferences.IMMEDIATE_FEEDBACK))); - immFeedback.setToolTipText("If checked this will update the colors of the tree view elements immediately"); + immFeedback.setToolTipText("Currently unimplemented, this does nothing right now"); immFeedbackRow.setLayout(new BorderLayout()); immFeedbackRow.add(immFeedback, BorderLayout.WEST); immFeedbackRow.setMaximumSize(new Dimension(Integer.MAX_VALUE, immFeedbackRow.getPreferredSize().height)); From cff86eae7cf971301c3131a9d2094dba097510d0 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Tue, 14 Jun 2022 16:03:00 -0400 Subject: [PATCH 21/86] created layout of the element buttons for the puzzle editor panel --- .../controller/EditorElementController.java | 43 ++++++++++ .../edu/rpi/legup/model/elements/Element.java | 77 ++++++++++++++++++ .../rpi/legup/model/elements/ElementType.java | 5 ++ .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 8 +- .../elementsview/ElementButton.java | 23 ++++++ .../elementsview/ElementFrame.java | 61 ++++++++++++++ .../elementsview/ElementPanel.java | 80 ++++++++++++++++++- 7 files changed, 293 insertions(+), 4 deletions(-) create mode 100644 src/main/java/edu/rpi/legup/controller/EditorElementController.java create mode 100644 src/main/java/edu/rpi/legup/model/elements/Element.java create mode 100644 src/main/java/edu/rpi/legup/model/elements/ElementType.java create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java diff --git a/src/main/java/edu/rpi/legup/controller/EditorElementController.java b/src/main/java/edu/rpi/legup/controller/EditorElementController.java new file mode 100644 index 000000000..52aa67cfe --- /dev/null +++ b/src/main/java/edu/rpi/legup/controller/EditorElementController.java @@ -0,0 +1,43 @@ +package edu.rpi.legup.controller; + +import edu.rpi.legup.app.GameBoardFacade; +import edu.rpi.legup.app.LegupPreferences; +import edu.rpi.legup.history.*; +import edu.rpi.legup.model.Puzzle; +import edu.rpi.legup.model.elements.Element; +import edu.rpi.legup.model.gameboard.CaseBoard; +import edu.rpi.legup.model.rules.*; +import edu.rpi.legup.model.tree.TreeElement; +import edu.rpi.legup.model.tree.TreeElementType; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleButton; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeView; +import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection; +import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementButton; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import static edu.rpi.legup.app.GameBoardFacade.getInstance; + +public class EditorElementController implements ActionListener { + protected Object lastSource; + + public EditorElementController() { + super(); + } + + public void buttonPressed(Element element) { + // TODO: implement what happens when element is pressed + } + + @Override + public void actionPerformed(ActionEvent e) { + lastSource = e.getSource(); + ElementButton button = (ElementButton) lastSource; + buttonPressed(button.getElement()); + } +} diff --git a/src/main/java/edu/rpi/legup/model/elements/Element.java b/src/main/java/edu/rpi/legup/model/elements/Element.java new file mode 100644 index 000000000..0fdabe383 --- /dev/null +++ b/src/main/java/edu/rpi/legup/model/elements/Element.java @@ -0,0 +1,77 @@ +package edu.rpi.legup.model.elements; + +import edu.rpi.legup.model.rules.RuleType; + +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; + +public abstract class Element { + protected String elementID; + protected String elementName; + protected String description; + + protected String imageName; + protected ImageIcon image; + + protected ElementType elementType; + + private final String INVALID_USE_MESSAGE; + + public Element(String elementID, String elementName, String description, String imageName) { + this.elementID = elementID; + this.elementName = elementName; + this.description = description; + this.imageName = imageName; + this.INVALID_USE_MESSAGE = "Invalid use of the rule " + this.elementName; + loadImage(); + } + + private void loadImage() { + if (imageName != null) { + this.image = new ImageIcon(ClassLoader.getSystemResource(imageName)); + //Resize images to be 100px wide + Image image = this.image.getImage(); + if(this.image.getIconWidth() < 120) return; + int height = (int) (100 * ((double) this.image.getIconHeight() / this.image.getIconWidth())); + if(height==0){ + System.out.println("height is 0 error"); + System.out.println("height: "+this.image.getIconHeight()); + System.out.println("width: "+this.image.getIconWidth()); + return; + } + BufferedImage bimage = new BufferedImage(100, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g = bimage.createGraphics(); + g.drawImage(image, 0, 0, 100, height, null); + this.image = new ImageIcon(bimage); + } + } + public String getElementName() { + return elementName; + } + + public void setElementName(String elementName) { + this.elementName = elementName; + } + + public String getElementID() { + return elementID; + } + + public String getDescription() { + return description; + } + + public ImageIcon getImageIcon() { + return image; + } + + public ElementType getElementType() { + return elementType; + } + + public String getInvalidUseOfRuleMessage() + { + return this.INVALID_USE_MESSAGE; + } +} diff --git a/src/main/java/edu/rpi/legup/model/elements/ElementType.java b/src/main/java/edu/rpi/legup/model/elements/ElementType.java new file mode 100644 index 000000000..85ec9be36 --- /dev/null +++ b/src/main/java/edu/rpi/legup/model/elements/ElementType.java @@ -0,0 +1,5 @@ +package edu.rpi.legup.model.elements; + +public enum ElementType { + NURIKABE, TREETENT, LIGHTUP, SKYSCRAPERS +} diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 46593bf59..351cef3ea 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -17,6 +17,8 @@ public class PuzzleEditorPanel extends LegupPanel { private JMenuBar menuBar; private JFrame frame; private JButton[] buttons; + + private JPanel elementPanel; private JPanel mainPanel; private FileDialog fileDialog; private JMenuItem undo, redo; @@ -57,11 +59,11 @@ public void setMenuBar() { newPuzzle.addActionListener((ActionEvent) -> promptPuzzle()); if(os.equals("mac")) newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK)); - // file>open - JMenuItem openPuzzle = new JMenuItem("Open"); + // file>save + JMenuItem savePuzzle = new JMenuItem("Save"); menus[0].add(newPuzzle); - menus[0].add(openPuzzle); + menus[0].add(savePuzzle); // EDIT menus[1] = new JMenu("Edit"); diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java new file mode 100644 index 000000000..a7fe8bf7c --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java @@ -0,0 +1,23 @@ +package edu.rpi.legup.ui.puzzleeditorui.elementsview; + +import edu.rpi.legup.model.elements.Element; +import edu.rpi.legup.model.rules.Rule; + +import javax.swing.*; + +public class ElementButton extends JButton { + + private Element element; + ElementButton(Element e) { + super(e.getImageIcon()); + this.element = e; + } + + public Element getElement() { + return element; + } + + public void setElement(Element e) { + this.element = e; + } +} diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java new file mode 100644 index 000000000..892f96918 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -0,0 +1,61 @@ +package edu.rpi.legup.ui.puzzleeditorui.elementsview; + +import edu.rpi.legup.controller.EditorElementController; +import edu.rpi.legup.controller.RuleController; +import edu.rpi.legup.ui.proofeditorui.rulesview.BasicRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.CaseRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.ContradictionRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.RulePanel; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; + +public class ElementFrame extends JPanel { + private static final String checkBox = " \u2714 "; + private static final String xBox = " \u2718 "; + private static final String htmlHead = ""; + private static final String htmlTail = ""; + + private JTabbedPane tabbedPane; + private JLabel status; + private ButtonGroup buttonGroup; + + private EditorElementController controller; + + public ElementFrame(EditorElementController controller) { + this.controller = controller; + + this.tabbedPane = new JTabbedPane(); + this.status = new JLabel(); + this.buttonGroup = new ButtonGroup(); + + setLayout(new BorderLayout()); + setMinimumSize(new Dimension(250, 256)); + setPreferredSize(new Dimension(330, 256)); + + add(tabbedPane); + add(status, BorderLayout.SOUTH); + + TitledBorder title = BorderFactory.createTitledBorder("Rules"); + title.setTitleJustification(TitledBorder.CENTER); + setBorder(title); + } + + public ButtonGroup getButtonGroup() { + return buttonGroup; + } + + public void resetSize() { + int buttonWidth = ((ElementPanel) tabbedPane.getSelectedComponent()).getElementButtons()[0].getWidth(); + this.setMinimumSize(new Dimension(2 * buttonWidth + 64, this.getHeight())); + } + + public EditorElementController getController() { + return controller; + } + + public JTabbedPane getTabbedPane() { + return tabbedPane; + } +} diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java index ee6d119e0..4c2429031 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java @@ -1,4 +1,82 @@ package edu.rpi.legup.ui.puzzleeditorui.elementsview; -public class ElementPanel { +import edu.rpi.legup.model.rules.Rule; +import edu.rpi.legup.ui.WrapLayout; +import edu.rpi.legup.model.elements.Element; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleButton; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; + +public abstract class ElementPanel extends JPanel { + protected ImageIcon icon; + protected String name; + protected String toolTip; + protected ElementButton[] elementButtons; + protected ElementFrame elementFrame; + protected List elements; + + public ElementPanel(ElementFrame eFrame) { + this.elementFrame = eFrame; + this.elements = new ArrayList<>(); + setLayout(new WrapLayout()); + } + public void setRules(List elements) { + this.elements = elements; + clearButtons(); + + elementButtons = new ElementButton[elements.size()]; + + for (int i = 0; i < elements.size(); i++) { + Element element = elements.get(i); + elementButtons[i] = new ElementButton(element); + elementFrame.getButtonGroup().add(elementButtons[i]); + + elementButtons[i].setToolTipText(element.getElementName() + ": " + element.getDescription()); + elementButtons[i].addActionListener(elementFrame.getController()); + add(elementButtons[i]); + } + revalidate(); + } + + protected void clearButtons() { + if (elementButtons != null) { + removeAll(); + for (int x = 0; x < elementButtons.length; ++x) { + elementButtons[x].removeActionListener(elementFrame.getController()); + } + } + } + + public ElementButton[] getElementButtons() { + return elementButtons; + } + + public ImageIcon getIcon() { + return icon; + } + + public void setIcon(ImageIcon icon) { + this.icon = icon; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + public String getToolTip() { + return toolTip; + } + + public void setToolTip(String toolTip) { + this.toolTip = toolTip; + } } + From 49aedcd26b02d4a5c33f10beee483a6404c770d2 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 16 Jun 2022 15:41:46 -0400 Subject: [PATCH 22/86] Changed Nurikabe rule names Changed two rule names to decrease confusion --- .../puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java | 2 +- .../rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java index 4118ce41d..bcea64e79 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java @@ -18,7 +18,7 @@ public class CantReachWhiteContradictionRule extends ContradictionRule { public CantReachWhiteContradictionRule() { super("NURI-CONT-0002", - "Unreachables are Black", + "Unreachable White Cell", "A white cell must be able to reach a white region", "edu/rpi/legup/images/nurikabe/contradictions/CantReach.png"); } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java index dd1ef7fae..b2186509c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java @@ -13,7 +13,7 @@ public class UnreachableBasicRule extends BasicRule { public UnreachableBasicRule() { super("NURI-BASC-0008", - "Unreachable white region", + "Can't Reach Cell", "A cell must be black if it cannot be reached by any white region", "edu/rpi/legup/images/nurikabe/rules/Unreachable.png"); } From 0ddb91aa5292e515b4374ef8b0fef08613eb6414 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 16 Jun 2022 15:43:23 -0400 Subject: [PATCH 23/86] Refactored two classes Refactored two classes to reflect new rule names and updated reference sheet to reflect this change --- ...eachableBasicRule.java => CannotReachCellBasicRule.java} | 6 +++--- ...Rule.java => UnreachableWhiteCellContradictionRule.java} | 4 ++-- .../puzzle/nurikabe/rules/nurikabe_reference_sheet.txt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/{UnreachableBasicRule.java => CannotReachCellBasicRule.java} (93%) rename src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/{CantReachWhiteContradictionRule.java => UnreachableWhiteCellContradictionRule.java} (93%) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CannotReachCellBasicRule.java similarity index 93% rename from src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java rename to src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CannotReachCellBasicRule.java index b2186509c..0cb016a92 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CannotReachCellBasicRule.java @@ -10,8 +10,8 @@ import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; import edu.rpi.legup.puzzle.nurikabe.NurikabeType; -public class UnreachableBasicRule extends BasicRule { - public UnreachableBasicRule() { +public class CannotReachCellBasicRule extends BasicRule { + public CannotReachCellBasicRule() { super("NURI-BASC-0008", "Can't Reach Cell", "A cell must be black if it cannot be reached by any white region", @@ -29,7 +29,7 @@ public UnreachableBasicRule() { */ @Override protected String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) { - ContradictionRule contraRule = new CantReachWhiteContradictionRule(); + ContradictionRule contraRule = new UnreachableWhiteCellContradictionRule(); NurikabeBoard destBoardState = (NurikabeBoard) transition.getBoard(); NurikabeCell cell = (NurikabeCell) destBoardState.getPuzzleElement(puzzleElement); diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableWhiteCellContradictionRule.java similarity index 93% rename from src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java rename to src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableWhiteCellContradictionRule.java index bcea64e79..f12bdb57f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/CantReachWhiteContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/UnreachableWhiteCellContradictionRule.java @@ -11,12 +11,12 @@ import java.util.ArrayList; import java.util.Set; -public class CantReachWhiteContradictionRule extends ContradictionRule { +public class UnreachableWhiteCellContradictionRule extends ContradictionRule { private final String NO_CONTRADICTION_MESSAGE = "Cell at this index can be reached"; private final String INVALID_USE_MESSAGE = "Does not contain a contradiction at this index"; - public CantReachWhiteContradictionRule() { + public UnreachableWhiteCellContradictionRule() { super("NURI-CONT-0002", "Unreachable White Cell", "A white cell must be able to reach a white region", diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/nurikabe_reference_sheet.txt b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/nurikabe_reference_sheet.txt index ae714e83f..2af0b5fea 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/nurikabe_reference_sheet.txt +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/nurikabe_reference_sheet.txt @@ -5,11 +5,11 @@ NURI-BASC-0004 : FillinBlackBasicRule NURI-BASC-0005 : FillinWhiteBasicRule NURI-BASC-0006 : PreventBlackSquareBasicRule NURI-BASC-0007 : SurroundRegionBasicRule -NURI-BASC-0008 : UnreachableBasicRule +NURI-BASC-0008 : CannotReachCellBasicRule NURI-BASC-0009 : WhiteBottleNeckBasicRule NURI-CONT-0001 : BlackSquareContradictionRule -NURI-CONT-0002 : CantReachWhiteContradictionRule +NURI-CONT-0002 : UnreachableWhiteCellContradictionRule NURI-CONT-0003 : IsolateBlackContradictionRule NURI-CONT-0004 : MultipleNumbersContradictionRule NURI-CONT-0005 : NoNumberContradictionRule From a7aed2cbbab1ae3b84d666d7fc8370de8aa62da5 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 16 Jun 2022 15:59:52 -0400 Subject: [PATCH 24/86] More adjustments to home screen --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 48ff2dd7b..98735eda8 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -97,6 +97,14 @@ private void render() welcome.setFont(new Font("Roboto", Font.BOLD, 23)); welcome.setAlignmentX(Component.CENTER_ALIGNMENT); + JLabel version = new JLabel("Version 3.0.0"); // This should be autochanged in the future + version.setFont(new Font("Roboto", Font.ITALIC, 10)); + version.setAlignmentX(Component.CENTER_ALIGNMENT); + + JLabel credits = new JLabel("A project by Dr. Bram van Heuveln"); + credits.setFont(new Font("Roboto", Font.PLAIN, 12)); + credits.setAlignmentX(Component.CENTER_ALIGNMENT); + JPanel buttons = new JPanel(); buttons.add(this.buttons[0]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); @@ -104,6 +112,8 @@ private void render() buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[2]); this.add(welcome); + this.add(version); + this.add(credits); this.add(buttons); } } From 4e7f165ea11021060b07a583d0e5df91fbd6a1e1 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Thu, 16 Jun 2022 16:08:19 -0400 Subject: [PATCH 25/86] Added Batch Grader option --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 98735eda8..726b3c80f 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -51,7 +51,7 @@ public void makeVisible() } private void initButtons() { - this.buttons = new JButton[3]; + this.buttons = new JButton[4]; this.buttons[0] = new JButton("Open Proof") { @@ -88,6 +88,18 @@ private void initButtons() { this.buttons[2].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[2].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[2].addActionListener(l -> this.legupUI.displayPanel(2)); // PLACEHOLDER + + this.buttons[3] = new JButton("Batch Grader") + { + { + setSize(buttonSize, buttonSize); + setMaximumSize(getSize()); + } + }; + this.buttons[3].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); // PLACEHOLDER + this.buttons[3].setHorizontalTextPosition(AbstractButton.CENTER); + this.buttons[3].setVerticalTextPosition(AbstractButton.BOTTOM); + this.buttons[3].addActionListener(l -> this.legupUI.displayPanel(2)); // PLACEHOLDER } private void render() @@ -111,6 +123,8 @@ private void render() buttons.add(this.buttons[1]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[2]); + buttons.add(Box.createRigidArea(new Dimension(5, 0))); + buttons.add(this.buttons[3]); this.add(welcome); this.add(version); this.add(credits); From 0a0358a543acae0940da124864534f1dd4409f12 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 17 Jun 2022 14:03:18 -0400 Subject: [PATCH 26/86] Update HomePanel.java Resized some buttons and moved batch grader button --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 726b3c80f..9b5763c85 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -9,7 +9,7 @@ public class HomePanel extends LegupPanel { private JButton[] buttons; private JMenuBar menuBar; - private final int buttonSize = 23; + private final int buttonSize = 100; public HomePanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.legupUI = legupUI; @@ -50,6 +50,13 @@ public void makeVisible() this.frame.setJMenuBar(this.getMenuBar()); } + private static ImageIcon resizeButtonIcon(ImageIcon icon, int width, int height) + { + Image image = icon.getImage(); + Image resizedImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + return new ImageIcon(resizedImage); + } + private void initButtons() { this.buttons = new JButton[4]; @@ -60,19 +67,22 @@ private void initButtons() { setMaximumSize(getSize()); } }; - this.buttons[0].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/openproof.png")); + + ImageIcon button0Icon = new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/openproof.png"); + this.buttons[0].setIcon(resizeButtonIcon(button0Icon, this.buttonSize, this.buttonSize)); this.buttons[0].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[0].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[0].addActionListener(l -> this.legupUI.displayPanel(1)); - this.buttons[1] = new JButton("Create New Puzzle") + this.buttons[1] = new JButton("New Puzzle") { { setSize(buttonSize, buttonSize); setMaximumSize(getSize()); } }; - this.buttons[1].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); + ImageIcon button1Icon = new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png"); + this.buttons[1].setIcon(resizeButtonIcon(button1Icon, this.buttonSize, this.buttonSize)); this.buttons[1].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[1].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[1].addActionListener(l -> this.legupUI.displayPanel(2)); @@ -84,22 +94,21 @@ private void initButtons() { setMaximumSize(getSize()); } }; - this.buttons[2].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); // PLACEHOLDER + ImageIcon button2Icon = new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png"); // PLACEHOLDER + this.buttons[2].setIcon(resizeButtonIcon(button2Icon, this.buttonSize, this.buttonSize)); this.buttons[2].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[2].setVerticalTextPosition(AbstractButton.BOTTOM); this.buttons[2].addActionListener(l -> this.legupUI.displayPanel(2)); // PLACEHOLDER - this.buttons[3] = new JButton("Batch Grader") + for (int i = 0; i < this.buttons.length - 1; i++) // -1 to avoid the batch grader button { - { - setSize(buttonSize, buttonSize); - setMaximumSize(getSize()); - } - }; - this.buttons[3].setIcon(new ImageIcon("src/main/resources/edu/rpi/legup/homepanel/edit.png")); // PLACEHOLDER + //this.buttons[i].setPreferredSize(new Dimension(100, 100)); + this.buttons[i].setBounds(200, 200, 700, 700); + } + + this.buttons[3] = new JButton("Batch Grader"); this.buttons[3].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[3].setVerticalTextPosition(AbstractButton.BOTTOM); - this.buttons[3].addActionListener(l -> this.legupUI.displayPanel(2)); // PLACEHOLDER } private void render() @@ -123,11 +132,15 @@ private void render() buttons.add(this.buttons[1]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[2]); - buttons.add(Box.createRigidArea(new Dimension(5, 0))); - buttons.add(this.buttons[3]); + + JPanel batchGraderButton = new JPanel(); + batchGraderButton.add(this.buttons[3]); + batchGraderButton.setAlignmentX(Component.LEFT_ALIGNMENT); + this.add(welcome); this.add(version); this.add(credits); this.add(buttons); + this.add(batchGraderButton); } } From 04347211f86453b573f9bb810d84f31a9208d2bf Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 17 Jun 2022 14:13:36 -0400 Subject: [PATCH 27/86] Renamed method to be consistent with new naming scheme --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 4 ++-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index c695139fa..25c6ae4f0 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -76,8 +76,8 @@ public synchronized static GameBoardFacade getInstance() { public void initializeUI() { EventQueue.invokeLater(() ->{ legupUI = new LegupUI(); - puzzleSolver = legupUI.getPuzzleSolver(); - addHistoryListener(legupUI.getPuzzleSolver()); + puzzleSolver = legupUI.getProofEditor(); + addHistoryListener(legupUI.getProofEditor()); }); } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 005422d86..df81fc60b 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -149,7 +149,7 @@ protected void displayPanel(int option) { repaint(); } - public ProofEditorPanel getPuzzleSolver() { + public ProofEditorPanel getProofEditor() { return (ProofEditorPanel) panels[1]; } @@ -158,7 +158,7 @@ public static boolean profFlag(int flag) { } public void repaintTree() { - getPuzzleSolver().repaintTree(); + getProofEditor().repaintTree(); } private void directions() { @@ -301,14 +301,14 @@ public void windowDeactivated(WindowEvent e) { } public BoardView getBoardView() { - return getPuzzleSolver().getBoardView(); + return getProofEditor().getBoardView(); } public DynamicView getDynamicBoardView() { - return getPuzzleSolver().getDynamicBoardView(); + return getProofEditor().getDynamicBoardView(); } public TreePanel getTreePanel() { - return getPuzzleSolver().getTreePanel(); + return getProofEditor().getTreePanel(); } } From a181123018353bd6fca4fc11c22ff04e0e45ed55 Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:45:24 -0400 Subject: [PATCH 28/86] `BattleShipCell` uses `BattleShipType` as casted type instead of `Integer`. Also fixed any dependencies. --- .../edu/rpi/legup/puzzle/battleship/BattleShipExporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java index bb8bd2a12..564b60eb3 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java @@ -21,7 +21,7 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { org.w3c.dom.Element cellsElement = newDocument.createElement("cells"); for (PuzzleElement puzzleElement : board.getPuzzleElements()) { BattleShipCell cell = (BattleShipCell) puzzleElement; - if (cell.getData() != 0) { + if (cell.getData() != BattleShipType.getType(0)) { org.w3c.dom.Element cellElement = puzzle.getFactory().exportCell(newDocument, puzzleElement); cellsElement.appendChild(cellElement); } From c9a0defa70920527daee62353115b1f7c030d902 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:00:09 -0400 Subject: [PATCH 29/86] progress on setting up editor panels running into some issues with swing --- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 151 +++++++++++++++--- .../NonPlaceableElementPanel.java | 12 ++ .../elementsview/PlaceableElementPanel.java | 12 ++ 3 files changed, 154 insertions(+), 21 deletions(-) create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java create mode 100644 src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 351cef3ea..2c6b3eea1 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -1,49 +1,78 @@ package edu.rpi.legup.ui; import edu.rpi.legup.app.GameBoardFacade; +import edu.rpi.legup.controller.BoardController; +import edu.rpi.legup.controller.EditorElementController; +import edu.rpi.legup.controller.ElementController; +import edu.rpi.legup.controller.RuleController; +import edu.rpi.legup.history.ICommand; +import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.save.InvalidFileFormatException; +import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; +import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.swing.*; +import javax.swing.border.TitledBorder; import java.awt.*; +import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.io.File; +import java.net.URL; -public class PuzzleEditorPanel extends LegupPanel { +public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private final static Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); private JMenu[] menus; private JMenuBar menuBar; + private JToolBar toolBar; private JFrame frame; private JButton[] buttons; - + private JButton[] toolBarButtons; private JPanel elementPanel; - private JPanel mainPanel; + private DynamicView dynamicBoardView; + private BoardView boardView; + private TitledBorder boardBorder; + private JSplitPane mainPanel; private FileDialog fileDialog; private JMenuItem undo, redo; + private ElementFrame elementFrame; + final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame) { this.fileDialog = fileDialog; this.frame = frame; setLayout(new GridLayout(2, 1)); - setup(); } - private void setup() { - mainPanel = new JPanel(); - mainPanel.setSize(100,300); - // menu bar + protected void setupContent() { + JPanel elementBox = new JPanel(new BorderLayout()); - // buttons - buttons = new JButton[3]; - buttons[0] = new JButton("element 0"); - buttons[1] = new JButton("element 1"); - buttons[2] = new JButton("element 2"); - for (JButton button : buttons) { - mainPanel.add(button); - } - setMenuBar(); + EditorElementController elementController = new EditorElementController(); + elementFrame = new ElementFrame(elementController); + elementBox.add(elementFrame, BorderLayout.WEST); + + dynamicBoardView = new DynamicView(new ScrollView(new BoardController())); + TitledBorder titleBoard = BorderFactory.createTitledBorder("Board"); + titleBoard.setTitleJustification(TitledBorder.CENTER); + dynamicBoardView.setBorder(titleBoard); + + JPanel boardPanel = new JPanel(new BorderLayout()); + mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, elementFrame, dynamicBoardView); + mainPanel.setPreferredSize(new Dimension(600, 100)); + + boardPanel.add(mainPanel); + boardBorder = BorderFactory.createTitledBorder("Board"); + boardBorder.setTitleJustification(TitledBorder.CENTER); + + elementBox.add(boardPanel); + this.add(elementBox); + + mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation() + 100); + + revalidate(); } public void setMenuBar() { @@ -86,10 +115,63 @@ public void setMenuBar() { @Override public void makeVisible() { - render(); + setupToolBar(); + setupContent(); + setMenuBar(); frame.setJMenuBar(menuBar); } + private void setupToolBar() { + setToolBarButtons(new JButton[ToolbarName.values().length]); + for (int i = 0; i < ToolbarName.values().length; i++) { + String toolBarName = ToolbarName.values()[i].toString(); + URL resourceLocation = ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/" + toolBarName + ".png"); + JButton button = new JButton(toolBarName, new ImageIcon(resourceLocation)); + button.setFocusPainted(false); + getToolBarButtons()[i] = button; + } + toolBar = new JToolBar(); + toolBar.setFloatable(false); + toolBar.setRollover(true); + + for (int i = 0; i < getToolBarButtons().length; i++) { + for (int s = 0; s < TOOLBAR_SEPARATOR_BEFORE.length; s++) { + if (i == TOOLBAR_SEPARATOR_BEFORE[s]) { + toolBar.addSeparator(); + } + } + String toolBarName = ToolbarName.values()[i].toString(); + + toolBar.add(getToolBarButtons()[i]); + getToolBarButtons()[i].setToolTipText(toolBarName); + + getToolBarButtons()[i].setVerticalTextPosition(SwingConstants.BOTTOM); + getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER); + } + + toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); + //toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); + toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); + toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); + toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> { + }); + toolBarButtons[ToolbarName.SUBMIT.ordinal()].addActionListener((ActionEvent e) -> { + }); + toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].addActionListener((ActionEvent e) -> { + }); + + toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].setEnabled(false); + toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].setEnabled(true); + + this.add(toolBar, BorderLayout.NORTH); + } + public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { @@ -123,8 +205,35 @@ public boolean noQuit(String instr) { int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_CANCEL_OPTION); return n != JOptionPane.YES_OPTION; } - private void render() { - add(mainPanel); - add(new JLabel("Welcome to the puzzle editor!")); + + @Override + public void onPushChange(ICommand command) { + + } + + @Override + public void onUndo(boolean isBottom, boolean isTop) { + + } + + @Override + public void onRedo(boolean isBottom, boolean isTop) { + + } + + @Override + public void onClearHistory() { + + } + + public JButton[] getToolBarButtons() { + return toolBarButtons; + } + public void setToolBarButtons(JButton[] toolBarButtons) { + this.toolBarButtons = toolBarButtons; + } + + private void repaintAll() { + boardView.repaint(); } } diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java new file mode 100644 index 000000000..5c3328e73 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java @@ -0,0 +1,12 @@ +package edu.rpi.legup.ui.puzzleeditorui.elementsview; + +import javax.swing.*; + +public class NonPlaceableElementPanel extends ElementPanel{ + NonPlaceableElementPanel(ElementFrame elementFrame) { + super(elementFrame); + this.icon = new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Basic Rules.gif")); + this.name = "Non-Placeable Elements"; + this.toolTip = "Non-Placeable Elements"; + } +} diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java new file mode 100644 index 000000000..19ede5510 --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java @@ -0,0 +1,12 @@ +package edu.rpi.legup.ui.puzzleeditorui.elementsview; + +import javax.swing.*; + +public class PlaceableElementPanel extends ElementPanel{ + PlaceableElementPanel(ElementFrame elementFrame) { + super(elementFrame); + this.icon = new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Basic Rules.gif")); + this.name = "Placeable Elements"; + this.toolTip = "Placeable Elements"; + } +} From 27e873ffb7970a846541c6fc79ad2e0c6ed7a1b5 Mon Sep 17 00:00:00 2001 From: littlebizaizi Date: Fri, 17 Jun 2022 15:04:48 -0400 Subject: [PATCH 30/86] Update PreferencesDialog.java add a border to preference menu --- src/main/java/edu/rpi/legup/ui/PreferencesDialog.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index 6fa8e9a67..8c5fae3b0 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -42,6 +42,7 @@ public PreferencesDialog(LegupUI legupUI) { setTitle("Preferences"); JPanel mainPanel = new JPanel(); + mainPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); mainPanel.setLayout(new BorderLayout()); mainPanel.add(createGeneralTab()); From e9c9742c50e99e99231480f7128df670be635f3a Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 17 Jun 2022 15:07:03 -0400 Subject: [PATCH 31/86] Adjustments made to Batch Grader Added a column to display puzzle type --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index a35d11584..290c37993 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -555,12 +555,15 @@ private void traverseDir(File folder, BufferedWriter writer, String path) throws facade = GameBoardFacade.getInstance(); Puzzle puzzle = facade.getPuzzleModule(); - // Write data + // Write data writer.append(fName).append(","); - if(puzzle.isPuzzleComplete()) writer.append("1,Solved\n"); - else writer.append("0,Unsolved\n"); + writer.append(puzzle.getName()).append(","); + if (puzzle.isPuzzleComplete()) + writer.append("1,Solved\n"); + else + writer.append("0,Unsolved\n"); } catch (InvalidFileFormatException e) { - writer.append(fName).append(" - invalid type,,Ungradeable\n"); + writer.append(fName).append(",Invalid,,Ungradeable\n"); } } else { LOGGER.debug("Failed to run sim"); @@ -591,10 +594,10 @@ private void checkProofAll() { folderBrowser.showOpenDialog(this); File folder = folderBrowser.getSelectedFile(); - // Write csv file (Path,File-Name,Score,Solved?) + // Write csv file (Path,File-Name,Puzzle-Type,Score,Solved?) File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { - writer.append("Name,File Name,Score,Solved?\n"); + writer.append("Name,File Name,Puzzle Type,Score,Solved?\n"); // Go through student folders for (final File folderEntry : Objects.requireNonNull(folder.listFiles(File::isDirectory))) { From 114c0c4600f99f005dcf6dcc798cb65df50d8dbf Mon Sep 17 00:00:00 2001 From: Chris Reed <55092742+cjreed121@users.noreply.github.com> Date: Sat, 18 Jun 2022 13:02:11 -0400 Subject: [PATCH 32/86] Add puzzle creator dialog --- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 95 +++++++++++++++++++ src/main/java/edu/rpi/legup/ui/HomePanel.java | 12 ++- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java new file mode 100644 index 000000000..2bbacc3af --- /dev/null +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -0,0 +1,95 @@ +package edu.rpi.legup.ui; + +import edu.rpi.legup.app.GameBoardFacade; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class CreatePuzzleDialog extends JDialog implements ActionListener { + private String[] games; + JComboBox gameBox; + JLabel gameLabel = new JLabel("Game:"); + JButton ok = new JButton("Ok"); + JButton cancel = new JButton("Cancel"); + JTextField width; + JTextField height; + private HomePanel homePanel; + + public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { + super(parent, true); + + this.homePanel = homePanel; + + initPuzzles(); + + Rectangle b = parent.getBounds(); + + setSize(350, 200); + setLocation((int) b.getCenterX() - getWidth() / 2, (int) b.getCenterY() - getHeight() / 2); + + Container c = getContentPane(); + c.setLayout(null); + + gameLabel.setBounds(10, 30, 70, 25); + gameBox.setBounds(80, 30, 190, 25); + + ok.setBounds(20, 130, 60, 25); + cancel.setBounds(170, 130, 90, 25); + + c.add(gameLabel); + c.add(gameBox); + + width = new JTextField(); + height = new JTextField(); + + JLabel widthLabel = new JLabel("Width:"); + JLabel heightLabel = new JLabel("Height:"); + + widthLabel.setBounds(30, 70, 60, 25); + heightLabel.setBounds(30, 95, 60, 25); + + width.setBounds(100, 70, 60, 25); + height.setBounds(100, 95, 60, 25); + + c.add(widthLabel); + c.add(heightLabel); + + c.add(width); + c.add(height); + + c.add(ok); + c.add(cancel); + + ok.addActionListener(this); + cancel.addActionListener(this); + } + + public void initPuzzles() { + Object[] o = GameBoardFacade.getInstance().getConfig().getPuzzleNames().toArray(); + + games = new String[o.length]; + + for (int x = 0; x < o.length; ++x) { + games[x] = (String) o[x]; + if (games[x].equals("ShortTruthTable")) { + games[x] = games[x] + " (Unsupported)"; + } + } + + gameBox = new JComboBox(games); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == ok) { + String game = (String) gameBox.getSelectedItem(); + this.homePanel.openEditorWithNewPuzzle(game); + setVisible(false); + } + else if (e.getSource() == cancel) { + setVisible(false); + } + } +} diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 9b5763c85..51ca01116 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -85,7 +85,7 @@ private void initButtons() { this.buttons[1].setIcon(resizeButtonIcon(button1Icon, this.buttonSize, this.buttonSize)); this.buttons[1].setHorizontalTextPosition(AbstractButton.CENTER); this.buttons[1].setVerticalTextPosition(AbstractButton.BOTTOM); - this.buttons[1].addActionListener(l -> this.legupUI.displayPanel(2)); + this.buttons[1].addActionListener(l -> this.openNewPuzzleDialog()); this.buttons[2] = new JButton("Edit Puzzle") { @@ -143,4 +143,14 @@ private void render() this.add(buttons); this.add(batchGraderButton); } + + private void openNewPuzzleDialog() { + CreatePuzzleDialog cpd = new CreatePuzzleDialog(this.frame, this); + cpd.setVisible(true); + } + + public void openEditorWithNewPuzzle(String game) { + // Set game type on the puzzle editor + this.legupUI.displayPanel(2); + } } From f29516e1bfd07e76d0b699ef435c759af9ed8749 Mon Sep 17 00:00:00 2001 From: RPIFisherman <91505581+RPIFisherman@users.noreply.github.com> Date: Mon, 20 Jun 2022 17:24:20 -0400 Subject: [PATCH 33/86] First scratch to fix The mouseWheelMoved in TreeController.java need further change. Write some new methods in ScrollView. --- .../rpi/legup/controller/TreeController.java | 11 ++++++++- .../java/edu/rpi/legup/ui/ScrollView.java | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index 462cbe142..24c767ba9 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -5,6 +5,7 @@ import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.treeview.*; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; @@ -149,6 +150,14 @@ public void mouseMoved(MouseEvent e) { */ @Override public void mouseWheelMoved(MouseWheelEvent e) { - super.mouseWheelMoved(e); + if (e.isControlDown()) { + if (e.getWheelRotation() != 0){ + super.viewer.scrollDown(-1); + } + } else { + if (e.getWheelRotation() != 0) { + super.viewer.scrollUp(-1); + } + } } } diff --git a/src/main/java/edu/rpi/legup/ui/ScrollView.java b/src/main/java/edu/rpi/legup/ui/ScrollView.java index 922b0ec9a..832d16526 100644 --- a/src/main/java/edu/rpi/legup/ui/ScrollView.java +++ b/src/main/java/edu/rpi/legup/ui/ScrollView.java @@ -305,4 +305,28 @@ protected void draw(Graphics2D graphics2D) { graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); canvas.paint(graphics2D); } + + /** + * Scroll up the ScrollView + * + * @param mag The magnitude for scroll up + * */ + public void scrollUp(int mag){ + System.out.println(viewport.getX()+' '+viewport.getY()); + viewport.setViewPosition(new Point(viewport.getX(), viewport.getY()+1)); + updateSize(); + revalidate(); + } + + /** + * Scroll down the ScrollView + * + * @param mag The magnitude for scroll up + * */ + public void scrollDown(int mag){ + System.out.println(viewport.getX()+' '+viewport.getY()); + viewport.setViewPosition(new Point(viewport.getX(), viewport.getY()-1)); + updateSize(); + revalidate(); + } } From a86005f584738a621d2ed1fb0b781e9575ae28b4 Mon Sep 17 00:00:00 2001 From: Hiimadd Date: Mon, 20 Jun 2022 22:12:00 -0400 Subject: [PATCH 34/86] Fix TouchingTents, Work on FillInRow Fixed TouchingTents not accounting for diagonal tents, and made significant progress on FillInRow (although some will need to be redone because I misunderstood the class of the clues) --- bin/legup-2022-06-07.log.gz | Bin 0 -> 7004 bytes bin/legup-2022-06-09.log.gz | Bin 0 -> 2561 bytes bin/legup-2022-06-10.log.gz | Bin 0 -> 4642 bytes bin/legup-2022-06-14.log.gz | Bin 0 -> 1737 bytes .../treetent/rules/FillinRowCaseRule.java | 92 +++++++++++++++++- .../rules/TouchingTentsContradictionRule.java | 3 +- 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 bin/legup-2022-06-07.log.gz create mode 100644 bin/legup-2022-06-09.log.gz create mode 100644 bin/legup-2022-06-10.log.gz create mode 100644 bin/legup-2022-06-14.log.gz diff --git a/bin/legup-2022-06-07.log.gz b/bin/legup-2022-06-07.log.gz new file mode 100644 index 0000000000000000000000000000000000000000..e140b16933ad85c88d372de517aa621ba4949e1a GIT binary patch literal 7004 zcmXw7cRU;J^S4@~wO18YdsV4XtAf_9Mr&3PZK>2wNsZX6s`j3dplB&RHEQo,&{ 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

XkBT#zF5AhZtp|h*rR{uUmg93KYTJ$-$P078D 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 literal 0 HcmV?d00001 diff --git a/bin/legup-2022-06-09.log.gz b/bin/legup-2022-06-09.log.gz new file mode 100644 index 0000000000000000000000000000000000000000..608b866a5173e77c6ebcc56020b3528caf2f3078 GIT binary patch literal 2561 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 Xu;XE`tHp}cUnK`{FA=h^k!@P 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 literal 0 HcmV?d00001 diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java index cac8aa31a..19a8b8116 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java @@ -5,8 +5,14 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.treetent.TreeTentBoard; +import edu.rpi.legup.puzzle.treetent.TreeTentCell; +import edu.rpi.legup.puzzle.treetent.TreeTentType; +import edu.rpi.legup.puzzle.treetent.TreeTentClue; import java.util.ArrayList; +import java.util.List; +import java.awt.*; public class FillinRowCaseRule extends CaseRule { @@ -18,7 +24,19 @@ public FillinRowCaseRule() { @Override public CaseBoard getCaseBoard(Board board) { - return null; + TreeTentBoard treeTentBoard = (TreeTentBoard) board.copy(); + treeTentBoard.setModifiable(false); + CaseBoard caseBoard = new CaseBoard(treeTentBoard, this); + ArrayList clues = treeTentBoard.getRowClues(); + clues.addAll(treeTentBoard.getColClues()); + for (PuzzleElement element : clues) { + // if ((((TreeTentCell) element).getType() == TreeTentType.CLUE_SOUTH && treeTentBoard.getRowCol(((TreeTentCell)element).getLocation().y, TreeTentType.UNKNOWN, true).size() != 0) || + // (((TreeTentCell) element).getType() == TreeTentType.CLUE_EAST && treeTentBoard.getRowCol(((TreeTentCell)element).getLocation().x, TreeTentType.UNKNOWN, false).size() != 0)) { + // caseBoard.addPickableElement(element); + // } + caseBoard.addPickableElement(element); + } + return caseBoard; } /** @@ -30,9 +48,81 @@ public CaseBoard getCaseBoard(Board board) { */ @Override public ArrayList getCases(Board board, PuzzleElement puzzleElement) { + ArrayList cases = new ArrayList(); + List group; + int treesLeft; + Point loc = ((TreeTentCell) puzzleElement).getLocation(); + TreeTentBoard tBoard = (TreeTentBoard)board; + if(((TreeTentCell) puzzleElement).getType() == TreeTentType.CLUE_SOUTH) { + group = tBoard.getRowCol(loc.y, TreeTentType.UNKNOWN, true); + treesLeft = tBoard.getRowClues().get(loc.y).getData() - tBoard.getRowCol(loc.y, TreeTentType.TREE, true).size(); + cases = genCombinations(tBoard, group, treesLeft, loc, true); + } else { + group = tBoard.getRowCol(loc.x, TreeTentType.UNKNOWN, false); + treesLeft = tBoard.getRowClues().get(loc.x).getData() - tBoard.getRowCol(loc.x, TreeTentType.TREE, false).size(); + cases = genCombinations(tBoard, group, treesLeft, loc, true); + } + + //generate every combination (nCr) + //call goodBoard for each generated combination + //alternitive would be to implement collision avoidance while generating instead of after + if(cases.size() > 0) {return cases;} return null; } + private ArrayList genCombinations(TreeTentBoard iBoard, List tiles, int target, Point loc, boolean isRow) + { + return genCombRecursive(iBoard, tiles, target, 0, new ArrayList(), loc, isRow); + } + + private ArrayList genCombRecursive(TreeTentBoard iBoard, List tiles, int target, int current, List selected, Point loc, boolean isRow) + { + ArrayList b = new ArrayList<>(); + if(target == current) + { + TreeTentBoard temp = iBoard.copy(); + for(TreeTentCell c : selected) + { + PuzzleElement change = temp.getPuzzleElement(c); + change.setData(TreeTentType.TENT.value); + temp.addModifiedData(change); + } + if(goodBoard(temp, loc, isRow)) {b.add(temp);} + return b; + } + for(int i = 0; i < tiles.size(); ++i) + { + List sub = tiles.subList(i, tiles.size()); + List next = new ArrayList(selected); + next.add(tiles.get(i)); + b.addAll(genCombRecursive(iBoard, sub, target, current+1, next, loc, isRow)); + } + return b; + } + + //Effectively runs TouchingTents check on all the added trees to make sure that the proposed board is valid. + //Could check more or less in the future depending on how "smart" this case rule should be. + private boolean goodBoard(TreeTentBoard board, Point loc, boolean isRow) + { + List trees; + if(isRow) + { + trees = board.getRowCol(loc.x, TreeTentType.TREE, true); + } + else + { + trees = board.getRowCol(loc.y, TreeTentType.TREE, false); + } + + for(TreeTentCell t : trees) + { + List adj = board.getAdjacent(t, TreeTentType.TREE); + List diag = board.getDiagonals(t, TreeTentType.TREE); + if(adj.size() > 0 || diag.size() > 0) {return false;} + } + return true; + } + /** * Checks whether the transition logically follows from the parent node using this rule * diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java index 23c3e4f43..69c37b314 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java @@ -31,7 +31,8 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { return super.getNoContradictionMessage(); } int adjTree = treeTentBoard.getAdjacent(cell, TreeTentType.TENT).size(); - if (adjTree > 0) { + int diagTree = treeTentBoard.getDiagonals(cell, TreeTentType.TENT).size(); + if (adjTree > 0 || diagTree > 0) { return null; } else { return super.getNoContradictionMessage(); From 37ec44383f053a3a274983ac3332f0ef36d5ab98 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 21 Jun 2022 14:15:14 -0400 Subject: [PATCH 35/86] Cosmetic changes --- src/main/java/edu/rpi/legup/app/Config.java | 1 + .../java/edu/rpi/legup/ui/CreatePuzzleDialog.java | 10 +++++----- src/main/resources/edu/rpi/legup/legup/config | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/Config.java b/src/main/java/edu/rpi/legup/app/Config.java index c5e51fb47..f8bcea20b 100644 --- a/src/main/java/edu/rpi/legup/app/Config.java +++ b/src/main/java/edu/rpi/legup/app/Config.java @@ -78,6 +78,7 @@ private void loadConfig(InputStream stream) throws InvalidConfigException { String name = puzzle.getAttribute("name"); String className = puzzle.getAttribute("qualifiedClassName"); Logger.debug("Class Name: "+className); + System.out.println("CLASS NAME: " + name); puzzles.put(name, className); } diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 2bbacc3af..877a6a4cb 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -10,7 +10,7 @@ public class CreatePuzzleDialog extends JDialog implements ActionListener { private String[] games; JComboBox gameBox; - JLabel gameLabel = new JLabel("Game:"); + JLabel puzzleLabel = new JLabel("Puzzle:"); JButton ok = new JButton("Ok"); JButton cancel = new JButton("Cancel"); JTextField width; @@ -32,20 +32,20 @@ public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { Container c = getContentPane(); c.setLayout(null); - gameLabel.setBounds(10, 30, 70, 25); + puzzleLabel.setBounds(10, 30, 70, 25); gameBox.setBounds(80, 30, 190, 25); ok.setBounds(20, 130, 60, 25); cancel.setBounds(170, 130, 90, 25); - c.add(gameLabel); + c.add(puzzleLabel); c.add(gameBox); width = new JTextField(); height = new JTextField(); - JLabel widthLabel = new JLabel("Width:"); - JLabel heightLabel = new JLabel("Height:"); + JLabel widthLabel = new JLabel("Rows:"); + JLabel heightLabel = new JLabel("Columns:"); widthLabel.setBounds(30, 70, 60, 25); heightLabel.setBounds(30, 95, 60, 25); diff --git a/src/main/resources/edu/rpi/legup/legup/config b/src/main/resources/edu/rpi/legup/legup/config index 3937fbc3b..2ffd6969c 100644 --- a/src/main/resources/edu/rpi/legup/legup/config +++ b/src/main/resources/edu/rpi/legup/legup/config @@ -1,14 +1,14 @@ - + - + - - + + - + - + \ No newline at end of file From 7928c27f1879856722c5afdbc22e31b98a4e09f7 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:30:55 -0400 Subject: [PATCH 36/86] more setup to make PlaceableElements be seen --- src/main/java/edu/rpi/legup/model/Puzzle.java | 19 ++++++++++++++++++- .../rpi/legup/model/elements/ElementType.java | 2 +- .../model/elements/NonPlaceableElement.java | 8 ++++++++ .../model/elements/PlaceableElement.java | 8 ++++++++ .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 14 +++++++------- .../elementsview/ElementFrame.java | 14 ++++++++++++++ .../elementsview/ElementPanel.java | 2 +- 7 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java create mode 100644 src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index 24fa967e1..ca6c5d214 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -1,5 +1,7 @@ package edu.rpi.legup.model; +import edu.rpi.legup.model.elements.NonPlaceableElement; +import edu.rpi.legup.model.elements.PlaceableElement; import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.ElementFactory; import edu.rpi.legup.model.observer.IBoardListener; @@ -11,6 +13,7 @@ import edu.rpi.legup.model.tree.TreeElement; import edu.rpi.legup.model.tree.TreeElementType; import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.ui.puzzleeditorui.elementsview.NonPlaceableElementPanel; import edu.rpi.legup.utility.LegupUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -53,6 +56,8 @@ public abstract class Puzzle implements IBoardSubject, ITreeSubject { protected List basicRules; protected List contradictionRules; protected List caseRules; + protected List placeableElements; + protected List nonPlaceableElements; /** * Puzzle Constructor - creates a new Puzzle @@ -256,6 +261,13 @@ public String getName() { public List getBasicRules() { return basicRules; } + public List getPlaceableElements() { + return placeableElements; + } + public List getNonPlaceableElements() { + return nonPlaceableElements; + } + /** * Sets the list of basic rules @@ -274,7 +286,12 @@ public void setBasicRules(List basicRules) { public void addBasicRule(BasicRule rule) { basicRules.add(rule); } - + public void addPlaceableElement(PlaceableElement element) { + placeableElements.add(element); + } + public void addNonPlaceableElement(NonPlaceableElement element) { + nonPlaceableElements.add(element); + } /** * Remove a basic rule from this Puzzle * diff --git a/src/main/java/edu/rpi/legup/model/elements/ElementType.java b/src/main/java/edu/rpi/legup/model/elements/ElementType.java index 85ec9be36..ea47ca0eb 100644 --- a/src/main/java/edu/rpi/legup/model/elements/ElementType.java +++ b/src/main/java/edu/rpi/legup/model/elements/ElementType.java @@ -1,5 +1,5 @@ package edu.rpi.legup.model.elements; public enum ElementType { - NURIKABE, TREETENT, LIGHTUP, SKYSCRAPERS + PLACEABLE, NONPLACEABLE } diff --git a/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java b/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java new file mode 100644 index 000000000..87859991f --- /dev/null +++ b/src/main/java/edu/rpi/legup/model/elements/NonPlaceableElement.java @@ -0,0 +1,8 @@ +package edu.rpi.legup.model.elements; + +public abstract class NonPlaceableElement extends Element { + public NonPlaceableElement(String elementID, String elementName, String description, String imageName) { + super(elementID, elementName, description, imageName); + this.elementType = ElementType.NONPLACEABLE; + } +} diff --git a/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java b/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java new file mode 100644 index 000000000..b22bdbf5e --- /dev/null +++ b/src/main/java/edu/rpi/legup/model/elements/PlaceableElement.java @@ -0,0 +1,8 @@ +package edu.rpi.legup.model.elements; + +public abstract class PlaceableElement extends Element{ + public PlaceableElement(String elementID, String elementName, String description, String imageName) { + super(elementID, elementName, description, imageName); + this.elementType = ElementType.PLACEABLE; + } +} diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 2c6b3eea1..d3f457ec4 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -35,7 +35,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private DynamicView dynamicBoardView; private BoardView boardView; private TitledBorder boardBorder; - private JSplitPane mainPanel; + private JSplitPane mainPanel, topHalfPanel; private FileDialog fileDialog; private JMenuItem undo, redo; private ElementFrame elementFrame; @@ -60,8 +60,10 @@ protected void setupContent() { dynamicBoardView.setBorder(titleBoard); JPanel boardPanel = new JPanel(new BorderLayout()); - mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, elementFrame, dynamicBoardView); - mainPanel.setPreferredSize(new Dimension(600, 100)); + + topHalfPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, elementFrame, dynamicBoardView); + mainPanel = new JSplitPane(); + mainPanel.setPreferredSize(new Dimension(600, 300)); boardPanel.add(mainPanel); boardBorder = BorderFactory.createTitledBorder("Board"); @@ -70,7 +72,7 @@ protected void setupContent() { elementBox.add(boardPanel); this.add(elementBox); - mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation() + 100); + mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation()+100); revalidate(); } @@ -111,6 +113,7 @@ public void setMenuBar() { for (JMenu menu : menus) { menuBar.add(menu); } + frame.setJMenuBar(menuBar); } @Override @@ -118,7 +121,6 @@ public void makeVisible() { setupToolBar(); setupContent(); setMenuBar(); - frame.setJMenuBar(menuBar); } private void setupToolBar() { @@ -164,10 +166,8 @@ private void setupToolBar() { toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].setEnabled(true); this.add(toolBar, BorderLayout.NORTH); } diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index 892f96918..e080225dd 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -2,6 +2,7 @@ import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.RuleController; +import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.ui.proofeditorui.rulesview.BasicRulePanel; import edu.rpi.legup.ui.proofeditorui.rulesview.CaseRulePanel; import edu.rpi.legup.ui.proofeditorui.rulesview.ContradictionRulePanel; @@ -17,6 +18,8 @@ public class ElementFrame extends JPanel { private static final String htmlHead = ""; private static final String htmlTail = ""; + private PlaceableElementPanel placeableElementPanel; + private NonPlaceableElementPanel nonPlaceableElementPanel; private JTabbedPane tabbedPane; private JLabel status; private ButtonGroup buttonGroup; @@ -30,6 +33,12 @@ public ElementFrame(EditorElementController controller) { this.status = new JLabel(); this.buttonGroup = new ButtonGroup(); + placeableElementPanel = new PlaceableElementPanel(this); + tabbedPane.addTab(placeableElementPanel.getName(), placeableElementPanel.getIcon(), new JScrollPane(placeableElementPanel), placeableElementPanel.getToolTip()); + + nonPlaceableElementPanel = new NonPlaceableElementPanel(this); + tabbedPane.addTab(nonPlaceableElementPanel.getName(), nonPlaceableElementPanel.getIcon(), new JScrollPane(nonPlaceableElementPanel), nonPlaceableElementPanel.getToolTip()); + setLayout(new BorderLayout()); setMinimumSize(new Dimension(250, 256)); setPreferredSize(new Dimension(330, 256)); @@ -51,6 +60,11 @@ public void resetSize() { this.setMinimumSize(new Dimension(2 * buttonWidth + 64, this.getHeight())); } + public void setElements(Puzzle puzzle) { + placeableElementPanel.setElements(puzzle.getPlaceableElements()); + nonPlaceableElementPanel.setElements(puzzle.getNonPlaceableElements()); + } + public EditorElementController getController() { return controller; } diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java index 4c2429031..4c2bebd54 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java @@ -22,7 +22,7 @@ public ElementPanel(ElementFrame eFrame) { this.elements = new ArrayList<>(); setLayout(new WrapLayout()); } - public void setRules(List elements) { + public void setElements(List elements) { this.elements = elements; clearButtons(); From 62b7492dfe4360dc034776752775bc07a30bf557 Mon Sep 17 00:00:00 2001 From: RPIFisherman <91505581+RPIFisherman@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:34:31 -0400 Subject: [PATCH 37/86] fix the scroll of tree view Edit the code in TreeController.java. Combined the scrollUp and scrollDown methods into one scroll in ScrollView --- .../rpi/legup/controller/TreeController.java | 10 +------- .../java/edu/rpi/legup/ui/ScrollView.java | 24 +++++++------------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/main/java/edu/rpi/legup/controller/TreeController.java b/src/main/java/edu/rpi/legup/controller/TreeController.java index 24c767ba9..d695466fc 100644 --- a/src/main/java/edu/rpi/legup/controller/TreeController.java +++ b/src/main/java/edu/rpi/legup/controller/TreeController.java @@ -150,14 +150,6 @@ public void mouseMoved(MouseEvent e) { */ @Override public void mouseWheelMoved(MouseWheelEvent e) { - if (e.isControlDown()) { - if (e.getWheelRotation() != 0){ - super.viewer.scrollDown(-1); - } - } else { - if (e.getWheelRotation() != 0) { - super.viewer.scrollUp(-1); - } - } + super.viewer.scroll(e.getWheelRotation()); } } diff --git a/src/main/java/edu/rpi/legup/ui/ScrollView.java b/src/main/java/edu/rpi/legup/ui/ScrollView.java index 832d16526..1e1af6430 100644 --- a/src/main/java/edu/rpi/legup/ui/ScrollView.java +++ b/src/main/java/edu/rpi/legup/ui/ScrollView.java @@ -307,25 +307,17 @@ protected void draw(Graphics2D graphics2D) { } /** - * Scroll up the ScrollView + * Scroll up or down on the ScrollView * * @param mag The magnitude for scroll up + * positive is scroll up, negative is scroll down, + * recommend to use getWheelRotation() as the mag * */ - public void scrollUp(int mag){ - System.out.println(viewport.getX()+' '+viewport.getY()); - viewport.setViewPosition(new Point(viewport.getX(), viewport.getY()+1)); - updateSize(); - revalidate(); - } - - /** - * Scroll down the ScrollView - * - * @param mag The magnitude for scroll up - * */ - public void scrollDown(int mag){ - System.out.println(viewport.getX()+' '+viewport.getY()); - viewport.setViewPosition(new Point(viewport.getX(), viewport.getY()-1)); + public void scroll(int mag){ + Point point = super.viewport.getViewPosition(); + // the point changing with th + point.y += mag*getZoom()/20; + viewport.setViewPosition(point); updateSize(); revalidate(); } From c259c2860c778726088ed96e3b1243c08f467e0a Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 21 Jun 2022 14:39:50 -0400 Subject: [PATCH 38/86] Added fileCreatonDisabled flag in config file You can now set in the config file whether or not you want the ability to create new files within Legup to be enabled or disabled (primarily to prevent users from accidentally trying to create files for puzzles that are a work in progress) --- src/main/java/edu/rpi/legup/app/Config.java | 19 +++++-- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 14 ++---- src/main/resources/edu/rpi/legup/legup/config | 49 +++++++++++++++---- 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/Config.java b/src/main/java/edu/rpi/legup/app/Config.java index f8bcea20b..b03b01cb9 100644 --- a/src/main/java/edu/rpi/legup/app/Config.java +++ b/src/main/java/edu/rpi/legup/app/Config.java @@ -19,6 +19,7 @@ public class Config { private final static Logger Logger = LogManager.getLogger(Config.class.getName()); private Map puzzles; + private Map fileCreationDisabledStatuses; private static final String CONFIG_LOCATION = "edu/rpi/legup/legup/config"; /** @@ -27,7 +28,8 @@ public class Config { * @throws InvalidConfigException */ public Config() throws InvalidConfigException { - puzzles = new Hashtable<>(); + this.puzzles = new Hashtable<>(); + this.fileCreationDisabledStatuses = new Hashtable<>(); loadConfig(this.getClass().getClassLoader().getResourceAsStream(CONFIG_LOCATION)); } @@ -40,6 +42,16 @@ public List getPuzzleNames() { return new ArrayList<>(puzzles.keySet()); } + public List getFileCreationEnabledPuzzles() + { + LinkedList puzzles = new LinkedList(); + for (String puzzle : this.puzzles.keySet()) + if (!this.fileCreationDisabledStatuses.get(puzzle)) + puzzles.add(puzzle); + return puzzles; + } + + /** * Gets a {@link edu.rpi.legup.model.Puzzle} class for a puzzle name * @@ -77,9 +89,10 @@ private void loadConfig(InputStream stream) throws InvalidConfigException { Element puzzle = (Element) puzzleNodes.item(i); String name = puzzle.getAttribute("name"); String className = puzzle.getAttribute("qualifiedClassName"); + boolean status = Boolean.parseBoolean(puzzle.getAttribute("fileCreationDisabled").toLowerCase()); Logger.debug("Class Name: "+className); - System.out.println("CLASS NAME: " + name); - puzzles.put(name, className); + this.puzzles.put(name, className); + this.fileCreationDisabledStatuses.put(name, Boolean.valueOf(status)); } } catch (ParserConfigurationException | SAXException | IOException e) { diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 877a6a4cb..b89689223 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -6,6 +6,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Arrays; public class CreatePuzzleDialog extends JDialog implements ActionListener { private String[] games; @@ -67,17 +68,8 @@ public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { } public void initPuzzles() { - Object[] o = GameBoardFacade.getInstance().getConfig().getPuzzleNames().toArray(); - - games = new String[o.length]; - - for (int x = 0; x < o.length; ++x) { - games[x] = (String) o[x]; - if (games[x].equals("ShortTruthTable")) { - games[x] = games[x] + " (Unsupported)"; - } - } - + this.games = GameBoardFacade.getInstance().getConfig().getFileCreationEnabledPuzzles().toArray(new String[0]); + Arrays.sort(this.games); gameBox = new JComboBox(games); } diff --git a/src/main/resources/edu/rpi/legup/legup/config b/src/main/resources/edu/rpi/legup/legup/config index 2ffd6969c..5e685d554 100644 --- a/src/main/resources/edu/rpi/legup/legup/config +++ b/src/main/resources/edu/rpi/legup/legup/config @@ -1,14 +1,43 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file From 29cca42fb3dae9d9da71e34634f1249de1558d93 Mon Sep 17 00:00:00 2001 From: RPIFisherman <91505581+RPIFisherman@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:39:59 -0400 Subject: [PATCH 39/86] merge dev and check locally Check the code and merge the origin/dev to the current branch. The code runs properly on local. --- src/main/java/edu/rpi/legup/ui/ScrollView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/ScrollView.java b/src/main/java/edu/rpi/legup/ui/ScrollView.java index 1e1af6430..807d95e06 100644 --- a/src/main/java/edu/rpi/legup/ui/ScrollView.java +++ b/src/main/java/edu/rpi/legup/ui/ScrollView.java @@ -315,7 +315,7 @@ protected void draw(Graphics2D graphics2D) { * */ public void scroll(int mag){ Point point = super.viewport.getViewPosition(); - // the point changing with th + // the point changing speed changes with the scale point.y += mag*getZoom()/20; viewport.setViewPosition(point); updateSize(); From 91a40490b7a591481b8260ca74dfdb087a2637fa Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:02:04 -0400 Subject: [PATCH 40/86] fixed toolbar size issue --- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index d3f457ec4..f5ae071df 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -3,13 +3,10 @@ import edu.rpi.legup.app.GameBoardFacade; import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; -import edu.rpi.legup.controller.ElementController; -import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -35,19 +32,20 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private DynamicView dynamicBoardView; private BoardView boardView; private TitledBorder boardBorder; - private JSplitPane mainPanel, topHalfPanel; + //private JSplitPane splitPanel, topHalfPanel; private FileDialog fileDialog; private JMenuItem undo, redo; private ElementFrame elementFrame; + private JPanel treePanel; final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame) { this.fileDialog = fileDialog; this.frame = frame; - setLayout(new GridLayout(2, 1)); + setLayout(new BorderLayout()); } protected void setupContent() { - + JSplitPane splitPanel; JPanel elementBox = new JPanel(new BorderLayout()); EditorElementController elementController = new EditorElementController(); @@ -60,19 +58,17 @@ protected void setupContent() { dynamicBoardView.setBorder(titleBoard); JPanel boardPanel = new JPanel(new BorderLayout()); + splitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, elementFrame, dynamicBoardView); + splitPanel.setPreferredSize(new Dimension(600, 400)); - topHalfPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, elementFrame, dynamicBoardView); - mainPanel = new JSplitPane(); - mainPanel.setPreferredSize(new Dimension(600, 300)); - - boardPanel.add(mainPanel); + boardPanel.add(splitPanel); boardBorder = BorderFactory.createTitledBorder("Board"); boardBorder.setTitleJustification(TitledBorder.CENTER); elementBox.add(boardPanel); this.add(elementBox); - mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation()+100); + splitPanel.setDividerLocation(splitPanel.getMaximumDividerLocation()+100); revalidate(); } From c29af43eff62b86bbe66c71f6049b0ca49058c63 Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:20:17 -0400 Subject: [PATCH 41/86] JavaDoc comments for some board class methods. Also added more methods for identifying other cells in `BattleShipBoard`. --- .../edu/rpi/legup/model/tree/TreeElement.java | 2 +- .../puzzle/battleship/BattleShipBoard.java | 89 ++++++++++++++++++- .../rules/AdjacentShipsContradictionRule.java | 32 +++++-- .../legup/puzzle/treetent/TreeTentBoard.java | 8 ++ 4 files changed, 120 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeElement.java b/src/main/java/edu/rpi/legup/model/tree/TreeElement.java index 420cc6204..17168ac98 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeElement.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeElement.java @@ -24,7 +24,7 @@ public TreeElement(TreeElementType type) { public abstract boolean isContradictoryBranch(); /** - * Recursively determines if the sub tree rooted at this tree puzzleElement is valid by checking + * Recursively determines if the sub-tree rooted at this tree puzzleElement is valid by checking * whether this tree puzzleElement and all descendants of this tree puzzleElement is justified * and justified correctly * diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java index 154f41fd1..4807ef330 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java @@ -2,17 +2,26 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; +import org.jetbrains.annotations.NotNull; +import java.awt.*; import java.util.ArrayList; import java.util.List; public class BattleShipBoard extends GridBoard { + /** + * The column of clues on the east side of the board. + */ private List east; + + /** + * The column of clues on the south side of the board. + */ private List south; /** - * BattleShipBoard Constructor creates a new battleship board from the specified width and height + * Constructor for creating a rectangular battleship board. * * @param width width of the board * @param height height of the board @@ -32,7 +41,7 @@ public BattleShipBoard(int width, int height) { } /** - * BattleShipBoard Constructor creates a new battleship board which is square from the specified size + * Constructor for creating a square-sized battleship board. * * @param size size of the board */ @@ -43,7 +52,8 @@ public BattleShipBoard(int size) { /** * Gets the east {@link BattleShipClue} * - * @return east battle ship clues + * @return List of BattleShipClue objects on the east + * side of the board */ public List getEast() { return east; @@ -65,7 +75,8 @@ public BattleShipCell getCell(int x, int y) { @Override public BattleShipBoard copy() { - BattleShipBoard copy = new BattleShipBoard(dimension.width, dimension.height); + BattleShipBoard copy = new BattleShipBoard(dimension.width, + dimension.height); for (int x = 0; x < this.dimension.width; x++) { for (int y = 0; y < this.dimension.height; y++) { copy.setCell(x, y, getCell(x, y).copy()); @@ -78,4 +89,74 @@ public BattleShipBoard copy() { copy.south = this.south; return copy; } + + /** + * Get a list of all orthogonally adjacent cells. + * + * @param cell The cell to get adjacent cells from. + * @return List of adjacent cells in clockwise order: + * { up, right, down, left } + */ + public List getAdjacent(@NotNull BattleShipCell cell) { + List adj = new ArrayList<>(); + Point loc = cell.getLocation(); + BattleShipCell up = getCell(loc.x, loc.y - 1); + BattleShipCell right = getCell(loc.x + 1, loc.y); + BattleShipCell down = getCell(loc.x, loc.y + 1); + BattleShipCell left = getCell(loc.x - 1, loc.y); + adj.add(up); + adj.add(right); + adj.add(down); + adj.add(left); + return adj; + } + + /** + * Get a list of all diagonally adjacent cells. + * + * @param cell The cell to get diagonally adjacent cells from. + * @return List of diagonally adjacent cells in clockwise order: + * { upRight, downRight, downLeft, upLeft } + */ + public List getAdjDiagonals(@NotNull BattleShipCell cell) { + List dia = new ArrayList<>(); + Point loc = cell.getLocation(); + BattleShipCell upRight = getCell(loc.x + 1, loc.y - 1); + BattleShipCell downRight = getCell(loc.x + 1, loc.y + 1); + BattleShipCell downLeft = getCell(loc.x - 1, loc.y + 1); + BattleShipCell upLeft = getCell(loc.x - 1, loc.y - 1); + dia.add(upRight); + dia.add(downRight); + dia.add(downLeft); + dia.add(upLeft); + return dia; + } + + /** + * Get a list of cells in a row. + * + * @param y The y-coordinate of the row. + * @return List of cells in the row in increasing x-coordinate order. + */ + public List getRow(int y) { + List row = new ArrayList<>(); + for (int x = 0; x < dimension.width; x++) { + row.add(getCell(x, y)); + } + return row; + } + + /** + * Get a list of cells in a column. + * + * @param x The x-coordinate of the column. + * @return List of cells in the column in increasing y-coordinate order. + */ + public List getColumn(int x) { + List column = new ArrayList<>(); + for (int y = 0; y < dimension.height; y++) { + column.add(getCell(x, y)); + } + return column; + } } \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java index c336a4daf..4f3fd700e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java @@ -3,26 +3,46 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; +import edu.rpi.legup.puzzle.battleship.BattleShipBoard; +import edu.rpi.legup.puzzle.battleship.BattleShipCell; +import edu.rpi.legup.puzzle.battleship.BattleShipType; + +import java.util.List; public class AdjacentShipsContradictionRule extends ContradictionRule { + private final String NO_CONTRADICTION_MESSAGE + = "No instance of the contradiction " + this.ruleName + " here"; + public AdjacentShipsContradictionRule() { super("BTSP-CONT-0001", "Adjacent Ships", - "", - "edu/rpi/legup/images/battleship/contradictions/AdjacentShips.png"); + "Cells next to the battleship must be water.", + "edu/rpi/legup/images/battleship/contradictions" + + "/AdjacentShips.png"); } /** - * Checks whether the transition has a contradiction at the specific puzzleElement index using this rule + * Checks whether the transition has a contradiction at the specific + * {@link PuzzleElement} index using this rule * * @param board board to check contradiction - * @param puzzleElement equivalent puzzleElement - * @return null if the transition contains a contradiction at the specified puzzleElement, - * otherwise error message + * @param puzzleElement equivalent {@link PuzzleElement} + * @return null if the transition contains a + * contradiction at the specified {@link PuzzleElement}, + * otherwise error message */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { + BattleShipBoard bsBoard = (BattleShipBoard) board; + BattleShipCell cell = (BattleShipCell) bsBoard.getPuzzleElement(puzzleElement); + + // check orthogonally adjacent cells + List orthoAdjCells + = bsBoard.getAdjacent(cell); + + BattleShipCell up = orthoAdjCells.get(0); + return null; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentBoard.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentBoard.java index 776f325b9..73bc9293b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentBoard.java @@ -101,6 +101,14 @@ public void notifyDeletion(PuzzleElement puzzleElement) { } } + /** + * Get a list of all orthogonally adjacent cells. + * + * @param cell The cell to get adjacent cells from. + * @param type The cell types to get. + * @return List of adjacent cells in the form { up, right, down, left }. + * If an adjacent cell is null, it will not be added to the list. + */ public List getAdjacent(TreeTentCell cell, TreeTentType type) { List adj = new ArrayList<>(); Point loc = cell.getLocation(); From 430db21f91ad910d13883c491af21e789b62aa2a Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 21 Jun 2022 15:23:40 -0400 Subject: [PATCH 42/86] Refactored Battleship classes --- README.md | 2 +- bin/main/edu/rpi/legup/legup/config | 2 +- .../{BattleShip.java => Battleship.java} | 20 +++++++------- ...tleShipBoard.java => BattleshipBoard.java} | 26 +++++++++---------- ...attleShipCell.java => BattleshipCell.java} | 10 +++---- ...ler.java => BattleshipCellController.java} | 16 ++++++------ ...actory.java => BattleshipCellFactory.java} | 10 +++---- ...attleShipClue.java => BattleshipClue.java} | 12 ++++----- ...pClueView.java => BattleshipClueView.java} | 12 ++++----- ...ntView.java => BattleshipElementView.java} | 8 +++--- ...pExporter.java => BattleshipExporter.java} | 16 ++++++------ ...pImporter.java => BattleshipImporter.java} | 22 ++++++++-------- ...attleShipType.java => BattleshipType.java} | 8 +++--- ...attleShipView.java => BattleshipView.java} | 10 +++---- src/main/resources/edu/rpi/legup/legup/config | 2 +- 15 files changed, 88 insertions(+), 88 deletions(-) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShip.java => Battleship.java} (91%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipBoard.java => BattleshipBoard.java} (71%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipCell.java => BattleshipCell.java} (75%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipCellController.java => BattleshipCellController.java} (60%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipCellFactory.java => BattleshipCellFactory.java} (90%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipClue.java => BattleshipClue.java} (79%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipClueView.java => BattleshipClueView.java} (80%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipElementView.java => BattleshipElementView.java} (93%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipExporter.java => BattleshipExporter.java} (79%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipImporter.java => BattleshipImporter.java} (89%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipType.java => BattleshipType.java} (79%) rename src/main/java/edu/rpi/legup/puzzle/battleship/{BattleShipView.java => BattleshipView.java} (71%) diff --git a/README.md b/README.md index 439c057ab..cb3711be1 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ An example for the Battleship puzzle demonstrates the proper format for XML file ``` - + diff --git a/bin/main/edu/rpi/legup/legup/config b/bin/main/edu/rpi/legup/legup/config index 3937fbc3b..9a40395f1 100644 --- a/bin/main/edu/rpi/legup/legup/config +++ b/bin/main/edu/rpi/legup/legup/config @@ -1,6 +1,6 @@ - + diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java b/src/main/java/edu/rpi/legup/puzzle/battleship/Battleship.java similarity index 91% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/Battleship.java index a59bfd548..7ddf25236 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/Battleship.java @@ -5,16 +5,16 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; -public class BattleShip extends Puzzle { - public BattleShip() { +public class Battleship extends Puzzle { + public Battleship() { super(); - this.name = "BattleShip"; + this.name = "Battleship"; - this.importer = new BattleShipImporter(this); - this.exporter = new BattleShipExporter(this); + this.importer = new BattleshipImporter(this); + this.exporter = new BattleshipExporter(this); - this.factory = new BattleShipCellFactory(); + this.factory = new BattleshipCellFactory(); } /** @@ -22,7 +22,7 @@ public BattleShip() { */ @Override public void initializeView() { - boardView = new BattleShipView((BattleShipBoard) currentBoard); + boardView = new BattleshipView((BattleshipBoard) currentBoard); addBoardListener(boardView); } @@ -39,7 +39,7 @@ public Board generatePuzzle(int difficulty) { */ @Override public boolean isBoardComplete(Board board) { - BattleShipBoard battleShipBoard = (BattleShipBoard) board; + BattleshipBoard battleShipBoard = (BattleshipBoard) board; for (ContradictionRule rule : contradictionRules) { if (rule.checkContradiction(battleShipBoard) == null) { @@ -47,8 +47,8 @@ public boolean isBoardComplete(Board board) { } } for (PuzzleElement data : battleShipBoard.getPuzzleElements()) { - BattleShipCell cell = (BattleShipCell) data; - if (cell.getType() == BattleShipType.UNKNOWN) { + BattleshipCell cell = (BattleshipCell) data; + if (cell.getType() == BattleshipType.UNKNOWN) { return false; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java similarity index 71% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java index 154f41fd1..d5ce402d6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java @@ -6,10 +6,10 @@ import java.util.ArrayList; import java.util.List; -public class BattleShipBoard extends GridBoard { +public class BattleshipBoard extends GridBoard { - private List east; - private List south; + private List east; + private List south; /** * BattleShipBoard Constructor creates a new battleship board from the specified width and height @@ -17,7 +17,7 @@ public class BattleShipBoard extends GridBoard { * @param width width of the board * @param height height of the board */ - public BattleShipBoard(int width, int height) { + public BattleshipBoard(int width, int height) { super(width, height); this.east = new ArrayList<>(); @@ -36,36 +36,36 @@ public BattleShipBoard(int width, int height) { * * @param size size of the board */ - public BattleShipBoard(int size) { + public BattleshipBoard(int size) { this(size, size); } /** - * Gets the east {@link BattleShipClue} + * Gets the east {@link BattleshipClue} * * @return east battle ship clues */ - public List getEast() { + public List getEast() { return east; } /** - * Gets the east {@link BattleShipClue} + * Gets the east {@link BattleshipClue} * * @return east battle ship clues */ - public List getSouth() { + public List getSouth() { return south; } @Override - public BattleShipCell getCell(int x, int y) { - return (BattleShipCell) super.getCell(x, y); + public BattleshipCell getCell(int x, int y) { + return (BattleshipCell) super.getCell(x, y); } @Override - public BattleShipBoard copy() { - BattleShipBoard copy = new BattleShipBoard(dimension.width, dimension.height); + public BattleshipBoard copy() { + BattleshipBoard copy = new BattleshipBoard(dimension.width, dimension.height); for (int x = 0; x < this.dimension.width; x++) { for (int y = 0; y < this.dimension.height; y++) { copy.setCell(x, y, getCell(x, y).copy()); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCell.java similarity index 75% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCell.java index db48adece..5f2c5b975 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCell.java @@ -4,7 +4,7 @@ import java.awt.*; -public class BattleShipCell extends GridCell { +public class BattleshipCell extends GridCell { /** * BattleShipCell Constructor - creates a BattleShipCell from the specified value and location @@ -12,7 +12,7 @@ public class BattleShipCell extends GridCell { * @param value value of the BattleShipCell * @param location position of the BattleShipCell */ - public BattleShipCell(BattleShipType value, Point location) { + public BattleshipCell(BattleshipType value, Point location) { super(value, location); } @@ -21,7 +21,7 @@ public BattleShipCell(BattleShipType value, Point location) { * * @return type of BattleShipCell */ - public BattleShipType getType() { + public BattleshipType getType() { return data; } @@ -30,8 +30,8 @@ public BattleShipType getType() { * * @return a new copy of the BattleShipCell that is independent of this one */ - public BattleShipCell copy() { - BattleShipCell copy = new BattleShipCell(data, (Point) location.clone()); + public BattleshipCell copy() { + BattleshipCell copy = new BattleshipCell(data, (Point) location.clone()); copy.setIndex(index); copy.setModifiable(isModifiable); copy.setGiven(isGiven); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java similarity index 60% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java index 2df1bc110..7623ec499 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellController.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java @@ -5,25 +5,25 @@ import java.awt.event.MouseEvent; -public class BattleShipCellController extends ElementController { +public class BattleshipCellController extends ElementController { @Override public void changeCell(MouseEvent e, PuzzleElement data) { - BattleShipCell cell = (BattleShipCell) data; + BattleshipCell cell = (BattleshipCell) data; if (e.getButton() == MouseEvent.BUTTON1) { if (e.isControlDown()) { this.boardView.getSelectionPopupMenu().show(boardView, this.boardView.getCanvas().getX() + e.getX(), this.boardView.getCanvas().getY() + e.getY()); } else { - if (cell.getData() == BattleShipType.SHIP_SEGMENT_MIDDLE) { - cell.setData(BattleShipType.UNKNOWN); + if (cell.getData() == BattleshipType.SHIP_SEGMENT_MIDDLE) { + cell.setData(BattleshipType.UNKNOWN); } else { - cell.setData(BattleShipType.getType(cell.getData().value + 1)); + cell.setData(BattleshipType.getType(cell.getData().value + 1)); } } } else if (e.getButton() == MouseEvent.BUTTON3) { - if (cell.getData() == BattleShipType.UNKNOWN) { - cell.setData(BattleShipType.SHIP_SEGMENT_MIDDLE); + if (cell.getData() == BattleshipType.UNKNOWN) { + cell.setData(BattleshipType.SHIP_SEGMENT_MIDDLE); } else { - cell.setData(BattleShipType.getType(cell.getData().value - 1)); + cell.setData(BattleshipType.getType(cell.getData().value - 1)); } } } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java similarity index 90% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java index 9f401580c..7caaad50b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java @@ -10,7 +10,7 @@ import java.awt.*; -public class BattleShipCellFactory extends ElementFactory { +public class BattleshipCellFactory extends ElementFactory { /** * Creates a puzzleElement based on the xml document Node and adds it to the board * @@ -20,9 +20,9 @@ public class BattleShipCellFactory extends ElementFactory { * @throws InvalidFileFormatException */ @Override - public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { + public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { try { - BattleShipBoard battleShipBoard = (BattleShipBoard) board; + BattleshipBoard battleShipBoard = (BattleshipBoard) board; int width = battleShipBoard.getWidth(); int height = battleShipBoard.getHeight(); NamedNodeMap attributeList = node.getAttributes(); @@ -38,7 +38,7 @@ public PuzzleElement importCell(Node node, Board board) throws I throw new InvalidFileFormatException("BattleShip Factory: cell unknown value"); } - BattleShipCell cell = new BattleShipCell(BattleShipType.getType(value), new Point(x, y)); + BattleshipCell cell = new BattleshipCell(BattleshipType.getType(value), new Point(x, y)); cell.setIndex(y * height + x); return cell; } else { @@ -61,7 +61,7 @@ public PuzzleElement importCell(Node node, Board board) throws I public org.w3c.dom.Element exportCell(Document document, PuzzleElement puzzleElement) { org.w3c.dom.Element cellElement = document.createElement("cell"); - BattleShipCell cell = (BattleShipCell) puzzleElement; + BattleshipCell cell = (BattleshipCell) puzzleElement; Point loc = cell.getLocation(); cellElement.setAttribute("value", String.valueOf(cell.getData())); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClue.java similarity index 79% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClue.java index 20fa2a7a2..31652e464 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClue.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClue.java @@ -2,11 +2,11 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; -public class BattleShipClue extends PuzzleElement { +public class BattleshipClue extends PuzzleElement { - private BattleShipType type; + private BattleshipType type; - public BattleShipClue(int value, int index, BattleShipType type) { + public BattleshipClue(int value, int index, BattleshipType type) { super(value); this.index = index; this.type = type; @@ -42,15 +42,15 @@ public Integer getData() { return (Integer) super.getData(); } - public BattleShipType getType() { + public BattleshipType getType() { return type; } - public void setType(BattleShipType type) { + public void setType(BattleshipType type) { this.type = type; } - public BattleShipClue copy() { + public BattleshipClue copy() { return null; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClueView.java similarity index 80% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClueView.java index 06e4901d7..f220ba4a2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipClueView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipClueView.java @@ -4,12 +4,12 @@ import java.awt.*; -public class BattleShipClueView extends ElementView { +public class BattleshipClueView extends ElementView { private static final Font FONT = new Font("TimesRoman", Font.BOLD, 16); private static final Color FONT_COLOR = Color.BLACK; - public BattleShipClueView(BattleShipClue clue) { + public BattleshipClueView(BattleshipClue clue) { super(clue); } @@ -19,8 +19,8 @@ public BattleShipClueView(BattleShipClue clue) { * @return PuzzleElement associated with this view */ @Override - public BattleShipClue getPuzzleElement() { - return (BattleShipClue) super.getPuzzleElement(); + public BattleshipClue getPuzzleElement() { + return (BattleshipClue) super.getPuzzleElement(); } @Override @@ -30,7 +30,7 @@ public void draw(Graphics2D graphics2D) { FontMetrics metrics = graphics2D.getFontMetrics(FONT); String value; - BattleShipClue clue = getPuzzleElement(); + BattleshipClue clue = getPuzzleElement(); switch (clue.getType()) { case CLUE_NORTH: value = String.valueOf(clue.getData() + 1); @@ -42,7 +42,7 @@ public void draw(Graphics2D graphics2D) { value = String.valueOf(clue.getData()); break; case CLUE_WEST: - value = BattleShipClue.colNumToString(clue.getData() + 1); + value = BattleshipClue.colNumToString(clue.getData() + 1); break; default: value = ""; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java similarity index 93% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java index 964bd3aba..6fda00797 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java @@ -4,7 +4,7 @@ import java.awt.*; -public class BattleShipElementView extends GridElementView { +public class BattleshipElementView extends GridElementView { private static final Stroke OUTLINE_STROKE = new BasicStroke(1); private static final Color OUTLINE_COLOR = new Color(0x212121); @@ -15,14 +15,14 @@ public class BattleShipElementView extends GridElementView { private static final Font FONT = new Font("TimesRoman", Font.BOLD, 10); private static final Color FONT_COLOR = new Color(0xFFEB3B); - public BattleShipElementView(BattleShipCell cell) { + public BattleshipElementView(BattleshipCell cell) { super(cell); } @Override public void drawElement(Graphics2D graphics2D) { - BattleShipCell cell = (BattleShipCell) puzzleElement; - BattleShipType type = cell.getType(); + BattleshipCell cell = (BattleshipCell) puzzleElement; + BattleshipType type = cell.getType(); switch (type) { case UNKNOWN: diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java similarity index 79% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java index 564b60eb3..e8aa00108 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java @@ -4,15 +4,15 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import org.w3c.dom.Document; -public class BattleShipExporter extends PuzzleExporter { +public class BattleshipExporter extends PuzzleExporter { - public BattleShipExporter(BattleShip battleShip) { + public BattleshipExporter(Battleship battleShip) { super(battleShip); } @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - BattleShipBoard board = (BattleShipBoard) puzzle.getTree().getRootNode().getBoard(); + BattleshipBoard board = (BattleshipBoard) puzzle.getTree().getRootNode().getBoard(); org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); @@ -20,8 +20,8 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { org.w3c.dom.Element cellsElement = newDocument.createElement("cells"); for (PuzzleElement puzzleElement : board.getPuzzleElements()) { - BattleShipCell cell = (BattleShipCell) puzzleElement; - if (cell.getData() != BattleShipType.getType(0)) { + BattleshipCell cell = (BattleshipCell) puzzleElement; + if (cell.getData() != BattleshipType.getType(0)) { org.w3c.dom.Element cellElement = puzzle.getFactory().exportCell(newDocument, puzzleElement); cellsElement.appendChild(cellElement); } @@ -30,17 +30,17 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { org.w3c.dom.Element axisEast = newDocument.createElement("axis"); axisEast.setAttribute("side", "east"); - for (BattleShipClue clue : board.getEast()) { + for (BattleshipClue clue : board.getEast()) { org.w3c.dom.Element clueElement = newDocument.createElement("clue"); clueElement.setAttribute("value", String.valueOf(clue.getData())); - clueElement.setAttribute("index", BattleShipClue.colNumToString(clue.getIndex())); + clueElement.setAttribute("index", BattleshipClue.colNumToString(clue.getIndex())); axisEast.appendChild(clueElement); } boardElement.appendChild(axisEast); org.w3c.dom.Element axisSouth = newDocument.createElement("axis"); axisSouth.setAttribute("side", "south"); - for (BattleShipClue clue : board.getEast()) { + for (BattleshipClue clue : board.getEast()) { org.w3c.dom.Element clueElement = newDocument.createElement("clue"); clueElement.setAttribute("value", String.valueOf(clue.getData())); clueElement.setAttribute("index", String.valueOf(clue.getIndex())); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java similarity index 89% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java index d588b8eb8..02035abf7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java @@ -8,8 +8,8 @@ import java.awt.*; -public class BattleShipImporter extends PuzzleImporter { - public BattleShipImporter(BattleShip battleShip) { +public class BattleshipImporter extends PuzzleImporter { + public BattleshipImporter(Battleship battleShip) { super(battleShip); } @@ -32,14 +32,14 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { Element dataElement = (Element) boardElement.getElementsByTagName("cells").item(0); NodeList elementDataList = dataElement.getElementsByTagName("cell"); - BattleShipBoard battleShipBoard = null; + BattleshipBoard battleShipBoard = null; if (!boardElement.getAttribute("size").isEmpty()) { int size = Integer.valueOf(boardElement.getAttribute("size")); - battleShipBoard = new BattleShipBoard(size); + battleShipBoard = new BattleshipBoard(size); } else if (!boardElement.getAttribute("width").isEmpty() && !boardElement.getAttribute("height").isEmpty()) { int width = Integer.valueOf(boardElement.getAttribute("width")); int height = Integer.valueOf(boardElement.getAttribute("height")); - battleShipBoard = new BattleShipBoard(width, height); + battleShipBoard = new BattleshipBoard(width, height); } if (battleShipBoard == null) { @@ -50,10 +50,10 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { int height = battleShipBoard.getHeight(); for (int i = 0; i < elementDataList.getLength(); i++) { - BattleShipCell cell = (BattleShipCell) puzzle.getFactory().importCell( + BattleshipCell cell = (BattleshipCell) puzzle.getFactory().importCell( elementDataList.item(i), battleShipBoard); Point loc = cell.getLocation(); - if (cell.getData() != BattleShipType.getType(0)) { + if (cell.getData() != BattleshipType.getType(0)) { cell.setModifiable(false); cell.setGiven(true); } @@ -63,7 +63,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (battleShipBoard.getCell(x, y) == null) { - BattleShipCell cell = new BattleShipCell(BattleShipType.UNKNOWN, new Point(x, y)); + BattleshipCell cell = new BattleshipCell(BattleshipType.UNKNOWN, new Point(x, y)); cell.setIndex(y * height + x); cell.setModifiable(true); battleShipBoard.setCell(x, y, cell); @@ -98,7 +98,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { for (int i = 0; i < eastClues.getLength(); i++) { Element clue = (Element) eastClues.item(i); int value = Integer.valueOf(clue.getAttribute("value")); - int index = BattleShipClue.colStringToColNum(clue.getAttribute("index")); + int index = BattleshipClue.colStringToColNum(clue.getAttribute("index")); if (index - 1 < 0 || index - 1 > battleShipBoard.getHeight()) { throw new InvalidFileFormatException("BattleShip Importer: clue index out of bounds"); @@ -107,7 +107,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { if (battleShipBoard.getEast().get(index - 1) != null) { throw new InvalidFileFormatException("BattleShip Importer: duplicate clue index"); } - battleShipBoard.getEast().set(index - 1, new BattleShipClue(value, index, BattleShipType.CLUE_EAST)); + battleShipBoard.getEast().set(index - 1, new BattleshipClue(value, index, BattleshipType.CLUE_EAST)); } for (int i = 0; i < southClues.getLength(); i++) { @@ -122,7 +122,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { if (battleShipBoard.getSouth().get(index - 1) != null) { throw new InvalidFileFormatException("BattleShip Importer: duplicate clue index"); } - battleShipBoard.getSouth().set(index - 1, new BattleShipClue(value, index, BattleShipType.CLUE_SOUTH)); + battleShipBoard.getSouth().set(index - 1, new BattleshipClue(value, index, BattleshipType.CLUE_SOUTH)); } puzzle.setCurrentBoard(battleShipBoard); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java similarity index 79% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java index a8ed1dcb4..720363625 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipType.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java @@ -1,13 +1,13 @@ package edu.rpi.legup.puzzle.battleship; -public enum BattleShipType { +public enum BattleshipType { UNKNOWN, WATER, SHIP_SEGMENT_UNKNOWN, SHIP_SIZE_1, SHIP_SEGMENT_TOP, SHIP_SEGMENT_RIGHT, SHIP_SEGMENT_BOTTOM, SHIP_SEGMENT_LEFT, SHIP_SEGMENT_MIDDLE, CLUE_NORTH, CLUE_EAST, CLUE_SOUTH, CLUE_WEST; public int value; - BattleShipType() { + BattleshipType() { this.value = this.ordinal(); } @@ -16,8 +16,8 @@ public enum BattleShipType { * * @return enum equivalent BattleShipType of integer value */ - public static BattleShipType getType(int value) { - BattleShipType[] vals = values(); + public static BattleshipType getType(int value) { + BattleshipType[] vals = values(); if (value >= 0 && value < vals.length) { return vals[value]; } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipView.java similarity index 71% rename from src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java rename to src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipView.java index 7c4353888..0768d4f66 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipView.java @@ -6,14 +6,14 @@ import java.awt.*; -public class BattleShipView extends GridBoardView { - public BattleShipView(BattleShipBoard board) { - super(new BoardController(), new BattleShipCellController(), board.getDimension()); +public class BattleshipView extends GridBoardView { + public BattleshipView(BattleshipBoard board) { + super(new BoardController(), new BattleshipCellController(), board.getDimension()); for (PuzzleElement puzzleElement : board.getPuzzleElements()) { - BattleShipCell cell = (BattleShipCell) puzzleElement; + BattleshipCell cell = (BattleshipCell) puzzleElement; Point loc = cell.getLocation(); - BattleShipElementView elementView = new BattleShipElementView(cell); + BattleshipElementView elementView = new BattleshipElementView(cell); elementView.setIndex(cell.getIndex()); elementView.setSize(elementSize); elementView.setLocation(new Point(loc.x * elementSize.width, loc.y * elementSize.height)); diff --git a/src/main/resources/edu/rpi/legup/legup/config b/src/main/resources/edu/rpi/legup/legup/config index 3937fbc3b..9a40395f1 100644 --- a/src/main/resources/edu/rpi/legup/legup/config +++ b/src/main/resources/edu/rpi/legup/legup/config @@ -1,6 +1,6 @@ - + From 40b35bf669cc443af47783234cc26d9d28bf3b5a Mon Sep 17 00:00:00 2001 From: Chris Reed <55092742+cjreed121@users.noreply.github.com> Date: Wed, 22 Jun 2022 22:29:53 -0400 Subject: [PATCH 43/86] Fix resize bug --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index df81fc60b..ed994fc72 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -128,6 +128,7 @@ public void keyTyped(KeyEvent e) { private void initPanels() { window = new JPanel(); + window.setLayout(new BorderLayout()); add(window); panels = new LegupPanel[3]; From 960f872098c88c575fa058b42a45100df65cd73f Mon Sep 17 00:00:00 2001 From: Weijun Li <83390795+wei-jun7@users.noreply.github.com> Date: Thu, 23 Jun 2022 12:59:15 -0400 Subject: [PATCH 44/86] Update LegupUI.java --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 1afbd0c86..335feaeda 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -695,13 +695,30 @@ public void promptPuzzle() { } } - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setTitle("Select Puzzle"); - fileDialog.setVisible(true); +// fileDialog.setMode(FileDialog.LOAD); +// fileDialog.setTitle("Select Puzzle"); +// fileDialog.setVisible(true); +// String fileName = null; +// File puzzleFile = null; +// if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { +// fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); +// puzzleFile = new File(fileName); +// } + folderBrowser = new JFileChooser(); + folderBrowser.setCurrentDirectory(new java.io.File(".")); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + folderBrowser.setAcceptAllFileFilterUsed(true); + folderBrowser.showOpenDialog(this); + folderBrowser.setVisible(true); + File puzzleFile = folderBrowser.getSelectedFile(); + String fileName = null; - File puzzleFile = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + + + if (folderBrowser.getCurrentDirectory().getName() != null && folderBrowser.getSelectedFile().getName() != null) { + fileName = puzzleFile.getAbsolutePath() + File.separator; + puzzleFile = new File(fileName); } From 216c60d1bb143e7b3d4f4cbc43cce0d600232b93 Mon Sep 17 00:00:00 2001 From: Corppet Date: Thu, 23 Jun 2022 21:09:43 -0400 Subject: [PATCH 45/86] Removed JetBrains annotations. --- .../edu/rpi/legup/puzzle/battleship/BattleShipBoard.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java index 4807ef330..e05a569a9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java @@ -2,7 +2,6 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.ArrayList; @@ -97,7 +96,7 @@ public BattleShipBoard copy() { * @return List of adjacent cells in clockwise order: * { up, right, down, left } */ - public List getAdjacent(@NotNull BattleShipCell cell) { + public List getAdjacent(BattleShipCell cell) { List adj = new ArrayList<>(); Point loc = cell.getLocation(); BattleShipCell up = getCell(loc.x, loc.y - 1); @@ -118,7 +117,7 @@ public List getAdjacent(@NotNull BattleShipCell cell) { * @return List of diagonally adjacent cells in clockwise order: * { upRight, downRight, downLeft, upLeft } */ - public List getAdjDiagonals(@NotNull BattleShipCell cell) { + public List getAdjDiagonals(BattleShipCell cell) { List dia = new ArrayList<>(); Point loc = cell.getLocation(); BattleShipCell upRight = getCell(loc.x + 1, loc.y - 1); From c8fea1a8b367ee86304add85b18ae0f918b9fad2 Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Thu, 23 Jun 2022 23:39:46 -0400 Subject: [PATCH 46/86] Revert "Removed JetBrains annotations." This reverts commit 216c60d1bb143e7b3d4f4cbc43cce0d600232b93. --- .../edu/rpi/legup/puzzle/battleship/BattleShipBoard.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java index e05a569a9..4807ef330 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipBoard.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.ArrayList; @@ -96,7 +97,7 @@ public BattleShipBoard copy() { * @return List of adjacent cells in clockwise order: * { up, right, down, left } */ - public List getAdjacent(BattleShipCell cell) { + public List getAdjacent(@NotNull BattleShipCell cell) { List adj = new ArrayList<>(); Point loc = cell.getLocation(); BattleShipCell up = getCell(loc.x, loc.y - 1); @@ -117,7 +118,7 @@ public List getAdjacent(BattleShipCell cell) { * @return List of diagonally adjacent cells in clockwise order: * { upRight, downRight, downLeft, upLeft } */ - public List getAdjDiagonals(BattleShipCell cell) { + public List getAdjDiagonals(@NotNull BattleShipCell cell) { List dia = new ArrayList<>(); Point loc = cell.getLocation(); BattleShipCell upRight = getCell(loc.x + 1, loc.y - 1); From eef234f7459e5c7d85939fe9a3933c2d434dd748 Mon Sep 17 00:00:00 2001 From: Corppet Date: Thu, 23 Jun 2022 23:45:58 -0400 Subject: [PATCH 47/86] Removed JetBrains annotations. --- .../puzzle/battleship/BattleshipBoard.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java index 637cbd926..abe63e22b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java @@ -2,7 +2,6 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; -import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.ArrayList; @@ -89,13 +88,13 @@ public BattleshipBoard copy() { * @return List of adjacent cells in clockwise order: * { up, right, down, left } */ - public List getAdjacent(@NotNull BattleShipCell cell) { - List adj = new ArrayList<>(); + public List getAdjacent(BattleshipCell cell) { + List adj = new ArrayList<>(); Point loc = cell.getLocation(); - BattleShipCell up = getCell(loc.x, loc.y - 1); - BattleShipCell right = getCell(loc.x + 1, loc.y); - BattleShipCell down = getCell(loc.x, loc.y + 1); - BattleShipCell left = getCell(loc.x - 1, loc.y); + BattleshipCell up = getCell(loc.x, loc.y - 1); + BattleshipCell right = getCell(loc.x + 1, loc.y); + BattleshipCell down = getCell(loc.x, loc.y + 1); + BattleshipCell left = getCell(loc.x - 1, loc.y); adj.add(up); adj.add(right); adj.add(down); @@ -110,13 +109,13 @@ public List getAdjacent(@NotNull BattleShipCell cell) { * @return List of diagonally adjacent cells in clockwise order: * { upRight, downRight, downLeft, upLeft } */ - public List getAdjDiagonals(@NotNull BattleShipCell cell) { - List dia = new ArrayList<>(); + public List getAdjDiagonals(BattleshipCell cell) { + List dia = new ArrayList<>(); Point loc = cell.getLocation(); - BattleShipCell upRight = getCell(loc.x + 1, loc.y - 1); - BattleShipCell downRight = getCell(loc.x + 1, loc.y + 1); - BattleShipCell downLeft = getCell(loc.x - 1, loc.y + 1); - BattleShipCell upLeft = getCell(loc.x - 1, loc.y - 1); + BattleshipCell upRight = getCell(loc.x + 1, loc.y - 1); + BattleshipCell downRight = getCell(loc.x + 1, loc.y + 1); + BattleshipCell downLeft = getCell(loc.x - 1, loc.y + 1); + BattleshipCell upLeft = getCell(loc.x - 1, loc.y - 1); dia.add(upRight); dia.add(downRight); dia.add(downLeft); @@ -130,8 +129,8 @@ public List getAdjDiagonals(@NotNull BattleShipCell cell) { * @param y The y-coordinate of the row. * @return List of cells in the row in increasing x-coordinate order. */ - public List getRow(int y) { - List row = new ArrayList<>(); + public List getRow(int y) { + List row = new ArrayList<>(); for (int x = 0; x < dimension.width; x++) { row.add(getCell(x, y)); } @@ -144,8 +143,8 @@ public List getRow(int y) { * @param x The x-coordinate of the column. * @return List of cells in the column in increasing y-coordinate order. */ - public List getColumn(int x) { - List column = new ArrayList<>(); + public List getColumn(int x) { + List column = new ArrayList<>(); for (int y = 0; y < dimension.height; y++) { column.add(getCell(x, y)); } From 55f9eb10d455afe65ffce8658f66a784c6974b05 Mon Sep 17 00:00:00 2001 From: Corppet Date: Thu, 23 Jun 2022 23:52:46 -0400 Subject: [PATCH 48/86] Other refactoring fixes. --- .../rules/AdjacentShipsContradictionRule.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java index 4f3fd700e..92d7df933 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java @@ -3,9 +3,9 @@ import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.ContradictionRule; -import edu.rpi.legup.puzzle.battleship.BattleShipBoard; -import edu.rpi.legup.puzzle.battleship.BattleShipCell; -import edu.rpi.legup.puzzle.battleship.BattleShipType; +import edu.rpi.legup.puzzle.battleship.BattleshipBoard; +import edu.rpi.legup.puzzle.battleship.BattleshipCell; +import edu.rpi.legup.puzzle.battleship.BattleshipType; import java.util.List; @@ -34,14 +34,14 @@ public AdjacentShipsContradictionRule() { */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { - BattleShipBoard bsBoard = (BattleShipBoard) board; - BattleShipCell cell = (BattleShipCell) bsBoard.getPuzzleElement(puzzleElement); + BattleshipBoard bsBoard = (BattleshipBoard) board; + BattleshipCell cell = (BattleshipCell) bsBoard.getPuzzleElement(puzzleElement); // check orthogonally adjacent cells - List orthoAdjCells + List orthoAdjCells = bsBoard.getAdjacent(cell); - BattleShipCell up = orthoAdjCells.get(0); + BattleshipCell up = orthoAdjCells.get(0); return null; } From b0ac2484a17eb7c0464bb68c1c66b43465a3e9e0 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 24 Jun 2022 13:47:13 -0400 Subject: [PATCH 49/86] Added stuff to handle input from home screen --- src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 ++- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 ++ src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 7 ++++--- .../legup/ui/puzzleeditorui/elementsview/ElementFrame.java | 7 +------ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 877a6a4cb..0614a5680 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -85,7 +85,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game); + this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); setVisible(false); } else if (e.getSource() == cancel) { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 51ca01116..a4341f762 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -149,8 +149,9 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game) { + public void openEditorWithNewPuzzle(String game, int width, int height) { // Set game type on the puzzle editor this.legupUI.displayPanel(2); + this.legupUI.getPuzzleEditor().promptPuzzle(game, width, height); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index df81fc60b..e2264af54 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -153,6 +153,8 @@ public ProofEditorPanel getProofEditor() { return (ProofEditorPanel) panels[1]; } + public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } + public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 2c6b3eea1..968d8bbeb 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -4,12 +4,10 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.ElementController; -import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -171,7 +169,10 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } - +// public void loadPuzzleFromHome(String game, int width, int height) { +// GameBoardFacade facade = GameBoardFacade.getInstance(); +// facade.loadPuzzle(); +// } public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index 892f96918..b8eaf5297 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -1,11 +1,6 @@ package edu.rpi.legup.ui.puzzleeditorui.elementsview; import edu.rpi.legup.controller.EditorElementController; -import edu.rpi.legup.controller.RuleController; -import edu.rpi.legup.ui.proofeditorui.rulesview.BasicRulePanel; -import edu.rpi.legup.ui.proofeditorui.rulesview.CaseRulePanel; -import edu.rpi.legup.ui.proofeditorui.rulesview.ContradictionRulePanel; -import edu.rpi.legup.ui.proofeditorui.rulesview.RulePanel; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -37,7 +32,7 @@ public ElementFrame(EditorElementController controller) { add(tabbedPane); add(status, BorderLayout.SOUTH); - TitledBorder title = BorderFactory.createTitledBorder("Rules"); + TitledBorder title = BorderFactory.createTitledBorder("Elements"); title.setTitleJustification(TitledBorder.CENTER); setBorder(title); } From a46638689911a41210a99d3cef0f7613b6ab1cc8 Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Fri, 24 Jun 2022 14:08:07 -0400 Subject: [PATCH 50/86] Revert "Added stuff to handle input from home screen" This reverts commit b0ac2484a17eb7c0464bb68c1c66b43465a3e9e0. --- src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 +-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 -- src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 7 +++---- .../legup/ui/puzzleeditorui/elementsview/ElementFrame.java | 7 ++++++- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 0614a5680..877a6a4cb 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -85,7 +85,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); + this.homePanel.openEditorWithNewPuzzle(game); setVisible(false); } else if (e.getSource() == cancel) { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index a4341f762..51ca01116 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -149,9 +149,8 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game, int width, int height) { + public void openEditorWithNewPuzzle(String game) { // Set game type on the puzzle editor this.legupUI.displayPanel(2); - this.legupUI.getPuzzleEditor().promptPuzzle(game, width, height); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index e2264af54..df81fc60b 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -153,8 +153,6 @@ public ProofEditorPanel getProofEditor() { return (ProofEditorPanel) panels[1]; } - public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } - public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 968d8bbeb..2c6b3eea1 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -4,10 +4,12 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.ElementController; +import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -169,10 +171,7 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } -// public void loadPuzzleFromHome(String game, int width, int height) { -// GameBoardFacade facade = GameBoardFacade.getInstance(); -// facade.loadPuzzle(); -// } + public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index b8eaf5297..892f96918 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -1,6 +1,11 @@ package edu.rpi.legup.ui.puzzleeditorui.elementsview; import edu.rpi.legup.controller.EditorElementController; +import edu.rpi.legup.controller.RuleController; +import edu.rpi.legup.ui.proofeditorui.rulesview.BasicRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.CaseRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.ContradictionRulePanel; +import edu.rpi.legup.ui.proofeditorui.rulesview.RulePanel; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -32,7 +37,7 @@ public ElementFrame(EditorElementController controller) { add(tabbedPane); add(status, BorderLayout.SOUTH); - TitledBorder title = BorderFactory.createTitledBorder("Elements"); + TitledBorder title = BorderFactory.createTitledBorder("Rules"); title.setTitleJustification(TitledBorder.CENTER); setBorder(title); } From 1dd1603aeba20133ecc63aef76cfc989957d6192 Mon Sep 17 00:00:00 2001 From: HenryCullom <54919530+HenryCullom@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:26:11 -0400 Subject: [PATCH 51/86] more formatting of code --- .../edu/rpi/legup/app/GameBoardFacade.java | 5 ++++ src/main/java/edu/rpi/legup/ui/LegupUI.java | 3 +++ .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 23 +++++++++++++++++++ .../elementsview/ElementFrame.java | 5 +++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 25c6ae4f0..cb665f2f3 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -7,6 +7,7 @@ import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; import edu.rpi.legup.ui.ProofEditorPanel; +import edu.rpi.legup.ui.PuzzleEditorPanel; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -45,6 +46,8 @@ public class GameBoardFacade implements IHistorySubject { private ProofEditorPanel puzzleSolver; + private PuzzleEditorPanel puzzleEditor; + private String curFileName; private History history; @@ -77,6 +80,7 @@ public void initializeUI() { EventQueue.invokeLater(() ->{ legupUI = new LegupUI(); puzzleSolver = legupUI.getProofEditor(); + puzzleEditor = legupUI.getPuzzleEditor(); addHistoryListener(legupUI.getProofEditor()); }); } @@ -84,6 +88,7 @@ public void initializeUI() { public void setPuzzle(Puzzle puzzle) { this.puzzle = puzzle; this.puzzleSolver.setPuzzleView(puzzle); + this.puzzleEditor.setPuzzleView((puzzle)); this.history.clear(); } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index ed994fc72..6c873bd90 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -153,6 +153,9 @@ protected void displayPanel(int option) { public ProofEditorPanel getProofEditor() { return (ProofEditorPanel) panels[1]; } + public PuzzleEditorPanel getPuzzleEditor() { + return (PuzzleEditorPanel) panels[2]; + } public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index f5ae071df..f2610a982 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -5,6 +5,7 @@ import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; +import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; @@ -27,6 +28,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private JToolBar toolBar; private JFrame frame; private JButton[] buttons; + JSplitPane splitPanel; private JButton[] toolBarButtons; private JPanel elementPanel; private DynamicView dynamicBoardView; @@ -232,4 +234,25 @@ public void setToolBarButtons(JButton[] toolBarButtons) { private void repaintAll() { boardView.repaint(); } + + public void setPuzzleView(Puzzle puzzle) { + this.boardView = puzzle.getBoardView(); + + dynamicBoardView = new DynamicView(boardView); + this.splitPanel.setRightComponent(dynamicBoardView); + this.splitPanel.setVisible(true); + + TitledBorder titleBoard = BorderFactory.createTitledBorder(boardView.getClass().getSimpleName()); + titleBoard.setTitleJustification(TitledBorder.CENTER); + dynamicBoardView.setBorder(titleBoard); + + puzzle.addBoardListener(puzzle.getBoardView()); + + elementFrame.getNonPlaceableElementPanel().setElements(puzzle.getNonPlaceableElements()); + elementFrame.getPlaceableElementPanel().setElements(puzzle.getPlaceableElements()); + + toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true); + toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); + } + } diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index e080225dd..9fd3dfa6b 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -46,7 +46,7 @@ public ElementFrame(EditorElementController controller) { add(tabbedPane); add(status, BorderLayout.SOUTH); - TitledBorder title = BorderFactory.createTitledBorder("Rules"); + TitledBorder title = BorderFactory.createTitledBorder("Elements"); title.setTitleJustification(TitledBorder.CENTER); setBorder(title); } @@ -72,4 +72,7 @@ public EditorElementController getController() { public JTabbedPane getTabbedPane() { return tabbedPane; } + + public NonPlaceableElementPanel getNonPlaceableElementPanel() { return nonPlaceableElementPanel; } + public PlaceableElementPanel getPlaceableElementPanel() { return placeableElementPanel; } } From b1532fb9bf0ba31e4bcb260e9b1eb295966ef17a Mon Sep 17 00:00:00 2001 From: Weijun Li <83390795+wei-jun7@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:38:54 -0400 Subject: [PATCH 52/86] Update LegupUI.java issue 167 faster than before --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 1afbd0c86..c678a1869 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -540,11 +540,14 @@ private void checkProofAll() { GameBoardFacade facade = GameBoardFacade.getInstance(); folderBrowser = new JFileChooser(); + + folderBrowser.showOpenDialog(this); + folderBrowser.setVisible(true); folderBrowser.setCurrentDirectory(new java.io.File(".")); folderBrowser.setDialogTitle("Select Directory"); folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folderBrowser.setAcceptAllFileFilterUsed(false); - folderBrowser.showOpenDialog(this); + File folder = folderBrowser.getSelectedFile(); //FileWriter csvWriter = new FileWriter("new.csv"); @@ -695,13 +698,19 @@ public void promptPuzzle() { } } - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setTitle("Select Puzzle"); - fileDialog.setVisible(true); + folderBrowser = new JFileChooser(); + + folderBrowser.showOpenDialog(this); + folderBrowser.setVisible(true); + folderBrowser.setCurrentDirectory(new java.io.File(".")); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.FILES_ONLY); + folderBrowser.setAcceptAllFileFilterUsed(true); + String fileName = null; - File puzzleFile = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + File puzzleFile = folderBrowser.getSelectedFile(); + if (folderBrowser.getCurrentDirectory() != null && folderBrowser.getSelectedFile().getName() != null) { + fileName = puzzleFile.getAbsolutePath()+ File.separator; puzzleFile = new File(fileName); } From 1c3edac172a40090ccd97e73b08605cbb5db7237 Mon Sep 17 00:00:00 2001 From: TURBOCRINGE Date: Fri, 24 Jun 2022 14:51:13 -0400 Subject: [PATCH 53/86] Updated code to add support for elements --- src/main/java/edu/rpi/legup/model/Puzzle.java | 3 +++ .../rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java | 2 +- .../puzzleeditorui/elementsview/NonPlaceableElementPanel.java | 2 +- .../ui/puzzleeditorui/elementsview/PlaceableElementPanel.java | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index ca6c5d214..ef683375d 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -70,6 +70,9 @@ public Puzzle() { this.contradictionRules = new ArrayList<>(); this.caseRules = new ArrayList<>(); + this.placeableElements = new ArrayList<>(); + this.nonPlaceableElements = new ArrayList<>(); + registerRules(); } diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java index c1f71d08e..ebb0e9ca4 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java @@ -25,7 +25,7 @@ public ElementFrame(EditorElementController controller) { this.controller = controller; this.tabbedPane = new JTabbedPane(); - this.status = new JLabel(); + this.status = new JLabel("", SwingConstants.CENTER); this.buttonGroup = new ButtonGroup(); placeableElementPanel = new PlaceableElementPanel(this); diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java index 5c3328e73..6704d1aa2 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/NonPlaceableElementPanel.java @@ -3,7 +3,7 @@ import javax.swing.*; public class NonPlaceableElementPanel extends ElementPanel{ - NonPlaceableElementPanel(ElementFrame elementFrame) { + public NonPlaceableElementPanel(ElementFrame elementFrame) { super(elementFrame); this.icon = new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Basic Rules.gif")); this.name = "Non-Placeable Elements"; diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java index 19ede5510..2021d43cc 100644 --- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java +++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/PlaceableElementPanel.java @@ -3,7 +3,7 @@ import javax.swing.*; public class PlaceableElementPanel extends ElementPanel{ - PlaceableElementPanel(ElementFrame elementFrame) { + public PlaceableElementPanel(ElementFrame elementFrame) { super(elementFrame); this.icon = new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Basic Rules.gif")); this.name = "Placeable Elements"; From 73de0d06e3c24808a18a8e248f1019dbfbb33753 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 24 Jun 2022 14:53:38 -0400 Subject: [PATCH 54/86] Progress made Just storing the changes I've made so far --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 26 +++++++++++++++---- src/main/java/edu/rpi/legup/ui/LegupUI.java | 6 ++--- .../edu/rpi/legup/ui/ProofEditorPanel.java | 6 +++-- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 5 +++- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 51ca01116..09dd24bd1 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -7,6 +7,7 @@ public class HomePanel extends LegupPanel { private LegupUI legupUI; private JFrame frame; private JButton[] buttons; + private JLabel[] text; private JMenuBar menuBar; private final int buttonSize = 100; @@ -15,6 +16,7 @@ public HomePanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.legupUI = legupUI; this.frame = frame; setLayout(new GridLayout(1, 2)); + initText(); initButtons(); } @@ -111,9 +113,10 @@ private void initButtons() { this.buttons[3].setVerticalTextPosition(AbstractButton.BOTTOM); } - private void render() + private void initText() { - this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + this.text = new JLabel[3]; + JLabel welcome = new JLabel("Welcome to Legup"); welcome.setFont(new Font("Roboto", Font.BOLD, 23)); welcome.setAlignmentX(Component.CENTER_ALIGNMENT); @@ -125,6 +128,19 @@ private void render() JLabel credits = new JLabel("A project by Dr. Bram van Heuveln"); credits.setFont(new Font("Roboto", Font.PLAIN, 12)); credits.setAlignmentX(Component.CENTER_ALIGNMENT); + + this.text[0] = welcome; + this.text[1] = version; + this.text[2] = credits; + } + + private void render() + { + this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + + //JPanel welcomeText = new JPanel(); + //for (JLabel label : this.text) + // welcomeText.add(label); JPanel buttons = new JPanel(); buttons.add(this.buttons[0]); @@ -137,9 +153,9 @@ private void render() batchGraderButton.add(this.buttons[3]); batchGraderButton.setAlignmentX(Component.LEFT_ALIGNMENT); - this.add(welcome); - this.add(version); - this.add(credits); + // this.add(welcomeText); + for (JLabel label : this.text) + this.add(label); this.add(buttons); this.add(batchGraderButton); } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index ed994fc72..8142319e4 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -133,13 +133,13 @@ private void initPanels() { panels = new LegupPanel[3]; panels[0] = new HomePanel(this.fileDialog, this, this); - panels[1] = new ProofEditorPanel(this.fileDialog, this); - panels[2] = new PuzzleEditorPanel(this.fileDialog, this); + panels[1] = new ProofEditorPanel(this.fileDialog, this, this); + panels[2] = new PuzzleEditorPanel(this.fileDialog, this, this); } protected void displayPanel(int option) { - if (option > panels.length) { + if (option > panels.length || option < 0) { throw new InvalidParameterException("Invalid option"); } this.window.removeAll(); diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 48080d7d1..e18e8482e 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -50,12 +50,14 @@ public class ProofEditorPanel extends LegupPanel implements IHistoryListener { private BoardView boardView; private JFileChooser folderBrowser; private JMenuItem undo, redo; + private LegupUI legupUI; final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; - public ProofEditorPanel(FileDialog fileDialog, JFrame frame) { + public ProofEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.fileDialog = fileDialog; this.frame = frame; + this.legupUI = legupUI; setLayout(new BorderLayout()); } @@ -187,7 +189,7 @@ public JMenuBar getMenuBar() { file.addSeparator(); file.add(exit); - exit.addActionListener((ActionEvent) -> System.exit(0)); + exit.addActionListener((ActionEvent) -> this.legupUI.displayPanel(0)); if(os.equals("mac")) exit.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else exit.setAccelerator(KeyStroke.getKeyStroke('Q', InputEvent.CTRL_DOWN_MASK)); mBar.add(edit); diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index f5ae071df..d40529f9e 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -37,10 +37,13 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private JMenuItem undo, redo; private ElementFrame elementFrame; private JPanel treePanel; + private LegupUI legupUI; final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; - public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame) { + + public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.fileDialog = fileDialog; this.frame = frame; + this.legupUI = legupUI; setLayout(new BorderLayout()); } From afceb4d97b70fb4f70031c8ee756f3cefc821d1c Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Fri, 24 Jun 2022 15:12:05 -0400 Subject: [PATCH 55/86] started functionality for creating empty puzzles --- .../edu/rpi/legup/app/GameBoardFacade.java | 35 +++++++++++++++++++ .../edu/rpi/legup/model/PuzzleImporter.java | 11 ++++++ .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 +- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 ++ .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 12 +++++-- 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index cb665f2f3..232670732 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -96,6 +96,41 @@ public void setConfig(Config config) { this.config = config; } + /** + * Loads an empty puzzle + * + * @param game name of the puzzle + * @param width width of the puzzle + * @param height height of the puzzle + */ + public void loadPuzzle(String game, int width, int height) throws RuntimeException { + setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); + String qualifiedClassName = config.getPuzzleClassForName(game); + LOGGER.debug("Loading " + qualifiedClassName); + + try { + Class c = Class.forName(qualifiedClassName); + Constructor cons = c.getConstructor(); + Puzzle puzzle = (Puzzle) cons.newInstance(); + + PuzzleImporter importer = puzzle.getImporter(); + if (importer == null) { + LOGGER.error("Puzzle importer is null"); + throw new RuntimeException("Puzzle importer null"); + } + + importer.initializePuzzle(width, height); + puzzle.initializeView(); + puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); + setPuzzle(puzzle); + } + catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | + IllegalAccessException | InstantiationException e) { + LOGGER.error(e); + throw new RuntimeException("Puzzle creation error"); + } + } + /** * Loads a puzzle file * diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 0f73efa22..496c4ed4f 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -29,6 +29,17 @@ public PuzzleImporter(Puzzle puzzle) { this.puzzle = puzzle; } + /** + * Initializes an empty puzzle + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + public void initializePuzzle(int width, int height) throws RuntimeException { + + } + /** * Initializes the puzzle attributes * diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index b89689223..b67709186 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -77,7 +77,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game); + this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); setVisible(false); } else if (e.getSource() == cancel) { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 51ca01116..7e71dd868 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -149,8 +149,9 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game) { + public void openEditorWithNewPuzzle(String game, int width, int height) { // Set game type on the puzzle editor this.legupUI.displayPanel(2); + this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 6c873bd90..4e2182b0e 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -157,6 +157,8 @@ public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } + public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } + public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 1abe0a2b4..ae8ce34ec 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -4,13 +4,11 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.ElementController; -import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -172,7 +170,15 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } - + public void loadPuzzleFromHome(String game, int width, int height) { + GameBoardFacade facade = GameBoardFacade.getInstance(); + try { + facade.loadPuzzle(game, width, height); + } + catch (RuntimeException e){ + LOGGER.error(e.getMessage()); + } + } public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { From f385d6049f3d2eb8f81d4fc27dc3018524e042d9 Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Fri, 24 Jun 2022 15:14:06 -0400 Subject: [PATCH 56/86] Revert "started functionality for creating empty puzzles" This reverts commit afceb4d97b70fb4f70031c8ee756f3cefc821d1c. --- .../edu/rpi/legup/app/GameBoardFacade.java | 35 ------------------- .../edu/rpi/legup/model/PuzzleImporter.java | 11 ------ .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 +- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 -- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 12 ++----- 6 files changed, 5 insertions(+), 60 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 232670732..cb665f2f3 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -96,41 +96,6 @@ public void setConfig(Config config) { this.config = config; } - /** - * Loads an empty puzzle - * - * @param game name of the puzzle - * @param width width of the puzzle - * @param height height of the puzzle - */ - public void loadPuzzle(String game, int width, int height) throws RuntimeException { - setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); - String qualifiedClassName = config.getPuzzleClassForName(game); - LOGGER.debug("Loading " + qualifiedClassName); - - try { - Class c = Class.forName(qualifiedClassName); - Constructor cons = c.getConstructor(); - Puzzle puzzle = (Puzzle) cons.newInstance(); - - PuzzleImporter importer = puzzle.getImporter(); - if (importer == null) { - LOGGER.error("Puzzle importer is null"); - throw new RuntimeException("Puzzle importer null"); - } - - importer.initializePuzzle(width, height); - puzzle.initializeView(); - puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); - setPuzzle(puzzle); - } - catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | - IllegalAccessException | InstantiationException e) { - LOGGER.error(e); - throw new RuntimeException("Puzzle creation error"); - } - } - /** * Loads a puzzle file * diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 496c4ed4f..0f73efa22 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -29,17 +29,6 @@ public PuzzleImporter(Puzzle puzzle) { this.puzzle = puzzle; } - /** - * Initializes an empty puzzle - * - * @param width width of puzzle - * @param height height of puzzle - * @throws RuntimeException - */ - public void initializePuzzle(int width, int height) throws RuntimeException { - - } - /** * Initializes the puzzle attributes * diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index b67709186..b89689223 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -77,7 +77,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); + this.homePanel.openEditorWithNewPuzzle(game); setVisible(false); } else if (e.getSource() == cancel) { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 7e71dd868..51ca01116 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -149,9 +149,8 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game, int width, int height) { + public void openEditorWithNewPuzzle(String game) { // Set game type on the puzzle editor this.legupUI.displayPanel(2); - this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 4e2182b0e..6c873bd90 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -157,8 +157,6 @@ public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } - public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } - public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index ae8ce34ec..1abe0a2b4 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -4,11 +4,13 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.ElementController; +import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; +import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -170,15 +172,7 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } - public void loadPuzzleFromHome(String game, int width, int height) { - GameBoardFacade facade = GameBoardFacade.getInstance(); - try { - facade.loadPuzzle(game, width, height); - } - catch (RuntimeException e){ - LOGGER.error(e.getMessage()); - } - } + public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { From cbe616382c776cf62298be782c28c7d2031b025c Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Fri, 24 Jun 2022 15:24:16 -0400 Subject: [PATCH 57/86] Revert "Revert "started functionality for creating empty puzzles"" This reverts commit f385d6049f3d2eb8f81d4fc27dc3018524e042d9. --- .../edu/rpi/legup/app/GameBoardFacade.java | 35 +++++++++++++++++++ .../edu/rpi/legup/model/PuzzleImporter.java | 11 ++++++ .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 +- src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 ++ .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 12 +++++-- 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index cb665f2f3..232670732 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -96,6 +96,41 @@ public void setConfig(Config config) { this.config = config; } + /** + * Loads an empty puzzle + * + * @param game name of the puzzle + * @param width width of the puzzle + * @param height height of the puzzle + */ + public void loadPuzzle(String game, int width, int height) throws RuntimeException { + setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); + String qualifiedClassName = config.getPuzzleClassForName(game); + LOGGER.debug("Loading " + qualifiedClassName); + + try { + Class c = Class.forName(qualifiedClassName); + Constructor cons = c.getConstructor(); + Puzzle puzzle = (Puzzle) cons.newInstance(); + + PuzzleImporter importer = puzzle.getImporter(); + if (importer == null) { + LOGGER.error("Puzzle importer is null"); + throw new RuntimeException("Puzzle importer null"); + } + + importer.initializePuzzle(width, height); + puzzle.initializeView(); + puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); + setPuzzle(puzzle); + } + catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | + IllegalAccessException | InstantiationException e) { + LOGGER.error(e); + throw new RuntimeException("Puzzle creation error"); + } + } + /** * Loads a puzzle file * diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 0f73efa22..496c4ed4f 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -29,6 +29,17 @@ public PuzzleImporter(Puzzle puzzle) { this.puzzle = puzzle; } + /** + * Initializes an empty puzzle + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + public void initializePuzzle(int width, int height) throws RuntimeException { + + } + /** * Initializes the puzzle attributes * diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index b89689223..b67709186 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -77,7 +77,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game); + this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); setVisible(false); } else if (e.getSource() == cancel) { diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 51ca01116..7e71dd868 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -149,8 +149,9 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game) { + public void openEditorWithNewPuzzle(String game, int width, int height) { // Set game type on the puzzle editor this.legupUI.displayPanel(2); + this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); } } diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 6c873bd90..4e2182b0e 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -157,6 +157,8 @@ public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } + public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } + public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 1abe0a2b4..ae8ce34ec 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -4,13 +4,11 @@ import edu.rpi.legup.controller.BoardController; import edu.rpi.legup.controller.EditorElementController; import edu.rpi.legup.controller.ElementController; -import edu.rpi.legup.controller.RuleController; import edu.rpi.legup.history.ICommand; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.save.InvalidFileFormatException; import edu.rpi.legup.ui.boardview.BoardView; -import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame; import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -172,7 +170,15 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } - + public void loadPuzzleFromHome(String game, int width, int height) { + GameBoardFacade facade = GameBoardFacade.getInstance(); + try { + facade.loadPuzzle(game, width, height); + } + catch (RuntimeException e){ + LOGGER.error(e.getMessage()); + } + } public void promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { From 1e9f24b109f0c86542c2fa8420dffb107544638f Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Sat, 25 Jun 2022 00:21:57 -0400 Subject: [PATCH 58/86] Shorter enum names in `BattleshipType` and some helper methods in `BattleshipBoard` and `BattleshipType`. Also revised some JavaDoc comments for better clarity and easier readability. --- .../battleship/BattleshipCellController.java | 4 ++-- .../battleship/BattleshipElementView.java | 14 +++++++------- .../legup/puzzle/battleship/BattleshipType.java | 17 ++++++++++++++--- .../rules/AdjacentShipsContradictionRule.java | 11 ++++++++++- .../battleship/rules/ContinueShipBasicRule.java | 2 +- .../rules/TouchingTentsContradictionRule.java | 10 ++++++---- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java index 7623ec499..c37fc4184 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellController.java @@ -13,7 +13,7 @@ public void changeCell(MouseEvent e, PuzzleElement data) { if (e.isControlDown()) { this.boardView.getSelectionPopupMenu().show(boardView, this.boardView.getCanvas().getX() + e.getX(), this.boardView.getCanvas().getY() + e.getY()); } else { - if (cell.getData() == BattleshipType.SHIP_SEGMENT_MIDDLE) { + if (cell.getData() == BattleshipType.SHIP_MIDDLE) { cell.setData(BattleshipType.UNKNOWN); } else { cell.setData(BattleshipType.getType(cell.getData().value + 1)); @@ -21,7 +21,7 @@ public void changeCell(MouseEvent e, PuzzleElement data) { } } else if (e.getButton() == MouseEvent.BUTTON3) { if (cell.getData() == BattleshipType.UNKNOWN) { - cell.setData(BattleshipType.SHIP_SEGMENT_MIDDLE); + cell.setData(BattleshipType.SHIP_MIDDLE); } else { cell.setData(BattleshipType.getType(cell.getData().value - 1)); } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java index 6fda00797..9ed944654 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipElementView.java @@ -33,7 +33,7 @@ public void drawElement(Graphics2D graphics2D) { graphics2D.setColor(WATER_COLOR); graphics2D.fillRect(location.x, location.y, size.width, size.height); break; - case SHIP_SEGMENT_UNKNOWN: + case SHIP_UNKNOWN: graphics2D.setColor(SHIP_COLOR); graphics2D.fillRect(location.x + 3 * size.width / 8, location.y + 3 * size.height / 8, size.width / 4, size.height / 4); @@ -46,28 +46,28 @@ public void drawElement(Graphics2D graphics2D) { int yText = location.y + ((size.height - metrics.getHeight()) / 2) + metrics.getAscent(); graphics2D.drawString(value, xText, yText); break; - case SHIP_SIZE_1: + case SUBMARINE: graphics2D.setColor(SHIP_COLOR); graphics2D.fillOval(location.x + size.width / 4, location.y + size.width / 4, size.width / 2, size.height / 2); break; - case SHIP_SEGMENT_TOP: + case SHIP_TOP: graphics2D.setColor(SHIP_COLOR); graphics2D.fillArc(location.x, location.y - size.height / 2, size.width, size.height, 180, 180); break; - case SHIP_SEGMENT_RIGHT: + case SHIP_RIGHT: graphics2D.setColor(SHIP_COLOR); graphics2D.fillArc(location.x + size.height / 2, location.y, size.width, size.height, 90, 180); break; - case SHIP_SEGMENT_BOTTOM: + case SHIP_BOTTOM: graphics2D.setColor(SHIP_COLOR); graphics2D.fillArc(location.x, location.y + size.height / 2, size.width, size.height, 0, 180); break; - case SHIP_SEGMENT_LEFT: + case SHIP_LEFT: graphics2D.setColor(SHIP_COLOR); graphics2D.fillArc(location.x - size.height / 2, location.y, size.width, size.height, 270, 180); break; - case SHIP_SEGMENT_MIDDLE: + case SHIP_MIDDLE: graphics2D.setColor(SHIP_COLOR); graphics2D.fillRect(location.x, location.y, size.width, size.height); break; diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java index 720363625..46e0304b1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java @@ -1,9 +1,9 @@ package edu.rpi.legup.puzzle.battleship; public enum BattleshipType { - UNKNOWN, WATER, SHIP_SEGMENT_UNKNOWN, SHIP_SIZE_1, SHIP_SEGMENT_TOP, - SHIP_SEGMENT_RIGHT, SHIP_SEGMENT_BOTTOM, SHIP_SEGMENT_LEFT, - SHIP_SEGMENT_MIDDLE, CLUE_NORTH, CLUE_EAST, CLUE_SOUTH, CLUE_WEST; + UNKNOWN, WATER, SUBMARINE, SHIP_UNKNOWN, + SHIP_TOP, SHIP_RIGHT, SHIP_BOTTOM, SHIP_LEFT, SHIP_MIDDLE, + CLUE_NORTH, CLUE_EAST, CLUE_SOUTH, CLUE_WEST; public int value; @@ -23,4 +23,15 @@ public static BattleshipType getType(int value) { } return null; } + + /** + * Checks if the type is a ship. + * + * @param type the {@link BattleshipType} to check + * @return true if the type is a ship, false otherwise + */ + public static boolean isShip(BattleshipType type) { + return type == SHIP_UNKNOWN || type == SHIP_TOP || type == SHIP_RIGHT + || type == SHIP_BOTTOM || type == SHIP_LEFT || type == SHIP_MIDDLE; + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java index 92d7df933..78ae1225f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java @@ -30,7 +30,7 @@ public AdjacentShipsContradictionRule() { * @param puzzleElement equivalent {@link PuzzleElement} * @return null if the transition contains a * contradiction at the specified {@link PuzzleElement}, - * otherwise error message + * otherwise error message. */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { @@ -42,6 +42,15 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { = bsBoard.getAdjacent(cell); BattleshipCell up = orthoAdjCells.get(0); + BattleshipCell right = orthoAdjCells.get(1); + BattleshipCell down = orthoAdjCells.get(2); + BattleshipCell left = orthoAdjCells.get(3); + + boolean isVertical = (up != null && BattleshipType.isShip(up.getData())) + || (down != null && BattleshipType.isShip(down.getData())); + + boolean isHorizontal = (left != null && BattleshipType.isShip(left.getData())) + || (right != null && BattleshipType.isShip(right.getData())); return null; } diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/ContinueShipBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/ContinueShipBasicRule.java index b30110838..f947fb859 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/ContinueShipBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/ContinueShipBasicRule.java @@ -18,7 +18,7 @@ public ContinueShipBasicRule() { /** * Checks whether the child node logically follows from the parent node * at the specific puzzleElement index using this rule - * This method is the one that should overridden in child classes + * This method is the one that should be overridden in child classes * * @param transition transition to check * @param puzzleElement equivalent puzzleElement diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java index 3c56c12f0..196725310 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TouchingTentsContradictionRule.java @@ -16,12 +16,14 @@ public TouchingTentsContradictionRule() { } /** - * Checks whether the transition has a contradiction at the specific puzzleElement index using this rule + * Checks whether the transition has a contradiction at the specific + * {@link PuzzleElement} index using this rule * * @param board board to check contradiction - * @param puzzleElement equivalent puzzleElement - * @return null if the transition contains a contradiction at the specified puzzleElement, - * otherwise error message + * @param puzzleElement equivalent {@link PuzzleElement} + * @return null if the transition contains a + * contradiction at the specified puzzleElement, + * otherwise error message. */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { From b1e1d5497fefbffbdf201d68d7dd0b7d45971736 Mon Sep 17 00:00:00 2001 From: Hiimadd Date: Mon, 27 Jun 2022 18:47:25 -0400 Subject: [PATCH 59/86] Implement Fill in Row Implement fill in row, make some fixes for no tree for tent --- .../treetent/rules/FillinRowCaseRule.java | 65 +++++++++++-------- .../rules/NoTreeForTentContradictionRule.java | 27 +++++++- 2 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java index 19a8b8116..edf4a657c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/FillinRowCaseRule.java @@ -50,17 +50,18 @@ public CaseBoard getCaseBoard(Board board) { public ArrayList getCases(Board board, PuzzleElement puzzleElement) { ArrayList cases = new ArrayList(); List group; - int treesLeft; - Point loc = ((TreeTentCell) puzzleElement).getLocation(); + int tentsLeft; + TreeTentClue clue = ((TreeTentClue) puzzleElement); + int clueIndex = clue.getClueIndex()-1; TreeTentBoard tBoard = (TreeTentBoard)board; - if(((TreeTentCell) puzzleElement).getType() == TreeTentType.CLUE_SOUTH) { - group = tBoard.getRowCol(loc.y, TreeTentType.UNKNOWN, true); - treesLeft = tBoard.getRowClues().get(loc.y).getData() - tBoard.getRowCol(loc.y, TreeTentType.TREE, true).size(); - cases = genCombinations(tBoard, group, treesLeft, loc, true); + if(clue.getType() == TreeTentType.CLUE_SOUTH) { + group = tBoard.getRowCol(clueIndex, TreeTentType.UNKNOWN, false); + tentsLeft = tBoard.getRowClues().get(clueIndex).getData() - tBoard.getRowCol(clueIndex, TreeTentType.TENT, false).size(); + cases = genCombinations(tBoard, group, tentsLeft, clueIndex, false); } else { - group = tBoard.getRowCol(loc.x, TreeTentType.UNKNOWN, false); - treesLeft = tBoard.getRowClues().get(loc.x).getData() - tBoard.getRowCol(loc.x, TreeTentType.TREE, false).size(); - cases = genCombinations(tBoard, group, treesLeft, loc, true); + group = tBoard.getRowCol(clueIndex, TreeTentType.UNKNOWN, true); + tentsLeft = tBoard.getRowClues().get(clueIndex).getData() - tBoard.getRowCol(clueIndex, TreeTentType.TENT, true).size(); + cases = genCombinations(tBoard, group, tentsLeft, clueIndex, true); } //generate every combination (nCr) @@ -70,54 +71,64 @@ public ArrayList getCases(Board board, PuzzleElement puzzleElement) { return null; } - private ArrayList genCombinations(TreeTentBoard iBoard, List tiles, int target, Point loc, boolean isRow) + private ArrayList genCombinations(TreeTentBoard iBoard, List tiles, int target, Integer index, boolean isRow) { - return genCombRecursive(iBoard, tiles, target, 0, new ArrayList(), loc, isRow); + return genCombRecursive(iBoard, tiles, tiles, target, 0, new ArrayList(), index, isRow); } - private ArrayList genCombRecursive(TreeTentBoard iBoard, List tiles, int target, int current, List selected, Point loc, boolean isRow) + private ArrayList genCombRecursive(TreeTentBoard iBoard, List original, List tiles, int target, int current, List selected, Integer index, boolean isRow) { ArrayList b = new ArrayList<>(); if(target == current) { TreeTentBoard temp = iBoard.copy(); - for(TreeTentCell c : selected) + for(TreeTentCell c : original) { - PuzzleElement change = temp.getPuzzleElement(c); - change.setData(TreeTentType.TENT.value); - temp.addModifiedData(change); + if(selected.contains(c)) + { + PuzzleElement change = temp.getPuzzleElement(c); + change.setData(TreeTentType.TENT.value); + temp.addModifiedData(change); + } + else + { + PuzzleElement change = temp.getPuzzleElement(c); + change.setData(TreeTentType.GRASS.value); + temp.addModifiedData(change); + } + } - if(goodBoard(temp, loc, isRow)) {b.add(temp);} + if(goodBoard(temp, index, isRow)) {b.add(temp);} return b; } for(int i = 0; i < tiles.size(); ++i) { - List sub = tiles.subList(i, tiles.size()); + List sub = tiles.subList(i+1, tiles.size()); List next = new ArrayList(selected); next.add(tiles.get(i)); - b.addAll(genCombRecursive(iBoard, sub, target, current+1, next, loc, isRow)); + b.addAll(genCombRecursive(iBoard, original, sub, target, current+1, next, index, isRow)); } return b; } - //Effectively runs TouchingTents check on all the added trees to make sure that the proposed board is valid. + //Effectively runs TouchingTents check on all the added tents to make sure that the proposed board is valid. //Could check more or less in the future depending on how "smart" this case rule should be. - private boolean goodBoard(TreeTentBoard board, Point loc, boolean isRow) + private boolean goodBoard(TreeTentBoard board, Integer index, boolean isRow) { - List trees; + List tents; if(isRow) { - trees = board.getRowCol(loc.x, TreeTentType.TREE, true); + tents = board.getRowCol(index, TreeTentType.TENT, true); } else { - trees = board.getRowCol(loc.y, TreeTentType.TREE, false); + tents = board.getRowCol(index, TreeTentType.TENT, false); } - for(TreeTentCell t : trees) + for(TreeTentCell t : tents) { - List adj = board.getAdjacent(t, TreeTentType.TREE); - List diag = board.getDiagonals(t, TreeTentType.TREE); + List adj = board.getAdjacent(t, TreeTentType.TENT); + List diag = board.getDiagonals(t, TreeTentType.TENT); if(adj.size() > 0 || diag.size() > 0) {return false;} } return true; diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/NoTreeForTentContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/NoTreeForTentContradictionRule.java index 951989d66..335017c98 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/NoTreeForTentContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/NoTreeForTentContradictionRule.java @@ -5,8 +5,12 @@ import edu.rpi.legup.model.rules.ContradictionRule; import edu.rpi.legup.puzzle.treetent.TreeTentBoard; import edu.rpi.legup.puzzle.treetent.TreeTentCell; +import edu.rpi.legup.puzzle.treetent.TreeTentLine; import edu.rpi.legup.puzzle.treetent.TreeTentType; +import java.util.List; +import java.util.Iterator; + public class NoTreeForTentContradictionRule extends ContradictionRule { public NoTreeForTentContradictionRule() { @@ -30,9 +34,26 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { if (cell.getType() != TreeTentType.TENT) { return super.getNoContradictionMessage(); } - int adjTree = treeTentBoard.getAdjacent(cell, TreeTentType.TREE).size(); - int adjUnknown = treeTentBoard.getAdjacent(cell, TreeTentType.UNKNOWN).size(); - if (adjTree == 0 && adjUnknown == 0) { + List adjTrees = treeTentBoard.getAdjacent(cell, TreeTentType.TREE); + List lines = treeTentBoard.getLines(); + for(TreeTentLine l : lines) + { + Iterator i = adjTrees.iterator(); + while(i.hasNext()) + { + TreeTentCell t = i.next(); + if (t.getLocation().equals(l.getC1().getLocation()) && !(cell.getLocation().equals(l.getC2().getLocation()))) + { + i.remove(); + } + if (t.getLocation().equals(l.getC2().getLocation()) && !(cell.getLocation().equals(l.getC2().getLocation()))) + { + i.remove(); + } + } + } + int adjTree = adjTrees.size(); + if (adjTree == 0) { return null; } else { return super.getNoContradictionMessage(); From 821d5d83fe29184079174ba3a31457afb6ab5c97 Mon Sep 17 00:00:00 2001 From: Charles <46334090+charlestian23@users.noreply.github.com> Date: Tue, 28 Jun 2022 21:51:57 -0400 Subject: [PATCH 60/86] Create LICENSE --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..f288702d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 8dd16e1b69e4762e90f1225dfe9f299fdadf995d Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 1 Jul 2022 14:40:28 -0400 Subject: [PATCH 61/86] Fixed whitespace problem --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 09dd24bd1..db2df5024 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -48,8 +48,7 @@ public JMenuBar getMenuBar() public void makeVisible() { render(); - this.frame.setVisible(true); - this.frame.setJMenuBar(this.getMenuBar()); + frame.setJMenuBar(this.getMenuBar()); } private static ImageIcon resizeButtonIcon(ImageIcon icon, int width, int height) @@ -136,26 +135,30 @@ private void initText() private void render() { + /* Removing this line will cause random whitespace to be added every time you return to + the home screen. However, this line does not seem to be present in other makeVisible() + methods. We should look into this in the future. + */ + this.removeAll(); + this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); - - //JPanel welcomeText = new JPanel(); - //for (JLabel label : this.text) - // welcomeText.add(label); JPanel buttons = new JPanel(); + buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[0]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[1]); buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(this.buttons[2]); + buttons.add(Box.createRigidArea(new Dimension(5, 0))); JPanel batchGraderButton = new JPanel(); batchGraderButton.add(this.buttons[3]); batchGraderButton.setAlignmentX(Component.LEFT_ALIGNMENT); // this.add(welcomeText); - for (JLabel label : this.text) - this.add(label); + for (int i = 0; i < this.text.length; i++) + this.add(this.text[i]); this.add(buttons); this.add(batchGraderButton); } From 45d89bf5080a607075ddfc4c9158aff463254992 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 1 Jul 2022 14:41:44 -0400 Subject: [PATCH 62/86] Added some padding to home screen --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index db2df5024..73fcdb9b4 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -156,11 +156,12 @@ the home screen. However, this line does not seem to be present in other makeVis batchGraderButton.add(this.buttons[3]); batchGraderButton.setAlignmentX(Component.LEFT_ALIGNMENT); - // this.add(welcomeText); + this.add(Box.createRigidArea(new Dimension(0, 5))); for (int i = 0; i < this.text.length; i++) this.add(this.text[i]); this.add(buttons); this.add(batchGraderButton); + this.add(Box.createRigidArea(new Dimension(0, 5))); } private void openNewPuzzleDialog() { From 143c5029fee885833ab6c411dc0ca0b7d16eca62 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 1 Jul 2022 14:46:48 -0400 Subject: [PATCH 63/86] Added exit button to Puzzle Editor --- src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index d40529f9e..c0739a082 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -82,6 +82,7 @@ public void setMenuBar() { menus = new JMenu[3]; // create menus + // FILE menus[0] = new JMenu("File"); // file>new @@ -91,9 +92,15 @@ public void setMenuBar() { else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK)); // file>save JMenuItem savePuzzle = new JMenuItem("Save"); - + JMenuItem exit = new JMenuItem("Exit"); + exit.addActionListener((ActionEvent) -> this.legupUI.displayPanel(0)); + if (os.equals("mac")) + exit.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + else + exit.setAccelerator(KeyStroke.getKeyStroke('Q', InputEvent.CTRL_DOWN_MASK)); menus[0].add(newPuzzle); menus[0].add(savePuzzle); + menus[0].add(exit); // EDIT menus[1] = new JMenu("Edit"); From b99c1dbe33d1e1c4aa9d3fd618a13d339638c6e4 Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Fri, 1 Jul 2022 14:51:32 -0400 Subject: [PATCH 64/86] Added functionality for loading an empty puzzle and implemented loading an empty sudoku puzzle --- .../edu/rpi/legup/app/GameBoardFacade.java | 12 ++++++-- .../edu/rpi/legup/model/PuzzleImporter.java | 11 ++++++- .../puzzle/battleship/BattleShipImporter.java | 12 ++++++++ .../puzzle/fillapix/FillapixImporter.java | 12 ++++++++ .../puzzle/heyawake/HeyawakeImporter.java | 12 ++++++++ .../legup/puzzle/lightup/LightUpImporter.java | 12 ++++++++ .../rpi/legup/puzzle/masyu/MasyuImporter.java | 12 ++++++++ .../puzzle/nurikabe/NurikabeImporter.java | 12 ++++++++ .../ShortTruthTableImporter.java | 10 +++++++ .../skyscrapers/SkyscrapersImporter.java | 12 ++++++++ .../legup/puzzle/sudoku/SudokuImporter.java | 29 +++++++++++++++++++ .../puzzle/treetent/TreeTentImporter.java | 12 ++++++++ src/main/java/edu/rpi/legup/ui/LegupUI.java | 2 +- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 6 ++-- 14 files changed, 158 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 232670732..0555adf58 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -82,16 +82,22 @@ public void initializeUI() { puzzleSolver = legupUI.getProofEditor(); puzzleEditor = legupUI.getPuzzleEditor(); addHistoryListener(legupUI.getProofEditor()); + addHistoryListener(legupUI.getPuzzleEditor()); }); } public void setPuzzle(Puzzle puzzle) { this.puzzle = puzzle; this.puzzleSolver.setPuzzleView(puzzle); - this.puzzleEditor.setPuzzleView((puzzle)); this.history.clear(); } + public void setPuzzleEditor(Puzzle puzzle) { + this.puzzle = puzzle; + this.puzzleEditor.setPuzzleView((puzzle)); +// this.history.clear(); + } + public void setConfig(Config config) { this.config = config; } @@ -121,8 +127,8 @@ public void loadPuzzle(String game, int width, int height) throws RuntimeExcepti importer.initializePuzzle(width, height); puzzle.initializeView(); - puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); - setPuzzle(puzzle); +// puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); + setPuzzleEditor(puzzle); } catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 496c4ed4f..6be9b0c67 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -37,7 +37,7 @@ public PuzzleImporter(Puzzle puzzle) { * @throws RuntimeException */ public void initializePuzzle(int width, int height) throws RuntimeException { - + initializeBoard(width, height); } /** @@ -91,6 +91,15 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { /** * Creates the board for building * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + public abstract void initializeBoard(int width, int height) throws RuntimeException; + + /** + * Creates an empty board for building + * * @param node xml document node * @throws InvalidFileFormatException */ diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java index 04a884085..4cce01e59 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java @@ -13,6 +13,18 @@ public BattleShipImporter(BattleShip battleShip) { super(battleShip); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java index 4bf28af2b..8c3e7dad1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -13,6 +13,18 @@ public FillapixImporter(Fillapix fillapix) { super(fillapix); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java index e72be136a..169d30718 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -14,6 +14,18 @@ public HeyawakeImporter(Heyawake heyawake) { super(heyawake); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java index 625483090..418cc4805 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -13,6 +13,18 @@ public LightUpImporter(LightUp lightUp) { super(lightUp); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java index 5e0b4ca57..9e25685a0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -13,6 +13,18 @@ public MasyuImporter(Masyu masyu) { super(masyu); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java index 82efff1c1..f56ac4e66 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -13,6 +13,18 @@ public NurikabeImporter(Nurikabe nurikabe) { super(nurikabe); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index cbf052521..c4f1ae6d8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -214,7 +214,17 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + } //STATEMENT IMPORTER diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java index 5ddcc673f..8a55a1a29 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java @@ -13,6 +13,18 @@ public SkyscrapersImporter(Skyscrapers treeTent) { super(treeTent); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java index 0805da8f9..201f4f93c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java @@ -13,6 +13,35 @@ public SudokuImporter(Sudoku sudoku) { super(sudoku); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + SudokuBoard sudokuBoard; + int minorSize = (int) Math.sqrt(width); + if(width != height || minorSize * minorSize != width) throw new RuntimeException("Sudoku Importer: invalid board dimensions"); + sudokuBoard = new SudokuBoard(width); + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + if (sudokuBoard.getCell(x, y) == null) { + int groupIndex = x / minorSize + y / minorSize * minorSize; + SudokuCell cell = new SudokuCell(0, new Point(x, y), groupIndex, width); + cell.setIndex(y * width + x); + cell.setModifiable(true); + sudokuBoard.setCell(x, y, cell); + } + } + } + + puzzle.setCurrentBoard(sudokuBoard); + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java index fdbef245e..e2ecdb4d4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java @@ -13,6 +13,18 @@ public TreeTentImporter(TreeTent treeTent) { super(treeTent); } + /** + * Creates an empty board for building + * + * @param width width of puzzle + * @param height height of puzzle + * @throws RuntimeException + */ + @Override + public void initializeBoard(int width, int height) throws RuntimeException { + + } + /** * Creates the board for building * diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 4e2182b0e..c712bda17 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -157,7 +157,7 @@ public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } - public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } +// public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; } public static boolean profFlag(int flag) { return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0); diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index ae8ce34ec..5fcab9356 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -23,7 +23,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { - private final static Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); + private final static Logger LOGGER = LogManager.getLogger(PuzzleEditorPanel.class.getName()); private JMenu[] menus; private JMenuBar menuBar; private JToolBar toolBar; @@ -72,7 +72,7 @@ protected void setupContent() { this.add(elementBox); splitPanel.setDividerLocation(splitPanel.getMaximumDividerLocation()+100); - + this.splitPanel = splitPanel; revalidate(); } @@ -246,8 +246,8 @@ private void repaintAll() { public void setPuzzleView(Puzzle puzzle) { this.boardView = puzzle.getBoardView(); - dynamicBoardView = new DynamicView(boardView); + this.splitPanel.setRightComponent(dynamicBoardView); this.splitPanel.setVisible(true); From bbb5e3a775ab7f1423570a2436f191aa530c01e5 Mon Sep 17 00:00:00 2001 From: Ivan Ho <41582274+Corppet@users.noreply.github.com> Date: Fri, 1 Jul 2022 14:58:06 -0400 Subject: [PATCH 65/86] Battleship: Adjacent Ships Contradiction Rule - Implementation - Incomplete test Also some JavaDoc revisions. --- .../puzzle/battleship/BattleshipBoard.java | 2 +- .../rules/AdjacentShipsContradictionRule.java | 35 ++++++++++-- .../rules/IsolateBlackContradictionRule.java | 8 +-- .../AdjacentShipsContradictionRuleTest.java | 54 +++++++++++++++++++ 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/test/java/puzzles/battleship/rules/AdjacentShipsContradictionRuleTest.java diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java index abe63e22b..c72aa9ac6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipBoard.java @@ -88,7 +88,7 @@ public BattleshipBoard copy() { * @return List of adjacent cells in clockwise order: * { up, right, down, left } */ - public List getAdjacent(BattleshipCell cell) { + public List getAdjOrthogonals(BattleshipCell cell) { List adj = new ArrayList<>(); Point loc = cell.getLocation(); BattleshipCell up = getCell(loc.x, loc.y - 1); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java index 78ae1225f..46360c43f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/rules/AdjacentShipsContradictionRule.java @@ -24,22 +24,26 @@ public AdjacentShipsContradictionRule() { /** * Checks whether the transition has a contradiction at the specific - * {@link PuzzleElement} index using this rule + * {@link PuzzleElement} index using this rule. * * @param board board to check contradiction * @param puzzleElement equivalent {@link PuzzleElement} * @return null if the transition contains a * contradiction at the specified {@link PuzzleElement}, - * otherwise error message. + * otherwise return a no contradiction message. */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { BattleshipBoard bsBoard = (BattleshipBoard) board; BattleshipCell cell = (BattleshipCell) bsBoard.getPuzzleElement(puzzleElement); + // rule only applies to battleship cells + if (!BattleshipType.isShip(cell.getType())) + return super.getNoContradictionMessage() + ": " + this.NO_CONTRADICTION_MESSAGE; + // check orthogonally adjacent cells List orthoAdjCells - = bsBoard.getAdjacent(cell); + = bsBoard.getAdjOrthogonals(cell); BattleshipCell up = orthoAdjCells.get(0); BattleshipCell right = orthoAdjCells.get(1); @@ -52,6 +56,29 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { boolean isHorizontal = (left != null && BattleshipType.isShip(left.getData())) || (right != null && BattleshipType.isShip(right.getData())); - return null; + // ships cannot be both vertical and horizontal + if (isVertical && isHorizontal) + return null; + + // check diagonally adjacent cells + List diagAdjCells + = bsBoard.getAdjDiagonals(cell); + + BattleshipCell upRight = diagAdjCells.get(0); + BattleshipCell downRight = diagAdjCells.get(1); + BattleshipCell downLeft = diagAdjCells.get(2); + BattleshipCell upLeft = diagAdjCells.get(3); + + // diagonally adjacent cells must be water + if (upRight != null && BattleshipType.isShip(upRight.getData())) + return null; + if (downRight != null && BattleshipType.isShip(downRight.getData())) + return null; + if (downLeft != null && BattleshipType.isShip(downLeft.getData())) + return null; + if (upLeft != null && BattleshipType.isShip(upLeft.getData())) + return null; + + return super.getNoContradictionMessage() + ": " + this.NO_CONTRADICTION_MESSAGE; } } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/IsolateBlackContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/IsolateBlackContradictionRule.java index 987d33e9c..5c2abf53a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/IsolateBlackContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/IsolateBlackContradictionRule.java @@ -24,12 +24,14 @@ public IsolateBlackContradictionRule() { } /** - * Checks whether the transition has a contradiction at the specific puzzleElement index using this rule + * Checks whether the transition has a contradiction at the specific + * {@link PuzzleElement} index using this rule. * * @param board board to check contradiction * @param puzzleElement equivalent puzzleElement - * @return null if the transition contains a contradiction at the specified puzzleElement, - * otherwise error message + * @return null if the transition contains a + * contradiction at the specified {@link PuzzleElement}, + * otherwise return a no contradiction message. */ @Override public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { diff --git a/src/test/java/puzzles/battleship/rules/AdjacentShipsContradictionRuleTest.java b/src/test/java/puzzles/battleship/rules/AdjacentShipsContradictionRuleTest.java new file mode 100644 index 000000000..20e4e8966 --- /dev/null +++ b/src/test/java/puzzles/battleship/rules/AdjacentShipsContradictionRuleTest.java @@ -0,0 +1,54 @@ +package puzzles.battleship.rules; + +import edu.rpi.legup.puzzle.battleship.BattleshipType; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import edu.rpi.legup.puzzle.battleship.Battleship; +import edu.rpi.legup.puzzle.battleship.BattleshipBoard; +import edu.rpi.legup.puzzle.battleship.BattleshipCell; +import edu.rpi.legup.puzzle.battleship.rules.AdjacentShipsContradictionRule; +import edu.rpi.legup.save.InvalidFileFormatException; + +import java.awt.*; + +public class AdjacentShipsContradictionRuleTest +{ + private static final AdjacentShipsContradictionRule RULE + = new AdjacentShipsContradictionRule(); + + private static Battleship battleship; + + @BeforeClass + public static void setUp() + { + MockGameBoardFacade.getInstance(); + battleship = new Battleship(); + } + + @Test + public void OrthogonalAdjacentTest() throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/battleship/rules/" + + "AdjacentShipsContradictionRule/OrthogonalAdjacentBoards", + battleship); + TreeNode rootNode = battleship.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + BattleshipBoard board = (BattleshipBoard)transition.getBoard(); + BattleshipCell cell1 = board.getCell(1, 1); + BattleshipCell cell2 = board.getCell(1, 2); + BattleshipCell cell3 = board.getCell(2, 1); + BattleshipCell cell4 = board.getCell(2, 2); + + Assert.assertNull(RULE.checkContradiction( + (BattleshipBoard)transition.getBoard())); + + + } +} From f826d063bd3d8aed82d26b3764f12ac45bc41b8d Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 1 Jul 2022 23:55:17 -0400 Subject: [PATCH 66/86] Created isValidDimensions New abstract method in Puzzle class meant to be used to check if a puzzle is a valid size --- src/main/java/edu/rpi/legup/model/Puzzle.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index ef683375d..a94f84b37 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -141,6 +141,15 @@ private void registerRules() { */ public abstract Board generatePuzzle(int difficulty); + /** + * Checks if the given height and width are valid board dimensions for the given puzzle + * + * @param rows the number of rows on the board + * @param columns the number of columns on the board + * @return true if the given dimensions are valid for the given puzzle, false otherwise + */ + public abstract boolean isValidDimensions(int rows, int columns); + /** * Determines if the edu.rpi.legup.puzzle was solves correctly * From 560964fb7768f3c2cd71ae7d01bd50c8d41b39cb Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 1 Jul 2022 23:55:53 -0400 Subject: [PATCH 67/86] Renamed variables Renamed width and height variables to rows and columns for clarity purposes --- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index b89689223..b8a33ccaf 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -14,8 +14,8 @@ public class CreatePuzzleDialog extends JDialog implements ActionListener { JLabel puzzleLabel = new JLabel("Puzzle:"); JButton ok = new JButton("Ok"); JButton cancel = new JButton("Cancel"); - JTextField width; - JTextField height; + JTextField rows; + JTextField columns; private HomePanel homePanel; public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { @@ -42,23 +42,23 @@ public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) { c.add(puzzleLabel); c.add(gameBox); - width = new JTextField(); - height = new JTextField(); + rows = new JTextField(); + columns = new JTextField(); - JLabel widthLabel = new JLabel("Rows:"); - JLabel heightLabel = new JLabel("Columns:"); + JLabel rowsLabel = new JLabel("Rows:"); + JLabel columnsLabel = new JLabel("Columns:"); - widthLabel.setBounds(30, 70, 60, 25); - heightLabel.setBounds(30, 95, 60, 25); + rowsLabel.setBounds(30, 70, 60, 25); + columnsLabel.setBounds(30, 95, 60, 25); - width.setBounds(100, 70, 60, 25); - height.setBounds(100, 95, 60, 25); + rows.setBounds(100, 70, 60, 25); + columns.setBounds(100, 95, 60, 25); - c.add(widthLabel); - c.add(heightLabel); + c.add(rowsLabel); + c.add(columnsLabel); - c.add(width); - c.add(height); + c.add(rows); + c.add(columns); c.add(ok); c.add(cancel); @@ -84,4 +84,9 @@ else if (e.getSource() == cancel) { setVisible(false); } } + + private boolean isValidDimensions() + { + // Needs to be implemented + } } From bf41229af05ed76eadc49e85b1dab3c8c53804d7 Mon Sep 17 00:00:00 2001 From: mattsweet417 Date: Tue, 5 Jul 2022 01:25:54 -0400 Subject: [PATCH 68/86] Fixed Null Puzzle Bug --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 0555adf58..f1debc8f7 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -110,7 +110,6 @@ public void setConfig(Config config) { * @param height height of the puzzle */ public void loadPuzzle(String game, int width, int height) throws RuntimeException { - setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); String qualifiedClassName = config.getPuzzleClassForName(game); LOGGER.debug("Loading " + qualifiedClassName); @@ -118,6 +117,7 @@ public void loadPuzzle(String game, int width, int height) throws RuntimeExcepti Class c = Class.forName(qualifiedClassName); Constructor cons = c.getConstructor(); Puzzle puzzle = (Puzzle) cons.newInstance(); + setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); PuzzleImporter importer = puzzle.getImporter(); if (importer == null) { From c1a22df3a37d18beb06bd78c0efef10f0520e376 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 11:01:04 -0400 Subject: [PATCH 69/86] Added placeholder isValidDimensions() method --- .../edu/rpi/legup/puzzle/battleship/BattleShip.java | 13 +++++++++++++ .../edu/rpi/legup/puzzle/fillapix/Fillapix.java | 13 +++++++++++++ .../edu/rpi/legup/puzzle/heyawake/Heyawake.java | 13 +++++++++++++ .../java/edu/rpi/legup/puzzle/lightup/LightUp.java | 13 +++++++++++++ src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java | 13 +++++++++++++ .../edu/rpi/legup/puzzle/nurikabe/Nurikabe.java | 13 +++++++++++++ .../puzzle/shorttruthtable/ShortTruthTable.java | 13 +++++++++++++ .../rpi/legup/puzzle/skyscrapers/Skyscrapers.java | 13 +++++++++++++ .../java/edu/rpi/legup/puzzle/sudoku/Sudoku.java | 13 +++++++++++++ .../edu/rpi/legup/puzzle/treetent/TreeTent.java | 13 +++++++++++++ 10 files changed, 130 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java index b89c448dd..e77bb7931 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java @@ -25,6 +25,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Battleship + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Battleship, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java index 8d35d3931..536f3f9c2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java @@ -33,6 +33,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Fillapix + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Fillapix, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + @Override public boolean isBoardComplete(Board board) { FillapixBoard fillapixBoard = (FillapixBoard) board; diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java index b28347e0a..e93534518 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java @@ -35,6 +35,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for HeyAwake + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for HeyAwake, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * 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 ed6007c65..b691374cc 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java @@ -38,6 +38,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Light Up + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Light Up, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java b/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java index 7ce783a6a..81323d1df 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java @@ -36,6 +36,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Masyu + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Masyu, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java index 782df59f2..dcb2df319 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java @@ -37,6 +37,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Nurikabe + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Nurikabe, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java index 62a39e870..6c23b43f2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java @@ -39,6 +39,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Short Truth Table + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Short Truth Table, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java index 063804b07..3c4a30a12 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java @@ -41,6 +41,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Skyscrapers + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Skyscrapers, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java index 2704ce314..4e69dccd9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java @@ -46,6 +46,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Sudoku + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Sudoku, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java index 1599965bd..b957c8fa8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java @@ -36,6 +36,19 @@ public Board generatePuzzle(int difficulty) { return null; } + @Override + /** + * Determines if the given dimensions are valid for Tree Tent + * + * @param rows the number of rows + * @param columns the number of columns + * @return true if the given dimensions are valid for Tree Tent, false otherwise + */ + public boolean isValidDimensions(int rows, int columns) { + // This is a placeholder, this method needs to be implemented + return false; + } + /** * Determines if the current board is a valid state * From 39dee91f5079f08eb262ea31ea31d6c1b74ddf4f Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 11:10:04 -0400 Subject: [PATCH 70/86] Renamed width and height to rows and columns Did this for clarity and to be consistent throughout the code. Note that I did not go through and change all the comments in all the importers. --- .../edu/rpi/legup/model/PuzzleImporter.java | 14 ++++++------- .../puzzle/battleship/BattleShipImporter.java | 6 +++--- .../puzzle/fillapix/FillapixImporter.java | 6 +++--- .../puzzle/heyawake/HeyawakeImporter.java | 6 +++--- .../legup/puzzle/lightup/LightUpImporter.java | 6 +++--- .../rpi/legup/puzzle/masyu/MasyuImporter.java | 6 +++--- .../puzzle/nurikabe/NurikabeImporter.java | 6 +++--- .../ShortTruthTableImporter.java | 6 +++--- .../skyscrapers/SkyscrapersImporter.java | 6 +++--- .../legup/puzzle/sudoku/SudokuImporter.java | 20 +++++++++---------- .../puzzle/treetent/TreeTentImporter.java | 6 +++--- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 3 ++- 12 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 6be9b0c67..7b7106f5c 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -32,12 +32,12 @@ public PuzzleImporter(Puzzle puzzle) { /** * Initializes an empty puzzle * - * @param width width of puzzle - * @param height height of puzzle + * @param rows number of rows on the puzzle + * @param columns number of columns on the puzzle * @throws RuntimeException */ - public void initializePuzzle(int width, int height) throws RuntimeException { - initializeBoard(width, height); + public void initializePuzzle(int rows, int columns) throws RuntimeException { + initializeBoard(rows, columns); } /** @@ -91,11 +91,11 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { /** * Creates the board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows number of rows on the puzzle + * @param columns number of columns on the puzzle * @throws RuntimeException */ - public abstract void initializeBoard(int width, int height) throws RuntimeException; + public abstract void initializeBoard(int rows, int columns) throws RuntimeException; /** * Creates an empty board for building diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java index 4cce01e59..5d86107fb 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java @@ -16,12 +16,12 @@ public BattleShipImporter(BattleShip battleShip) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java index 8c3e7dad1..82bb74098 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -16,12 +16,12 @@ public FillapixImporter(Fillapix fillapix) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java index 169d30718..5027e409c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -17,12 +17,12 @@ public HeyawakeImporter(Heyawake heyawake) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java index 418cc4805..f8dd93518 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -16,12 +16,12 @@ public LightUpImporter(LightUp lightUp) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java index 9e25685a0..5102cb987 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -16,12 +16,12 @@ public MasyuImporter(Masyu masyu) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java index f56ac4e66..a74d8bc11 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -16,12 +16,12 @@ public NurikabeImporter(Nurikabe nurikabe) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index c4f1ae6d8..fde2c5fca 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -217,12 +217,12 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java index 8a55a1a29..73607f002 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java @@ -16,12 +16,12 @@ public SkyscrapersImporter(Skyscrapers treeTent) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java index 201f4f93c..2d98ecc58 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java @@ -16,23 +16,23 @@ public SudokuImporter(Sudoku sudoku) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { SudokuBoard sudokuBoard; - int minorSize = (int) Math.sqrt(width); - if(width != height || minorSize * minorSize != width) throw new RuntimeException("Sudoku Importer: invalid board dimensions"); - sudokuBoard = new SudokuBoard(width); + int minorSize = (int) Math.sqrt(rows); + if(rows != columns || minorSize * minorSize != rows) throw new RuntimeException("Sudoku Importer: invalid board dimensions"); + sudokuBoard = new SudokuBoard(rows); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { + for (int y = 0; y < columns; y++) { + for (int x = 0; x < rows; x++) { if (sudokuBoard.getCell(x, y) == null) { int groupIndex = x / minorSize + y / minorSize * minorSize; - SudokuCell cell = new SudokuCell(0, new Point(x, y), groupIndex, width); - cell.setIndex(y * width + x); + SudokuCell cell = new SudokuCell(0, new Point(x, y), groupIndex, rows); + cell.setIndex(y * rows + x); cell.setModifiable(true); sudokuBoard.setCell(x, y, cell); } diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java index e2ecdb4d4..1dbf11d3d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java @@ -16,12 +16,12 @@ public TreeTentImporter(TreeTent treeTent) { /** * Creates an empty board for building * - * @param width width of puzzle - * @param height height of puzzle + * @param rows width of puzzle + * @param columns height of puzzle * @throws RuntimeException */ @Override - public void initializeBoard(int width, int height) throws RuntimeException { + public void initializeBoard(int rows, int columns) throws RuntimeException { } diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index c707e263d..9d70fbca4 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -77,7 +77,7 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText())); + this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(this.rows.getText()), Integer.valueOf(this.columns.getText())); setVisible(false); } else if (e.getSource() == cancel) { @@ -88,5 +88,6 @@ else if (e.getSource() == cancel) { private boolean isValidDimensions() { // Needs to be implemented + return false; } } From 3d3268f00413dcd4758722f65116129e4d8314c0 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 11:23:56 -0400 Subject: [PATCH 71/86] More variable renaming --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index f1debc8f7..17221bf22 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -106,10 +106,10 @@ public void setConfig(Config config) { * Loads an empty puzzle * * @param game name of the puzzle - * @param width width of the puzzle - * @param height height of the puzzle + * @param rows width of the puzzle + * @param columns height of the puzzle */ - public void loadPuzzle(String game, int width, int height) throws RuntimeException { + public void loadPuzzle(String game, int rows, int columns) throws RuntimeException { String qualifiedClassName = config.getPuzzleClassForName(game); LOGGER.debug("Loading " + qualifiedClassName); @@ -125,7 +125,7 @@ public void loadPuzzle(String game, int width, int height) throws RuntimeExcepti throw new RuntimeException("Puzzle importer null"); } - importer.initializePuzzle(width, height); + importer.initializePuzzle(rows, columns); puzzle.initializeView(); // puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); setPuzzleEditor(puzzle); From e5950a666cbbab1aecefc6dfd9dd061a7e50a30a Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 11:45:20 -0400 Subject: [PATCH 72/86] Prototype working --- .../edu/rpi/legup/app/GameBoardFacade.java | 10 +++++++++- .../edu/rpi/legup/model/PuzzleImporter.java | 5 ++++- .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 11 +++++++++-- src/main/java/edu/rpi/legup/ui/HomePanel.java | 19 ++++++++++++++++--- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 8 ++++++-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 17221bf22..d9b366bfc 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -125,7 +125,15 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti throw new RuntimeException("Puzzle importer null"); } - importer.initializePuzzle(rows, columns); + try + { + importer.initializePuzzle(rows, columns); + } + catch (IllegalArgumentException exception) + { + throw new IllegalArgumentException(exception.getMessage()); + } + puzzle.initializeView(); // puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); setPuzzleEditor(puzzle); diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 7b7106f5c..b45fd7a13 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -37,7 +37,10 @@ public PuzzleImporter(Puzzle puzzle) { * @throws RuntimeException */ public void initializePuzzle(int rows, int columns) throws RuntimeException { - initializeBoard(rows, columns); + if (this.puzzle.isValidDimensions(rows, columns)) + initializeBoard(rows, columns); + else + throw new IllegalArgumentException("Invalid dimensions provided"); } /** diff --git a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java index 9d70fbca4..9f6d242fc 100644 --- a/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java +++ b/src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java @@ -77,8 +77,15 @@ public void initPuzzles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { String game = (String) gameBox.getSelectedItem(); - this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(this.rows.getText()), Integer.valueOf(this.columns.getText())); - setVisible(false); + try + { + this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(this.rows.getText()), Integer.valueOf(this.columns.getText())); + setVisible(false); + } + catch (IllegalArgumentException exception) + { + // Don't do anything. This is here to prevent the dialog from closing if the dimensions are invalid. + } } else if (e.getSource() == cancel) { setVisible(false); diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 010dae8d6..ac57bf249 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -169,9 +169,22 @@ private void openNewPuzzleDialog() { cpd.setVisible(true); } - public void openEditorWithNewPuzzle(String game, int width, int height) { + public void openEditorWithNewPuzzle(String game, int width, int height) throws IllegalArgumentException { // Set game type on the puzzle editor - this.legupUI.displayPanel(2); - this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); + try + { + this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); + this.legupUI.displayPanel(2); + } + catch (IllegalArgumentException exception) + { + JOptionPane.showMessageDialog(null, + "The dimensions you entered are invalid. Please double check \n" + + "the number of rows and columns and try again.", + "ERROR: Invalid Dimensions", + JOptionPane.ERROR_MESSAGE); + throw new IllegalArgumentException(exception.getMessage()); + // this.legupUI.displayPanel(0); + } } } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 0694baa57..ea1a5ac78 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -180,10 +180,14 @@ private void setupToolBar() { this.add(toolBar, BorderLayout.NORTH); } - public void loadPuzzleFromHome(String game, int width, int height) { + public void loadPuzzleFromHome(String game, int rows, int columns) throws IllegalArgumentException { GameBoardFacade facade = GameBoardFacade.getInstance(); try { - facade.loadPuzzle(game, width, height); + facade.loadPuzzle(game, rows, columns); + } + catch (IllegalArgumentException exception) + { + throw new IllegalArgumentException(exception.getMessage()); } catch (RuntimeException e){ LOGGER.error(e.getMessage()); From 15cd99e5d6004ca732b7dbee10c8315c206f2154 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 11:53:06 -0400 Subject: [PATCH 73/86] Update Sudoku.java Implemented isValidDimensions() --- .../edu/rpi/legup/puzzle/sudoku/Sudoku.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java index 4e69dccd9..39064a472 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java @@ -55,8 +55,22 @@ public Board generatePuzzle(int difficulty) { * @return true if the given dimensions are valid for Sudoku, false otherwise */ public boolean isValidDimensions(int rows, int columns) { - // This is a placeholder, this method needs to be implemented - return false; + // The number of rows and columns must be greater than 0 + if (rows <= 0 || columns <= 0) + return false; + + // The number of rows and columns must be equal + if (rows != columns) + return false; + + // For Sudoku, the number of rows and columns must be a perfect square + // Note: we don't need to check the columns since by this point, we have verified that the number of rows + // equals the number of columns + double sqrtRows = Math.sqrt(rows); + if (sqrtRows - Math.floor(sqrtRows) != 0) + return false; + + return true; } /** From 46ce9c8c43b3a21660219777b4f6b8d5ea5b6967 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 12:24:24 -0400 Subject: [PATCH 74/86] Various bug fixes - Fixed null panel bug when opening apuzzle for the first time - Fixed a bug where puzzle editor panel wouldn't clear properly after entering invalid dimensions - Fixed the title not changing on the home screen after returning from the puzzle editor --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 2 +- src/main/java/edu/rpi/legup/ui/HomePanel.java | 9 +++------ src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java | 2 ++ src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 2 ++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index d9b366bfc..f3acf0c33 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -94,7 +94,7 @@ public void setPuzzle(Puzzle puzzle) { public void setPuzzleEditor(Puzzle puzzle) { this.puzzle = puzzle; - this.puzzleEditor.setPuzzleView((puzzle)); + this.puzzleEditor.setPuzzleView(puzzle); // this.history.clear(); } diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index ac57bf249..48ccea450 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -135,13 +135,10 @@ private void initText() private void render() { - /* Removing this line will cause random whitespace to be added every time you return to - the home screen. However, this line does not seem to be present in other makeVisible() - methods. We should look into this in the future. - */ this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + this.legupUI.setTitle("Legup: A Better Way to Learn Formal Logic"); JPanel buttons = new JPanel(); buttons.add(Box.createRigidArea(new Dimension(5, 0))); @@ -173,18 +170,18 @@ public void openEditorWithNewPuzzle(String game, int width, int height) throws I // Set game type on the puzzle editor try { - this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); this.legupUI.displayPanel(2); + this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height); } catch (IllegalArgumentException exception) { + this.legupUI.displayPanel(0); JOptionPane.showMessageDialog(null, "The dimensions you entered are invalid. Please double check \n" + "the number of rows and columns and try again.", "ERROR: Invalid Dimensions", JOptionPane.ERROR_MESSAGE); throw new IllegalArgumentException(exception.getMessage()); - // this.legupUI.displayPanel(0); } } } diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index e18e8482e..9a2bc39ef 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -63,6 +63,8 @@ public ProofEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { @Override public void makeVisible() { + this.removeAll(); + setupToolBar(); setupContent(); frame.setJMenuBar(getMenuBar()); diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index ea1a5ac78..68bdb4c25 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -127,6 +127,8 @@ public void setMenuBar() { @Override public void makeVisible() { + this.removeAll(); + setupToolBar(); setupContent(); setMenuBar(); From a21c2a869d9796e69e45c5038b16a42dc9599f6f Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 12:33:48 -0400 Subject: [PATCH 75/86] Removed dimension validation from initializeBoard --- src/main/java/edu/rpi/legup/model/PuzzleImporter.java | 2 +- .../edu/rpi/legup/puzzle/battleship/BattleShipImporter.java | 2 +- .../java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java | 2 +- .../java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java | 2 +- .../java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java | 2 +- src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java | 2 +- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java | 2 +- .../legup/puzzle/shorttruthtable/ShortTruthTableImporter.java | 2 +- .../edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java | 2 +- src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java | 3 +-- .../java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java | 2 +- 11 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index b45fd7a13..da15a62d4 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -98,7 +98,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * @param columns number of columns on the puzzle * @throws RuntimeException */ - public abstract void initializeBoard(int rows, int columns) throws RuntimeException; + public abstract void initializeBoard(int rows, int columns); /** * Creates an empty board for building diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java index 5d86107fb..5c0789db6 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java @@ -21,7 +21,7 @@ public BattleShipImporter(BattleShip battleShip) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java index 82bb74098..99033bfbe 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -21,7 +21,7 @@ public FillapixImporter(Fillapix fillapix) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java index 5027e409c..b10a2d881 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -22,7 +22,7 @@ public HeyawakeImporter(Heyawake heyawake) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java index f8dd93518..5e6b81e83 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -21,7 +21,7 @@ public LightUpImporter(LightUp lightUp) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java index 5102cb987..f8fce426e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -21,7 +21,7 @@ public MasyuImporter(Masyu masyu) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java index a74d8bc11..c811ccc21 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -21,7 +21,7 @@ public NurikabeImporter(Nurikabe nurikabe) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index fde2c5fca..08dcaf095 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -222,7 +222,7 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java index 73607f002..e691ef80a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java @@ -21,7 +21,7 @@ public SkyscrapersImporter(Skyscrapers treeTent) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java index 2d98ecc58..64f3519a7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java @@ -21,10 +21,9 @@ public SudokuImporter(Sudoku sudoku) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { SudokuBoard sudokuBoard; int minorSize = (int) Math.sqrt(rows); - if(rows != columns || minorSize * minorSize != rows) throw new RuntimeException("Sudoku Importer: invalid board dimensions"); sudokuBoard = new SudokuBoard(rows); for (int y = 0; y < columns; y++) { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java index 1dbf11d3d..c931b642f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java @@ -21,7 +21,7 @@ public TreeTentImporter(TreeTent treeTent) { * @throws RuntimeException */ @Override - public void initializeBoard(int rows, int columns) throws RuntimeException { + public void initializeBoard(int rows, int columns) { } From af931addcedead1f2932d6a392d3aa785431bda5 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 13:19:30 -0400 Subject: [PATCH 76/86] Update GameBoardFacade.java Fixed some bad coding style --- .../java/edu/rpi/legup/app/GameBoardFacade.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index f3acf0c33..67a963555 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -125,21 +125,19 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti throw new RuntimeException("Puzzle importer null"); } - try - { - importer.initializePuzzle(rows, columns); - } - catch (IllegalArgumentException exception) - { - throw new IllegalArgumentException(exception.getMessage()); - } + importer.initializePuzzle(rows, columns); puzzle.initializeView(); // puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); setPuzzleEditor(puzzle); } + catch (IllegalArgumentException exception) + { + throw new IllegalArgumentException(exception.getMessage()); + } catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | - IllegalAccessException | InstantiationException e) { + IllegalAccessException | InstantiationException e) + { LOGGER.error(e); throw new RuntimeException("Puzzle creation error"); } From 3dd02dc1cca50e602067e17b1aa7589f305d5387 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 13:31:45 -0400 Subject: [PATCH 77/86] Throw exception for unsupported isValidDimension calls Changed the placeholder code to be throwing an exception instead of returning false --- src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java | 2 +- src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java | 2 +- src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java | 2 +- src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java | 2 +- src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java | 2 +- src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java | 2 +- .../edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java | 2 +- src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java | 2 +- src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java index e77bb7931..b1c083fd2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShip.java @@ -35,7 +35,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java index 536f3f9c2..cf6df4064 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/Fillapix.java @@ -43,7 +43,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java index e93534518..951dd5c3e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/Heyawake.java @@ -45,7 +45,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** 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 b691374cc..0053335e2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java @@ -48,7 +48,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java b/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java index 81323d1df..2134f1f90 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/Masyu.java @@ -46,7 +46,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java index dcb2df319..fbd0d3d88 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java @@ -47,7 +47,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java index 6c23b43f2..e8a23b1e9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java @@ -49,7 +49,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java index 3c4a30a12..b04fb5123 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/Skyscrapers.java @@ -51,7 +51,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java index b957c8fa8..cf5fd5fdf 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTent.java @@ -46,7 +46,7 @@ public Board generatePuzzle(int difficulty) { */ public boolean isValidDimensions(int rows, int columns) { // This is a placeholder, this method needs to be implemented - return false; + throw new UnsupportedOperationException(); } /** From 3dce476c8a883a7f7333face577ad51584e4bc0b Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 5 Jul 2022 13:36:01 -0400 Subject: [PATCH 78/86] Changed minimum number of rows and columns Requires the number of rows and columns to be greater than 1 for Sudoku --- src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java index 39064a472..f94d2290a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/Sudoku.java @@ -55,8 +55,8 @@ public Board generatePuzzle(int difficulty) { * @return true if the given dimensions are valid for Sudoku, false otherwise */ public boolean isValidDimensions(int rows, int columns) { - // The number of rows and columns must be greater than 0 - if (rows <= 0 || columns <= 0) + // The number of rows and columns must be greater than 1 + if (rows <= 1 || columns <= 1) return false; // The number of rows and columns must be equal From ae791af9829030e4d32b949ff5f8067ddd707267 Mon Sep 17 00:00:00 2001 From: Gwin <106495933+GwinProGrammer@users.noreply.github.com> Date: Thu, 7 Jul 2022 19:55:26 -0400 Subject: [PATCH 79/86] Update ZoomWidget.java --- .../java/edu/rpi/legup/ui/ZoomWidget.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java index 435521148..dded8ce23 100644 --- a/src/main/java/edu/rpi/legup/ui/ZoomWidget.java +++ b/src/main/java/edu/rpi/legup/ui/ZoomWidget.java @@ -36,24 +36,24 @@ public ZoomWidget(ScrollView parent) { /** * */ - private class PopupSlider extends JPopupMenu implements ChangeListener { - private static final long serialVersionUID = 8225019381200459814L; + private class PopupSlider extends JPopupMenu implements ChangeListener { + private static final long serialVersionUID = 8225019381200459814L; - private JSlider slider; + private JSlider slider; - public PopupSlider() { - slider = new JSlider(SwingConstants.VERTICAL, 25, 400, 100); - slider.setMajorTickSpacing(25); - slider.setPaintTicks(true); + public PopupSlider() { + slider = new JSlider(SwingConstants.VERTICAL, 0, 400, 200); + slider.setMajorTickSpacing(25); + slider.setPaintTicks(true); - add(slider); - slider.addChangeListener(this); - } + add(slider); + slider.addChangeListener(this); + } - public void stateChanged(ChangeEvent e) { - if (slider.getValueIsAdjusting()) { - parent.zoomTo((double) slider.getValue() / 100.0); + public void stateChanged(ChangeEvent e) { + if (slider.getValueIsAdjusting()) { + parent.zoomTo((double) slider.getValue() / 100.0); + } } } - } } From 7c46b0754aac8205b17d9c5e1aaa375779268a81 Mon Sep 17 00:00:00 2001 From: Gwin <106495933+GwinProGrammer@users.noreply.github.com> Date: Mon, 11 Jul 2022 01:10:45 -0400 Subject: [PATCH 80/86] Update DynamicView.java --- src/main/java/edu/rpi/legup/ui/DynamicView.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/DynamicView.java b/src/main/java/edu/rpi/legup/ui/DynamicView.java index e4014debf..671e2d428 100644 --- a/src/main/java/edu/rpi/legup/ui/DynamicView.java +++ b/src/main/java/edu/rpi/legup/ui/DynamicView.java @@ -7,9 +7,7 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseWheelEvent; +import java.awt.event.*; import java.io.IOException; import java.util.Hashtable; import java.util.Objects; @@ -76,6 +74,14 @@ public void mouseWheelMoved(MouseWheelEvent e) { zoomSlider.setPreferredSize(new Dimension(160, 30)); + scrollView.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + zoomSlider.setValue(scrollView.getZoom() ); + zoomLabel.setText(zoomSlider.getValue() + "%"); + } + }); + zoomSlider.addChangeListener((ChangeEvent e) -> { scrollView.zoomTo(zoomSlider.getValue() / 100.0); zoomLabel.setText(zoomSlider.getValue() + "%"); From ff866d871dde00d3f5ca21c361f22b4b5bcba9cd Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 12 Jul 2022 13:40:34 -0400 Subject: [PATCH 81/86] Update Controller.java Commented out debugging print statement to make console output more readable --- src/main/java/edu/rpi/legup/controller/Controller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/controller/Controller.java b/src/main/java/edu/rpi/legup/controller/Controller.java index 97a0bef92..e52b9133f 100644 --- a/src/main/java/edu/rpi/legup/controller/Controller.java +++ b/src/main/java/edu/rpi/legup/controller/Controller.java @@ -117,7 +117,7 @@ public void mouseMoved(MouseEvent e) { */ @Override public void mouseWheelMoved(MouseWheelEvent e) { - System.out.println(e.getWheelRotation()); + // System.out.println(e.getWheelRotation()); if (e.isControlDown()) { if (e.getWheelRotation() != 0){ viewer.zoom(e.getWheelRotation() * 2, e.getPoint()); From 504e5b5bf8da7581c9fd48e65bab0b7e40180d39 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 12 Jul 2022 13:53:59 -0400 Subject: [PATCH 82/86] Deleted log files --- bin/legup-2022-06-07.log.gz | Bin 7004 -> 0 bytes bin/legup-2022-06-09.log.gz | Bin 2561 -> 0 bytes bin/legup-2022-06-10.log.gz | Bin 4642 -> 0 bytes bin/legup-2022-06-14.log.gz | Bin 1737 -> 0 bytes 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bin/legup-2022-06-07.log.gz delete mode 100644 bin/legup-2022-06-09.log.gz delete mode 100644 bin/legup-2022-06-10.log.gz delete mode 100644 bin/legup-2022-06-14.log.gz diff --git a/bin/legup-2022-06-07.log.gz b/bin/legup-2022-06-07.log.gz deleted file mode 100644 index e140b16933ad85c88d372de517aa621ba4949e1a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7004 zcmXw7cRU;J^S4@~wO18YdsV4XtAf_9Mr&3PZK>2wNsZX6s`j3dplB&RHEQo,&{ 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

XkBT#zF5AhZtp|h*rR{uUmg93KYTJ$-$P078D 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 diff --git a/bin/legup-2022-06-09.log.gz b/bin/legup-2022-06-09.log.gz deleted file mode 100644 index 608b866a5173e77c6ebcc56020b3528caf2f3078..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2561 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 Xu;XE`tHp}cUnK`{FA=h^k!@P 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 From c7248b8672683366c35965db9ba1063f9c0a8f6f Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 12 Jul 2022 14:30:02 -0400 Subject: [PATCH 83/86] Update initializeBoard() comments --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 6 +++--- .../edu/rpi/legup/puzzle/battleship/BattleShipImporter.java | 4 ++-- .../edu/rpi/legup/puzzle/fillapix/FillapixImporter.java | 4 ++-- .../edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java | 4 ++-- .../java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java | 4 ++-- src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java | 4 ++-- .../edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java | 4 ++-- .../puzzle/shorttruthtable/ShortTruthTableImporter.java | 4 ++-- .../rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java | 4 ++-- .../java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java | 4 ++-- .../edu/rpi/legup/puzzle/treetent/TreeTentImporter.java | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 67a963555..240ccc090 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -105,9 +105,9 @@ public void setConfig(Config config) { /** * Loads an empty puzzle * - * @param game name of the puzzle - * @param rows width of the puzzle - * @param columns height of the puzzle + * @param game name of the puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board */ public void loadPuzzle(String game, int rows, int columns) throws RuntimeException { String qualifiedClassName = config.getPuzzleClassForName(game); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java index 5c0789db6..d48200f4e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleShipImporter.java @@ -16,8 +16,8 @@ public BattleShipImporter(BattleShip battleShip) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java index 99033bfbe..0be80324a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -16,8 +16,8 @@ public FillapixImporter(Fillapix fillapix) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java index b10a2d881..018246175 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -17,8 +17,8 @@ public HeyawakeImporter(Heyawake heyawake) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java index 5e6b81e83..aa8c8458c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -16,8 +16,8 @@ public LightUpImporter(LightUp lightUp) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java index f8fce426e..0f96d59df 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -16,8 +16,8 @@ public MasyuImporter(Masyu masyu) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java index c811ccc21..f9dfb98f5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -16,8 +16,8 @@ public NurikabeImporter(Nurikabe nurikabe) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index 08dcaf095..a372b9053 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -217,8 +217,8 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java index e691ef80a..0f009a440 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java @@ -16,8 +16,8 @@ public SkyscrapersImporter(Skyscrapers treeTent) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java index 64f3519a7..f94f516ba 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java @@ -16,8 +16,8 @@ public SudokuImporter(Sudoku sudoku) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java index c931b642f..68b8fdf70 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java @@ -16,8 +16,8 @@ public TreeTentImporter(TreeTent treeTent) { /** * Creates an empty board for building * - * @param rows width of puzzle - * @param columns height of puzzle + * @param rows the number of rows on the board + * @param columns the number of columns on the board * @throws RuntimeException */ @Override From 4993dc0d3e2cebc6e7738092acf66714a3663859 Mon Sep 17 00:00:00 2001 From: littlebizaizi Date: Tue, 12 Jul 2022 14:52:27 -0400 Subject: [PATCH 84/86] Update RuleFrame.java already increase the speed of all three kinds of rule --- .../java/edu/rpi/legup/ui/rulesview/RuleFrame.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java b/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java index ca0c4ba0b..fd7bb869e 100644 --- a/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java +++ b/src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java @@ -41,14 +41,19 @@ public RuleFrame(RuleController controller) { this.buttonGroup = new ButtonGroup(); basicRulePanel = new BasicRulePanel(this); - - tabbedPane.addTab(basicRulePanel.getName(), basicRulePanel.getIcon(), new JScrollPane(basicRulePanel), basicRulePanel.getToolTip()); + JScrollPane newbrp = new JScrollPane(basicRulePanel); + newbrp.getVerticalScrollBar().setUnitIncrement(16); + tabbedPane.addTab(basicRulePanel.getName(), basicRulePanel.getIcon(), newbrp, basicRulePanel.getToolTip()); casePanel = new CaseRulePanel(this); - tabbedPane.addTab(casePanel.name, casePanel.icon, new JScrollPane(casePanel), casePanel.toolTip); + JScrollPane newcp = new JScrollPane(casePanel); + newcp.getVerticalScrollBar().setUnitIncrement(16); + tabbedPane.addTab(casePanel.name, casePanel.icon, newcp, casePanel.toolTip); contradictionPanel = new ContradictionRulePanel(this); - tabbedPane.addTab(contradictionPanel.name, contradictionPanel.icon, new JScrollPane(contradictionPanel), contradictionPanel.toolTip); + JScrollPane newp = new JScrollPane(contradictionPanel); + newp.getVerticalScrollBar().setUnitIncrement(16); + tabbedPane.addTab(contradictionPanel.name, contradictionPanel.icon, newp, contradictionPanel.toolTip); setLayout(new BorderLayout()); setMinimumSize(new Dimension(250, 256)); From 20d7a562824e5f1c84889240ac2a206eca579d48 Mon Sep 17 00:00:00 2001 From: Hiimadd Date: Thu, 14 Jul 2022 13:42:45 -0400 Subject: [PATCH 85/86] Work from 7/12/22 --- .../rules/LastCampingSpotBasicRule.java | 13 ---- .../treetent/rules/LinkTentCaseRule.java | 11 +++- .../treetent/rules/TreeForTentBasicRule.java | 65 ++++++++++++++++++- 3 files changed, 74 insertions(+), 15 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java index 6aac4e93b..836129e17 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LastCampingSpotBasicRule.java @@ -50,19 +50,6 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem } } - // private boolean isForced(TreeTentBoard board, TreeTentCell cell) { - // List adjTents = board.getAdjacent(cell, TreeTentType.TREE); - // for (TreeTentCell c : adjTents) { - // Point loc = c.getLocation(); - // for (TreeTentLine line : board.getLines()) { - // if (line.getC1().getLocation().equals(loc) || line.getC2().getLocation().equals(loc)) { - // return false; - // } - // } - // } - // return false; - // } - private boolean isForced(TreeTentBoard board, TreeTentCell cell) { List adjTrees = board.getAdjacent(cell, TreeTentType.TREE); for (TreeTentCell c : adjTrees) { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LinkTentCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LinkTentCaseRule.java index 851e668fd..92b567531 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LinkTentCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/LinkTentCaseRule.java @@ -5,6 +5,9 @@ import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.CaseRule; import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.treetent.TreeTentBoard; +import edu.rpi.legup.puzzle.treetent.TreeTentType; +import edu.rpi.legup.puzzle.treetent.TreeTentCell; import java.util.ArrayList; @@ -18,7 +21,13 @@ public LinkTentCaseRule() { @Override public CaseBoard getCaseBoard(Board board) { - return null; + TreeTentBoard treeTentBoard = (TreeTentBoard) board.copy(); + treeTentBoard.setModifiable(false); + CaseBoard caseBoard = new CaseBoard(treeTentBoard, this); + for(PuzzleElement element : treeTentBoard.getPuzzleElements()) { + if(((TreeTentCell) element).getType() == TreeTentType.TENT) {caseBoard.addPickableElement(element);} + } + return caseBoard; } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TreeForTentBasicRule.java b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TreeForTentBasicRule.java index d1cf01a9b..f68d85e38 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TreeForTentBasicRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/rules/TreeForTentBasicRule.java @@ -1,10 +1,15 @@ package edu.rpi.legup.puzzle.treetent.rules; +import java.util.List; import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.PuzzleElement; import edu.rpi.legup.model.rules.BasicRule; import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.treetent.TreeTentLine; +import edu.rpi.legup.puzzle.treetent.TreeTentBoard; +import edu.rpi.legup.puzzle.treetent.TreeTentType; +import edu.rpi.legup.puzzle.treetent.TreeTentCell; public class TreeForTentBasicRule extends BasicRule { public TreeForTentBasicRule() { @@ -24,7 +29,65 @@ public TreeForTentBasicRule() { */ @Override public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) { - return null; + if (!(puzzleElement instanceof TreeTentLine)) { + return super.getInvalidUseOfRuleMessage() + ": Lines must be created for this rule."; + } + TreeTentBoard board = (TreeTentBoard)transition.getBoard(); + TreeTentLine line = (TreeTentLine)board.getPuzzleElement(puzzleElement); + TreeTentCell tree,tent; + if (line.getC1().getType() == TreeTentType.TREE && line.getC2().getType() == TreeTentType.TENT) { + tree = line.getC1(); + tent = line.getC2(); + } else if (line.getC2().getType() == TreeTentType.TREE && line.getC1().getType() == TreeTentType.TENT) { + tree = line.getC2(); + tent = line.getC1(); + } else { + return super.getInvalidUseOfRuleMessage() + ": This line must connect a tree to a tent."; + } + int forced = isForced(board, tree, tent); + if(forced == 1) + { + return null; + } + else if (forced == -1) + { + return super.getInvalidUseOfRuleMessage() + ": This tent already has a link"; + } + else if (forced == -2) + { + return super.getInvalidUseOfRuleMessage() + ": This tree already has a link"; + } + else + { + return super.getInvalidUseOfRuleMessage() + ": This tree and tent don't need to be linked."; + } + } + + private Integer isForced(TreeTentBoard board, TreeTentCell tree, TreeTentCell tent) + { + List adjTrees = board.getAdjacent(tent, TreeTentType.TREE); + adjTrees.remove(tree); + List lines = board.getLines(); + for(TreeTentLine l : lines) + { + if(l.getC1().getLocation().equals(tree.getLocation()) || l.getC2().getLocation().equals(tree.getLocation())) {return -2;} + for(TreeTentCell c : adjTrees) + { + if(l.getC1().getLocation().equals(c.getLocation())) + { + if(l.getC2().getLocation().equals(tent.getLocation())) {return -1;} + adjTrees.remove(c); + + } + else if(l.getC2().getLocation().equals(c.getLocation())) + { + if(l.getC1().getLocation().equals(tent.getLocation())) {return -1;} + adjTrees.remove(c); + } + } + } + if(adjTrees.size() == 0) {return 1;} + else {return 0;} } /** From e0752bba26f9a86dfc4bf0ca2bfe5df94ad3d5d6 Mon Sep 17 00:00:00 2001 From: Matthew Sweet <98288154+mattsweet417@users.noreply.github.com> Date: Sat, 16 Jul 2022 14:20:28 -0400 Subject: [PATCH 86/86] Merged dev fixes with puzzle editor design --- src/main/java/edu/rpi/legup/ui/LegupUI.java | 1 + .../edu/rpi/legup/ui/PreferencesDialog.java | 6 +- .../edu/rpi/legup/ui/ProofEditorPanel.java | 222 +++++++++++------- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 16 +- 4 files changed, 153 insertions(+), 92 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index be2dfac90..8bca7f663 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -4,6 +4,7 @@ import java.awt.event.*; import java.io.*; import java.security.InvalidParameterException; +import java.util.Objects; import javax.swing.*; diff --git a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java index 8c5fae3b0..78d6cf72d 100644 --- a/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java +++ b/src/main/java/edu/rpi/legup/ui/PreferencesDialog.java @@ -36,8 +36,8 @@ public class PreferencesDialog extends JDialog { } } - public PreferencesDialog(LegupUI legupUI) { - super(legupUI); + public PreferencesDialog(Frame frame) { + super(frame); setTitle("Preferences"); @@ -76,7 +76,7 @@ public PreferencesDialog(LegupUI legupUI) { setContentPane(mainPanel); setSize(600, 400); - setLocationRelativeTo(legupUI); + setLocationRelativeTo(frame); setVisible(true); } diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 9a2bc39ef..ffeaa994b 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -34,6 +34,7 @@ import java.net.URI; import java.net.URL; import java.util.List; +import java.util.Objects; public class ProofEditorPanel extends LegupPanel implements IHistoryListener { private final static Logger LOGGER = LogManager.getLogger(ProofEditorPanel.class.getName()); @@ -45,14 +46,49 @@ public class ProofEditorPanel extends LegupPanel implements IHistoryListener { private DynamicView dynamicBoardView; private JSplitPane topHalfPanel, mainPanel; private TitledBorder boardBorder; + private JButton[] toolBarButtons; + private JMenu file; + private JMenuItem newPuzzle, resetPuzzle, saveProof, preferences, exit; + private JMenu edit; + private JMenuItem undo, redo; + + private JMenu view; + + private JMenu proof; + private JMenuItem add, delete, merge, collapse; + private JCheckBoxMenuItem allowDefault, caseRuleGen, imdFeedback; + + private JMenu about, help; + private JMenuItem helpLegup, aboutLegup; + private JToolBar toolBar; private BoardView boardView; private JFileChooser folderBrowser; - private JMenuItem undo, redo; + private LegupUI legupUI; + public static final int ALLOW_HINTS = 1; + public static final int ALLOW_DEFAPP = 2; + public static final int ALLOW_FULLAI = 4; + public static final int ALLOW_JUST = 8; + public static final int REQ_STEP_JUST = 16; + public static final int IMD_FEEDBACK = 32; + public static final int INTERN_RO = 64; + public static final int AUTO_JUST = 128; final static int[] TOOLBAR_SEPARATOR_BEFORE = {2, 4, 8}; + private static final String[] PROFILES = {"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}; + private JMenu proofMode = new JMenu("Proof Mode"); + private JCheckBoxMenuItem[] proofModeItems = new JCheckBoxMenuItem[PROF_FLAGS.length]; + + private static int CONFIG_INDEX = 0; + + protected JMenu ai = new JMenu("AI"); + protected JMenuItem runAI = new JMenuItem("Run AI to completion"); + protected JMenuItem setpAI = new JMenuItem("Run AI one Step"); + protected JMenuItem testAI = new JMenuItem("Test AI!"); + protected JMenuItem hintAI = new JMenuItem("Hint"); public ProofEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.fileDialog = fileDialog; @@ -71,76 +107,76 @@ public void makeVisible() { } public JMenuBar getMenuBar() { + if(mBar != null) return mBar; mBar = new JMenuBar(); - JMenu file = new JMenu("File"); - JMenuItem newPuzzle = new JMenuItem("Open"); - JMenuItem resetPuzzle = new JMenuItem("Reset Puzzle"); + file = new JMenu("File"); + newPuzzle = new JMenuItem("Open"); + resetPuzzle = new JMenuItem("Reset Puzzle"); // genPuzzle = new JMenuItem("Puzzle Generators"); - JMenuItem saveProof = new JMenuItem("Save Proof"); - JMenuItem preferences = new JMenuItem("Preferences"); - JMenuItem exit = new JMenuItem("Exit"); + saveProof = new JMenuItem("Save Proof"); + preferences = new JMenuItem("Preferences"); + exit = new JMenuItem("Exit"); - JMenu edit = new JMenu("Edit"); + edit = new JMenu("Edit"); undo = new JMenuItem("Undo"); redo = new JMenuItem("Redo"); - JMenu view = new JMenu("View"); + view = new JMenu("View"); - JMenu proof = new JMenu("Proof"); + proof = new JMenu("Proof"); String os = LegupUI.getOS(); - JMenuItem add = new JMenuItem("Add"); + add = new JMenuItem("Add"); add.addActionListener(a -> treePanel.add()); if(os.equals("mac")) add.setAccelerator(KeyStroke.getKeyStroke('A', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else add.setAccelerator(KeyStroke.getKeyStroke('A', InputEvent.CTRL_DOWN_MASK)); proof.add(add); - JMenuItem delete = new JMenuItem("Delete"); + delete = new JMenuItem("Delete"); delete.addActionListener(a -> treePanel.delete()); if(os.equals("mac")) delete.setAccelerator(KeyStroke.getKeyStroke('D', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else delete.setAccelerator(KeyStroke.getKeyStroke('D', InputEvent.CTRL_DOWN_MASK)); proof.add(delete); - JMenuItem merge = new JMenuItem("Merge"); + merge = new JMenuItem("Merge"); merge.addActionListener(a -> treePanel.merge()); if(os.equals("mac")) merge.setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else merge.setAccelerator(KeyStroke.getKeyStroke('M', InputEvent.CTRL_DOWN_MASK)); proof.add(merge); - JMenuItem collapse = new JMenuItem("Collapse"); + collapse = new JMenuItem("Collapse"); collapse.addActionListener(a -> treePanel.collapse()); if(os.equals("mac")) collapse.setAccelerator(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); else collapse.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK)); collapse.setEnabled(false); proof.add(collapse); - JCheckBoxMenuItem allowDefault = new JCheckBoxMenuItem("Allow Default Rule Applications", + allowDefault = new JCheckBoxMenuItem("Allow Default Rule Applications", LegupPreferences.getInstance().getUserPref(LegupPreferences.ALLOW_DEFAULT_RULES).equalsIgnoreCase(Boolean.toString(true))); allowDefault.addChangeListener(e -> { LegupPreferences.getInstance().setUserPref(LegupPreferences.ALLOW_DEFAULT_RULES, Boolean.toString(allowDefault.isSelected())); }); proof.add(allowDefault); - JCheckBoxMenuItem caseRuleGen = new JCheckBoxMenuItem("Automatically generate cases for CaseRule", + caseRuleGen = new JCheckBoxMenuItem("Automatically generate cases for CaseRule", LegupPreferences.getInstance().getUserPref(LegupPreferences.AUTO_GENERATE_CASES).equalsIgnoreCase(Boolean.toString(true))); caseRuleGen.addChangeListener(e -> { LegupPreferences.getInstance().setUserPref(LegupPreferences.AUTO_GENERATE_CASES, Boolean.toString(caseRuleGen.isSelected())); }); proof.add(caseRuleGen); - JCheckBoxMenuItem imdFeedback = new JCheckBoxMenuItem("Provide immediate feedback", + imdFeedback = new JCheckBoxMenuItem("Provide immediate feedback", LegupPreferences.getInstance().getUserPref(LegupPreferences.IMMEDIATE_FEEDBACK).equalsIgnoreCase(Boolean.toString(true))); imdFeedback.addChangeListener(e -> { LegupPreferences.getInstance().setUserPref(LegupPreferences.IMMEDIATE_FEEDBACK, Boolean.toString(imdFeedback.isSelected())); }); proof.add(imdFeedback); - JMenu about = new JMenu("About"); - JMenuItem checkUpdates = new JMenuItem("Check for Updates..."); - JMenuItem helpLegup = new JMenuItem("Help Legup"); - JMenuItem aboutLegup = new JMenuItem("About Legup"); + about = new JMenu("About"); + helpLegup = new JMenuItem("Help Legup"); + aboutLegup = new JMenuItem("About Legup"); // unused // help = new JMenu("Help"); @@ -185,9 +221,9 @@ public JMenuBar getMenuBar() { else saveProof.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_DOWN_MASK)); file.add(preferences); -// preferences.addActionListener(a -> { -// PreferencesDialog preferencesDialog = new PreferencesDialog(this); -// }); + preferences.addActionListener(a -> { + PreferencesDialog preferencesDialog = new PreferencesDialog(this.frame); + }); file.addSeparator(); file.add(exit); @@ -210,17 +246,11 @@ public JMenuBar getMenuBar() { { GameBoardFacade.getInstance().getHistory().redo(); }); - if(os.equals("mac")) redo.setAccelerator(KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - else redo.setAccelerator(KeyStroke.getKeyStroke('Y', InputEvent.CTRL_DOWN_MASK)); + if(os.equals("mac")) redo.setAccelerator(KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + InputEvent.SHIFT_DOWN_MASK)); + else redo.setAccelerator(KeyStroke.getKeyStroke('Z', InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); mBar.add(proof); - about.add(checkUpdates); - checkUpdates.addActionListener(l -> { - //checkUpdates(); - }); - checkUpdates.setEnabled(false); - about.add(aboutLegup); aboutLegup.addActionListener(l -> { JOptionPane.showMessageDialog(null, "Version: 2.0.0"); @@ -249,13 +279,19 @@ public void promptPuzzle() { } } - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setTitle("Select Puzzle"); - fileDialog.setVisible(true); + folderBrowser = new JFileChooser(); + + folderBrowser.showOpenDialog(this); + folderBrowser.setVisible(true); + folderBrowser.setCurrentDirectory(new java.io.File(".")); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.FILES_ONLY); + folderBrowser.setAcceptAllFileFilterUsed(true); + String fileName = null; - File puzzleFile = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + File puzzleFile = folderBrowser.getSelectedFile(); + if (folderBrowser.getCurrentDirectory() != null && folderBrowser.getSelectedFile().getName() != null) { + fileName = puzzleFile.getAbsolutePath()+ File.separator; puzzleFile = new File(fileName); } @@ -266,6 +302,10 @@ public void promptPuzzle() { frame.setTitle(puzzleName + " - " + puzzleFile.getName()); } catch (InvalidFileFormatException e) { LOGGER.error(e.getMessage()); + if (e.getMessage().contains("Proof Tree construction error: could not find rule by ID")) // TO DO: make error message not hardcoded + JOptionPane.showMessageDialog(null, "This file runs on an outdated version of Legup\nand is not compatible with the current version.", "Error", JOptionPane.ERROR_MESSAGE); + else + JOptionPane.showMessageDialog(null, "File does not exist or it cannot be read", "Error", JOptionPane.ERROR_MESSAGE); } } } @@ -308,12 +348,10 @@ private void saveProof() { } } + //ask to edu.rpi.legup.save current proof public boolean noquit(String instr) { int n = JOptionPane.showConfirmDialog(null, instr, "Confirm", JOptionPane.YES_NO_CANCEL_OPTION); - if (n == JOptionPane.YES_OPTION) { - return false; - } - return true; + return n != JOptionPane.YES_OPTION; } /** @@ -357,7 +395,7 @@ protected void setupContent() { // popupPanel.setVisible(true); mainPanel.setDividerLocation(mainPanel.getMaximumDividerLocation() + 100); - //frame.pack(); +// frame.pack(); revalidate(); } @@ -390,10 +428,10 @@ private void setupToolBar() { getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER); } - toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); - //toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); - toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); - toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); +// toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); +// toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); +// toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); +// toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> { }); toolBarButtons[ToolbarName.CHECK.ordinal()].addActionListener((ActionEvent e) -> checkProof()); @@ -404,9 +442,9 @@ private void setupToolBar() { toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].addActionListener((ActionEvent e) -> checkProofAll()); - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); @@ -473,8 +511,9 @@ public void setPuzzleView(Puzzle puzzle) { dynamicBoardView = new DynamicView(boardView); this.topHalfPanel.setRightComponent(dynamicBoardView); this.topHalfPanel.setVisible(true); - - TitledBorder titleBoard = BorderFactory.createTitledBorder(boardView.getClass().getSimpleName()); + String boardType = boardView.getBoard().getClass().getSimpleName(); + boardType = boardType.substring(0, boardType.indexOf("Board")); + TitledBorder titleBoard = BorderFactory.createTitledBorder(boardType + " Board"); titleBoard.setTitleJustification(TitledBorder.CENTER); dynamicBoardView.setBorder(titleBoard); @@ -489,7 +528,7 @@ public void setPuzzleView(Puzzle puzzle) { ruleFrame.getContradictionPanel().setRules(puzzle.getContradictionRules()); toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true); - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); +// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); reloadGui(); } @@ -508,7 +547,7 @@ public void repaintTree() { private void checkProofAll() { GameBoardFacade facade = GameBoardFacade.getInstance(); - /** + /* * Select dir to grade; recursively grade sub-dirs using traverseDir() * Selected dir must have sub-dirs for each student: * GradeThis @@ -516,44 +555,52 @@ private void checkProofAll() { * | -> Student 1 * | | * | | -> Proofs - **/ + */ folderBrowser = new JFileChooser(); + + folderBrowser.showOpenDialog(this); + folderBrowser.setVisible(true); folderBrowser.setCurrentDirectory(new java.io.File(".")); folderBrowser.setDialogTitle("Select Directory"); folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folderBrowser.setAcceptAllFileFilterUsed(false); - folderBrowser.showOpenDialog(this); + File folder = folderBrowser.getSelectedFile(); - // Write csv file (Path,File-Name,Score,Solved?) + // Write csv file (Path,File-Name,Puzzle-Type,Score,Solved?) File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { - writer.append("Name,File Name,Score,Solved?\n"); + writer.append("Name,File Name,Puzzle Type,Score,Solved?\n"); // Go through student folders - for (final File folderEntry : folder.listFiles(File::isDirectory)) { + for (final File folderEntry : Objects.requireNonNull(folder.listFiles(File::isDirectory))) { // Write path String path = folderEntry.getName(); traverseDir(folderEntry, writer, path); } }catch (IOException ex){ - //LOGGER.error(ex.getMessage()); + LOGGER.error(ex.getMessage()); } JOptionPane.showMessageDialog(null, "Batch grading complete."); } + private boolean basicCheckProof(int[][] origCells) { + return false; + } + private void traverseDir(File folder, BufferedWriter writer, String path) throws IOException { // Recursively traverse directory GameBoardFacade facade = GameBoardFacade.getInstance(); // Folder is empty - if(folder.listFiles().length == 0) { - writer.append(path + ",Empty folder,0,Ungradeable\n"); + if(Objects.requireNonNull(folder.listFiles()).length == 0) { + writer.append(path).append(",Empty folder,,Ungradeable\n"); return; } // Travese directory, recurse if sub-directory found - for(final File f : folder.listFiles()) { + // If ungradeable, do not leave a score (0, 1) + for(final File f : Objects.requireNonNull(folder.listFiles())) { // Recurse if(f.isDirectory()) { traverseDir(f, writer, path + "/" + f.getName()); @@ -561,14 +608,14 @@ private void traverseDir(File folder, BufferedWriter writer, String path) throws } // Set path name - writer.append(path + ","); + writer.append(path).append(","); // Load puzzle, run checker // If wrong file type, ungradeable String fName = f.getName(); String fPath = f.getAbsolutePath(); File puzzleFile = new File(fPath); - if(puzzleFile != null && puzzleFile.exists()) { + if(puzzleFile.exists()) { // Try to load file. If invalid, note in csv try { // Load puzzle, run checker @@ -579,11 +626,14 @@ private void traverseDir(File folder, BufferedWriter writer, String path) throws Puzzle puzzle = facade.getPuzzleModule(); // Write data - writer.append(fName + ","); - if(puzzle.isPuzzleComplete()) writer.append("1,Solved\n"); - else writer.append("0,Unsolved\n"); + writer.append(fName).append(","); + writer.append(puzzle.getName()).append(","); + if (puzzle.isPuzzleComplete()) + writer.append("1,Solved\n"); + else + writer.append("0,Unsolved\n"); } catch (InvalidFileFormatException e) { - writer.append(fName + " - invalid type,0,Ungradeable\n"); + writer.append(fName).append(",Invalid,,Ungradeable\n"); } } else { LOGGER.debug("Failed to run sim"); @@ -612,9 +662,9 @@ public TreePanel getTreePanel() { public void onPushChange(ICommand command) { LOGGER.info("Pushing " + command.getClass().getSimpleName() + " to stack."); undo.setEnabled(true); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true); redo.setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); @@ -627,9 +677,9 @@ public void onPushChange(ICommand command) { @Override public void onClearHistory() { undo.setEnabled(false); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); redo.setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); } /** @@ -641,9 +691,9 @@ public void onClearHistory() { @Override public void onRedo(boolean isBottom, boolean isTop) { undo.setEnabled(!isBottom); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); redo.setEnabled(!isTop); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); if (isBottom) { String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); @@ -664,16 +714,14 @@ public void onRedo(boolean isBottom, boolean isTop) { @Override public void onUndo(boolean isBottom, boolean isTop) { undo.setEnabled(!isBottom); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom); redo.setEnabled(!isTop); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop); + String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); + File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); if (isBottom) { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); frame.setTitle(puzzleName + " - " + puzzleFile.getName()); } else { - String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); - File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName()); frame.setTitle(puzzleName + " - " + puzzleFile.getName() + " *"); } } @@ -700,4 +748,16 @@ private void submit() { Submission submit = new Submission(board); } } + + private void directions() { + JOptionPane.showMessageDialog(null, "For every move you make, you must provide a rule for it (located in the Rules panel).\n" + "While working on the edu.rpi.legup.puzzle, you may click on the \"Check\" button to test your proof for correctness.", "Directions", JOptionPane.PLAIN_MESSAGE); + } + + public void errorEncountered(String error) { + JOptionPane.showMessageDialog(null, error); + } + + public void showStatus(String status, boolean error, int timer) { + // TODO: implement + } } diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index 68bdb4c25..92dd83df9 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -162,10 +162,10 @@ private void setupToolBar() { getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER); } - toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); - //toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); - toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); - toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); +// toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle()); +// toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof()); +// toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo()); +// toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo()); toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> { }); toolBarButtons[ToolbarName.SUBMIT.ordinal()].addActionListener((ActionEvent e) -> { @@ -173,9 +173,9 @@ private void setupToolBar() { toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].addActionListener((ActionEvent e) -> { }); - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); - toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false); +// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false); toolBarButtons[ToolbarName.DIRECTIONS.ordinal()].setEnabled(false); @@ -277,7 +277,7 @@ public void setPuzzleView(Puzzle puzzle) { elementFrame.getPlaceableElementPanel().setElements(puzzle.getPlaceableElements()); toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true); - toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); +// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true); } }