Skip to content

Commit c375985

Browse files
committed
Fix various comments and issues
1 parent 59aa466 commit c375985

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

core/src/main/java/edu/wpi/grip/core/Source.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.IOException;
66
import java.util.Optional;
77
import java.util.Properties;
8+
import java.util.concurrent.TimeoutException;
89

910
/**
1011
* Base class for an input into the pipeline.
@@ -55,7 +56,7 @@ public <T extends Source> T start(EventBus eventBus) throws IOException {
5556

5657
/**
5758
* Starts this source.
58-
* A source whose {@link #isRestartable()} returns true can also be stopped and started and stopped multiple times.
59+
* A source whose {@link #canStopAndStart()} returns true can also be stopped and started and stopped multiple times.
5960
*
6061
* @return The source object that created the camera
6162
* @throws IOException If the source fails to be started
@@ -65,12 +66,12 @@ public <T extends Source> T start(EventBus eventBus) throws IOException {
6566
/**
6667
* Stops this source.
6768
* This will stop the source publishing new socket values after this method returns.
68-
* A source whose {@link #isRestartable()} returns true can also be stopped and started and stopped multiple times.
69+
* A source whose {@link #canStopAndStart()} returns true can also be stopped and started and stopped multiple times.
6970
*
7071
* @return The source that was stopped
71-
* @throws Exception
72+
* @throws TimeoutException if the thread running the source fails to stop
7273
*/
73-
public abstract Source stop() throws Exception;
74+
public abstract Source stop() throws TimeoutException;
7475

7576
/**
7677
* Used to indicate if the source is running or stopped
@@ -84,5 +85,5 @@ public <T extends Source> T start(EventBus eventBus) throws IOException {
8485
*
8586
* @return true if this source can be restarted once created
8687
*/
87-
public abstract boolean isRestartable();
88+
public abstract boolean canStopAndStart();
8889
}

core/src/main/java/edu/wpi/grip/core/sources/CameraSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public boolean isRunning() {
230230
}
231231

232232
@Override
233-
public boolean isRestartable() {
233+
public boolean canStopAndStart() {
234234
return true;
235235
}
236236

core/src/main/java/edu/wpi/grip/core/sources/ImageFileSource.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ public ImageFileSource() {
5050
}
5151

5252
private void initialize(EventBus eventBus, String path) throws IOException {
53-
checkNotNull(eventBus, "Event Bus was null.");
54-
checkNotNull(path, "Path was null");
55-
56-
this.path = path;
53+
this.eventBus = checkNotNull(eventBus, "Event Bus was null.");
54+
this.path = checkNotNull(path, "Path was null");
5755
this.name = Files.getNameWithoutExtension(this.path);
5856
this.outputSocket = new OutputSocket<>(eventBus, imageOutputHint);
5957

@@ -103,7 +101,7 @@ public boolean isRunning() {
103101
}
104102

105103
@Override
106-
public boolean isRestartable() {
104+
public boolean canStopAndStart() {
107105
return false;
108106
}
109107

ui/src/main/java/edu/wpi/grip/ui/pipeline/AddSourceView.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,27 @@
2222
import java.net.URISyntaxException;
2323
import java.net.URL;
2424
import java.util.List;
25-
import java.util.concurrent.Executor;
2625
import java.util.function.Consumer;
2726
import java.util.function.Predicate;
2827

28+
import static com.google.common.base.Preconditions.checkNotNull;
29+
2930
/**
3031
* A box of buttons that let the user add different kinds of {@link edu.wpi.grip.core.Source Source}s. Depending on which button is pressed,
3132
* a different dialog is presented for the user to construct that source. As an example, the image file source results
3233
* in a file picker that the user can use to browse for an image.
3334
*/
3435
public class AddSourceView extends HBox {
3536

37+
private final EventBus eventBus;
38+
3639
@FunctionalInterface
3740
private interface SupplierWithIO<T> {
3841
T getWithIO() throws IOException;
3942
}
4043

41-
private final EventBus eventBus;
42-
4344
public AddSourceView(EventBus eventBus) {
44-
this.eventBus = eventBus;
45+
this.eventBus = checkNotNull(eventBus, "Event Bus can not be null");
4546

4647
this.setFillHeight(true);
4748

@@ -127,12 +128,11 @@ public AddSourceView(EventBus eventBus) {
127128
}
128129

129130
/**
130-
*
131-
* @param dialog The dialog to load the camera with
131+
* @param dialog The dialog to load the camera with
132132
* @param cameraSourceSupplier The supplier that will create the camera
133-
* @param failureCallback The handler for when the camera source supplier throws an IO Exception
133+
* @param failureCallback The handler for when the camera source supplier throws an IO Exception
134134
*/
135-
private void loadCamera(Dialog<ButtonType> dialog, SupplierWithIO<CameraSource> cameraSourceSupplier, Consumer<IOException> failureCallback){
135+
private void loadCamera(Dialog<ButtonType> dialog, SupplierWithIO<CameraSource> cameraSourceSupplier, Consumer<IOException> failureCallback) {
136136
assert Platform.isFxApplicationThread() : "Should only run in FX thread";
137137
dialog.showAndWait().filter(Predicate.isEqual(ButtonType.OK)).ifPresent(result -> {
138138
try {

ui/src/main/java/edu/wpi/grip/ui/pipeline/SourceView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public SourceView(EventBus eventBus, Source source) {
6767

6868
this.name.setText(source.getName());
6969

70-
if (!source.isRestartable()) startStopButton.setVisible(false);
70+
if (!source.canStopAndStart()) startStopButton.setVisible(false);
7171
else {
7272
HBox.setHgrow(startStopButton, Priority.NEVER);
7373
startStopButton.setContentDisplay(ContentDisplay.RIGHT);

0 commit comments

Comments
 (0)