From 2b021dcb30a27c2a503d615e082c222e68dfd71d Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 16 Apr 2005 03:41:40 +0000 Subject: [PATCH] printarr() totally gone, print() and println() take control --- processing/core/PApplet.java | 155 ++++++++++++++++++++++++++++++++++- processing/core/todo.txt | 16 ++-- processing/todo.txt | 6 +- 3 files changed, 163 insertions(+), 14 deletions(-) diff --git a/processing/core/PApplet.java b/processing/core/PApplet.java index 7ea933fca..b3c01e6f4 100644 --- a/processing/core/PApplet.java +++ b/processing/core/PApplet.java @@ -1998,8 +1998,85 @@ public class PApplet extends Applet } static public void print(Object what) { - System.out.print(what.toString()); - System.out.flush(); + if (what == null) { + // special case since this does fuggly things on > 1.1 + System.out.print("null"); + + } else { + String name = what.getClass().getName(); + if (name.charAt(0) == '[') { + switch (name.charAt(1)) { + case '[': + // don't even mess with multi-dimensional arrays (case '[') + // or anything else that's not int, float, boolean, char + System.out.print(what); + System.out.print(' '); + break; + + case 'L': + // print a 1D array of objects as individual elements + Object poo[] = (Object[]) what; + for (int i = 0; i < poo.length; i++) { + System.out.print(poo[i]); + System.out.print(' '); + } + break; + + case 'Z': // boolean + boolean zz[] = (boolean[]) what; + for (int i = 0; i < zz.length; i++) { + System.out.print(zz[i]); + System.out.print(' '); + } + break; + + case 'B': // byte + byte bb[] = (byte[]) what; + for (int i = 0; i < bb.length; i++) { + System.out.print(bb[i]); + System.out.print(' '); + } + break; + + case 'C': // char + char cc[] = (char[]) what; + for (int i = 0; i < cc.length; i++) { + System.out.print(cc[i]); + System.out.print(' '); + } + break; + + case 'I': // int + int ii[] = (int[]) what; + for (int i = 0; i < ii.length; i++) { + System.out.print(ii[i]); + System.out.print(' '); + } + break; + + case 'F': // float + float ff[] = (float[]) what; + for (int i = 0; i < ff.length; i++) { + System.out.print(ff[i]); + System.out.print(' '); + } + break; + + case 'D': // double + double dd[] = (double[]) what; + for (int i = 0; i < dd.length; i++) { + System.out.print(dd[i]); + System.out.print(' '); + } + break; + + default: + System.out.print(what); + } + } else { + System.out.print(what); //.toString()); + } + } } // @@ -2039,11 +2116,82 @@ public class PApplet extends Applet } static public void println(Object what) { - System.out.println(what.toString()); + if (what == null) { + // special case since this does fuggly things on > 1.1 + System.out.println("null"); + + } else { + String name = what.getClass().getName(); + if (name.charAt(0) == '[') { + switch (name.charAt(1)) { + case '[': + // don't even mess with multi-dimensional arrays (case '[') + // or anything else that's not int, float, boolean, char + System.out.println(what); + break; + + case 'L': + // print a 1D array of objects as individual elements + Object poo[] = (Object[]) what; + for (int i = 0; i < poo.length; i++) { + System.out.println(poo[i]); + } + break; + + case 'Z': // boolean + boolean zz[] = (boolean[]) what; + for (int i = 0; i < zz.length; i++) { + System.out.println(zz[i]); + } + break; + + case 'B': // byte + byte bb[] = (byte[]) what; + for (int i = 0; i < bb.length; i++) { + System.out.println(bb[i]); + } + break; + + case 'C': // char + char cc[] = (char[]) what; + for (int i = 0; i < cc.length; i++) { + System.out.println(cc[i]); + } + break; + + case 'I': // int + int ii[] = (int[]) what; + for (int i = 0; i < ii.length; i++) { + System.out.println(ii[i]); + } + break; + + case 'F': // float + float ff[] = (float[]) what; + for (int i = 0; i < ff.length; i++) { + System.out.println(ff[i]); + } + break; + + case 'D': // double + double dd[] = (double[]) what; + for (int i = 0; i < dd.length; i++) { + System.out.println(dd[i]); + } + break; + + default: + System.out.println(what); + } + } else { + System.out.println(what); //.toString()); + } + } } // + /* static public void printarr(byte what[]) { for (int i = 0; i < what.length; i++) System.out.println(what[i]); System.out.flush(); @@ -2083,6 +2231,7 @@ public class PApplet extends Applet for (int i = 0; i < what.length; i++) System.out.println(what[i]); System.out.flush(); } + */ // diff --git a/processing/core/todo.txt b/processing/core/todo.txt index 66152d365..c9aaa083b 100644 --- a/processing/core/todo.txt +++ b/processing/core/todo.txt @@ -123,8 +123,8 @@ X PFont.list() to return string list of all the available fonts X probably not a mode of use that we really want to encourage X actually important because the whole graphicsdevice crap is silly X and we need a 1.1 versus 1.3/1.4 version - -_ implement printarr() as println() ? +X implement printarr() as println() ? +X actually deal with all the array types.. oy _ rename video.Camera to video.Video ? _ VideoInput VideoOutput, SoundInput, SoundOutput or AudioInput/AudioOutput @@ -134,16 +134,16 @@ _ but don't put commas into the zero-padded version _ make nf/nfs/nfp not so weird _ nf(PLUS, ...) nf(PAD, ...) nfc(PLUS, ...) -_ fix the flicker in java2d mode -X is it because the lock was taken off (g) in PApplet? -_ appears to be much worse (unfinished drawing) on macosx -_ try turning off hw accel on the mac to see if that's the problem - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -NOT NECESSARY BEFORE BETA +NOT COMPLETELY NECESSARY BEFORE BETA + +_ fix the flicker in java2d mode +_ not clear what's happening here +_ appears to be much worse (unfinished drawing) on macosx +_ try turning off hw accel on the mac to see if that's the problem _ post() method to send a bunch of crap to a web url? _ or an example that does this? diff --git a/processing/todo.txt b/processing/todo.txt index 21d0b3de1..0fdae2843 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -14,9 +14,6 @@ _ remove PdeXxx prefixes on names, make PdeBase into just "Processing" _ fix macos readme about how to boost memory size, and 1.3 vs 1.4 -_ placement of 100x100 items is odd -_ happens with P3D and maybe also P2D? - _ update .exe to use new class/package _ update .app to use new class/package _ update linux build and shell scripts for new package @@ -92,6 +89,9 @@ saving a project over an already existing project does not get rid of the .pde f NOT NECESSARY BEFORE BETA +_ placement of 100x100 items is odd +_ happens with P3D and maybe also P2D? + _ if in full java mode _ if extends PApplet.. or rather, put PApplet cast into a _ try/catch block.. if it doesn't work, try applet. if that