You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Re-updated the code from a rollback to undo accidentally adding generated files. Functionality is complete, comments have been updated (including headers and javadocs) and the code has been reformatted.
Platform.runLater(() -> {//Run this function on the main gui thread
@@ -75,7 +77,7 @@ public synchronized void onPreviewOrderChanged(StepMovedEvent event) {
75
77
Stack<OutputSocket<?>> previewedMovedSockets = newStack<OutputSocket<?>>();//This will hold the sockets of the step that was moved that are open for preview
76
78
77
79
for (OutputSocket<?> i : socketsMovedArray) {
78
-
if (this.previewedSockets.indexOf(i)!= -1){//If this socket is previewed
80
+
if (this.previewedSockets.indexOf(i)!= -1){//If this socket is previewed
79
81
previewedMovedSockets.push(i);
80
82
if (rightmostIndex < this.previewedSockets.indexOf(i))
@@ -85,56 +87,58 @@ public synchronized void onPreviewOrderChanged(StepMovedEvent event) {
85
87
}
86
88
87
89
//Deal with each previewed socket from the step that was moved in turn
88
-
while (previewedMovedSockets.size() != 0){ //While there are still sockets to deal with on the stack
90
+
while (previewedMovedSockets.size() != 0){ //While there are still sockets to deal with on the stack
89
91
OutputSocket<?> current = previewedMovedSockets.pop();//Grab the top socket on the stack
90
92
intoldIndex = this.previewedSockets.indexOf(current);//Get the index of this preview so we can remove the correct entry
91
93
92
94
intnewLocation = 0;//This will hold the new index in the list of previewed sockets for this socket
93
95
94
-
if(distanceMoved<0) //If the step moved left....
96
+
if(distanceMoved < 0) //If the step moved left....
95
97
newLocation = leftmostIndex + distanceMoved; //Calculate the new index from the leftmost previewed socket of this step
96
98
else//The step must have moved right....
97
99
newLocation = rightmostIndex + distanceMoved;//So calculate the new index from the rightmost previewed socket of this step
98
100
99
-
if (newLocation <numberOfSourcePreviews){//If the new calculated index would put it in the midst of source previews
101
+
if (newLocation <numberOfSourcePreviews){//If the new calculated index would put it in the midst of source previews
100
102
newLocation = numberOfSourcePreviews;//Make the index the location of the first non-source preview
101
-
}else{ //The new index is the current location of another step (NOT a source)
102
-
103
-
//So we need to make sure that we jump over groups of previews associated with the same step as a unit
103
+
} else { //The new index is the current location of another step (NOT a source)
104
104
105
-
intcount = 0;
105
+
//So we need to make sure that we jump over GROUPS of previews associated with the SAME step as a unit
106
+
intcount = 0;//This will hold the number of previews open from the same step in sequence, starting from the new location and going in the direction we are moving
if (distanceMoved < 0) {//If the step moved left....
109
+
OutputSocket<?> nextSocketInDirection = this.previewedSockets.get(newLocation);//Grab the socket whose preview is open at the new location
110
+
booleanzeroReached = false;//We will set this to true if we reach the beginning of the list of previews (there are no source previews open)
111
+
while ((!zeroReached) &&
112
+
((nextSocketInDirection.getStep().isPresent())
113
+
&& (nextSocketInDirection.getStep().get() == this.previewedSockets.get(newLocation).getStep().get()))) { //While we haven't reached the beginning of the list of previews, the socket at this location is a socket from a step, and it is the SAME step as the step of the socket at the new location...
114
+
count++;
115
+
if ((newLocation - count) > 0)//If we haven't reached the beginning of the list of open previews...
116
+
nextSocketInDirection = this.previewedSockets.get(newLocation - count);//Grab the next previewed socket to examine in the direction we are moving
117
+
else
118
+
zeroReached = true;//Mark that we've reached the beginning of the list of previews so we know to stop looking for more
113
119
}
114
-
newLocation = newLocation - (count-1);
120
+
newLocation = newLocation - (count - 1);//Since the first compare of the while loop will always be true, we subract one from the count when we use it to adjust newLocation
115
121
116
-
}else {//The step must have moved right....
117
-
while ((newLocation+count < this.previewedSockets.size())
while ((newLocation + count < this.previewedSockets.size())
124
+
&& (this.previewedSockets.get(newLocation + count).getStep().get() == this.previewedSockets.get(newLocation).getStep().get())) {//While there are still previewed sockets to examine, and the socket being examined is one from the SAME step of the socket at the new location....
119
125
count++;
120
126
}
121
-
newLocation = newLocation + (count - 1);
127
+
newLocation = newLocation + (count - 1);//Since the first compare of the while loop will always be true, we subract one from the count when we use it to adjust newLocation
122
128
}
123
-
124
129
}
125
130
126
-
//Remove this socket from the previews
131
+
//Remove this socket from the old point in the previews
if (newLocation > this.previewedSockets.size())//If the new index is too big for the list of previews
135
+
if (newLocation > this.previewedSockets.size())//If the new index is now too big for the list of previews
131
136
newLocation = this.previewedSockets.size();//Make it so it will be added to the end of the list of previews
132
137
133
-
this.previewedSockets.add(newLocation, current);//...use this index to add it to the correct location in the list of previews open
138
+
this.previewedSockets.add(newLocation, current);//...add it to the correct location in the list of previews open
134
139
this.previewBox.getChildren().add(newLocation, SocketPreviewViewFactory.createPreviewView(this.eventBus, current));//...and display it in the correct location in the list of previews open
135
140
}
136
141
});
137
-
138
142
}
139
143
140
144
@Subscribe
@@ -181,7 +185,7 @@ public synchronized void onSocketPreviewChanged(SocketPreviewChangedEvent event)
181
185
/**
182
186
* Find the correct index in the displayed previews for a socket associated with a source (NOT a step socket)
183
187
* by comparing the indices in the pipeline.
184
-
* Called in {@link PreviewsView#onSocketPreviewChanged}
188
+
* Made to be called in {@link PreviewsView#onSocketPreviewChanged}
185
189
*
186
190
* @param socket An output socket associated with a source (NOT a step)
187
191
* @return The correct index (an int) in the list of displayed previews for the given <code>socket</code>
@@ -206,7 +210,7 @@ private int getIndexInPreviewsOfASourceSocket(OutputSocket<?> socket) {
206
210
/**
207
211
* Find the correct index in the displayed previews for a socket associated with a step (NOT a source socket)
208
212
* by comparing the indices in the pipeline, starting with the first non-source preview displayed.
209
-
* Called in {@link PreviewsView#onSocketPreviewChanged}
213
+
* Made to be called in {@link PreviewsView#onSocketPreviewChanged}
210
214
*
211
215
* @param socket An output socket associated with a step (NOT a source)
212
216
* @return The correct index in the list of displayed previews for the given <code>socket</code>
@@ -231,10 +235,11 @@ private int getIndexInPreviewsOfAStepSocket(OutputSocket<?> socket) {
231
235
232
236
/**
233
237
* Counts how many source previews (NOT step previews) are currently displayed.
234
-
* Called in {@link PreviewsView#getIndexInPreviewsOfAStepSocket}
238
+
* Called in {@link PreviewsView#getIndexInPreviewsOfAStepSocket} and {@link PreviewsView#onPreviewOrderChanged(StepMovedEvent)}
235
239
*
236
240
* @return The number of source (NOT step) previews that are currently displayed
0 commit comments