-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColorConfiguration.java
More file actions
213 lines (202 loc) · 7.45 KB
/
ColorConfiguration.java
File metadata and controls
213 lines (202 loc) · 7.45 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import processing.core.PApplet;
/**
**Class used to configure the design of the world
**/
class ColorConfiguration
{
private PApplet context;
public int background;
public int text;
public int normalNode;
public int newNode;
public int popupNode;
public int popupText;
public int connection;
public int tempConnection;
public String backgroundImage;
public String nodeImage;
public String nodeImageActive;
public String nodeImageHover;
public String nodeMenuImage;
public String nodeHitImage;
public String popupNodeImage;
public String connectionDeleteImage;
public String connectionDeleteImageHover;
public String textFieldImage;
public boolean interaction;
public String networks;
public int networkDelay;
//global menu icons
public String iconNew;
public String iconNewActive;
public String iconOpen;
public String iconOpenActive;
public String iconConnections;
public String iconConnectionsActive;
public String iconBack;
public String iconBackActive;
public String iconExit;
public String iconExitActive;
public String iconApply;
public String iconApplyActive;
public String menuLogo;
ColorConfiguration(PApplet context)
{
//Default configuration
this.context = context;
this.background = context.color(255);
this.text = context.color(0);
this.normalNode = context.color(211, 131, 138, 180);
this.newNode = context.color(226, 200);
this.popupNode = context.color(226,200);
this.popupText = context.color(80);
this.connection = context.color(0,0,0,40);
//this.connection = context.color(255,194,0);
this.tempConnection = context.color(0);
this.backgroundImage = "background.jpg";
this.nodeImage = "final_node.png";
this.nodeImageActive = "final_node_active.png";
this.nodeImageHover = "final_node_hover.png";
this.nodeMenuImage = "final_node_menu.png";
this.nodeHitImage = "final_node_menu_hover.png";
this.popupNodeImage = "final_node_hover.png";
this.connectionDeleteImage = "final_node_delete.png";
this.connectionDeleteImageHover = "final_node_delete_hover.png";
this.iconNew = "iconNew.png";
this.iconNewActive = "iconNewActive.png";
this.iconOpen = "iconOpen.png";
this.iconOpenActive = "iconOpenActive.png";
this.iconConnections = "iconConnections.png";
this.iconConnectionsActive = "iconConnectionsActive.png";
this.iconBack = "iconBack.png";
this.iconBackActive = "iconBackActive.png";
this.iconExit = "iconExit.png";
this.iconExitActive = "iconExitActive.png";
this.iconApply = "iconApply.png";
this.iconApplyActive = "iconApplyActive.png";
this.menuLogo = "menuLogo.png";
this.textFieldImage = "final_field_background.png";
this.interaction = true;
this.networks = "";
this.networkDelay = 60000;
}
//TODO: configuration through ini files
ColorConfiguration(PApplet context, String filename)
{
String[] lines = context.loadStrings(filename);
String mode = "";
String[] command = null;
String id = null;
String value = null;
String[] colorValue = null;
String networks = "";
this.context = context;
for (int i=0; i < lines.length; i++)
{
if (lines[i].equals("[Configuration]"))
{
mode = "Configuration";
}
else if (lines[i].equals("[Networks]"))
{
mode = "Networks";
}
else if (mode.equals("Configuration"))
{
command = context.split(lines[i], "=");
id = command[0];
value = command[1];
if (id.equals("background"))
{
colorValue = context.split(value, ",");
this.background = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("text"))
{
colorValue = context.split(value, ",");
this.text = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("normalNode"))
{
colorValue = context.split(value, ",");
this.normalNode = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("newNode"))
{
colorValue = context.split(value, ",");
this.newNode = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("popupNode"))
{
colorValue = context.split(value, ",");
this.popupNode = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("popupText"))
{
colorValue = context.split(value, ",");
this.popupText = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("connection"))
{
colorValue = context.split(value, ",");
this.connection = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("tempConnection"))
{
colorValue = context.split(value, ",");
this.tempConnection = context.color(context.parseInt(colorValue[0]), context.parseInt(colorValue[1]), context.parseInt(colorValue[2]), context.parseInt(colorValue[3]));
}
if (id.equals("interaction"))
{
if(value.equals("true"))
{
this.interaction = true;
}
else
{
this.interaction = false;
}
}
if (id.equals("networkDelay"))
{
this.networkDelay = context.parseInt(value);
}
}
else if (mode.equals("Networks"))
{
if (networks.equals(""))
{
networks = lines[i];
}
else
{
networks = networks + ";" + lines[i];
}
}
}
this.backgroundImage = "background.jpg";
this.nodeImage = "final_node.png";
this.nodeImageActive = "final_node_active.png";
this.nodeImageHover = "final_node_hover.png";
this.nodeMenuImage = "final_node_menu.png";
this.nodeHitImage = "final_node_menu_hover.png";
this.popupNodeImage = "final_node_hover.png";
this.connectionDeleteImage = "final_node_delete.png";
this.connectionDeleteImageHover = "final_node_delete_hover.png";
this.iconNew = "iconNew.png";
this.iconNewActive = "iconNewActive.png";
this.iconOpen = "iconOpen.png";
this.iconOpenActive = "iconOpenActive.png";
this.iconConnections = "iconConnections.png";
this.iconConnectionsActive = "iconConnectionsActive.png";
this.iconBack = "iconBack.png";
this.iconBackActive = "iconBackActive.png";
this.iconExit = "iconExit.png";
this.iconExitActive = "iconExitActive.png";
this.iconApply = "iconApply.png";
this.iconApplyActive = "iconApplyActive.png";
this.menuLogo = "menuLogo.png";
this.textFieldImage = "final_field_background.png";
this.networks = networks;
}
}