Skip to content

Commit 02e9824

Browse files
committed
Resolves PR Review Comments, Fixes Formatting
1 parent 7fb1ad0 commit 02e9824

47 files changed

Lines changed: 227 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,17 @@ public InputSocket<T> getInputSocket() {
4545
return this.inputSocket;
4646
}
4747

48-
private void runConnection() {
49-
inputSocket.setValueOptional(outputSocket.getValue());
50-
}
51-
5248
@Subscribe
5349
public void onConnectionAdded(ConnectionAddedEvent event) {
5450
if (event.getConnection().equals(this)) {
55-
runConnection();
51+
inputSocket.setValueOptional(outputSocket.getValue());
5652
}
5753
}
5854

5955
@Subscribe
6056
public void onOutputChanged(SocketChangedEvent e) {
6157
if (e.getSocket() == outputSocket) {
62-
runConnection();
58+
inputSocket.setValueOptional(outputSocket.getValue());
6359
}
6460
}
6561

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
4040

4141
bind(EventBus.class).toInstance(eventBus);
4242

43-
install(new FactoryModuleBuilder().build(new TypeLiteral<Connection.Factory<Object>>(){}));
43+
install(new FactoryModuleBuilder().build(new TypeLiteral<Connection.Factory<Object>>() {
44+
}));
4445

4546

4647
bind(Source.SourceFactory.class).to(Source.SourceFactoryImpl.class);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class Main {
2323
private Project project;
2424
@Inject
2525
private EventBus eventBus;
26+
@Inject
27+
private Logger logger;
2628

2729
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
2830
public static void main(String[] args) throws Exception {
@@ -74,15 +76,11 @@ public void start(String[] args) throws IOException, InterruptedException {
7476
}
7577

7678
/**
77-
* When an unexpected error happens in headless mode, print a stack trace and exit. Obviously we cannot show
78-
* a dialog here, so this will have to do until we have proper logging.
79-
* <p>
80-
* TODO: put actual logging in this method
79+
* When an unexpected error happens in headless mode, print a stack trace and exit.
8180
*/
8281
@Subscribe
8382
public final void onUnexpectedThrowableEvent(UnexpectedThrowableEvent event) {
84-
System.out.println(event.getMessage());
85-
event.getThrowable().printStackTrace();
83+
logger.log(Level.SEVERE, "UnexpectedThrowableEvent", event.getThrowable());
8684
if (event.isFatal()) {
8785
System.exit(1);
8886
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
@XStreamAlias(value = "grip:Pipeline")
2626
public class Pipeline {
2727

28-
@Inject @XStreamOmitField private EventBus eventBus;
28+
@Inject
29+
@XStreamOmitField
30+
private EventBus eventBus;
2931

30-
private List<Source> sources = new ArrayList<>();
31-
private List<Step> steps = new ArrayList<>();
32-
private Set<Connection> connections = new HashSet<>();
32+
private final List<Source> sources = new ArrayList<>();
33+
private final List<Step> steps = new ArrayList<>();
34+
private final Set<Connection> connections = new HashSet<>();
3335

3436
/**
3537
* Remove everything in the pipeline
@@ -142,7 +144,7 @@ public synchronized void addStep(int index, Step step) {
142144
this.eventBus.post(new StepAddedEvent(step, index));
143145
}
144146

145-
public synchronized void addStep(Step step) {
147+
public synchronized void addStep(Step step) {
146148
addStep(this.steps.size(), step);
147149
}
148150

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public static class SourceFactoryImpl implements SourceFactory {
2424

2525
@Override
2626
public Source create(Class type, Properties properties) throws IOException {
27-
if(type.isAssignableFrom(CameraSource.class)) return cameraFactory.create(properties);
28-
else if(type.isAssignableFrom(ImageFileSource.class)) return imageFactory.create(properties);
29-
else if(type.isAssignableFrom(MultiImageFileSource.class)) return multiImageFactory.create(properties);
27+
if (type.isAssignableFrom(CameraSource.class)) return cameraFactory.create(properties);
28+
else if (type.isAssignableFrom(ImageFileSource.class)) return imageFactory.create(properties);
29+
else if (type.isAssignableFrom(MultiImageFileSource.class)) return multiImageFactory.create(properties);
3030
else throw new IllegalArgumentException(type + " was not a valid type");
3131
}
3232
}

core/src/main/java/edu/wpi/grip/core/serialization/ConnectionConverter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import com.thoughtworks.xstream.converters.UnmarshallingContext;
88
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
99
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
10-
import edu.wpi.grip.core.*;
10+
import edu.wpi.grip.core.Connection;
11+
import edu.wpi.grip.core.InputSocket;
12+
import edu.wpi.grip.core.OutputSocket;
13+
import edu.wpi.grip.core.Socket;
1114
import edu.wpi.grip.core.events.ConnectionAddedEvent;
1215

1316
import javax.inject.Inject;
@@ -19,8 +22,10 @@
1922
*/
2023
public class ConnectionConverter<T> implements Converter {
2124

22-
@Inject private EventBus eventBus;
23-
@Inject private Connection.Factory<Object> connectionFactory;
25+
@Inject
26+
private EventBus eventBus;
27+
@Inject
28+
private Connection.Factory<Object> connectionFactory;
2429

2530
@Override
2631
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {

core/src/main/java/edu/wpi/grip/core/serialization/Project.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
@Singleton
1919
public class Project {
2020

21-
@Inject private EventBus eventBus;
22-
@Inject private Pipeline pipeline;
23-
@Inject private Palette palette;
21+
@Inject
22+
private EventBus eventBus;
23+
@Inject
24+
private Pipeline pipeline;
25+
@Inject
26+
private Palette palette;
2427

2528
protected final XStream xstream = new XStream();
2629
private Optional<File> file = Optional.empty();

core/src/main/java/edu/wpi/grip/core/serialization/SocketConverter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class SocketConverter implements Converter {
2929
final private static String SOCKET_ATTRIBUTE = "socket";
3030
final private static String PREVIEWED_ATTRIBUTE = "previewed";
3131

32-
@Inject private Pipeline pipeline;
33-
@Inject private Project project;
32+
@Inject
33+
private Pipeline pipeline;
34+
@Inject
35+
private Project project;
3436

3537
@Override
3638
public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {

core/src/main/java/edu/wpi/grip/core/serialization/SourceConverter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
*/
2828
public class SourceConverter implements Converter {
2929

30-
@Inject private EventBus eventBus;
31-
@Inject private Project project;
32-
@Inject private Source.SourceFactory sourceFactory;
30+
@Inject
31+
private EventBus eventBus;
32+
@Inject
33+
private Project project;
34+
@Inject
35+
private Source.SourceFactory sourceFactory;
3336

3437
@Override
3538
public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {

core/src/main/java/edu/wpi/grip/core/serialization/StepConverter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ public class StepConverter implements Converter {
2222

2323
private final static String NAME_ATTRIBUTE = "name";
2424

25-
@Inject private EventBus eventBus;
26-
@Inject private Palette palette;
27-
@Inject private Pipeline pipeline;
28-
@Inject private Step.Factory stepFactory;
25+
@Inject
26+
private EventBus eventBus;
27+
@Inject
28+
private Palette palette;
29+
@Inject
30+
private Pipeline pipeline;
31+
@Inject
32+
private Step.Factory stepFactory;
2933

3034
@Override
3135
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {

0 commit comments

Comments
 (0)