Skip to content

Commit 1944950

Browse files
committed
Style: Add comments and output statments
Signed-off-by: Ce Gao <[email protected]>
1 parent 8b3e7f8 commit 1944950

File tree

6 files changed

+37
-11
lines changed

6 files changed

+37
-11
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ build/
1919
try/
2020
*.log
2121
build.xml
22+
*.ucls
23+
*.graffle
2224

2325
# Demo
2426
*.mov

src/rprocessing/RLangPApplet.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
*/
2222
public class RLangPApplet extends PApplet {
2323

24+
public static boolean VERBOSE = Boolean.getBoolean("verbose");
25+
26+
private static void log(String msg) {
27+
if (!VERBOSE) {
28+
return;
29+
}
30+
System.err.println(RLangPApplet.class.getSimpleName() + ": " + msg);
31+
}
32+
2433
/**
2534
* Mode for Processing.
2635
*
@@ -35,7 +44,7 @@ private enum Mode {
3544
// definitions, which we then invoke during the run loop.
3645
private final Mode mode;
3746

38-
/** Program Code */
47+
/** Program code */
3948
private final String programText;
4049

4150
/** Engine to interpret R code */
@@ -57,7 +66,7 @@ public void prePassCode() {
5766
if (source.getClass().equals(ExpressionVector.class)) {
5867
ExpressionVector ev = (ExpressionVector) source;
5968
for (int i = 0; i < ev.length(); ++i) {
60-
System.out.println(ev.get(i).getClass());
69+
// LOGGER.info("The type of expression is ", ev.get(i).getClass());
6170
if (ev.get(i).getClass().equals(FunctionCall.class)) {
6271
this.renjinEngine.getTopLevelContext().evaluate(ev.get(i),
6372
this.renjinEngine.getTopLevelContext().getEnvironment());
@@ -112,7 +121,7 @@ public void setup() {
112121
try {
113122
this.renjinEngine.eval(this.programText);
114123
} catch (ScriptException e) {
115-
System.out.println(e);
124+
log(e.toString());
116125
}
117126
} else if (this.mode == Mode.ACTIVE) {
118127
Object obj = this.renjinEngine.get(Constant.SETUP_NAME);

src/rprocessing/Runner.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public class Runner {
2727

2828
public static boolean VERBOSE = Boolean.getBoolean("verbose");
2929

30-
static void log(final Object... objs) {
30+
private static void log(final Object... objs) {
3131
if (!VERBOSE) {
3232
return;
3333
}
3434
for (final Object o : objs) {
35-
System.err.print(String.valueOf(o));
35+
System.err.print(Runner.class.getSimpleName() + ": " + String.valueOf(o));
3636
}
3737
System.err.println();
3838
}
@@ -71,14 +71,12 @@ public synchronized static void runSketchBlocking(final RunnableSketch sketch,
7171
if (engine == null) {
7272
throw new RuntimeException("Renjin Script Engine not found on the classpath.");
7373
}
74-
System.out.println(1);
74+
log("Tring to initialize RLangPApplet.");
7575
RLangPApplet rp = new RLangPApplet(engine, sketch.getMainCode());
76-
System.out.println(1);
76+
log("Adding processing variable into R top context.");
7777
rp.AddPAppletToRContext();
7878

79-
System.out.println(rp);
8079
try {
81-
engine.eval("print(processing)");
8280
engine.eval(CORE_TEXT);
8381
// Run Sketch.
8482
PApplet.runSketch(args, rp);

src/rprocessing/mode/RLangEditor.java

+4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@
3636
import rprocessing.mode.run.SketchServiceRunner;
3737

3838
/**
39+
* RLangEditor is the editor abstraction in R mode, which builds a
40+
* editor and initialize all related components such as formatter
41+
* toolbar.
3942
*
4043
* @author github.com/gaocegege
4144
*/
4245
public class RLangEditor extends Editor {
46+
4347
private static void log(final String msg) {
4448
if (RLangMode.VERBOSE) {
4549
System.err.println(RLangEditor.class.getSimpleName() + ": " + msg);

src/rprocessing/mode/RLangMode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public String getDefaultExtension() {
7373

7474
@Override
7575
public String getModuleExtension() {
76-
return "py";
76+
return "r";
7777
}
7878

7979
/**

src/rprocessing/mode/RLangToolbar.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66
import processing.app.ui.EditorToolbar;
77

88
/**
9+
* RLangToolbar is toolbar in R mode, which takes care of run and stop
10+
* buttons.
911
*
1012
* @author github.com/gaocegege
1113
*/
1214
public class RLangToolbar extends EditorToolbar {
13-
/** */
15+
16+
public static boolean VERBOSE = Boolean.getBoolean("verbose");
17+
18+
static void log(String msg) {
19+
if (!VERBOSE) {
20+
return;
21+
}
22+
System.err.println(RLangToolbar.class.getSimpleName() + ": " + msg);
23+
}
24+
1425
private static final long serialVersionUID = -4227659009839101912L;
1526

1627
public RLangToolbar(final Editor editor) {
@@ -19,6 +30,7 @@ public RLangToolbar(final Editor editor) {
1930

2031
@Override
2132
public void handleRun(final int modifiers) {
33+
log("The toolbar is handling start-event.");
2234
final RLangEditor peditor = (RLangEditor) editor;
2335
final boolean shift = (modifiers & InputEvent.SHIFT_MASK) != 0;
2436
if (shift) {
@@ -30,6 +42,7 @@ public void handleRun(final int modifiers) {
3042

3143
@Override
3244
public void handleStop() {
45+
log("The toolbar is handling stop-event.");
3346
final RLangEditor peditor = (RLangEditor) editor;
3447
peditor.handleStop();
3548
}

0 commit comments

Comments
 (0)