Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jan 7, 2024
1 parent 4c843b6 commit ac39d5c
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 2 additions & 6 deletions src/main/java/armameeldoparti/models/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() {
Expand All @@ -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)
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/armameeldoparti/utils/common/CommonFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
* Custom text area class.
*
* <p>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 {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private void distributeSubsets(List<Team> teams, List<Player> 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
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/armameeldoparti/utils/mixers/RandomMixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public RandomMixer() {
/**
* Distributes the players randomly without considering anchorages.
*
* <p>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.
* <p>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.
*
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/armameeldoparti/views/AnchoragesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@ protected void addButtons() {
* Adds the players checkboxes and their position labels.
*/
private void addCheckBoxes() {
Map<Position, String> 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)));
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/armameeldoparti/views/HelpView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------------------
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/armameeldoparti/views/MainMenuView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/armameeldoparti/views/NamesInputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 --------------------------------------------------------------------
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/armameeldoparti/views/SkillPointsInputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------------------
Expand Down

0 comments on commit ac39d5c

Please sign in to comment.