Skip to content

Commit fa9901d

Browse files
committed
Some typos and changes
1 parent 5494a12 commit fa9901d

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

README.md

+53-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,46 @@ ProcessingJs-GWT is a thin Google Web Toolkit (GWT) wrapper that allows to use [
55

66
## How do I use it?
77

8-
TODO
8+
Following steps are required:
99

10+
Either create new interface that extends or create a class that implements the base interface `ProcessingInstance` and annotate it with `@JsType`. To interact with methods on the processing sketch define methods on that interface (i.e. `testMethod`):
11+
12+
```JAVA
13+
@JsType
14+
public interface MyCustomInstance extends ProcessingInstance {
15+
String testMethod(String msg);
16+
}
17+
```
18+
Load the Processing sketch either via `ExternalTextResource` or `URL` or pass it directly as a `String`:
19+
20+
**Loading via URL**:
21+
```JAVA
22+
final Processing<MyCustomInstance> processing = new Processing<>();
23+
processing.load(safeUri,new Runnable() {
24+
@Override
25+
public void run() {
26+
GWT.log("Sample initialized.");
27+
// Interact with sketch
28+
processing.getInstance().textMethod("test");
29+
}
30+
});
31+
```
32+
**Loading via ExternalTextResource**:
33+
```JAVA
34+
interface ProcessingCodeBundle extends ClientBundle {
35+
ProcessingCodeBundle INSTANCE = GWT.create(ProcessingCodeBundle.class);
36+
37+
@Source("sample.pde")
38+
ExternalTextResource sampleCode();
39+
}
40+
final Processing<MyCustomInstance> processing = new Processing<>();
41+
processing.load(ProcessingCodeBundle.INSTANCE.sampleCode(),()-> {
42+
GWT.log("Sample initialized.");
43+
// Interact with sketch
44+
processing.getInstance().textMethod("test");
45+
};
46+
```
47+
For a more sophistaced example that shows how to interact with the Processing sketch (Callbacks, etc) refer to the [LDViewer visualization][6]
1048

1149

1250
## How do I install it?
@@ -22,6 +60,16 @@ section:
2260
</dependency>
2361
```
2462
63+
ProcessingJs-GWT uses [GWT 2.7's][4] new [JSInterop feature][5] and thus it has to be enabled in the GWT compiler args.
64+
For maven:
65+
```xml
66+
<compilerArgs>
67+
<compilerArg>-XjsInteropMode</compilerArg>
68+
<compilerArg>JS</compilerArg>
69+
</compilerArgs>
70+
```
71+
or passing it to the compiler via `-XjsInteropMode`
72+
2573
You can also download the [jar][1] directly or check out the source using git
2674
from <https://github.com/timeu/processing-js-gwt.git> and build it yourself. Once
2775
you've installed ProcessingJs-GWT, be sure to inherit the module in your .gwt.xml
@@ -38,4 +86,7 @@ file like this:
3886
[0]: http://processingjs.org
3987
[1]: http://search.maven.org/remotecontent?filepath=com/github/timeu/dygraphs-gwt/dygraphs-gwt/1.0.0/dygraphs-gwt-1.0.0.jar
4088
[2]: https://timeu.github.io/processing-js-gwt
41-
[3]: https://github.com/timeu/processing-js-gwt/tree/master/processing-js-gwt-sample/src/main/java/sample/client
89+
[3]: https://github.com/timeu/processing-js-gwt/tree/master/processingjs-gwt-sample
90+
[4]: http://www.gwtproject.org/release-notes.html#Release_Notes_2_7_0_RC1
91+
[5]: https://docs.google.com/document/d/1tir74SB-ZWrs-gQ8w-lOEV3oMY6u6lF2MmNivDEihZ4/edit#
92+
[6]: https://github.com/timeu/LDViewer

0 commit comments

Comments
 (0)