-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathColorSettings.java
More file actions
123 lines (102 loc) · 3.01 KB
/
ColorSettings.java
File metadata and controls
123 lines (102 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package PamView;
import java.io.Serializable;
import java.util.ArrayList;
public class ColorSettings implements Serializable, Cloneable{
static public final long serialVersionUID = 1;
private ArrayList<ColourScheme> colourSchemes = new ArrayList<>();
private String currentScheme;
public static final int ACCESSIBLE_95 = 0;
public static final int ACCESSIBLE_99 = 1;
public static final int ACCESSIBLE_999 = 2;
private int colourBlindPalet = ACCESSIBLE_95;
public ColorSettings() {
super();
rebuildSchemes(colourBlindPalet);
}
public void rebuildSchemes(int colourBlindPalet2) {
colourBlindPalet = colourBlindPalet2;
colourSchemes.clear();
colourSchemes.add(ColourScheme.createDefaultDayScheme(colourBlindPalet2));
colourSchemes.add(ColourScheme.createDefaultNightScheme(colourBlindPalet2));
colourSchemes.add(ColourScheme.createDefaultPrintScheme(colourBlindPalet2));
}
/**
* Get, but don't select a colour scheme.
* @param schemeIndex
* @return Colour Scheme.
*/
public ColourScheme getScheme(int schemeIndex) {
return colourSchemes.get(schemeIndex);
}
/**
* Get the number of colour schemes.
* @return the number of colour schemes.
*/
public int getNumSchemes() {
return colourSchemes.size();
}
public ColourScheme selectScheme(int schemeIndex) {
if (schemeIndex >= colourSchemes.size()) {
currentScheme = colourSchemes.get(0).getName();
return colourSchemes.get(0);
}
else {
currentScheme = colourSchemes.get(schemeIndex).getName();
return colourSchemes.get(schemeIndex);
}
}
public ColourScheme selectScheme(String schemeName) {
if (schemeName == null) {
return selectScheme(0);
}
for (ColourScheme cs:colourSchemes) {
if (cs.getName().equalsIgnoreCase(schemeName)) {
currentScheme = cs.getName();
return cs;
}
}
return selectScheme(0);
}
@Override
protected ColorSettings clone() {
try {
ColorSettings newSettings = (ColorSettings) super.clone();
if (colourSchemes == null || colourSchemes.size() == 0) {
newSettings = new ColorSettings();
}
return newSettings;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return new ColorSettings();
}
public String getCurrentScheme() {
return currentScheme;
}
/**
* @return the colourBlindPalet
*/
public int getColourBlindPalet() {
return colourBlindPalet;
}
/**
* @param colourBlindPalet the colourBlindPalet to set
*/
public void setColourBlindPalet(int colourBlindPalet) {
this.colourBlindPalet = colourBlindPalet;
}
public String getColourBlindName() {
return getColourBlindName(colourBlindPalet);
}
public static String getColourBlindName(int scheme) {
switch (scheme) {
case ACCESSIBLE_95:
return "PAMGuard default: 95% accessibility";
case ACCESSIBLE_99:
return "Colour blind: 99% accessibility";
case ACCESSIBLE_999:
return "Colour blind: 99.9% accessibility";
}
return null;
}
}