use of games.strategy.engine.data.PlayerManager in project triplea by triplea-game.
the class PlayerChatRenderer method setIconMap.
private void setIconMap() {
final PlayerManager playerManager = game.getPlayerManager();
PlayerList playerList;
game.getData().acquireReadLock();
try {
playerList = game.getData().getPlayerList();
} finally {
game.getData().releaseReadLock();
}
// new HashSet removes duplicates
for (final INode playerNode : new HashSet<>(playerManager.getPlayerMapping().values())) {
final Set<String> players = playerManager.getPlayedBy(playerNode);
if (players.size() > 0) {
final List<Icon> icons = players.stream().filter(player -> uiContext != null && uiContext.getFlagImageFactory() != null).map(player -> new ImageIcon(uiContext.getFlagImageFactory().getSmallFlag(playerList.getPlayerId(player)))).collect(Collectors.toList());
maxIconCounter = Math.max(maxIconCounter, icons.size());
playerMap.put(playerNode.toString(), players);
if (uiContext == null) {
iconMap.put(playerNode.toString(), null);
} else {
iconMap.put(playerNode.toString(), icons);
}
}
}
}
Aggregations