Skip to content

Commit

Permalink
fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jan 7, 2024
1 parent 7f3ffc5 commit 4c843b6
Show file tree
Hide file tree
Showing 35 changed files with 222 additions and 250 deletions.
22 changes: 10 additions & 12 deletions src/main/java/armameeldoparti/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
public final class Main {

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Empty, private constructor.
Expand All @@ -57,7 +57,7 @@ private Main() {
// Body not needed
}

// ---------------------------------------- Main entry point ----------------------------------
// --------------------------------------------------------------- Main entry point ----------------------------------------------------------------

/**
* Starts the program by initializing the fields needed along with the program's graphical properties, and making the main menu
Expand Down Expand Up @@ -87,7 +87,7 @@ public static void main(String[] args) {
SwingUtilities.invokeLater(((MainMenuController) CommonFunctions.getController(ProgramView.MAIN_MENU))::showView);
}

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

/**
* Populates the players sets with empty players.
Expand All @@ -104,17 +104,15 @@ private static void populatePlayersSets() {
/**
* Gets the number of players for each position per team using regular expressions.
*
* <p>{@code [CLMFG].+>.+}: Retrieves the lines that start with C, L, M, F, or G, followed by at least one '>' character (these
* are the lines that matters in the .pda file).
* <p>{@code [CLMFG].+>.+}: Retrieves the lines that start with C, L, M, F, or G, followed by at least one '>' character (these are the lines that
* matters in the .pda file).
*
* <p>{@code (?!(?<=X)\\d).}: Gets the part of the line that is not a number that we are interested in (the number would take
* the place of the X).
* <p>{@code (?!(?<=X)\\d).}: Gets the part of the line that is not a number that we are interested in (the number would take the place of the X).
*
* <p>If the .pda file is modified in terms of the order of the important lines, it must be taken into account that
* {@code Position.values()[index]} trusts that what is found corresponds to the order in which the values in the Position enum
* are declared. Idem, if the order of the Position enum values are changed, it should be noted that
* {@code Position.values()[index]} trusts the order in which the data will be retrieved from the .pda file and, therefore, you
* should review the order of the important lines in the file.
* <p>If the .pda file is modified in terms of the order of the important lines, it must be taken into account that {@code Position.values()[index]}
* trusts that what is found corresponds to the order in which the values in the Position enum are declared. Idem, if the order of the Position enum
* values are changed, it should be noted that {@code Position.values()[index]} trusts the order in which the data will be retrieved from the .pda
* file and, therefore, you should review the order of the important lines in the file.
*/
private static void setPlayersDistribution() {
try (BufferedReader buff = new BufferedReader(
Expand Down
33 changes: 15 additions & 18 deletions src/main/java/armameeldoparti/controllers/AnchoragesController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/
public class AnchoragesController extends Controller<AnchoragesView> {

// ---------------------------------------- Private fields ------------------------------------
// ---------------------------------------------------------------- Private fields -----------------------------------------------------------------

private int anchoragesAmount;
private int anchoredPlayersAmount;

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Builds the anchorages view controller.
Expand All @@ -44,7 +44,7 @@ public AnchoragesController(AnchoragesView anchoragesView) {
toggleButtons();
}

// ---------------------------------------- Public methods ------------------------------------
// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------

/**
* Updates the checkboxes text with the players names.
Expand Down Expand Up @@ -138,8 +138,7 @@ public void deleteLastAnchorageButtonEvent() {
}

/**
* Prompts the user for the number of the anchorage to delete, and removes it, updating the text area and the state of the
* buttons.
* Prompts the user for the number of the anchorage to delete, and removes it, updating the text area and the state of the buttons.
*
* @param parentComponent Graphical component where the dialogs associated with the event should be displayed.
*/
Expand Down Expand Up @@ -173,8 +172,8 @@ public void clearAnchoragesButtonEvent() {
}

/**
* Makes the controlled view invisible, deletes every anchorage made, resets the controlled view to its default state and shows
* the names input view.
* Makes the controlled view invisible, deletes every anchorage made, resets the controlled view to its default state and shows the names input
* view.
*/
public void backButtonEvent() {
hideView();
Expand All @@ -184,13 +183,13 @@ public void backButtonEvent() {
.showView();
}

// ---------------------------------------- Protected methods ---------------------------------
// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------

/**
* Resets the controlled view to its default values.
*
* <p>Clears every anchorage made, updating the text area and the state of the buttons, and the checkboxes that were selected
* whose players were not anchored, are deselected.
* <p>Clears every anchorage made, updating the text area and the state of the buttons, and the checkboxes that were selected whose players were not
* anchored, are deselected.
*/
@Override
protected void resetView() {
Expand Down Expand Up @@ -225,7 +224,7 @@ protected void setUpListeners() {
.addActionListener(e -> backButtonEvent());
}

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

/**
* Sets a new anchorage based on the players checked.
Expand Down Expand Up @@ -345,9 +344,8 @@ private void clearAnchorages() {
/**
* Deletes a specific anchorage.
*
* <p>The players that have the specified anchorage, now will have anchorage number 0. If the anchorage number to delete is not
* the last one, then the remaining players (from {@code anchorageToDelete + 1} to {@code anchoragesAmount}) will have their
* anchorage number decreased by 1.
* <p>The players that have the specified anchorage, now will have anchorage number 0. If the anchorage number to delete is not the last one, then
* the remaining players (from {@code anchorageToDelete + 1} to {@code anchoragesAmount}) will have their anchorage number decreased by 1.
*
* @param anchorageToDelete Anchorage number to delete.
*/
Expand All @@ -366,8 +364,8 @@ private void deleteAnchorage(int anchorageToDelete) {
/**
* Changes the anchorage number of certain players.
*
* <p>If the replacement is 0 (an anchorage must be removed), then those players will be set as not-anchored, the players
* corresponding checkboxes will be visible and enabled again, and the anchored players amount will be decreased as needed.
* <p>If the replacement is 0 (an anchorage must be removed), then those players will be set as not-anchored, the players corresponding checkboxes
* will be visible and enabled again, and the anchored players amount will be decreased as needed.
*
* @param target Anchorage number to replace.
* @param replacement New anchorage number to set.
Expand Down Expand Up @@ -401,8 +399,7 @@ private void changeAnchorage(int target, int replacement) {
}

/**
* The checkboxes that were selected whose players were not anchored, are deselected. Then, shows the corresponding following
* view.
* The checkboxes that were selected whose players were not anchored, are deselected. Then, shows the corresponding following view.
*/
private void finish() {
hideView();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/armameeldoparti/controllers/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
public abstract class Controller<T extends View> {

// ---------------------------------------- Protected fields ----------------------------------
// --------------------------------------------------------------- Protected fields ----------------------------------------------------------------

protected T view;

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Builds the view controller.
Expand All @@ -31,7 +31,7 @@ protected Controller(T view) {
setView(view);
}

// ---------------------------------------- Protected methods ---------------------------------
// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------

/**
* Centers the controlled view on the current active monitor.
Expand Down Expand Up @@ -65,7 +65,7 @@ protected void showView() {
view.setVisible(true);
}

// ---------------------------------------- Abstract protected methods ------------------------
// ---------------------------------------------------------- Abstract protected methods -----------------------------------------------------------

/**
* Resets the controlled view to its default values.
Expand All @@ -82,13 +82,13 @@ protected void showView() {
*/
protected abstract void setUpListeners();

// ---------------------------------------- Getters -------------------------------------------
// -------------------------------------------------------------------- Getters --------------------------------------------------------------------

protected T getView() {
return view;
}

// ---------------------------------------- Setters -------------------------------------------
// -------------------------------------------------------------------- Setters --------------------------------------------------------------------

protected void setView(T view) {
this.view = view;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/armameeldoparti/controllers/HelpController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
*/
public class HelpController extends Controller<HelpView> {

// ---------------------------------------- Private constants ---------------------------------
// --------------------------------------------------------------- Private constants ---------------------------------------------------------------

private static final int TOTAL_HELP_PAGES = Constants.MAP_HELP_PAGES_FILES
.size();

// ---------------------------------------- Private fields ------------------------------------
// ---------------------------------------------------------------- Private fields -----------------------------------------------------------------

private int currentPageNumber;

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Builds the help view controller.
Expand All @@ -46,7 +46,7 @@ public HelpController(HelpView helpView) {
setUpInitialState();
}

// ---------------------------------------- Public methods ------------------------------------
// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------

/**
* Resets the page to the beginning, makes the controlled view invisible and shows the main menu view.
Expand Down Expand Up @@ -127,7 +127,7 @@ public void updatePage() {
}
}

// ---------------------------------------- Protected methods ---------------------------------
// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------

@Override
protected void resetView() {
Expand Down Expand Up @@ -155,7 +155,7 @@ protected void setUpListeners() {
.addActionListener(e -> backButtonEvent());
}

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

/**
* Updates the reading progress label text.
Expand All @@ -175,13 +175,13 @@ private void resetButtons() {
.setEnabled(true);
}

// ---------------------------------------- Getters -------------------------------------------
// -------------------------------------------------------------------- Getters --------------------------------------------------------------------

public int getCurrentPageNumber() {
return currentPageNumber;
}

// ---------------------------------------- Setters -------------------------------------------
// -------------------------------------------------------------------- Setters --------------------------------------------------------------------

public void setCurrentPageNumber(int currentPageNumber) {
this.currentPageNumber = currentPageNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class MainMenuController extends Controller<MainMenuView> {

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Builds the main menu view controller.
Expand All @@ -28,7 +28,7 @@ public MainMenuController(MainMenuView mainMenuView) {
setUpListeners();
}

// ---------------------------------------- Public methods ------------------------------------
// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------

@Override
public void showView() {
Expand Down Expand Up @@ -71,7 +71,7 @@ public void issuesButtonEvent() {
CommonFunctions.browserRedirect(Constants.URL_ISSUES);
}

// ---------------------------------------- Protected methods ---------------------------------
// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------

@Override
protected void resetView() {
Expand Down
30 changes: 13 additions & 17 deletions src/main/java/armameeldoparti/controllers/NamesInputController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class NamesInputController extends Controller<NamesInputView> {

// ---------------------------------------- Constructor ---------------------------------------
// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------

/**
* Builds the names input view controller.
Expand All @@ -42,7 +42,7 @@ public NamesInputController(NamesInputView namesInputView) {
setUpInitialState();
}

// ---------------------------------------- Public methods ------------------------------------
// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------

/**
* Resets the combobox to the initial state and gives it the view focus.
Expand All @@ -55,8 +55,8 @@ public void resetComboBox() {
}

/**
* Resets the controlled view to its default values, turns the anchorages flags to false, makes the controlled view invisible
* and shows the main menu view.
* Resets the controlled view to its default values, turns the anchorages flags to false, makes the controlled view invisible and shows the main
* menu view.
*/
public void backButtonEvent() {
resetView();
Expand All @@ -68,8 +68,7 @@ public void backButtonEvent() {
}

/**
* Asks the user for the players distribution method, makes the controlled view invisible and shows the corresponding following
* view.
* Asks the user for the players distribution method, makes the controlled view invisible and shows the corresponding following view.
*
* @param parentComponent Graphical component where the dialogs associated with the event should be displayed.
*/
Expand Down Expand Up @@ -100,12 +99,10 @@ public void mixButtonEvent(Component parentComponent) {
}

/**
* Validates the user input with a regular expression that checks if the string contains only latin characters from A to Z
* including Ñ, uppercase or lowercase, with or without accent mark, with or without spaces. If the input is not valid or
* already exists, the program asks for a new input.
* Validates the user input with a regular expression that checks if the string contains only latin characters from A to Z including Ñ, uppercase or
* lowercase, with or without accent mark, with or without spaces. If the input is not valid or already exists, the program asks for a new input.
*
* <p>If the input is valid, it will be applied as a player name in the players set corresponding to the combobox selected
* option.
* <p>If the input is valid, it will be applied as a player name in the players set corresponding to the combobox selected option.
*
* @param playerIndex The index of the player which name will be the text filed input.
* @param playersSet The set of players corresponding to the selected combobox option.
Expand Down Expand Up @@ -145,21 +142,20 @@ public void comboBoxEvent(String selectedOption) {
}

/**
* Since there can be only one distribution method at a time: if one radio button is selected, the other is unselected
* automatically. Then, if the conditions are met, the mix button is enabled.
* Since there can be only one distribution method at a time: if one radio button is selected, the other is unselected automatically. Then, if the
* conditions are met, the mix button is enabled.
*
* @param e Radio button click event.
*/
public void radioButtonEvent(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
(e.getSource() == view.getRadioButtonRandom() ? view.getRadioButtonBySkillPoints()
: view.getRadioButtonRandom()).setSelected(false);
(e.getSource() == view.getRadioButtonRandom() ? view.getRadioButtonBySkillPoints() : view.getRadioButtonRandom()).setSelected(false);
}

validateMixButtonEnable();
}

// ---------------------------------------- Protected methods ---------------------------------
// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------

@Override
protected void resetView() {
Expand Down Expand Up @@ -256,7 +252,7 @@ protected void showView() {
view.setVisible(true);
}

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

/**
* The mix button is enabled only when every condition needed to distribute the players is met.
Expand Down
Loading

0 comments on commit 4c843b6

Please sign in to comment.