diff --git a/app/src/processing/mode/android/AndroidBuild.java b/app/src/processing/mode/android/AndroidBuild.java index a966a4ea4..b5c183e9c 100644 --- a/app/src/processing/mode/android/AndroidBuild.java +++ b/app/src/processing/mode/android/AndroidBuild.java @@ -125,8 +125,9 @@ class AndroidBuild extends JavaBuild { // if (sizeInfo == null) { // throw new SketchException("Could not parse the size() command."); // } + // On Android, this init will throw a SketchException if there's a problem with size() preproc.initSketchSize(sketch.getMainProgram()); - sketchClassName = preprocess(srcFolder, manifest.getPackageName(), preproc); + sketchClassName = preprocess(srcFolder, manifest.getPackageName(), preproc, false); if (sketchClassName != null) { File tempManifest = new File(tmpFolder, "AndroidManifest.xml"); manifest.writeBuild(tempManifest, sketchClassName, target.equals("debug")); diff --git a/app/src/processing/mode/android/AndroidPreprocessor.java b/app/src/processing/mode/android/AndroidPreprocessor.java index 490c1e17f..4a706f0d5 100644 --- a/app/src/processing/mode/android/AndroidPreprocessor.java +++ b/app/src/processing/mode/android/AndroidPreprocessor.java @@ -162,6 +162,7 @@ public class AndroidPreprocessor extends PdePreprocessor { if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) { out.println(); + if (sketchWidth != null) { out.println(indent + "public int sketchWidth() { return " + sketchWidth + "; }"); } diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index 052ed1ab0..d4e756f12 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -121,8 +121,8 @@ public class JavaBuild { * @return null if compilation failed, main class name if not * @throws RunnerException */ - public String build() throws SketchException { - return build(sketch.makeTempFolder(), sketch.makeTempFolder()); + public String build(boolean sizeWarning) throws SketchException { + return build(sketch.makeTempFolder(), sketch.makeTempFolder(), sizeWarning); } @@ -135,7 +135,7 @@ public class JavaBuild { * * @return null if compilation failed, main class name if not */ - public String build(File srcFolder, File binFolder) throws SketchException { + public String build(File srcFolder, File binFolder, boolean sizeWarning) throws SketchException { this.srcFolder = srcFolder; this.binFolder = binFolder; @@ -143,7 +143,7 @@ public class JavaBuild { // Base.openFolder(binFolder); // run the preprocessor - String classNameFound = preprocess(srcFolder); + String classNameFound = preprocess(srcFolder, sizeWarning); // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build(). @@ -183,8 +183,8 @@ public class JavaBuild { // } - public String preprocess(File srcFolder) throws SketchException { - return preprocess(srcFolder, null, new PdePreprocessor(sketch.getName())); + public String preprocess(File srcFolder, boolean sizeWarning) throws SketchException { + return preprocess(srcFolder, null, new PdePreprocessor(sketch.getName()), sizeWarning); } @@ -197,7 +197,8 @@ public class JavaBuild { */ public String preprocess(File srcFolder, String packageName, - PdePreprocessor preprocessor) throws SketchException { + PdePreprocessor preprocessor, + boolean sizeWarning) throws SketchException { // make sure the user isn't playing "hide the sketch folder" sketch.ensureExistence(); @@ -246,7 +247,7 @@ public class JavaBuild { // if this fella is OpenGL, and if so, to add the import. It's messy and // gross and someday we'll just always include OpenGL. String[] sizeInfo = - preprocessor.initSketchSize(sketch.getMainProgram()); + preprocessor.initSketchSize(sketch.getMainProgram(), sizeWarning); //PdePreprocessor.parseSketchSize(sketch.getMainProgram(), false); if (sizeInfo != null) { String sketchRenderer = sizeInfo[3]; @@ -710,7 +711,7 @@ public class JavaBuild { srcFolder = sketch.makeTempFolder(); binFolder = sketch.makeTempFolder(); - String foundName = build(srcFolder, binFolder); + String foundName = build(srcFolder, binFolder, true); // (already reported) error during export, exit this function if (foundName == null) return false; @@ -1042,7 +1043,7 @@ public class JavaBuild { // not redoing the compilation for each platform. In particular, though, // importedLibraries won't be set until the preprocessing has finished, // so we have to do that before the stuff below. - String foundName = build(); + String foundName = build(true); // (already reported) error during export, exit this function if (foundName == null) return false; diff --git a/app/src/processing/mode/java/JavaMode.java b/app/src/processing/mode/java/JavaMode.java index 55c1e6deb..404cb3243 100644 --- a/app/src/processing/mode/java/JavaMode.java +++ b/app/src/processing/mode/java/JavaMode.java @@ -174,7 +174,7 @@ public class JavaMode extends Mode { public Runner handleRun(Sketch sketch, RunnerListener listener) throws SketchException { JavaBuild build = new JavaBuild(sketch); - String appletClassName = build.build(); + String appletClassName = build.build(false); if (appletClassName != null) { final Runner runtime = new Runner(build, listener); new Thread(new Runnable() { @@ -190,7 +190,7 @@ public class JavaMode extends Mode { public Runner handlePresent(Sketch sketch, RunnerListener listener) throws SketchException { JavaBuild build = new JavaBuild(sketch); - String appletClassName = build.build(); + String appletClassName = build.build(false); if (appletClassName != null) { final Runner runtime = new Runner(build, listener); new Thread(new Runnable() { diff --git a/app/src/processing/mode/java/preproc/PdePreprocessor.java b/app/src/processing/mode/java/preproc/PdePreprocessor.java index 11f0746fa..3b81d3a0b 100644 --- a/app/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/app/src/processing/mode/java/preproc/PdePreprocessor.java @@ -183,8 +183,8 @@ public class PdePreprocessor { } - public String[] initSketchSize(String code) throws SketchException { - String[] info = parseSketchSize(code, true); + public String[] initSketchSize(String code, boolean sizeWarning) throws SketchException { + String[] info = parseSketchSize(code, sizeWarning); if (info != null) { sizeStatement = info[0]; sketchWidth = info[1]; @@ -249,8 +249,11 @@ public class PdePreprocessor { return null; } + // Remove additional space 'round the renderer + matches[3] = matches[3].trim(); + // if the renderer entry is empty, set it to null - if (matches[3].trim().length() == 0) { + if (matches[3].length() == 0) { matches[3] = null; } return matches; @@ -832,13 +835,25 @@ public class PdePreprocessor { if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) { if (sketchWidth != null && !hasMethod("sketchWidth")) { - out.println(indent + "public int sketchWidth() { return " + sketchWidth + "; }"); + // Only include if it's a number (a variable will be a problem) + if (PApplet.parseInt(sketchWidth, -1) != -1 || sketchWidth.equals("displayWidth")) { + out.println(indent + "public int sketchWidth() { return " + sketchWidth + "; }"); + } } if (sketchHeight != null && !hasMethod("sketchHeight")) { - out.println(indent + "public int sketchHeight() { return " + sketchHeight + "; }"); + // Only include if it's a number + if (PApplet.parseInt(sketchHeight, -1) != -1 || sketchHeight.equals("displayHeight")) { + out.println(indent + "public int sketchHeight() { return " + sketchHeight + "; }"); + } } if (sketchRenderer != null && !hasMethod("sketchRenderer")) { - out.println(indent + "public String sketchRenderer() { return " + sketchRenderer + "; }"); + // Only include if it's a known renderer (otherwise it might be a variable) + if (sketchRenderer.equals("P2D") || + sketchRenderer.equals("P3D") || + sketchRenderer.equals("OPENGL") || + sketchRenderer.equals("JAVA2D")) { + out.println(indent + "public String sketchRenderer() { return " + sketchRenderer + "; }"); + } } if (!hasMethod("main")) { diff --git a/core/todo.txt b/core/todo.txt index b743dfc5c..1d68b8cac 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -11,23 +11,19 @@ X loadXML and loadTable are now in desktop o trimming text on URLs? o http://code.google.com/p/processing/issues/detail?id=715 X change screenWidth/Height to displayWidth/Height -_ update wiki.processing.org/w/Window_Size_and_Full_Screen -_ docs: P2D and P3D are now OpenGL variations +X update wiki.processing.org/w/Window_Size_and_Full_Screen X add createGraphics() with no renderer param to point to JAVA2D X also added to Android -_ add to docs X removals X CENTER_RADIUS, CENTER_DIAMETER, NORMALIZED X text(x, y, w, h, z) X textX/Y/Z variables -_ update changes Wiki -_ let's remove 'online' +X update changes Wiki +X let's remove 'online' X changed to 'appletViewer' -_ doesn't test net connection to see if 'online' -_ only tests whether running inside an applet viewer X registerSize() has been removed -_ it hasn't worked for a while, also not a good way to get updates on size -_ use pre() or something like that instead +X it hasn't worked for a while, also not a good way to get updates on size +X use pre() or something like that instead o displayWidth/Height not set until just before setup o don't use size(displayWidth, displayHeight) anymore o to do full screen, should use: @@ -101,11 +97,6 @@ o vectors shouldn't be exposed, need to expose attr lists as arrays o or also add a method for getting the vectors? X no longer an issue post-NanoXML X several other items under the LIBRARIES / XML section below -_ hasChildren()? -_ http://code.google.com/p/processing/issues/detail?id=1045 - -X test what happens with NPE in OpenGL, does the error make sense? -_ nope, it doesn't, need to clean this up sort out full screen issues X make screenWidth and screenHeight work properly with multiple screens @@ -152,6 +143,22 @@ X fix build script to include the jnilib, also add more error checks X screenX and screenY are both already taken, so not including vars for them X decide on naming for the next release + +docs (2.0a6) +_ 'online' has been changed to 'appletViewer' +_ doesn't test net connection to see if 'online' +_ only tests whether running inside an applet viewer +_ createGraphics() with no renderer param to point to JAVA2D +_ docs: P2D and P3D are now OpenGL variations + +_ setAntiAlias() should instead just use parent.smooth +_ antialias -> smoothMode(), smoothQuality(), quality() +_ NEAREST, BILINEAR, BICUBIC, or 0, 2, 4? (need 8x too, so maybe numbers) +_ add hasChildren() to XML library? +_ http://code.google.com/p/processing/issues/detail?id=1045 +X test what happens with NPE in OpenGL, does the error make sense? +_ nope, it doesn't, need to clean this up + _ move requestFocusInWindow() to safter EDT place _ look into using BufferStrategy again to improve performance _ there are more improvements to be made ala issue #729 diff --git a/todo.txt b/todo.txt index 28ae5d946..7f3733de8 100644 --- a/todo.txt +++ b/todo.txt @@ -28,6 +28,10 @@ o pro: can write out error messages (or output) o con: loses cross platform ability o but: open() is platform specific anyway, ppl can use exec() X deciding no, open() would talk to the launcher, not the app +X size(640, 480, P3D ); -> doesn't pick up as a P3D sketch +X too many warnings re: use of size() command +X fjen complaint about size(), update with links to new docs: +X http://code.google.com/p/processing/issues/detail?id=1071 fixed earlier X Export reports "Could not copy source file" (even though it works) @@ -65,13 +69,20 @@ X if no window color set, then don't apply it o also add option for FSEM or not X nope, FSEM too buggy and error-prone -_ size(640, 480, P3D ); -> doesn't pick up as a P3D sketch -_ too many warnings re: use of size() command -_ fjen complaint about size(), update with links to new docs: -_ http://code.google.com/p/processing/issues/detail?id=1071 -_ setAntiAlias() should instead just use parent.smooth -_ antialias -> smoothMode(), smoothQuality(), quality() -_ NEAREST, BILINEAR, BICUBIC, or 0, 2, 4? (need 8x too, so maybe numbers) +o find in reference issues +o if() and for() don't work, they look for for_.html instead of for.html +o XMLElement is not linked for find in ref +o the ? operator is not in find in ref (no ref page either?) +o update keywords generator script on the site +o perhaps move this closer to the dev process? +o move reference folder around so that it matches site organization +o otherwise several links break on the main faq page +o discuss i18n issues and proper system (?) +o look through 404 issues on the site +o TRIANGLE_STRIP not highlighted for "find in reference" +o nor is it listed on the reference page +o so students can't find the ref for it +o needs to link TRIANGLE_STRIP to the beginShape() reference recent/open X add EditorState class, device-aware placement @@ -140,20 +151,6 @@ _ but don't do this with untitled, cuz it kinda stinks _ this is too weird--just put examples into individual zip files _ mark example files as untitled _ though will that require the sketch to be saved before export? -o find in reference issues -o if() and for() don't work, they look for for_.html instead of for.html -o XMLElement is not linked for find in ref -o the ? operator is not in find in ref (no ref page either?) -o update keywords generator script on the site -o perhaps move this closer to the dev process? -o move reference folder around so that it matches site organization -o otherwise several links break on the main faq page -o discuss i18n issues and proper system (?) -o look through 404 issues on the site -o TRIANGLE_STRIP not highlighted for "find in reference" -o nor is it listed on the reference page -o so students can't find the ref for it -o needs to link TRIANGLE_STRIP to the beginShape() reference 2.0 / command line