Skip to content

Commit

Permalink
aesthetic fixes, migrating CommonFields
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jul 6, 2023
1 parent 0a2aa7d commit d81bb8f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
21 changes: 19 additions & 2 deletions src/main/java/armameeldoparti/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
import java.util.TreeMap;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.plaf.FontUIResource;
Expand Down Expand Up @@ -64,8 +66,23 @@ private Main() {
* @param args Program arguments (not used yet).
*/
public static void main(String[] args) {
CommonFields.initializeActiveMonitor();
CommonFields.initializeMaps();
// Establishes the main monitor as active monitor by default.
CommonFields.setActiveMonitor(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
CommonFields.setControllersMap(new EnumMap<>(ProgramView.class));
CommonFields.setPlayersAmountMap(new EnumMap<>(Position.class));
CommonFields.setPositionsMap(new EnumMap<>(Position.class));
CommonFields.setPlayersSets(new TreeMap<>());
CommonFields.getPositionsMap()
.put(Position.CENTRAL_DEFENDER, Constants.POSITION_CENTRAL_DEFENDERS);
CommonFields.getPositionsMap()
.put(Position.LATERAL_DEFENDER, Constants.POSITION_LATERAL_DEFENDERS);
CommonFields.getPositionsMap()
.put(Position.MIDFIELDER, Constants.POSITION_MIDFIELDERS);
CommonFields.getPositionsMap()
.put(Position.FORWARD, Constants.POSITION_FORWARDS);
CommonFields.getPositionsMap()
.put(Position.GOALKEEPER, Constants.POSITION_GOALKEEPERS);
CommonFields.setAnchoragesEnabled(false);

setGraphicalProperties();
Expand Down
38 changes: 4 additions & 34 deletions src/main/java/armameeldoparti/utils/common/CommonFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import armameeldoparti.models.Position;
import armameeldoparti.models.ProgramView;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -32,10 +29,10 @@ public final class CommonFields {

@Getter @Setter private static GraphicsDevice activeMonitor;

@Getter private static Map<Position, Integer> playersAmountMap;
@Getter private static Map<Position, List<Player>> playersSets;
@Getter private static Map<Position, String> positionsMap;
@Getter private static Map<ProgramView, Controller> controllersMap;
@Getter @Setter private static Map<Position, Integer> playersAmountMap;
@Getter @Setter private static Map<Position, List<Player>> playersSets;
@Getter @Setter private static Map<Position, String> positionsMap;
@Getter @Setter private static Map<ProgramView, Controller> controllersMap;

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

Expand All @@ -45,31 +42,4 @@ public final class CommonFields {
private CommonFields() {
// Not needed
}

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

/**
* Establishes the main monitor as active monitor by default.
*/
public static void initializeActiveMonitor() {
setActiveMonitor(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
}

/**
* Initializes the common-used maps.
*/
public static void initializeMaps() {
controllersMap = new EnumMap<>(ProgramView.class);
playersAmountMap = new EnumMap<>(Position.class);
positionsMap = new EnumMap<>(Position.class);

playersSets = new TreeMap<>();

positionsMap.put(Position.CENTRAL_DEFENDER, Constants.POSITION_CENTRAL_DEFENDERS);
positionsMap.put(Position.LATERAL_DEFENDER, Constants.POSITION_LATERAL_DEFENDERS);
positionsMap.put(Position.MIDFIELDER, Constants.POSITION_MIDFIELDERS);
positionsMap.put(Position.FORWARD, Constants.POSITION_FORWARDS);
positionsMap.put(Position.GOALKEEPER, Constants.POSITION_GOALKEEPERS);
}
}
5 changes: 3 additions & 2 deletions src/main/java/armameeldoparti/views/AnchoragesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ protected void configureScrollBarColors() {
this.trackColor = Constants.GREEN_MEDIUM;
}
});
scrollPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED,
Constants.GREEN_MEDIUM,
Constants.GREEN_MEDIUM));

CommonFields.getPlayersSets()
.forEach((key, value) -> {
Expand All @@ -114,12 +117,10 @@ protected void configureScrollBarColors() {
.get(key));
});

textArea.setBorder(BorderFactory.createBevelBorder(1));
textArea.setEditable(false);

getMasterPanel().add(leftPanel, "west");
getMasterPanel().add(rightPanel, "east");

addButtons();
add(getMasterPanel());
setTitle(getFrameTitle());
Expand Down

0 comments on commit d81bb8f

Please sign in to comment.