diff --git a/src/main/java/armameeldoparti/controllers/AnchoragesController.java b/src/main/java/armameeldoparti/controllers/AnchoragesController.java index e804dc6..ebd831a 100644 --- a/src/main/java/armameeldoparti/controllers/AnchoragesController.java +++ b/src/main/java/armameeldoparti/controllers/AnchoragesController.java @@ -115,10 +115,7 @@ public void newAnchorageButtonEvent(Component parentComponent) { } if (!validAnchoredPlayersAmount(playersToAnchorAmount)) { - CommonFunctions.showErrorMessage( - "No puede haber más de " + Constants.MAX_ANCHORED_PLAYERS + " jugadores anclados en total", - parentComponent - ); + CommonFunctions.showErrorMessage("No puede haber más de " + Constants.MAX_ANCHORED_PLAYERS + " jugadores anclados en total", parentComponent); return; } diff --git a/src/main/java/armameeldoparti/controllers/NamesInputController.java b/src/main/java/armameeldoparti/controllers/NamesInputController.java index 6cbfa2a..4b7a9a8 100644 --- a/src/main/java/armameeldoparti/controllers/NamesInputController.java +++ b/src/main/java/armameeldoparti/controllers/NamesInputController.java @@ -389,8 +389,6 @@ private boolean validString(String string) { * @return Whether the given name is valid. */ private boolean validName(String name) { - return !name.isBlank() - && name.length() <= Constants.MAX_NAME_LEN - && !alreadyExists(name); + return !name.isBlank() && name.length() <= Constants.MAX_NAME_LEN && !alreadyExists(name); } } \ No newline at end of file diff --git a/src/main/java/armameeldoparti/models/Team.java b/src/main/java/armameeldoparti/models/Team.java index c00b96a..4a98d62 100644 --- a/src/main/java/armameeldoparti/models/Team.java +++ b/src/main/java/armameeldoparti/models/Team.java @@ -49,9 +49,7 @@ public void clear() { } /** - * Gets the amount of players in this team. - * - * @return The amount of players in this team. + * @return The amount of players in the team. */ public int getPlayersCount() { return teamPlayers.values() @@ -61,8 +59,6 @@ public int getPlayersCount() { } /** - * Gets the team skill points accumulated so far. - * * @return The team skill points accumulated so far. */ public int getTeamSkill() { @@ -78,7 +74,7 @@ public int getTeamSkill() { * * @param position The position of the set to check. * - * @return Whether the position set in the team is full. + * @return Whether the specified position set in the team is full. */ public boolean isPositionFull(Position position) { return teamPlayers.get(position) diff --git a/src/main/java/armameeldoparti/utils/common/CommonFunctions.java b/src/main/java/armameeldoparti/utils/common/CommonFunctions.java index 7407d58..13548aa 100644 --- a/src/main/java/armameeldoparti/utils/common/CommonFunctions.java +++ b/src/main/java/armameeldoparti/utils/common/CommonFunctions.java @@ -67,13 +67,7 @@ public static void exitProgram(Error error) { * @param parentComponent Graphical component where the dialogs associated with the event should be displayed. */ public static void showErrorMessage(String errorMessage, Component parentComponent) { - JOptionPane.showMessageDialog( - parentComponent, - errorMessage, - Constants.ERROR_MESSAGE_TITLE, - JOptionPane.ERROR_MESSAGE, - null - ); + JOptionPane.showMessageDialog(parentComponent, errorMessage, Constants.ERROR_MESSAGE_TITLE, JOptionPane.ERROR_MESSAGE, null); } /** @@ -136,11 +130,10 @@ public static String buildMigLayoutConstraints(String... constraints) { * @return The given string with the first letter uppercase and the rest lowercase. */ public static String capitalize(String input) { - return input.isBlank() ? input - : input.substring(0, 1) - .toUpperCase() - + input.substring(1) - .toLowerCase(); + return input.isBlank() ? input : input.substring(0, 1) + .toUpperCase() + + input.substring(1) + .toLowerCase(); } /** diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomArrowButton.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomArrowButton.java index c1194d4..e98c94b 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomArrowButton.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomArrowButton.java @@ -27,7 +27,7 @@ public class CustomArrowButton extends BasicArrowButton { /** * Builds a basic arrow button pointing up or down, using the established program aesthetics. * - * @param orientation The text to display on the button. + * @param orientation The arrow button orientation. */ public CustomArrowButton(int orientation) { super(orientation); diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomComboBox.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomComboBox.java index 9da4db7..6abfa5c 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomComboBox.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomComboBox.java @@ -58,14 +58,7 @@ protected void paintComponent(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.fillRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.fillRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); super.paintComponent(g); @@ -77,14 +70,7 @@ protected void paintBorder(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.drawRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.drawRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); } @@ -183,14 +169,7 @@ public void paintComponent(Graphics g) { g2.setColor(getBackground()); g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); - g2.fillRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_COMBOBOX, - Constants.ROUNDED_BORDER_ARC_COMBOBOX - ); + g2.fillRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_COMBOBOX, Constants.ROUNDED_BORDER_ARC_COMBOBOX); g2.dispose(); super.paintComponent(g); diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomLabel.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomLabel.java index 698489c..5a6685a 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomLabel.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomLabel.java @@ -40,14 +40,7 @@ protected void paintComponent(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.fillRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.fillRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); super.paintComponent(g); @@ -61,14 +54,7 @@ protected void paintBorder(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.drawRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.drawRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); } diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomScrollPane.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomScrollPane.java index d2c3425..90a4791 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomScrollPane.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomScrollPane.java @@ -45,14 +45,7 @@ protected void paintBorder(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(Constants.COLOR_GREEN_LIGHT_WHITE); - g2.fillRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.fillRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); } diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomSeparator.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomSeparator.java index 3588a66..96416b6 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomSeparator.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomSeparator.java @@ -25,13 +25,6 @@ protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); - g2.fillRoundRect( - 0, - getHeight() / 2, - getWidth(), - 5, - Constants.ROUNDED_BORDER_ARC_SEPARATOR, - Constants.ROUNDED_BORDER_ARC_SEPARATOR - ); + g2.fillRoundRect(0, getHeight() / 2, getWidth(), 5, Constants.ROUNDED_BORDER_ARC_SEPARATOR, Constants.ROUNDED_BORDER_ARC_SEPARATOR); } } \ No newline at end of file diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextArea.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextArea.java index e4732eb..d0030da 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextArea.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextArea.java @@ -8,13 +8,15 @@ * Custom text area class. * *

