Skip to content

Commit

Permalink
Reformatted code to fit CheckStyle requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestian23 committed Aug 11, 2022
1 parent 9b63078 commit f4799ac
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement_request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Enhancement request
description: Improve an already-existing feature
title: "[ENHANCEMENT] <description>"
labels: [enhancement]
labels: [ enhancement ]
body:
- type: textarea
id: current_behavior
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Feature request
description: Suggest an idea for this project
title: "[FEATURE] <description>"
<<<<<<< HEAD
labels: [new feature]
=======
<<<<<<< HEAD
labels: [ new feature ]
=======
labels: [ enhancement, new feature ]
>>>>>>> b28ba6c38166142ecd457ffee2797fffc89a51b4
>>>>>>> b28ba6c38166142ecd457ffee2797fffc89a51b4
body:
- type: textarea
id: description
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/edu/rpi/legup/app/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<String> getPuzzleClassNames() {
/**
* Returns a list of the names of the puzzles which can have puzzles created and edited
* within the proof editor.
*
* @return the aforementioned list of Strings
*/
public List<String> getFileCreationEnabledPuzzles() {
Expand All @@ -67,34 +68,38 @@ public List<String> getFileCreationEnabledPuzzles() {
*/
public static String convertClassNameToDisplayName(String className) {
String displayName = "";
for (int i = 0; i < className.length(); i++)
{
if (Character.isUpperCase(className.charAt(i)) && i != 0)
for (int i = 0; i < className.length(); i++) {
if (Character.isUpperCase(className.charAt(i)) && i != 0) {
displayName += " ";
}
displayName += className.charAt(i);
}
return displayName;
}

public static String convertDisplayNameToClassName(String displayName) {
String className = "";
for (int i = 0; i < displayName.length(); i++)
if (displayName.charAt(i) != ' ')
for (int i = 0; i < displayName.length(); i++) {
if (displayName.charAt(i) != ' ') {
className += displayName;
}
}
return className;
}

public List<String> getPuzzleNames() {
List<String> names = new LinkedList<String>();
for (String puzzle : this.getPuzzleClassNames())
for (String puzzle : this.getPuzzleClassNames()) {
names.add(Config.convertClassNameToDisplayName(puzzle));
}
return names;
}

public List<String> getFileCreationEnabledPuzzleNames() {
List<String> names = new LinkedList<String>();
for (String puzzle : this.getFileCreationEnabledPuzzles())
for (String puzzle : this.getFileCreationEnabledPuzzles()) {
names.add(Config.convertClassNameToDisplayName(puzzle));
}
return names;
}

Expand Down
31 changes: 17 additions & 14 deletions src/main/java/edu/rpi/legup/controller/ElementController.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void mouseReleased(MouseEvent e) {
if (treeView != null) {
selection = treeView.getSelection();
}
// funny
// funny
if (elementView != null) {
if (board instanceof CaseBoard) {
CaseBoard caseBoard = (CaseBoard) board;
Expand All @@ -113,31 +113,34 @@ public void mouseReleased(MouseEvent e) {
}
}
}
else if (selection != null){
ICommand edit = new EditDataCommand(elementView, selection, e);
if (edit.canExecute()) {
edit.execute();
getInstance().getHistory().pushChange(edit);
if (treePanel != null) {
treePanel.updateError("");
else {
if (selection != null) {
ICommand edit = new EditDataCommand(elementView, selection, e);
if (edit.canExecute()) {
edit.execute();
getInstance().getHistory().pushChange(edit);
if (treePanel != null) {
treePanel.updateError("");
}
}
}
else {
if (treePanel != null) {
treePanel.updateError(edit.getError());
else {
if (treePanel != null) {
treePanel.updateError(edit.getError());
}
}
}
}
}
if (selectedElement != null) {
GridBoard b = (GridBoard) this.boardView.getBoard();
Point point = e.getPoint();
Point scaledPoint = new Point((int) Math.floor(point.x / (30*this.boardView.getScale())), (int) Math.floor(point.y / (30*this.boardView.getScale())));
Point scaledPoint = new Point((int) Math.floor(point.x / (30 * this.boardView.getScale())), (int) Math.floor(point.y / (30 * this.boardView.getScale())));
System.out.printf("selected Element is NOT null, attempting to change board at (%d, %d)\n", scaledPoint.x, scaledPoint.y);
System.out.println("Before: " + b.getCell(scaledPoint.x, scaledPoint.y).getData());
b.setCell(scaledPoint.x, scaledPoint.y, this.selectedElement, e);
System.out.println("After: " + b.getCell(scaledPoint.x, scaledPoint.y).getData());
} else {
}
else {
System.out.println("selected Element is null!");
}
boardView.repaint();
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,36 @@ public NurikabeType getType() {
public void setType(Element e, MouseEvent m) {
if (e.getElementName().equals("Black Tile")) {
this.data = -1;
} else if (e.getElementName().equals("White Tile")) {
this.data = 0;
} else if (e.getElementName().equals("Number Tile")) {
if(m.getButton() == MouseEvent.BUTTON1) {
if(this.data <= 0 || this.data > 8) this.data = 1;
else this.data = this.data + 1;
}
else {
if (e.getElementName().equals("White Tile")) {
this.data = 0;
}
else if(m.getButton() == MouseEvent.BUTTON3) {
if(this.data > 1) this.data = this.data - 1;
else this.data = 9;
else {
if (e.getElementName().equals("Number Tile")) {
if (m.getButton() == MouseEvent.BUTTON1) {
if (this.data <= 0 || this.data > 8) {
this.data = 1;
}
else {
this.data = this.data + 1;
}
}
else {
if (m.getButton() == MouseEvent.BUTTON3) {
if (this.data > 1) {
this.data = this.data - 1;
}
else {
this.data = 9;
}
}
}
}
else { // unknown tile
this.data = -2;
}
}
} else { // unknown tile
this.data = -2;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public NurikabeExporter(Nurikabe nurikabe) {
@Override
protected org.w3c.dom.Element createBoardElement(Document newDocument) {
NurikabeBoard board;
if(puzzle.getTree() != null) {
if (puzzle.getTree() != null) {
board = (NurikabeBoard) puzzle.getTree().getRootNode().getBoard();
}
else {
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/edu/rpi/legup/ui/DynamicView.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,29 @@ public DynamicView(ScrollView scrollView, DynamicViewType type) {

/**
* Sets up the zoomer for the given DynamicViewType
*
* @param type The DynamicView that we are setting up the zoomer for (so
* the zoomer for the board view or the zoomer for the proof
* tree view)
* @return A JPanel containing the zoomer
*/
private JPanel setUpZoomer(DynamicViewType type) {
if (type == DynamicViewType.BOARD)
if (type == DynamicViewType.BOARD) {
return setUpBoardZoomer();
else if (type == DynamicViewType.PROOF_TREE)
return setUpProofTreeZoomer();
}
else {
if (type == DynamicViewType.PROOF_TREE) {
return setUpProofTreeZoomer();
}
}

// Should never reach here; if you reach here, that's a problem!
return null;
}

/**
* Sets up the zoomer for the board view
*
* @return A JPanel containing the zoomer
*/
private JPanel setUpBoardZoomer() {
Expand All @@ -68,6 +74,7 @@ private JPanel setUpBoardZoomer() {

/**
* Sets up the zoomer for the proof tree view
*
* @return A JPanel containing the zoomer
*/
private JPanel setUpProofTreeZoomer() {
Expand All @@ -78,8 +85,9 @@ private JPanel setUpProofTreeZoomer() {

/**
* Creates the zoomer
* @param label A string containing the label to be displayed
* on the fit to screen button
*
* @param label A string containing the label to be displayed
* on the fit to screen button
* @param listener A listener that determines what the resize
* button will do
* @return A JPanel containing the zoomer
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ public JMenuBar getMenuBar() {
public Object[] promptPuzzle() {
GameBoardFacade facade = GameBoardFacade.getInstance();
if (facade.getBoard() != null) {
if (noquit("Opening a new puzzle?")) // !noquit or noquit?
{
if (noquit("Opening a new puzzle?")) {
return new Object[0];
}
}
Expand All @@ -344,16 +343,14 @@ public Object[] promptPuzzle() {
return new Object[]{fileName, puzzleFile};
}

public void loadPuzzle()
{
public void loadPuzzle() {
Object[] items = promptPuzzle();
String fileName = (String) items[0];
File puzzleFile = (File) items[1];
loadPuzzle(fileName, puzzleFile);
}

public void loadPuzzle(String fileName, File puzzleFile)
{
public void loadPuzzle(String fileName, File puzzleFile) {
if (puzzleFile != null && puzzleFile.exists()) {
try {
GameBoardFacade.getInstance().loadPuzzle(fileName);
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public void loadPuzzleFromHome(String game, int rows, int columns) throws Illega
public Object[] promptPuzzle() {
GameBoardFacade facade = GameBoardFacade.getInstance();
if (facade.getBoard() != null) {
if (noQuit("Opening a new puzzle to edit?")) // !noquit or noquit?
{
if (noQuit("Opening a new puzzle to edit?")) {
return new Object[0];
}
}
Expand All @@ -260,16 +259,14 @@ public Object[] promptPuzzle() {
return new Object[]{fileName, puzzleFile};
}

public void loadPuzzle()
{
public void loadPuzzle() {
Object[] items = promptPuzzle();
String fileName = (String) items[0];
File puzzleFile = (File) items[1];
loadPuzzle(fileName, puzzleFile);
}

public void loadPuzzle(String fileName, File puzzleFile)
{
public void loadPuzzle(String fileName, File puzzleFile) {
if (puzzleFile != null && puzzleFile.exists()) {
try {
GameBoardFacade.getInstance().loadPuzzleEditor(fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void setUp() {
public void HorizontalValidTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/battleship/rules" +
"/FinishWithShipsBasicRuleTests/HorizontalValidBoard",
battleship);
battleship);
TreeNode rootNode = battleship.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand All @@ -38,7 +38,7 @@ public void HorizontalValidTest() throws InvalidFileFormatException {
public void VerticaValidTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/battleship/rules" +
"/FinishWithShipsBasicRuleTests/VerticalValidBoard",
battleship);
battleship);
TreeNode rootNode = battleship.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand All @@ -50,7 +50,7 @@ public void VerticaValidTest() throws InvalidFileFormatException {
public void HorizontalInvalidTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/battleship/rules" +
"/FinishWithShipsBasicRuleTests/HorizontalInvalidBoard",
battleship);
battleship);
TreeNode rootNode = battleship.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand All @@ -62,7 +62,7 @@ public void HorizontalInvalidTest() throws InvalidFileFormatException {
public void VerticalInvalidTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/battleship/rules" +
"/FinishWithShipsBasicRuleTests/VerticalInvalidBoard",
battleship);
battleship);
TreeNode rootNode = battleship.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand Down

0 comments on commit f4799ac

Please sign in to comment.