Skip to content

Commit 6b83bc3

Browse files
committed
Remove usage of pApplet from Widget class and instead use global existing ourApplet variable and clean up legacy comments in Widgets
1 parent 2a9ba27 commit 6b83bc3

24 files changed

Lines changed: 202 additions & 239 deletions

OpenBCI_GUI/ADS1299SettingsController.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ class ADS1299SettingsController {
6464
protected int channelCount;
6565
protected List<Integer> activeChannels;
6666

67-
ADS1299SettingsController(PApplet _parent, List<Integer> _activeChannels, int _x, int _y, int _w, int _h, int _channelBarHeight) {
67+
ADS1299SettingsController(PApplet _parentApplet, List<Integer> _activeChannels, int _x, int _y, int _w, int _h, int _channelBarHeight) {
6868
x = _x;
6969
y = _y;
7070
w = _w;
7171
h = _h;
7272
channelBarHeight = _channelBarHeight;
7373

74-
_parentApplet = _parent;
74+
_parentApplet = _parentApplet;
7575
hwsCp5 = new ControlP5(_parentApplet);
7676
hwsCp5.setGraphics(_parentApplet, 0,0);
7777
hwsCp5.setAutoDraw(false);

OpenBCI_GUI/ChannelSelect.pde

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class ChannelSelect {
1010
protected boolean channelSelectHover;
1111
protected boolean isVisible;
1212

13-
ChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH) {
13+
ChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH) {
1414
x = _x;
1515
y = _y;
1616
w = _w;
1717
h = _navH;
1818
navH = _navH;
1919

2020
//setup for checkboxes
21-
cp5_chanSelect = new ControlP5(_parent);
22-
cp5_chanSelect.setGraphics(_parent, 0, 0);
21+
cp5_chanSelect = new ControlP5(_parentApplet);
22+
cp5_chanSelect.setGraphics(_parentApplet, 0, 0);
2323
cp5_chanSelect.setAutoDraw(false); //draw only when specified
2424
}
2525

@@ -66,8 +66,8 @@ class ChannelSelect {
6666
popStyle();
6767
}
6868

69-
public void screenResized(PApplet _parent) {
70-
cp5_chanSelect.setGraphics(_parent, 0, 0);
69+
public void screenResized(PApplet _parentApplet) {
70+
cp5_chanSelect.setGraphics(_parentApplet, 0, 0);
7171
}
7272

7373
public void mousePressed(boolean dropdownIsActive) {
@@ -111,8 +111,8 @@ class ExGChannelSelect extends ChannelSelect {
111111
protected List<Toggle> channelButtons;
112112
private List<Integer> activeChannels = new ArrayList<Integer>();
113113

114-
ExGChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH) {
115-
super(_parent, _x, _y, _w, _navH);
114+
ExGChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH) {
115+
super(_parentApplet, _x, _y, _w, _navH);
116116
createButtons();
117117
}
118118

@@ -282,8 +282,8 @@ class DualExGChannelSelect extends ExGChannelSelect {
282282

283283
DualChannelSelector dualChannelSelector;
284284

285-
DualExGChannelSelect(PApplet _parent, int _x, int _y, int _w, int _navH, boolean isFirstRow) {
286-
super(_parent, _x, _y, _w, _navH);
285+
DualExGChannelSelect(PApplet _parentApplet, int _x, int _y, int _w, int _navH, boolean isFirstRow) {
286+
super(_parentApplet, _x, _y, _w, _navH);
287287
dualChannelSelector = new DualChannelSelector(isFirstRow);
288288
}
289289

OpenBCI_GUI/FifoChannelBar.pde

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FifoChannelBar {
2525

2626
private GPlotAutoscaler gplotAutoscaler = new GPlotAutoscaler();
2727

28-
FifoChannelBar(PApplet _parent, String yAxisLabel, int xLimit, float yLimit, int _x, int _y, int _w, int _h, color lineColor, int _layerCount, int _samplingRate, int _totalBufferSeconds) {
28+
FifoChannelBar(PApplet _parentApplet, String yAxisLabel, int xLimit, float yLimit, int _x, int _y, int _w, int _h, color lineColor, int _layerCount, int _samplingRate, int _totalBufferSeconds) {
2929
x = _x;
3030
y = _y;
3131
w = _w;
@@ -42,7 +42,7 @@ class FifoChannelBar {
4242
isOpenness = true;
4343
}
4444

45-
plot = new GPlot(_parent);
45+
plot = new GPlot(_parentApplet);
4646
plot.setPos(x + 36 + 4 + xOffset, y);
4747
plot.setDim(w - 36 - 4 - xOffset, h);
4848
plot.setMar(0f, 0f, 0f, 0f);
@@ -77,12 +77,12 @@ class FifoChannelBar {
7777
valueTextBox.setVisible(false);
7878
}
7979

80-
FifoChannelBar(PApplet _parent, String yAxisLabel, int xLimit, int _x, int _y, int _w, int _h, color lineColor, int layerCount, int _totalBufferSeconds) {
81-
this(_parent, yAxisLabel, xLimit, 1, _x, _y, _w, _h, lineColor, layerCount, 200, _totalBufferSeconds);
80+
FifoChannelBar(PApplet _parentApplet, String yAxisLabel, int xLimit, int _x, int _y, int _w, int _h, color lineColor, int layerCount, int _totalBufferSeconds) {
81+
this(_parentApplet, yAxisLabel, xLimit, 1, _x, _y, _w, _h, lineColor, layerCount, 200, _totalBufferSeconds);
8282
}
8383

84-
FifoChannelBar(PApplet _parent, String yAxisLabel, int xLimit, float yLimit, int _x, int _y, int _w, int _h, color lineColor, int _totalBufferSeconds) {
85-
this(_parent, yAxisLabel, xLimit, yLimit, _x, _y, _w, _h, lineColor, 1, 200, _totalBufferSeconds);
84+
FifoChannelBar(PApplet _parentApplet, String yAxisLabel, int xLimit, float yLimit, int _x, int _y, int _w, int _h, color lineColor, int _totalBufferSeconds) {
85+
this(_parentApplet, yAxisLabel, xLimit, yLimit, _x, _y, _w, _h, lineColor, 1, 200, _totalBufferSeconds);
8686
}
8787

8888
private void initArrays() {

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ void settings() {
342342
}
343343

344344
void setup() {
345+
346+
ourApplet = this;
347+
345348
frameRate(120);
346349

347350
copyPaste = new CopyPaste();
@@ -432,9 +435,6 @@ void setup() {
432435
guiSettings = new GuiSettings(directoryManager.getSettingsPath());
433436
userPlaybackHistoryFile = directoryManager.getSettingsPath()+"UserPlaybackHistory.json";
434437

435-
//open window
436-
ourApplet = this;
437-
438438
// Bug #426: If setup takes too long, JOGL will time out waiting for the GUI to draw something.
439439
// moving the setup to a separate thread solves this. We just have to make sure not to
440440
// start drawing until delayed setup is done.
@@ -743,7 +743,7 @@ void initSystem() {
743743
topNav.controlPanelCollapser.setOff();
744744

745745
verbosePrint("OpenBCI_GUI: initSystem: -- Init 4 -- " + millis());
746-
wm = new WidgetManager(this);
746+
wm = new WidgetManager();
747747

748748
verbosePrint("OpenBCI_GUI: initSystem: -- Init 5 -- " + millis());
749749

OpenBCI_GUI/W_Accelerometer.pde

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ class W_Accelerometer extends Widget {
4444

4545
private AccelerometerCapableBoard accelBoard;
4646

47-
W_Accelerometer(PApplet _parent) {
48-
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
47+
W_Accelerometer(String _widgetName) {
48+
super(_widgetName);
4949

5050
accelBoard = (AccelerometerCapableBoard)currentBoard;
5151

52-
53-
5452
//Make dropdowns
5553
addDropdown("accelerometerVerticalScaleDropdown", "Vert Scale", verticalScale.getEnumStringsAsList(), verticalScale.getIndex());
5654
addDropdown("accelerometerHorizontalScaleDropdown", "Window", horizontalScale.getEnumStringsAsList(), horizontalScale.getIndex());
@@ -62,7 +60,7 @@ class W_Accelerometer extends Widget {
6260
lastDataSampleValues = new float[NUM_ACCEL_DIMS];
6361

6462
//Create our channel bar and populate our accelerometerBar array
65-
accelerometerBar = new AccelerometerBar(_parent, verticalScale.getHighestValue(), accelGraphX, accelGraphY, accelGraphWidth, accelGraphHeight);
63+
accelerometerBar = new AccelerometerBar(ourApplet, verticalScale.getHighestValue(), accelGraphX, accelGraphY, accelGraphWidth, accelGraphHeight);
6664
accelerometerBar.adjustTimeAxis(horizontalScale.getValue());
6765
accelerometerBar.adjustVertScale(verticalScale.getValue());
6866

@@ -82,7 +80,7 @@ class W_Accelerometer extends Widget {
8280
}
8381

8482
void update() {
85-
super.update(); //calls the parent update() method of Widget (DON'T REMOVE)
83+
super.update();
8684

8785
if (accelBoard.isAccelerometerActive()) {
8886
//update the line graph and corresponding gplot points
@@ -109,7 +107,7 @@ class W_Accelerometer extends Widget {
109107
}
110108

111109
void draw() {
112-
super.draw(); //calls the parent draw() method of Widget (DON'T REMOVE)
110+
super.draw();
113111

114112
pushStyle();
115113

@@ -159,7 +157,7 @@ class W_Accelerometer extends Widget {
159157
int prevY = y;
160158
int prevW = w;
161159
int prevH = h;
162-
super.screenResized(); //calls the parent screenResized() method of Widget (DON'T REMOVE)
160+
super.screenResized();
163161
setGraphDimensions();
164162
//resize the accelerometer line graph
165163
accelerometerBar.screenResized(accelGraphX, accelGraphY, accelGraphWidth, accelGraphHeight); //bar x, bar y, bar w, bar h
@@ -168,11 +166,11 @@ class W_Accelerometer extends Widget {
168166
}
169167

170168
void mousePressed() {
171-
super.mousePressed(); //calls the parent mousePressed() method of Widget (DON'T REMOVE)
169+
super.mousePressed();
172170
}
173171

174172
void mouseReleased() {
175-
super.mouseReleased(); //calls the parent mouseReleased() method of Widget (DON'T REMOVE)
173+
super.mouseReleased();
176174
}
177175

178176
private void createAccelModeButton(String name, String text, int _x, int _y, int _w, int _h, PFont _font, int _fontSize, color _bg, color _textColor) {
@@ -316,7 +314,7 @@ class AccelerometerBar {
316314

317315
private AccelerometerCapableBoard accelBoard;
318316

319-
AccelerometerBar(PApplet _parent, float _yLimit, int _x, int _y, int _w, int _h) { //channel number, x/y location, height, width
317+
AccelerometerBar(PApplet _parentApplet, float _yLimit, int _x, int _y, int _w, int _h) { //channel number, x/y location, height, width
320318

321319
// This widget is only instantiated when the board is accel capable, so we don't need to check
322320
accelBoard = (AccelerometerCapableBoard)currentBoard;
@@ -326,7 +324,7 @@ class AccelerometerBar {
326324
w = _w;
327325
h = _h;
328326

329-
plot = new GPlot(_parent);
327+
plot = new GPlot(_parentApplet);
330328
plot.setPos(x + 36 + 4, y); //match Accelerometer plot position with Time Series
331329
plot.setDim(w - 36 - 4, h);
332330
plot.setMar(0f, 0f, 0f, 0f);

OpenBCI_GUI/W_AnalogRead.pde

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class W_AnalogRead extends Widget {
2828

2929
private AnalogCapableBoard analogBoard;
3030

31-
W_AnalogRead(PApplet _parent) {
32-
super(_parent);
31+
W_AnalogRead(String _widgetName) {
32+
super(_widgetName);
3333

3434
analogBoard = (AnalogCapableBoard)currentBoard;
3535

@@ -49,7 +49,7 @@ class W_AnalogRead extends Widget {
4949
//create our channel bars and populate our analogReadBars array!
5050
for(int i = 0; i < analogReadBars.length; i++) {
5151
int analogReadBarY = int(ar_y) + i*(analogReadBarHeight); //iterate through bar locations
52-
AnalogReadBar tempBar = new AnalogReadBar(_parent, i+5, int(ar_x), analogReadBarY, int(ar_w), analogReadBarHeight); //int _channelNumber, int _x, int _y, int _w, int _h
52+
AnalogReadBar tempBar = new AnalogReadBar(ourApplet, i+5, int(ar_x), analogReadBarY, int(ar_w), analogReadBarHeight); //int _channelNumber, int _x, int _y, int _w, int _h
5353
analogReadBars[i] = tempBar;
5454
}
5555

@@ -60,7 +60,7 @@ class W_AnalogRead extends Widget {
6060
}
6161

6262
public void update() {
63-
super.update(); //calls the parent update() method of Widget (DON'T REMOVE)
63+
super.update();
6464

6565
if (currentBoard instanceof DataSourcePlayback) {
6666
if (((DataSourcePlayback)currentBoard) instanceof AnalogCapableBoard
@@ -87,7 +87,7 @@ class W_AnalogRead extends Widget {
8787
}
8888

8989
public void draw() {
90-
super.draw(); //calls the parent draw() method of Widget (DON'T REMOVE)
90+
super.draw();
9191

9292
//remember to refer to x,y,w,h which are the positioning variables of the Widget class
9393
if (analogBoard.isAnalogActive()) {
@@ -98,7 +98,7 @@ class W_AnalogRead extends Widget {
9898
}
9999

100100
public void screenResized() {
101-
super.screenResized(); //calls the parent screenResized() method of Widget (DON'T REMOVE)
101+
super.screenResized();
102102

103103
ar_x = float(x) + arPadding;
104104
ar_y = float(y) + (arPadding);
@@ -115,11 +115,11 @@ class W_AnalogRead extends Widget {
115115
}
116116

117117
public void mousePressed() {
118-
super.mousePressed(); //calls the parent mousePressed() method of Widget (DON'T REMOVE)
118+
super.mousePressed();
119119
}
120120

121121
public void mouseReleased() {
122-
super.mouseReleased(); //calls the parent mouseReleased() method of Widget (DON'T REMOVE)
122+
super.mouseReleased();
123123
}
124124

125125
private void createAnalogModeButton(String name, String text, int _x, int _y, int _w, int _h, PFont _font, int _fontSize, color _bg, color _textColor) {
@@ -212,7 +212,7 @@ class AnalogReadBar{
212212

213213
private AnalogCapableBoard analogBoard;
214214

215-
AnalogReadBar(PApplet _parent, int _analogInputPin, int _x, int _y, int _w, int _h) { // channel number, x/y location, height, width
215+
AnalogReadBar(PApplet _parentApplet, int _analogInputPin, int _x, int _y, int _w, int _h) { // channel number, x/y location, height, width
216216

217217
analogInputPin = _analogInputPin;
218218
int digitalPinNum = 0;
@@ -236,7 +236,7 @@ class AnalogReadBar{
236236
h = _h;
237237

238238
numSeconds = 20;
239-
plot = new GPlot(_parent);
239+
plot = new GPlot(_parentApplet);
240240
plot.setPos(x + 36 + 4, y);
241241
plot.setDim(w - 36 - 4, h);
242242
plot.setMar(0f, 0f, 0f, 0f);

OpenBCI_GUI/W_BandPower.pde

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ class W_BandPower extends Widget {
4040
int[] autoCleanTimers;
4141
boolean[] previousThresholdCrossed;
4242

43-
W_BandPower(PApplet _parent) {
44-
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
43+
W_BandPower(String _widgetName) {
44+
super(_widgetName);
4545

4646
autoCleanTimers = new int[currentBoard.getNumEXGChannels()];
4747
previousThresholdCrossed = new boolean[currentBoard.getNumEXGChannels()];
4848

4949
//Add channel select dropdown to this widget
50-
bpChanSelect = new ExGChannelSelect(pApplet, x, y, w, navH);
50+
bpChanSelect = new ExGChannelSelect(ourApplet, x, y, w, navH);
5151
bpChanSelect.activateAllButtons();
5252

5353
cp5ElementsToCheck.addAll(bpChanSelect.getCp5ElementsForOverlapCheck());
@@ -65,7 +65,7 @@ class W_BandPower extends Widget {
6565
addDropdown("bandPowerDataFilteringDropdown", "Filtered?", filteredEnum.getEnumStringsAsList(), filteredEnum.getIndex());
6666

6767
// Setup for the BandPower plot
68-
bp_plot = new GPlot(_parent, x, y-navHeight, w, h+navHeight);
68+
bp_plot = new GPlot(ourApplet, x, y-navHeight, w, h+navHeight);
6969
// bp_plot.setPos(x, y+navHeight);
7070
bp_plot.setDim(w, h);
7171
bp_plot.setLogScale("y");
@@ -107,7 +107,7 @@ class W_BandPower extends Widget {
107107
}
108108

109109
public void update() {
110-
super.update(); //calls the parent update() method of Widget (DON'T REMOVE)
110+
super.update();
111111

112112
// If enabled, automatically turn channels on or off in ExGChannelSelect for this widget
113113
autoCleanByEnableDisableChannels();
@@ -135,7 +135,7 @@ class W_BandPower extends Widget {
135135
}
136136

137137
public void draw() {
138-
super.draw(); //calls the parent draw() method of Widget (DON'T REMOVE)
138+
super.draw();
139139
pushStyle();
140140

141141
//remember to refer to x,y,w,h which are the positioning variables of the Widget class
@@ -158,15 +158,15 @@ class W_BandPower extends Widget {
158158
}
159159

160160
public void screenResized() {
161-
super.screenResized(); //calls the parent screenResized() method of Widget (DON'T REMOVE)
161+
super.screenResized();
162162

163163
flexGPlotSizeAndPosition();
164164

165-
bpChanSelect.screenResized(pApplet);
165+
bpChanSelect.screenResized(ourApplet);
166166
}
167167

168168
public void mousePressed() {
169-
super.mousePressed(); //calls the parent mousePressed() method of Widget (DON'T REMOVE)
169+
super.mousePressed();
170170
bpChanSelect.mousePressed(this.dropdownIsActive); //Calls channel select mousePressed and checks if clicked
171171
}
172172

0 commit comments

Comments
 (0)