This class is used to instantiate a custom text area that fits the overall program aesthetics. It is supposed to be used along with a - * CustomScrollPane to ensure its correct display. + * custom scroll pane to ensure its correct display. * * @author Bonino, Francisco Ignacio. * * @version 0.0.1 * * @since 3.0 + * + * @see armameeldoparti.utils.common.custom.graphical.CustomScrollPane */ public class CustomTextArea extends JTextArea { diff --git a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextField.java b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextField.java index c92c6a3..1c8dba7 100644 --- a/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextField.java +++ b/src/main/java/armameeldoparti/utils/common/custom/graphical/CustomTextField.java @@ -43,14 +43,7 @@ protected void paintComponent(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.fillRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.fillRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); super.paintComponent(g); @@ -64,14 +57,7 @@ protected void paintBorder(Graphics g) { g2.setRenderingHints(Constants.MAP_RENDERING_HINTS); g2.setColor(getBackground()); - g2.drawRoundRect( - 0, - 0, - (getWidth() - 1), - (getHeight() - 1), - Constants.ROUNDED_BORDER_ARC_GENERAL, - Constants.ROUNDED_BORDER_ARC_GENERAL - ); + g2.drawRoundRect(0, 0, (getWidth() - 1), (getHeight() - 1), Constants.ROUNDED_BORDER_ARC_GENERAL, Constants.ROUNDED_BORDER_ARC_GENERAL); g2.dispose(); } diff --git a/src/main/java/armameeldoparti/utils/mixers/BySkillPointsMixer.java b/src/main/java/armameeldoparti/utils/mixers/BySkillPointsMixer.java index 7f31b3d..804f61d 100644 --- a/src/main/java/armameeldoparti/utils/mixers/BySkillPointsMixer.java +++ b/src/main/java/armameeldoparti/utils/mixers/BySkillPointsMixer.java @@ -171,8 +171,8 @@ private void distributeSubsets(List teams, List playersSet, Positi int currentPositionPlayersPerTeam = playersSet.size() / 2; - for (int i = 0; i < currentPositionPlayersPerTeam; i++) { - playersSubsets.add(Arrays.asList(playersSet.get(i), playersSet.get(playersSet.size() - 1 - i))); + for (int playerIndex = 0; playerIndex < currentPositionPlayersPerTeam; playerIndex++) { + playersSubsets.add(Arrays.asList(playersSet.get(playerIndex), playersSet.get(playersSet.size() - 1 - playerIndex))); } // Subsets sorted lowest to highest diff --git a/src/main/java/armameeldoparti/utils/mixers/RandomMixer.java b/src/main/java/armameeldoparti/utils/mixers/RandomMixer.java index 6510a81..4e5f0fc 100644 --- a/src/main/java/armameeldoparti/utils/mixers/RandomMixer.java +++ b/src/main/java/armameeldoparti/utils/mixers/RandomMixer.java @@ -46,8 +46,7 @@ public RandomMixer() { /** * Distributes the players randomly without considering anchorages. * - *

Half of the players of each players-set are randomly assigned a team number. The rest of the players are assigned to the - * opposing team number. + *

Half of the players of each players-set are randomly assigned a team number. The rest of the players are assigned to the opposing team number. * * @param teams Teams where to distribute the players. * @@ -197,7 +196,7 @@ private void shuffleTeamNumbers(int range) { * @param team Team where the player should be added. * @param player The players to add. * - * @return If a player can be added to a team. + * @return Whether a player can be added to the specified team. */ private boolean playerCanBeAdded(Team team, Player player) { return !team.isPositionFull(player.getPosition()); diff --git a/src/main/java/armameeldoparti/views/AnchoragesView.java b/src/main/java/armameeldoparti/views/AnchoragesView.java index 5f63ed1..b62fc56 100644 --- a/src/main/java/armameeldoparti/views/AnchoragesView.java +++ b/src/main/java/armameeldoparti/views/AnchoragesView.java @@ -131,12 +131,11 @@ protected void addButtons() { * Adds the players checkboxes and their position labels. */ private void addCheckBoxes() { - Map positionsMap = CommonFields.getPositionsMap(); - CommonFields.getPlayersSets() .forEach((position, playersSet) -> { fillCheckboxesSet(playersSet, checkboxesMap.get(position)); - addCheckboxesSet(checkboxesMap.get(position), CommonFunctions.capitalize(positionsMap.get(position))); + addCheckboxesSet(checkboxesMap.get(position), CommonFunctions.capitalize(CommonFields.getPositionsMap() + .get(position))); }); } diff --git a/src/main/java/armameeldoparti/views/HelpView.java b/src/main/java/armameeldoparti/views/HelpView.java index 3daba99..abfc0dd 100644 --- a/src/main/java/armameeldoparti/views/HelpView.java +++ b/src/main/java/armameeldoparti/views/HelpView.java @@ -74,8 +74,7 @@ protected void addButtons() { .split()); masterPanel.add(nextPageButton, new CC().width("50%") .wrap()); - masterPanel.add(backButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWX, - Constants.MIG_LAYOUT_SPAN)); + masterPanel.add(backButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWX, Constants.MIG_LAYOUT_SPAN)); } // ---------------------------------------------------------------- Private methods ---------------------------------------------------------------- diff --git a/src/main/java/armameeldoparti/views/MainMenuView.java b/src/main/java/armameeldoparti/views/MainMenuView.java index de51e41..ab30ab4 100644 --- a/src/main/java/armameeldoparti/views/MainMenuView.java +++ b/src/main/java/armameeldoparti/views/MainMenuView.java @@ -69,18 +69,9 @@ protected void addButtons() { */ private void addBackground() { addBackgroundImage(); - addBackgroundLabel(Constants.SIZE_FONT_TITLE_LABEL, - Constants.PROGRAM_TITLE, - Constants.MIG_LAYOUT_ALIGN_CENTER, - Constants.COLOR_GREEN_DARK); - addBackgroundLabel(Constants.SIZE_FONT_AUTHOR_LABEL, - Constants.PROGRAM_AUTHOR, - Constants.MIG_LAYOUT_ALIGN_CENTER, - Color.WHITE); - addBackgroundLabel(Constants.SIZE_FONT_VERSION_LABEL, - Constants.PROGRAM_VERSION, - Constants.MIG_LAYOUT_ALIGN_RIGHT, - Constants.COLOR_GREEN_DARK); + addBackgroundLabel(Constants.SIZE_FONT_TITLE_LABEL, Constants.PROGRAM_TITLE, Constants.MIG_LAYOUT_ALIGN_CENTER, Constants.COLOR_GREEN_DARK); + addBackgroundLabel(Constants.SIZE_FONT_AUTHOR_LABEL, Constants.PROGRAM_AUTHOR, Constants.MIG_LAYOUT_ALIGN_CENTER, Color.WHITE); + addBackgroundLabel(Constants.SIZE_FONT_VERSION_LABEL, Constants.PROGRAM_VERSION, Constants.MIG_LAYOUT_ALIGN_RIGHT, Constants.COLOR_GREEN_DARK); } /** diff --git a/src/main/java/armameeldoparti/views/NamesInputView.java b/src/main/java/armameeldoparti/views/NamesInputView.java index ce230ef..e9994c5 100644 --- a/src/main/java/armameeldoparti/views/NamesInputView.java +++ b/src/main/java/armameeldoparti/views/NamesInputView.java @@ -87,8 +87,7 @@ public NamesInputView() { @Override protected void initializeInterface() { - leftPanel.add(leftTopPanel, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWY, - Constants.MIG_LAYOUT_PUSHY)); + leftPanel.add(leftTopPanel, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWY, Constants.MIG_LAYOUT_PUSHY)); leftPanel.add(leftBottomPanel, Constants.MIG_LAYOUT_SOUTH); masterPanel.add(leftPanel, Constants.MIG_LAYOUT_WEST); @@ -190,8 +189,7 @@ private void addRadioButtons() { CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWX, Constants.MIG_LAYOUT_PUSHX)); leftBottomPanel.add(radioButtonRandom); leftBottomPanel.add(radioButtonBySkillPoints); - leftBottomPanel.add(new CustomSeparator(), - CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWX, Constants.MIG_LAYOUT_PUSHX)); + leftBottomPanel.add(new CustomSeparator(), CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROWX, Constants.MIG_LAYOUT_PUSHX)); } // -------------------------------------------------------------------- Getters -------------------------------------------------------------------- diff --git a/src/main/java/armameeldoparti/views/SkillPointsInputView.java b/src/main/java/armameeldoparti/views/SkillPointsInputView.java index 9203c37..104e87a 100644 --- a/src/main/java/armameeldoparti/views/SkillPointsInputView.java +++ b/src/main/java/armameeldoparti/views/SkillPointsInputView.java @@ -71,12 +71,9 @@ protected void addButtons() { finishButton = new CustomButton("Finalizar", Constants.ROUNDED_BORDER_ARC_GENERAL); resetSkillPointsButton = new CustomButton("Reiniciar puntuaciones", Constants.ROUNDED_BORDER_ARC_GENERAL); - masterPanel.add(finishButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, - Constants.MIG_LAYOUT_SPAN)); - masterPanel.add(resetSkillPointsButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, - Constants.MIG_LAYOUT_SPAN)); - masterPanel.add(backButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, - Constants.MIG_LAYOUT_SPAN)); + masterPanel.add(finishButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, Constants.MIG_LAYOUT_SPAN)); + masterPanel.add(resetSkillPointsButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, Constants.MIG_LAYOUT_SPAN)); + masterPanel.add(backButton, CommonFunctions.buildMigLayoutConstraints(Constants.MIG_LAYOUT_GROW, Constants.MIG_LAYOUT_SPAN)); } // ---------------------------------------------------------------- Private methods ----------------------------------------------------------------