diff --git a/README.md b/README.md index bbcae0e5..c4dc57f3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![buildBadge](https://github.com/akmsw/armame-el-doparti/actions/workflows/maven.yml/badge.svg?branch=develop-v3.0)](https://github.com/akmsw/armame-el-doparti/actions/workflows/maven.yml) [![issuesBadge](https://img.shields.io/github/issues/akmsw/armame-el-doparti.svg?logo=github)](https://github.com/akmsw/armame-el-doparti/issues) -[![checkStyleBadge](https://img.shields.io/badge/checkstyle%2010.12.0-passing-brightgreen)](https://checkstyle.sourceforge.io/) +[![checkStyleBadge](https://img.shields.io/badge/checkstyle%2010.12.1-passing-brightgreen)](https://checkstyle.sourceforge.io/) [![sonarLintBadge](https://img.shields.io/badge/sonarlint-3-yellow?logo=sonarlint)](https://www.sonarlint.org/) [![jUnit5Badge](https://img.shields.io/badge/junit%205.9.2-passing-brightgreen?logo=junit5)](https://junit.org/junit5/) @@ -116,11 +116,7 @@ No se pueden anclar a un mismo equipo todos los jugadores de un mismo tipo (por - Seleccionalo como opción predeterminada para la ejecución de archivos .jar ## 🔜 Próximamente -Si querés estar al tanto de qué cambios están planeados para las próximas versiones, te dejo acá los links a los proyectos: -- [v3.1](https://github.com/users/akmsw/projects/10/views/1) -- [v4.0](https://github.com/users/akmsw/projects/7/views/1) -- [v4.1](https://github.com/users/akmsw/projects/8/views/1) -- [v5.0](https://github.com/users/akmsw/projects/9/views/1) +Si querés estar al tanto de qué cambios están planeados para las próximas versiones, [acá](https://github.com/akmsw?query=is%3Aopen+sort%3Atitle-asc&tab=projects) vas a poder ver los detalles y metas planificadas. ## ⚠️ Reportes y sugerencias Si el programa presenta algún error que debería ser reportado para arreglarlo, si se te ocurrió alguna nueva funcionalidad para agregar al programa, o si opinás que algo podría ser modificado, la sección de [issues](https://github.com/akmsw/armame-el-doparti/issues) está abierta para que hagas estos reportes y/o sugerencias. Es necesario tener una cuenta en GitHub para abrir un nuevo reporte en el repositorio. Para poder trabajar en eso lo más rápidamente posible, te proveo unas plantillas para cada caso donde te pido toda la información que necesito. diff --git a/src/main/java/armameeldoparti/controllers/AnchoragesController.java b/src/main/java/armameeldoparti/controllers/AnchoragesController.java index 4c5918fa..1fee3bbc 100644 --- a/src/main/java/armameeldoparti/controllers/AnchoragesController.java +++ b/src/main/java/armameeldoparti/controllers/AnchoragesController.java @@ -1,6 +1,7 @@ package armameeldoparti.controllers; import armameeldoparti.models.Player; +import armameeldoparti.models.Position; import armameeldoparti.models.ProgramView; import armameeldoparti.utils.common.CommonFields; import armameeldoparti.utils.common.CommonFunctions; @@ -8,6 +9,7 @@ import armameeldoparti.views.AnchoragesView; import java.awt.Component; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import javax.swing.JCheckBox; import javax.swing.JOptionPane; @@ -65,7 +67,21 @@ public void resetView() { * Updates the checkboxes text with the players names. */ public void updateCheckBoxesText() { - ((AnchoragesView) getView()).updateCheckBoxesText(); + Map> checkBoxesMap = ((AnchoragesView) getView()).getCheckBoxesMap(); + + for (Position position : Position.values()) { + for (int i = 0; i < CommonFields.getPlayersSets() + .get(position) + .size(); i++) { + checkBoxesMap.get(position) + .get(i) + .setText(CommonFields.getPlayersSets() + .get(position) + .get(i) + .getName()); + } + } + getView().pack(); } diff --git a/src/main/java/armameeldoparti/controllers/ResultsController.java b/src/main/java/armameeldoparti/controllers/ResultsController.java index e4b465ae..6c6b41df 100644 --- a/src/main/java/armameeldoparti/controllers/ResultsController.java +++ b/src/main/java/armameeldoparti/controllers/ResultsController.java @@ -33,6 +33,11 @@ public class ResultsController extends Controller { // ---------------------------------------- Private constants --------------------------------- + /** + * Fixed table cells width (in pixels). This value depends on the program's font and the maximum + * player name length. + */ + private static final int FIXED_CELL_WIDTH = 250; private static final int TABLE_COLUMNS = 3; /** @@ -105,9 +110,7 @@ public void setUp() { setTableFormat(); fillTableFields(); updateTable(); - - ((ResultsView) getView()).setTableCellsSize(); - + setTableCellsSize(); getView().pack(); } @@ -215,6 +218,32 @@ public List bySkillsMix() { // ---------------------------------------- Private methods ----------------------------------- + /** + * Sets the ideal table cells size. + */ + public void setTableCellsSize() { + JTable table = ((ResultsView) getView()).getTable(); + + for (int column = 0; column < table.getColumnCount(); column++) { + table.getColumnModel() + .getColumn(column) + .setPreferredWidth(FIXED_CELL_WIDTH); + } + + for (int i = 0; i < table.getRowCount(); i++) { + int rowHeight = table.getRowHeight(); + + for (int j = 0; j < table.getColumnCount(); j++) { + Component component = table.prepareRenderer(table.getCellRenderer(i, j), i, j); + + rowHeight = Math.max(rowHeight, component.getPreferredSize() + .height); + } + + table.setRowHeight(i, rowHeight); + } + } + /** * Sets the table cells format, including text alignment and background and foreground colors. * diff --git a/src/main/java/armameeldoparti/controllers/SkillPointsInputController.java b/src/main/java/armameeldoparti/controllers/SkillPointsInputController.java index cd08d3f1..e88e9a3f 100644 --- a/src/main/java/armameeldoparti/controllers/SkillPointsInputController.java +++ b/src/main/java/armameeldoparti/controllers/SkillPointsInputController.java @@ -1,10 +1,15 @@ package armameeldoparti.controllers; +import armameeldoparti.models.Player; +import armameeldoparti.models.Position; import armameeldoparti.models.ProgramView; import armameeldoparti.utils.common.CommonFields; import armameeldoparti.utils.common.CommonFunctions; import armameeldoparti.utils.common.Constants; import armameeldoparti.views.SkillPointsInputView; +import java.util.Map; +import javax.swing.JLabel; +import javax.swing.JSpinner; import lombok.NonNull; /** @@ -85,7 +90,16 @@ public void backButtonEvent() { * Updates the players name labels. */ public void updateNameLabels() { - ((SkillPointsInputView) getView()).updateNameLabels(); + Map labelsMap = ((SkillPointsInputView) getView()).getLabelsMap(); + Map spinnersMap = ((SkillPointsInputView) getView()).getSpinnersMap(); + + for (Position position : Position.values()) { + for (Player player : CommonFields.getPlayersSets() + .get(position)) { + labelsMap.get(spinnersMap.get(player)) + .setText(player.getName()); + } + } getView().pack(); } diff --git a/src/main/java/armameeldoparti/views/AnchoragesView.java b/src/main/java/armameeldoparti/views/AnchoragesView.java index c5879857..53151bea 100644 --- a/src/main/java/armameeldoparti/views/AnchoragesView.java +++ b/src/main/java/armameeldoparti/views/AnchoragesView.java @@ -89,26 +89,6 @@ public AnchoragesView() { initializeInterface(); } - // ---------------------------------------- Public methods ------------------------------------ - - /** - * Updates the checkboxes text with the players names. - */ - public void updateCheckBoxesText() { - for (Position position : Position.values()) { - for (int i = 0; i < CommonFields.getPlayersSets() - .get(position) - .size(); i++) { - checkBoxesMap.get(position) - .get(i) - .setText(CommonFields.getPlayersSets() - .get(position) - .get(i) - .getName()); - } - } - } - // ---------------------------------------- Protected methods --------------------------------- /** diff --git a/src/main/java/armameeldoparti/views/ResultsView.java b/src/main/java/armameeldoparti/views/ResultsView.java index 53d9bd1f..c1dc2539 100644 --- a/src/main/java/armameeldoparti/views/ResultsView.java +++ b/src/main/java/armameeldoparti/views/ResultsView.java @@ -5,7 +5,6 @@ import armameeldoparti.utils.common.CommonFields; import armameeldoparti.utils.common.CommonFunctions; import armameeldoparti.utils.common.Constants; -import java.awt.Component; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JTable; @@ -25,12 +24,6 @@ */ public class ResultsView extends View { - /** - * Fixed table cells width (in pixels). This value depends on the program's font and the maximum - * player name length. - */ - private static final int FIXED_CELL_WIDTH = 250; - // ---------------------------------------- Private fields ------------------------------------ private @Getter @Setter JTable table; @@ -62,30 +55,6 @@ public void initializeInterface() { add(getMasterPanel()); } - /** - * Sets the ideal table cells size. - */ - public void setTableCellsSize() { - for (int column = 0; column < table.getColumnCount(); column++) { - table.getColumnModel() - .getColumn(column) - .setPreferredWidth(FIXED_CELL_WIDTH); - } - - for (int i = 0; i < table.getRowCount(); i++) { - int rowHeight = table.getRowHeight(); - - for (int j = 0; j < table.getColumnCount(); j++) { - Component component = table.prepareRenderer(table.getCellRenderer(i, j), i, j); - - rowHeight = Math.max(rowHeight, component.getPreferredSize() - .height); - } - - table.setRowHeight(i, rowHeight); - } - } - // ---------------------------------------- Protected methods --------------------------------- /** diff --git a/src/main/java/armameeldoparti/views/SkillPointsInputView.java b/src/main/java/armameeldoparti/views/SkillPointsInputView.java index 0767546f..334fd9e2 100644 --- a/src/main/java/armameeldoparti/views/SkillPointsInputView.java +++ b/src/main/java/armameeldoparti/views/SkillPointsInputView.java @@ -30,11 +30,12 @@ * * @since 06/03/2021 */ +@Getter public class SkillPointsInputView extends View { // ---------------------------------------- Private fields ------------------------------------ - private final transient @Getter Map spinnersMap; + private final transient Map spinnersMap; private final transient Map labelsMap; // ---------------------------------------- Constructor --------------------------------------- @@ -69,19 +70,6 @@ public void initializeInterface() { pack(); } - /** - * Updates the labels with the players names. - */ - public void updateNameLabels() { - for (Position position : Position.values()) { - for (Player player : CommonFields.getPlayersSets() - .get(position)) { - labelsMap.get(spinnersMap.get(player)) - .setText(player.getName()); - } - } - } - // ---------------------------------------- Protected methods --------------------------------- /**