@@ -68,11 +68,6 @@ public SurfaceInfo initSketchSize(String code) throws SketchException {
68
68
System .err .println ("found here: http://wiki.processing.org/w/Android" );
69
69
throw new SketchException ("Could not parse the size() command." );
70
70
}
71
- /*
72
- sizeStatement = surfaceInfo.getStatement();
73
- sketchWidth = surfaceInfo.getWidth();
74
- sketchHeight = surfaceInfo.getHeight();
75
- sketchRenderer = surfaceInfo.getRenderer();*/
76
71
return surfaceInfo ;
77
72
}
78
73
@@ -108,7 +103,6 @@ static public String[] parseSketchSmooth(String code, boolean fussy) {
108
103
"value (not variables) for the smooth() command.\n " +
109
104
"See the smooth() reference for an explanation." ;
110
105
Messages .showWarning ("Could not find smooth level" , message , null );
111
- // new Exception().printStackTrace(System.out);
112
106
return null ;
113
107
}
114
108
@@ -117,89 +111,6 @@ static public String[] parseSketchSmooth(String code, boolean fussy) {
117
111
return new String [] { null , null }; // not an error, just empty
118
112
}
119
113
120
-
121
- /*
122
- protected boolean parseSketchSize() {
123
- // This matches against any uses of the size() function, whether numbers
124
- // or variables or whatever. This way, no warning is shown if size() isn't
125
- // actually used in the applet, which is the case especially for anyone
126
- // who is cutting/pasting from the reference.
127
-
128
- String scrubbed = processing.mode.java.JavaBuild.scrubComments(sketch.getCode(0).getProgram());
129
- String[] matches = PApplet.match(scrubbed, processing.mode.java.JavaBuild.SIZE_REGEX);
130
- // PApplet.println("matches: " + Sketch.SIZE_REGEX);
131
- // PApplet.println(matches);
132
-
133
- if (matches != null) {
134
- boolean badSize = false;
135
-
136
- if (matches[1].equals("screenWidth") ||
137
- matches[1].equals("screenHeight") ||
138
- matches[2].equals("screenWidth") ||
139
- matches[2].equals("screenHeight")) {
140
- final String message =
141
- "The screenWidth and screenHeight variables are named\n" +
142
- "displayWidth and displayHeight in this release of Processing.";
143
- Base.showWarning("Time for a quick update", message, null);
144
- return false;
145
- }
146
-
147
- if (!matches[1].equals("displayWidth") &&
148
- !matches[1].equals("displayHeight") &&
149
- PApplet.parseInt(matches[1], -1) == -1) {
150
- badSize = true;
151
- }
152
- if (!matches[2].equals("displayWidth") &&
153
- !matches[2].equals("displayHeight") &&
154
- PApplet.parseInt(matches[2], -1) == -1) {
155
- badSize = true;
156
- }
157
-
158
- if (badSize) {
159
- // found a reference to size, but it didn't seem to contain numbers
160
- final String message =
161
- "The size of this applet could not automatically be determined\n" +
162
- "from your code. Use only numeric values (not variables) for the\n" +
163
- "size() command. See the size() reference for more information.";
164
- Base.showWarning("Could not find sketch size", message, null);
165
- System.out.println("More about the size() command on Android can be");
166
- System.out.println("found here: http://wiki.processing.org/w/Android");
167
- return false;
168
- }
169
-
170
- // PApplet.println(matches);
171
- sizeStatement = matches[0]; // the full method to be removed from the source
172
- sketchWidth = matches[1];
173
- sketchHeight = matches[2];
174
- sketchRenderer = matches[3].trim();
175
- if (sketchRenderer.length() == 0) {
176
- sketchRenderer = null;
177
- }
178
- } else {
179
- sizeStatement = null;
180
- sketchWidth = null;
181
- sketchHeight = null;
182
- sketchRenderer = null;
183
- }
184
- return true;
185
- }
186
- */
187
-
188
-
189
- /*
190
- public PreprocessorResult write(Writer out, String program, String[] codeFolderPackages)
191
- throws SketchException, RecognitionException, TokenStreamException {
192
- if (sizeStatement != null) {
193
- int start = program.indexOf(sizeStatement);
194
- program = program.substring(0, start) +
195
- program.substring(start + sizeStatement.length());
196
- }
197
- // the OpenGL package is back in 2.0a5
198
- //program = program.replaceAll("import\\s+processing\\.opengl\\.\\S+;", "");
199
- return super.write(out, program, codeFolderPackages);
200
- }
201
- */
202
-
203
114
204
115
@ Override
205
116
protected int writeImports (final PrintWriter out ,
@@ -214,19 +125,22 @@ protected int writeImports(final PrintWriter out,
214
125
}
215
126
216
127
217
- /*
218
128
@ Override
219
129
protected void writeFooter (PrintWriter out , String className ) {
220
130
SurfaceInfo info = null ;
221
131
try {
222
132
info = initSketchSize (sketch .getMainProgram ());
223
133
} catch (SketchException e ) {
134
+ e .printStackTrace ();
224
135
}
225
136
226
137
if (info == null ) {
227
138
// Cannot get size info, just use parent's implementation.
228
139
super .writeFooter (out , className );
229
140
} else {
141
+ // Same as in the parent, but without writing the main() method, which is
142
+ // not needed in Android.
143
+
230
144
if (mode == Mode .STATIC ) {
231
145
// close off setup() definition
232
146
out .println (indent + indent + "noLoop();" );
@@ -235,14 +149,22 @@ protected void writeFooter(PrintWriter out, String className) {
235
149
}
236
150
237
151
if ((mode == Mode .STATIC ) || (mode == Mode .ACTIVE )) {
152
+ // doesn't remove the original size() method, but calling size()
153
+ // again in setup() is harmless.
238
154
if (!hasMethod ("settings" ) && info .hasSettings ()) {
239
155
out .println (indent + "public void settings() { " + info .getSettings () + " }" );
240
156
}
157
+
158
+ // close off the class definition
241
159
out .println ("}" );
242
160
}
243
161
}
244
162
}
245
- */
163
+
164
+
165
+ ////////////////////////////////////////////////////////////////////////////////
166
+ // Assorted commented out code
167
+ //
246
168
247
169
// As of revision 0215 (2.0b7-ish), the default imports are now identical
248
170
// between desktop and Android (to avoid unintended incompatibilities).
@@ -314,4 +236,86 @@ public String[] getAndroidImports() {
314
236
};
315
237
}
316
238
*/
239
+
240
+ /*
241
+ protected boolean parseSketchSize() {
242
+ // This matches against any uses of the size() function, whether numbers
243
+ // or variables or whatever. This way, no warning is shown if size() isn't
244
+ // actually used in the applet, which is the case especially for anyone
245
+ // who is cutting/pasting from the reference.
246
+
247
+ String scrubbed = processing.mode.java.JavaBuild.scrubComments(sketch.getCode(0).getProgram());
248
+ String[] matches = PApplet.match(scrubbed, processing.mode.java.JavaBuild.SIZE_REGEX);
249
+ // PApplet.println("matches: " + Sketch.SIZE_REGEX);
250
+ // PApplet.println(matches);
251
+
252
+ if (matches != null) {
253
+ boolean badSize = false;
254
+
255
+ if (matches[1].equals("screenWidth") ||
256
+ matches[1].equals("screenHeight") ||
257
+ matches[2].equals("screenWidth") ||
258
+ matches[2].equals("screenHeight")) {
259
+ final String message =
260
+ "The screenWidth and screenHeight variables are named\n" +
261
+ "displayWidth and displayHeight in this release of Processing.";
262
+ Base.showWarning("Time for a quick update", message, null);
263
+ return false;
264
+ }
265
+
266
+ if (!matches[1].equals("displayWidth") &&
267
+ !matches[1].equals("displayHeight") &&
268
+ PApplet.parseInt(matches[1], -1) == -1) {
269
+ badSize = true;
270
+ }
271
+ if (!matches[2].equals("displayWidth") &&
272
+ !matches[2].equals("displayHeight") &&
273
+ PApplet.parseInt(matches[2], -1) == -1) {
274
+ badSize = true;
275
+ }
276
+
277
+ if (badSize) {
278
+ // found a reference to size, but it didn't seem to contain numbers
279
+ final String message =
280
+ "The size of this applet could not automatically be determined\n" +
281
+ "from your code. Use only numeric values (not variables) for the\n" +
282
+ "size() command. See the size() reference for more information.";
283
+ Base.showWarning("Could not find sketch size", message, null);
284
+ System.out.println("More about the size() command on Android can be");
285
+ System.out.println("found here: http://wiki.processing.org/w/Android");
286
+ return false;
287
+ }
288
+
289
+ // PApplet.println(matches);
290
+ sizeStatement = matches[0]; // the full method to be removed from the source
291
+ sketchWidth = matches[1];
292
+ sketchHeight = matches[2];
293
+ sketchRenderer = matches[3].trim();
294
+ if (sketchRenderer.length() == 0) {
295
+ sketchRenderer = null;
296
+ }
297
+ } else {
298
+ sizeStatement = null;
299
+ sketchWidth = null;
300
+ sketchHeight = null;
301
+ sketchRenderer = null;
302
+ }
303
+ return true;
304
+ }
305
+ */
306
+
307
+
308
+ /*
309
+ public PreprocessorResult write(Writer out, String program, String[] codeFolderPackages)
310
+ throws SketchException, RecognitionException, TokenStreamException {
311
+ if (sizeStatement != null) {
312
+ int start = program.indexOf(sizeStatement);
313
+ program = program.substring(0, start) +
314
+ program.substring(start + sizeStatement.length());
315
+ }
316
+ // the OpenGL package is back in 2.0a5
317
+ //program = program.replaceAll("import\\s+processing\\.opengl\\.\\S+;", "");
318
+ return super.write(out, program, codeFolderPackages);
319
+ }
320
+ */
317
321
}
0 commit comments