diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 59b9f4b0a..dad092741 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1353,9 +1353,28 @@ public class PApplet extends Applet RegisteredMethods mouseEventMethods, keyEventMethods; + protected void reportDeprecation(Class c, boolean mouse) { + if (g != null) { + PGraphics.showWarning("The class " + c.getName() + + " is incompatible with Processing 2.0."); + PGraphics.showWarning("A library (or other code) is using register" + + (mouse ? "Mouse" : "Key") + "Event()" + + "which is no longer available."); + // This will crash with OpenGL, so quit anyway + if (g instanceof PGraphicsOpenGL) { + PGraphics.showWarning("Stopping the sketch because this code will " + + "not work correctly with OpenGL."); + throw new RuntimeException("This sketch uses a library that " + + "needs to be updated for Processing 2.0."); + } + } + } + + @Deprecated public void registerMouseEvent(Object o) { Class c = o.getClass(); + reportDeprecation(c, true); try { Method method = c.getMethod("mouseEvent", new Class[] { java.awt.event.MouseEvent.class }); if (mouseEventMethods == null) { @@ -1368,9 +1387,22 @@ public class PApplet extends Applet } + @Deprecated + public void unregisterMouseEvent(Object o) { + try { +// Method method = o.getClass().getMethod("mouseEvent", new Class[] { MouseEvent.class }); +// mouseEventMethods.remove(o, method); + mouseEventMethods.remove(o); + } catch (Exception e) { + die("Could not unregister mouseEvent() for " + o, e); + } + } + + @Deprecated public void registerKeyEvent(Object o) { Class c = o.getClass(); + reportDeprecation(c, false); try { Method method = c.getMethod("keyEvent", new Class[] { java.awt.event.KeyEvent.class }); if (keyEventMethods == null) { @@ -1383,18 +1415,6 @@ public class PApplet extends Applet } - @Deprecated - public void unregisterMouseEvent(Object o) { - try { -// Method method = o.getClass().getMethod("mouseEvent", new Class[] { MouseEvent.class }); -// mouseEventMethods.remove(o, method); - mouseEventMethods.remove(o); - } catch (Exception e) { - die("Could not unregister mouseEvent() for " + o, e); - } - } - - @Deprecated public void unregisterKeyEvent(Object o) { try { @@ -10475,66 +10495,6 @@ public class PApplet extends Applet } - /** - * ( begin auto-generated from hint.xml ) - * - * Set various hints and hacks for the renderer. This is used to handle - * obscure rendering features that cannot be implemented in a consistent - * manner across renderers. Many options will often graduate to standard - * features instead of hints over time. - *

- * hint(ENABLE_OPENGL_4X_SMOOTH) - Enable 4x anti-aliasing for P3D. This - * can help force anti-aliasing if it has not been enabled by the user. On - * some graphics cards, this can also be set by the graphics driver's - * control panel, however not all cards make this available. This hint must - * be called immediately after the size() command because it resets the - * renderer, obliterating any settings and anything drawn (and like size(), - * re-running the code that came before it again). - *

- * hint(DISABLE_OPENGL_2X_SMOOTH) - In Processing 1.0, Processing always - * enables 2x smoothing when the P3D renderer is used. This hint disables - * the default 2x smoothing and returns the smoothing behavior found in - * earlier releases, where smooth() and noSmooth() could be used to enable - * and disable smoothing, though the quality was inferior. - *

- * hint(ENABLE_NATIVE_FONTS) - Use the native version fonts when they are - * installed, rather than the bitmapped version from a .vlw file. This is - * useful with the default (or JAVA2D) renderer setting, as it will improve - * font rendering speed. This is not enabled by default, because it can be - * misleading while testing because the type will look great on your - * machine (because you have the font installed) but lousy on others' - * machines if the identical font is unavailable. This option can only be - * set per-sketch, and must be called before any use of textFont(). - *

- * hint(DISABLE_DEPTH_TEST) - Disable the zbuffer, allowing you to draw on - * top of everything at will. When depth testing is disabled, items will be - * drawn to the screen sequentially, like a painting. This hint is most - * often used to draw in 3D, then draw in 2D on top of it (for instance, to - * draw GUI controls in 2D on top of a 3D interface). Starting in release - * 0149, this will also clear the depth buffer. Restore the default with - * hint(ENABLE_DEPTH_TEST), but note that with the depth buffer cleared, - * any 3D drawing that happens later in draw() will ignore existing shapes - * on the screen. - *

- * hint(ENABLE_DEPTH_SORT) - Enable primitive z-sorting of triangles and - * lines in P3D and OPENGL. This can slow performance considerably, and the - * algorithm is not yet perfect. Restore the default with hint(DISABLE_DEPTH_SORT). - *

- * hint(DISABLE_OPENGL_ERROR_REPORT) - Speeds up the P3D renderer setting - * by not checking for errors while running. Undo with hint(ENABLE_OPENGL_ERROR_REPORT). - *

- * As of release 0149, unhint() has been removed in favor of adding - * additional ENABLE/DISABLE constants to reset the default behavior. This - * prevents the double negatives, and also reinforces which hints can be - * enabled or disabled. - * - * ( end auto-generated ) - * @webref rendering - * @param which name of the hint to be enabled or disabled - * @see PGraphics - * @see PApplet#createGraphics(int, int, String, String) - * @see PApplet#size(int, int) - */ public void hint(int which) { if (recorder != null) recorder.hint(which); g.hint(which); diff --git a/core/todo.txt b/core/todo.txt index f4922e32b..31e8292ce 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -20,16 +20,13 @@ o when using loadFont(), don't enable native fonts unless hint() in use o but on createFont(), we're probably OK o might need to make reference notes about the two behaviors X decision: remove hint(ENABLE_NATIVE_FONTS) - -_ PImage.resize() greater than loaded image size hangs Java App -_ http://code.google.com/p/processing/issues/detail?id=1463 -_ add a warning message with registerMouseEvent() -_ don't let OpenGL fire those mouse events at all -_ phrase the warning differently when OpenGL is in use (or only show then?) -_ api note: size() used in data classes -_ length() too confusing w/ array.length being built-in (when to use ()?) -_ size() a bit confusing with the p5 size command, but less problematic -_ also shorter than getCount() or getLength() +X PImage.resize() greater than image size hangs +X http://code.google.com/p/processing/issues/detail?id=1463 +X turns out to be errata from the book +X add warning message when registering AWT mouse/key events +X don't let OpenGL fire those mouse events at all +X phrase the warning differently when OpenGL is in use (or only show then?) +X halt with OpenGL, otherwise will be ignored decisions on data @@ -42,8 +39,13 @@ X or leave it in as an advanced feature? X createXxx() methods less important X XML.parse() - or new XML("") or new XML("tag") _ add parseXML() and parseJSONObject(x) - +X api note: size() used in data classes +X length() too confusing w/ array.length being built-in (when to use ()?) +X size() a bit confusing with the p5 size command, but less problematic +X also shorter than getCount() or getLength() _ why not HashMap and ArrayList for JSON? +_ could enable loadHash() and loadArray() functions +_ or loadDict() and loadList() as the case might be _ JSONObject.has(key) vs XML.hasAttribute(attr) vs HashMap.containsKey() _ and how it should be handled with hash/dict