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 0a2fce0
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 147 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 @@ -216,8 +216,7 @@ protected void setUpListeners() {
textField.getText());
} catch (IllegalArgumentException | InvalidNameException ex) {
CommonFunctions.showErrorMessage(
ex instanceof IllegalArgumentException ? Constants.MSG_ERROR_INVALID_STRING
: Constants.MSG_ERROR_INVALID_NAME,
ex instanceof IllegalArgumentException ? Constants.MSG_ERROR_INVALID_STRING : Constants.MSG_ERROR_INVALID_NAME,
CommonFunctions.getComponentFromEvent(e)
);

Expand Down Expand Up @@ -389,8 +388,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);
}
}
10 changes: 4 additions & 6 deletions src/main/java/armameeldoparti/controllers/ResultsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public void remixButtonEvent() {
/**
* Fills the table with the distribution results.
*
* <p>The table cells are filled trusting the positions order in the first column (same order as the positions enum).
* <p>The table cells are filled trusting the positions order in the first column (same order as the Position enum).
*
* @see armameeldoparti.models.Position
*/
public void updateTable() {
var wrapper = new Object() {
Expand Down Expand Up @@ -248,11 +250,7 @@ private void fillTableFields() {

if (CommonFields.getDistribution() == Constants.MIX_BY_SKILL_POINTS) {
for (int colIndex = 0; colIndex < teams.size(); colIndex++) {
table.setValueAt(
colIndex == 0 ? positionsMap.get(Position.GOALKEEPER) : "Puntuación del equipo",
table.getRowCount() + colIndex - 2,
0
);
table.setValueAt(colIndex == 0 ? positionsMap.get(Position.GOALKEEPER) : "Puntuación del equipo", table.getRowCount() + colIndex - 2, 0);
}
} else {
table.setValueAt(positionsMap.get(Position.GOALKEEPER), table.getRowCount() - 1, 0);
Expand Down
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 @@ -7,14 +7,16 @@
/**
* 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.
* <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 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 Expand Up @@ -46,7 +48,7 @@ public Insets getInsets() {
return Constants.INSETS_GENERAL;
}

// --------------------------------------------------------------- Private methods -----------------------------------
// --------------------------------------------------------------- Private methods -----------------------------------------------------------------

/**
* Configures the graphical properties for the text area in order to fit the program aesthetics.
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
16 changes: 8 additions & 8 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 All @@ -213,7 +212,7 @@ private boolean playerCanBeAdded(Team team, Player player) {
* @param team Team where the anchored players should be added.
* @param anchoredPlayers List containing the players with the same anchorage number.
*
* @return If a set of anchored players can be added to a team.
* @return Whether a set of anchored players can be added to a team.
*/
private boolean anchorageCanBeAdded(Team team, List<Player> anchoredPlayers) {
return !(anchorageOverflowsTeamSize(team, anchoredPlayers) || anchorageOverflowsAnyPositionSet(team, anchoredPlayers));
Expand All @@ -225,7 +224,7 @@ private boolean anchorageCanBeAdded(Team team, List<Player> anchoredPlayers) {
* @param team Team to check if the anchored players can be added.
* @param anchoredPlayers Anchored players to check.
*
* @return If the amount of anchored players to be added to a team would exceed the maximum allowed amount of players per team.
* @return Whether the amount of anchored players to be added to a team would exceed the maximum allowed amount of players per team.
*/
private boolean anchorageOverflowsTeamSize(Team team, List<Player> anchoredPlayers) {
return team.getPlayersCount() + anchoredPlayers.size() > Constants.PLAYERS_PER_TEAM;
Expand All @@ -237,7 +236,8 @@ private boolean anchorageOverflowsTeamSize(Team team, List<Player> anchoredPlaye
* @param team Team to check if the anchored players can be added.
* @param anchoredPlayers Anchored players to check.
*
* @return If the amount of anchored players to be added to a team would exceed the maximum allowed amount of players per team in any position set.
* @return Whether the amount of anchored players to be added to a team would exceed the maximum allowed amount of players per team in any position
* set.
*/
private boolean anchorageOverflowsAnyPositionSet(Team team, List<Player> anchoredPlayers) {
return anchoredPlayers.stream()
Expand All @@ -253,8 +253,8 @@ private boolean anchorageOverflowsAnyPositionSet(Team team, List<Player> anchore
* @param anchoredPlayers Anchored players to check.
* @param position Anchored players position.
*
* @return If the amount of anchored players to be added to a position set in a team would exceed the maximum allowed amount of players per team for
* that particular position.
* @return Whether the amount of anchored players to be added to a position set in a team would exceed the maximum allowed amount of players per
* team for that particular position.
*/
private boolean anchorageOverflowsPositionSet(Team team, List<Player> anchoredPlayers, Position position) {
return team.getTeamPlayers()
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/armameeldoparti/views/AnchoragesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,17 @@ protected void addButtons() {
rightPanel.add(clearAnchoragesButton, Constants.MIG_LAYOUT_GROW);
}

// ---------------------------------------------------------------- Private methods ------------------------------------------------------------------------
// ---------------------------------------------------------------- Private methods ----------------------------------------------------------------

/**
* 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
Loading

0 comments on commit 0a2fce0

Please sign in to comment.