forked from SynapticWall/SynapticWall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlPanel.pde
89 lines (81 loc) · 2.02 KB
/
ControlPanel.pde
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
final int SCALEID = 0;
final int ZOOMID = 1;
public class ControlPanel extends Collection {
EventReceiver fEvents;
Soma fSoma;
ControllerSynapse fSynapse;
Slider fScale, fZoom;
ObjectCollection fObjCollection;
public ControlPanel (ObjectCollection objs) {
fObjCollection = objs;
fEvents = new EventReceiver();
// Initiate Control Panel
fSoma = new ControllerSoma(
0.8 * width,
0.8 * height
);
fSoma.setVisible(false);
fSoma.setMovable(false);
fSoma.showControls();
fObjs.add(fSoma);
fSynapse = new ControllerSynapse(
0.8 * width,
0.6 * height
);
fSynapse.setVisible(false);
fSynapse.setMovable(false);
fSynapse.showControls();
fObjs.add(fSynapse);
fScale = new LinearSlider(
0.75 * width,
0.1 * height,
150f,
SCALE, 1f, MAX_SCALE,
SCALEID, fEvents
);
fScale.setLabel("Scale");
fScale.setVisible(false);
fScale.setMovable(false);
fObjs.add(fScale);
fZoom = new LinearSlider(
0.75 * width,
0.05 * height,
150f,
ZOOM_FACTOR, 1f, MAX_ZOOM,
ZOOMID, fEvents
);
fZoom.setLabel("Zoom");
fZoom.setVisible(false);
fZoom.setMovable(false);
fObjs.add(fZoom);
}
public int getType() {
return -1;
}
// private void syncAttributes(Interactive curr) {
// for (Interactive s : fSelectedObjs) {
// if (curr != s && curr.getType() == s.getType()) {
// if (curr.getType() == SOMA || curr.getType() == INITIATOR) {
// ((Cell)s).copyAttributes((Cell)curr);
// }
// }
// }
// }
}
public class EventReceiver implements Controllable {
public EventReceiver() {}
public void drawControls() {}
public void showControls() {}
public void hideControls() {}
public void onEvent(int controlID, float value) {
switch (controlID) {
case SCALEID:
Constants.SCALE = value;
Constants.recalculate();
break;
case ZOOMID:
Constants.ZOOM_FACTOR = value;
break;
}
}
}