OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 112 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 112 Rev 147
Line 8... Line 8...
8
import org.openconcerto.sql.users.User;
8
import org.openconcerto.sql.users.User;
9
import org.openconcerto.sql.users.UserManager;
9
import org.openconcerto.sql.users.UserManager;
10
 
10
 
11
public class UserColor {
11
public class UserColor {
12
    private static UserColor instance;
12
    private static UserColor instance;
13
    private String[] colors = new String[] { "#303F9F", "#31DE39", "#FFC107", "#C2185B", "#00796B", "#212121", "#00BCD4", "#A6A6A6", "#795548", "#B3E5FC", "#FF0000" };
13
    private static final String[] COLORS = new String[] { "#303F9F", "#31DE39", "#FFC107", "#C2185B", "#00796B", "#212121", "#00BCD4", "#A6A6A6", "#795548", "#B3E5FC", "#FF0000" };
14
    private Map<Integer, Color> map = new HashMap<Integer, Color>();
14
    private final Map<Integer, Color> map = new HashMap<>();
15
 
15
 
16
    public UserColor() {
16
    public UserColor() {
17
        List<User> users = UserManager.getInstance().getAllUser();
17
        final List<User> users = UserManager.getInstance().getAllActiveUsers();
18
        final int size = users.size();
18
        final int size = users.size();
19
        for (int i = 0; i < size; i++) {
19
        for (int i = 0; i < size; i++) {
20
            User u = users.get(i);
20
            final User u = users.get(i);
21
            map.put(u.getId(), Color.decode(colors[i % colors.length]));
21
            map.put(u.getId(), Color.decode(COLORS[i % COLORS.length]));
22
        }
22
        }
23
    }
23
    }
24
 
24
 
25
    public synchronized Color getColor(int id) {
25
    public synchronized Color getColor(int id) {
26
        return map.get(id);
26
        return map.get(id);
27
    }
27
    }
28
 
28
 
29
    public synchronized static final UserColor getInstance() {
29
    public static final synchronized UserColor getInstance() {
30
        if (instance == null) {
30
        if (instance == null) {
31
            instance = new UserColor();
31
            instance = new UserColor();
32
        }
32
        }
33
        return instance;
33
        return instance;
34
    }
34
    }