Skip to content

Commit

Permalink
real-time api
Browse files Browse the repository at this point in the history
  • Loading branch information
TTangNingzhi committed Dec 28, 2023
1 parent 7858a38 commit d7a8424
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
9 changes: 6 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ We provide a real-time data API for future JetBrains plugin developers and resea
IDE tracker and eye tracker separately. The API is based on the [IDE Tracker](#ide-tracker)
and [Eye Tracker](#eye-tracker).

#### Example Project

We provide an example project [DataStreamReceiver](https://github.com/codegrits/DataStreamReceiver)
that builds on top of the real-time data API. It is designed to receive real-time IDE tracking and eye tracking data and
directly visualize them in two separate windows. You could refer to the source code of the example project to learn how
to use the API.

### Configuration

Before using the API, you first need to build CodeGRITS from source
Expand All @@ -52,6 +59,13 @@ intellij {
}
```

You also need to add the following to `./src/main/resources/META-INF/plugin.xml`.

```xml

<depends>com.nd.codegrits</depends>
```

### Quick Start

To use the API, simply call the `getInstance()` method to get the instance of the IDE Tracker or Eye Tracker. Then, set
Expand All @@ -60,13 +74,13 @@ the `ideTrackerDataHandler` or `eyeTrackerDataHandler` to handle the real-time d
method to start tracking.

```java
IDETracker ideTracker = IDETracker.getInstance();
ideTracker.setIsRealTimeDataTransmitting(true);
ideTracker.setIdeTrackerDataHandler(element -> {
String formattedStr = "Event: " + element.getAttribute("id");
System.out.println(formattedStr);
});
ideTracker.startTracking(currentProject);
IDETracker ideTracker=IDETracker.getInstance();
ideTracker.setIsRealTimeDataTransmitting(true);
ideTracker.setIdeTrackerDataHandler(element->{
String formattedStr="Event: "+element.getAttribute("id");
System.out.println(formattedStr);
});
ideTracker.startTracking(currentProject);
```

!!!
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/trackers/EyeTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,20 @@ public void selectionChanged(@NotNull FileEditorManagerEvent event) {
}
}
});
}

public EyeTracker(String pythonInterpreter, double sampleFrequency, boolean isUsingMouse) throws ParserConfigurationException {
// designed specifically for the real-time data API
this(); // call default constructor
if (isUsingMouse) {
deviceIndex = 0;
} else {
deviceIndex = 1;
}
this.pythonInterpreter = pythonInterpreter;
this.sampleFrequency = sampleFrequency;
setPythonScriptMouse();
setPythonScriptTobii();
}

VisibleAreaListener visibleAreaListener = e -> visibleArea = e.getNewRectangle();
Expand Down

0 comments on commit d7a8424

Please sign in to comment.