From fb8dfbfd9b5ac8087d80a7f13846213984e64ff6 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 7 Aug 2022 22:17:47 -0400 Subject: [PATCH] purge several "applet" references from the code --- app/src/processing/app/Mode.java | 2 +- core/README.md | 48 +++---- core/src/processing/awt/PSurfaceAWT.java | 60 +-------- core/src/processing/core/PGraphics.java | 2 +- core/src/processing/core/PShapeSVG.java | 2 +- core/src/processing/opengl/PSurfaceJOGL.java | 40 +++--- .../net/src/processing/net/Client.java | 120 +++++++++--------- .../net/src/processing/net/Server.java | 80 ++++++------ .../serial/src/processing/serial/Serial.java | 78 ++++++------ todo.txt | 2 +- 10 files changed, 188 insertions(+), 246 deletions(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index be8ec3674..67ec35259 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -810,7 +810,7 @@ public abstract class Mode { /** - * Create a fresh applet/application folder if the 'delete target folder' + * Create a fresh application folder if the 'delete target folder' * pref has been set in the preferences. */ public void prepareExportFolder(File targetFolder) { diff --git a/core/README.md b/core/README.md index 98c046fc2..81c77cf01 100644 --- a/core/README.md +++ b/core/README.md @@ -6,10 +6,10 @@ We've removed `Applet` as the base class for `PApplet` and have redone the entir #### Why? -1. The changes improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like `Applet` (which subclasses `Component`) cause (sometimes major) performance restrictions or other visual glitches like flicker. +1. The changes improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like `Applet` (which subclasses `Component`) cause (sometimes major) performance restrictions or other visual glitches like flicker. 2. Without making these changes, the code to mitigate the issues from #1 is very difficult to debug and make work properly across the many platforms we support: Macs, Macs with retina displays, Windows 7, Windows 8, 32- and 64-bit machines, Linux who-knows-what, and so on. 3. The design of `core` is 13 years old, and the graphics features available (OpenGL, `VolatileImage`, `BufferStrategy`, etc) have changed drastically since then. I've papered over these changes and done my best to keep performance on-pace so that we don't break a lot of old code (or libraries), but now is the time for a clean break. -4. With the death of applets, keeping the `Applet` base class is anachronistic (in addition to hindering performance). However, we're keeping the name `PApplet` because with any luck, these changes will only require a recompile of any sketch (or library) code. +4. With the death of applets, keeping the `Applet` base class is anachronistic (in addition to hindering performance). However, we're keeping the name `PApplet` because with any luck, these changes will only require a recompile of any sketch (or library) code. #### What else? @@ -20,17 +20,17 @@ We've removed `Applet` as the base class for `PApplet` and have redone the entir 5. In 3.0a2 we changed the OS X version to use Apple's "official" full screen mode. With this came a dorky animation and the inability to span multiple screens. We've rolled that back because of the latter, though the former was also a consideration. -#### But what about...? +#### But what about...? We're still determining how much code we're willing to break due to API changes. Stay tuned. #### Integration with Java applications -One downside of these changes is that you'll no longer be able to just drop a Processing sketch into other Java code, because `PApplet` will no longer subclass `Applet` (and therefore, `Component`). This is a huge downside for a tiny number of users. +One downside of these changes is that you'll no longer be able to just drop a Processing sketch into other Java code, because `PApplet` will no longer subclass `Applet` (and therefore, `Component`). This is a huge downside for a tiny number of users. -Making it a generic `Component`, however, means that we cannot improve performance, due to the cross-platform mess of Java's outdated (and somewhat unsuspported) AWT. +Making it a generic `Component`, however, means that we cannot improve performance, due to the cross-platform mess of Java's outdated (and somewhat unsuspported) AWT. -In 3.0 alpha 6, the `getCanvas()` method (called`getComponent()` in alpha 7) provided a way to get an object to be embedded, but it looks like we'll have to move in another direction. At the present time, it looks like it'll be necessary to create a separate `PComponent` or `PCanvas` class that can be used, but it's not clear how that will work. We'll have this sorted out by the final release of 3.0. +In 3.0 alpha 6, the `getCanvas()` method (called`getComponent()` in alpha 7) provided a way to get an object to be embedded, but it looks like we'll have to move in another direction. At the present time, it looks like it'll be necessary to create a separate `PComponent` or `PCanvas` class that can be used, but it's not clear how that will work. We'll have this sorted out by the final release of 3.0. This is one of many unfortunate tradeoffs I'm trying to sort through as we try to remove significant barriers to performance caused by the design of Java's AWT, while also supporting features (like embedding) that we've spent so much time supporting in the past. @@ -41,10 +41,10 @@ Prior to Processing 3, dark magic was used to make the `size()` command work. Th * `setup()` would run, and if the renderer changed, the sketch would throw an exception causing things to restart (re-calling the `setup()` method) * The previous step gave fits to any other variants of Processing (like Python or Ruby or Scala) -We had a tricky, stuttery situation where some things would happen automatically, other things would be delayed slightly. -In the Android version of Processing, these methods weren't possible, so we enhanced the preprocessor to parse the `size()` command used in the sketch and create methods called `sketchWidth()` and `sketchHeight()` and so on, that returned the values found in `setup()`. +We had a tricky, stuttery situation where some things would happen automatically, other things would be delayed slightly. +In the Android version of Processing, these methods weren't possible, so we enhanced the preprocessor to parse the `size()` command used in the sketch and create methods called `sketchWidth()` and `sketchHeight()` and so on, that returned the values found in `setup()`. -In Processing 3, we've moved in a different direction. A new method called `settings()` has been introduced. When running inside the PDE, commands like `size()`, `fullScreen()`, `pixelDensity()`, and `smooth()` are all moved to the `settings()` method, which is called once, before `setup()`. Those are the only methods that can be called inside `settings()`. When outside the PDE (i.e. using Eclipse), you'll need to move those methods to `settings()` yourself. +In Processing 3, we've moved in a different direction. A new method called `settings()` has been introduced. When running inside the PDE, commands like `size()`, `fullScreen()`, `pixelDensity()`, and `smooth()` are all moved to the `settings()` method, which is called once, before `setup()`. Those are the only methods that can be called inside `settings()`. When outside the PDE (i.e. using Eclipse), you'll need to move those methods to `settings()` yourself. #### Offscreen rendering @@ -56,34 +56,34 @@ Documentation is on its way, see [here](https://github.com/processing/processing #### The Event Dispatch Thread -The source has gone back and forth between putting all AWT (and Swing, if any) calls on the [EDT](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html). Per Oracle's statements in Java's documentation, this is best practice (at least for Swing; for AWT it's not clear). However, we've gone back and forth several times as to whether it's necessary or worthwhile. +The source has gone back and forth between putting all AWT (and Swing, if any) calls on the [EDT](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html). Per Oracle's statements in Java's documentation, this is best practice (at least for Swing; for AWT it's not clear). However, we've gone back and forth several times as to whether it's necessary or worthwhile. Actual rendering in the default renderer happens off the EDT, but the EDT is used to blit the image to the screen (or resize windows, etc). By moving to the EDT, we're looking for more consistent cross-platform results. In practice, results are either mixed or not there. -## OpenGL +## OpenGL And now, for something completely different. ### Changes from 2.x -Any code that uses `javax.media.opengl` in imports should replace that `com.jogamp.opengl`. I guess the JOGL folks are fully on their own w/o Oracle/Sun support. +Any code that uses `javax.media.opengl` in imports should replace that `com.jogamp.opengl`. I guess the JOGL folks are fully on their own w/o Oracle/Sun support. -### NEWT +### NEWT NEWT was written by the JOGL guys so that they could avoid AWT altogether. The outdated/outmoded AWT makes a lot of assumptions that make implementation of GL a mess and causes performance trouble. This is a big part of the rendering changes that I’ve been making in 3—that we’re moving away from AWT as much as possible so that we don’t have performance problems. In the GL case, AWT causes some stuttering and lowered frame rates. We can get rid of those by dropping Applet, Component, and Canvas, and switching to NEWT’s windowing mechanism. ### JOGL vs LWJGL -During the alpha 6, 7, and 8 release process we did some juggling with what OpenGL library we should use. +During the alpha 6, 7, and 8 release process we did some juggling with what OpenGL library we should use. The short version of how it played out (written 15 May 2015) * JOGL had some major bugs and development seemed to have stopped (summer/fall 2014) * @codeanticode had been trying out LWJGL2 to see how it fared (last fall 2014) * The LWJGL project has moved all their development effort to LWJGL3 (since then) * Andrés spent the week rewriting OpenGL to use LWJGL3 -* LWJGL3 is simply too unstable for us to use, would require major reworking of PApplet to remove *all* uses of AWT, and they seem to be still struggling with many fundamental issues (this week) -* Andrés went back to JOGL (last 48 hours) to find that many bugs had been fixed and development was continuing. +* LWJGL3 is simply too unstable for us to use, would require major reworking of PApplet to remove *all* uses of AWT, and they seem to be still struggling with many fundamental issues (this week) +* Andrés went back to JOGL (last 48 hours) to find that many bugs had been fixed and development was continuing. * For 3.0a8, we dropped LWJGL since JOGL is performing much better, and we're 99% sure that's the final decision for 3.0 (yesterday). It looks like LWJGL3 will be a nice game-centric platform (full screen, affordances for game input/behavior) in the coming months, but the direction they're having to go with 3 means they're moving further away from what we need in Processing with something *slightly* more general. @@ -91,7 +91,7 @@ It looks like LWJGL3 will be a nice game-centric platform (full screen, affordan LWJGL and JOGL are both great projects and we're thankful for all the work that they put in, and our own experience with Processing means that we couldn't be more sympathetic to the difficulty they face in maintaining their cross-platform, cross-chipset, cross-everything code. Like Processing, both projects are open source and created by volunteers who give their work away for free. We're enormously appreciative of their efforts. -## JavaFX +## JavaFX Similarly to the NEWT situation in JOGL described above, we’ve hit the upper bound of what we can do on performance in Java2D as well. The graphics engineers from the Java team seem to have all moved to JavaFX for the last few years, perhaps because AWT is a dead end. So… I’ve started doing the JavaFX port so that we can drop even more of the AWT code. @@ -102,9 +102,9 @@ We hope to make JavaFX the default renderer instead of Java2D. With any luck, we ## Whither AWT -Run away from the AWT. All of our focus is on the OpenGL and JavaFX rendering engines, neither of which use AWT. Even the (currently) default `PGraphicsJava2D` renderer will be de-emphasized (though not removed) in the final 3.0. +Run away from the AWT. All of our focus is on the OpenGL and JavaFX rendering engines, neither of which use AWT. Even the (currently) default `PGraphicsJava2D` renderer will be de-emphasized (though not removed) in the final 3.0. -* * * +* * * # The Mess @@ -126,11 +126,11 @@ The rest of this document are my notes while I'm making changes. 6. renderer that draws to screen (Java2D) or not (PDF) 7. OpenGL or not -resize events: +resize events: Frame > Canvas > PGraphics > PApplet user-driven Frame resize events follow that order all resize events happen on the surface -applet sends message to the surface, which notifies the renderer itself +sketch sends message to the surface, which notifies the renderer itself resize of component is handled in thread-safe way from PSurface PApplet.size() calls setSize() in PSurface, and in surface: @@ -152,7 +152,7 @@ inside main, will know the screen that's being used for the app #### Questions/To Do - change size() command to check through renderer constants and give better error message when using one of the built-in renderers - bad idea, or worst idea, to have 'surface' var in PGraphics? -- move getFontRenderContext(font) to PApplet? surface? elsewhere? +- move getFontRenderContext(font) to PApplet? surface? elsewhere? _ do we need canDraw() anymore? - Can we remove while() loop that waits until defaultSize is set false? - Does init() need to go away, because it's not going to work in any other setting? Because a surface must first be created, the init() method on its own will be a mess. @@ -165,10 +165,10 @@ _ do we need canDraw() anymore? - do we need sketchOutputPath() and sketchOutputStream()? #### Removed functions (not final, just notes) -param() +param() the old awt event handlers (they were a warning in 2.x) PGraphics.requestDraw(), because renderers now have their own threads PGraphics.setFrameRate removed, added to PSurface requires 1.7.. uses revalidate() method -destroy() (only called by applet? calls dispose()) +destroy() (only called by Applet? calls dispose()) diff --git a/core/src/processing/awt/PSurfaceAWT.java b/core/src/processing/awt/PSurfaceAWT.java index 5f306a25d..71e0ef2be 100644 --- a/core/src/processing/awt/PSurfaceAWT.java +++ b/core/src/processing/awt/PSurfaceAWT.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2014-15 The Processing Foundation + Copyright (c) 2014-22 The Processing Foundation This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -388,7 +388,7 @@ public class PSurfaceAWT extends PSurfaceNone { // For 0149, moving this code (up to the pack() method) before init(). // For OpenGL (and perhaps other renderers in the future), a peer is // needed before a GLDrawable can be created. So pack() needs to be - // called on the Frame before applet.init(), which itself calls size(), + // called on the Frame before init(), which itself calls size(), // and launches the Thread that will kick off setup(). // https://download.processing.org/bugzilla/891.html // https://download.processing.org/bugzilla/908.html @@ -421,7 +421,6 @@ public class PSurfaceAWT extends PSurfaceNone { } */ frame.setLayout(null); - //frame.add(applet); // Need to pass back our new sketchWidth/Height here, because it may have // been overridden by numbers we calculated above if fullScreen and/or @@ -653,63 +652,10 @@ public class PSurfaceAWT extends PSurfaceNone { label.setSize(labelSize); label.setLocation(20, screenRect.height - labelSize.height - 20); } - -// if (sketch.getGraphics().displayable()) { -// setVisible(true); -// } } - /* - @Override - public void placeWindow(int[] location) { - setFrameSize(); //sketchWidth, sketchHeight); - - if (location != null) { - // a specific location was received from the Runner - // (applet has been run more than once, user placed window) - frame.setLocation(location[0], location[1]); - - } else { // just center on screen - // Can't use frame.setLocationRelativeTo(null) because it sends the - // frame to the main display, which undermines the --display setting. - frame.setLocation(screenRect.x + (screenRect.width - sketchWidth) / 2, - screenRect.y + (screenRect.height - sketchHeight) / 2); - } - Point frameLoc = frame.getLocation(); - if (frameLoc.y < 0) { - // Windows actually allows you to place frames where they can't be - // closed. Awesome. https://download.processing.org/bugzilla/1508.html - frame.setLocation(frameLoc.x, 30); - } - -// if (backgroundColor != null) { -// ((JFrame) frame).getContentPane().setBackground(backgroundColor); -// } - - setCanvasSize(); //sketchWidth, sketchHeight); - - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); - - // handle frame resizing events - setupFrameResizeListener(); - - // all set for rockin - if (sketch.getGraphics().displayable()) { - frame.setVisible(true); - } - } - */ - - private void setCanvasSize() { -// System.out.format("setting canvas size %d %d%n", sketchWidth, sketchHeight); -// new Exception().printStackTrace(System.out); int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH); int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT); @@ -784,7 +730,7 @@ public class PSurfaceAWT extends PSurfaceNone { if (!sketch.sketchFullScreen()) { if (location != null) { // a specific location was received from the Runner - // (applet has been run more than once, user placed window) + // (sketch has been run more than once, user placed window) frame.setLocation(location[0], location[1]); } else if (editorLocation != null) { diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 60accd765..583bdb60e 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -971,7 +971,7 @@ public class PGraphics extends PImage implements PConstants { textAlign = LEFT; textMode = MODEL; - // if this fella is associated with an applet, then clear its background. + // if this fella is associated with a component, then clear its background. // if it's been created by someone else through createGraphics, // they have to call background() themselves, otherwise everything gets // a gray background (when just a transparent surface or an empty pdf diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index 8e8e78242..39cbf0c11 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-22 The Processing Foundation Copyright (c) 2006-12 Ben Fry and Casey Reas Copyright (c) 2004-06 Michael Chang diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index 8bec77415..6a81f3e89 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -549,30 +549,26 @@ public class PSurfaceJOGL implements PSurface { } catch (IOException ignored) { } try { - // attempt to load from a local file, used when running as - // an application, or as a signed applet - try { // first try to catch any security exceptions - try { - String path = sketch.dataPath(filename); - stream = new FileInputStream(path); - stream.close(); - return path; - } catch (IOException ignored) { } + // attempt to load from a local file + try { + String path = sketch.dataPath(filename); + stream = new FileInputStream(path); + stream.close(); + return path; + } catch (IOException ignored) { } - try { - String path = sketch.sketchPath(filename); - stream = new FileInputStream(path); - stream.close(); - return path; - } catch (Exception ignored) { } + try { + String path = sketch.sketchPath(filename); + stream = new FileInputStream(path); + stream.close(); + return path; + } catch (Exception ignored) { } - try { - stream = new FileInputStream(filename); - stream.close(); - return filename; - } catch (IOException ignored) { } - - } catch (SecurityException ignored) { } // online, whups + try { + stream = new FileInputStream(filename); + stream.close(); + return filename; + } catch (IOException ignored) { } } catch (Exception e) { //die(e.getMessage(), e); diff --git a/java/libraries/net/src/processing/net/Client.java b/java/libraries/net/src/processing/net/Client.java index 7b03c5e8e..048c6799b 100644 --- a/java/libraries/net/src/processing/net/Client.java +++ b/java/libraries/net/src/processing/net/Client.java @@ -32,11 +32,11 @@ import java.net.*; import java.nio.charset.StandardCharsets; /** - * - * A client connects to a server and sends data back and forth. If anything - * goes wrong with the connection, for example the host is not there or is + * + * A client connects to a server and sends data back and forth. If anything + * goes wrong with the connection, for example the host is not there or is * listening on a different port, an exception is thrown. - * + * * @webref client * @webBrief The client class is used to create client Objects which connect to a server to exchange data * @instanceName client any variable of type Client @@ -67,8 +67,8 @@ public class Client implements Runnable { int bufferLast; boolean disposeRegistered = false; - - + + /** * @param parent typically use "this" * @param host address of the server @@ -113,7 +113,7 @@ public class Client implements Runnable { } } - + /** * @param socket any object of type Socket */ @@ -147,15 +147,15 @@ public class Client implements Runnable { /** - * - * Disconnects from the server. Use to shut the connection when you're + * + * Disconnects from the server. Use to shut the connection when you're * finished with the Client. - * + * * @webref client * @webBrief Disconnects from the server * @usage application */ - public void stop() { + public void stop() { if (disconnectEventMethod != null && thread != null){ try { disconnectEventMethod.invoke(parent, this); @@ -181,7 +181,7 @@ public class Client implements Runnable { * Disconnect from the server: internal use only. *

* This should only be called by the internal functions in PApplet, - * use stop() instead from within your own applets. + * use stop() instead from within your own sketches. */ public void dispose() { thread = null; @@ -202,7 +202,7 @@ public class Client implements Runnable { } catch (Exception e) { e.printStackTrace(); } - + try { if (socket != null) { socket.close(); @@ -230,7 +230,7 @@ public class Client implements Runnable { while (input != null) { int readCount; - // try to read a byte using a blocking read. + // try to read a byte using a blocking read. // An exception will occur when the sketch is exits. try { readCount = input.read(readBuffer, 0, readBuffer.length); @@ -240,7 +240,7 @@ public class Client implements Runnable { stop(); return; } - + // read returns -1 if end-of-stream occurs (for example if the host disappears) if (readCount == -1) { System.err.println("Client got end-of-stream."); @@ -303,10 +303,10 @@ public class Client implements Runnable { /** - * + * * Returns true if this client is still active and hasn't run * into any trouble. - * + * * @webref client * @webBrief Returns true if this client is still active * @usage application @@ -317,9 +317,9 @@ public class Client implements Runnable { /** - * + * * Returns the IP address of the computer to which the Client is attached. - * + * * @webref client * @usage application * @webBrief Returns the IP address of the machine as a String @@ -333,10 +333,10 @@ public class Client implements Runnable { /** - * - * Returns the number of bytes available. When any client has bytes + * + * Returns the number of bytes available. When any client has bytes * available from the server, it returns the number of bytes. - * + * * @webref client * @usage application * @webBrief Returns the number of bytes in the buffer waiting to be read @@ -349,9 +349,9 @@ public class Client implements Runnable { /** - * + * * Empty the buffer, removes all the data stored there. - * + * * @webref client * @usage application * @webBrief Clears the buffer @@ -365,11 +365,11 @@ public class Client implements Runnable { /** - * - * Returns a number between 0 and 255 for the next byte that's waiting in - * the buffer. Returns -1 if there is no byte, although this should be + * + * Returns a number between 0 and 255 for the next byte that's waiting in + * the buffer. Returns -1 if there is no byte, although this should be * avoided by first checking available() to see if any data is available. - * + * * @webref client * @usage application * @webBrief Returns a value from the buffer @@ -389,10 +389,10 @@ public class Client implements Runnable { /** - * - * Returns the next byte in the buffer as a char. Returns -1 or + * + * Returns the next byte in the buffer as a char. Returns -1 or * 0xffff if nothing is there. - * + * * @webref client * @usage application * @webBrief Returns the next byte in the buffer as a char @@ -406,21 +406,21 @@ public class Client implements Runnable { /** - * - * Reads a group of bytes from the buffer. The version with no parameters - * returns a byte array of all data in the buffer. This is not efficient, - * but is easy to use. The version with the byteBuffer parameter is - * more memory and time efficient. It grabs the data in the buffer and puts - * it into the byte array passed in and returns an int value for the number - * of bytes read. If more bytes are available than can fit into the + * + * Reads a group of bytes from the buffer. The version with no parameters + * returns a byte array of all data in the buffer. This is not efficient, + * but is easy to use. The version with the byteBuffer parameter is + * more memory and time efficient. It grabs the data in the buffer and puts + * it into the byte array passed in and returns an int value for the number + * of bytes read. If more bytes are available than can fit into the * byteBuffer, only those that fit are read. - * + * *

Advanced

* Return a byte array of anything that's in the serial buffer. * Not particularly memory/speed efficient, because it creates * a byte array on each read, but it's easier to use than * readBytes(byte b[]) (see below). - * + * * @webref client * @usage application * @webBrief Reads a group of bytes from the buffer @@ -479,7 +479,7 @@ public class Client implements Runnable { * Returns an int for how many bytes were read. If more bytes * are available than can fit into the byte array, only those * that will fit are read. - * + * * @param bytebuffer passed in byte array to be altered */ public int readBytes(byte[] bytebuffer) { @@ -501,18 +501,18 @@ public class Client implements Runnable { /** - * - * Reads from the port into a buffer of bytes up to and including a - * particular character. If the character isn't in the buffer, 'null' is - * returned. The version with no byteBuffer parameter returns a byte - * array of all data up to and including the interesting byte. This - * is not efficient, but is easy to use. The version with the - * byteBuffer parameter is more memory and time efficient. It grabs - * the data in the buffer and puts it into the byte array passed in and - * returns an int value for the number of bytes read. If the byte buffer is - * not large enough, -1 is returned and an error is printed to the message + * + * Reads from the port into a buffer of bytes up to and including a + * particular character. If the character isn't in the buffer, 'null' is + * returned. The version with no byteBuffer parameter returns a byte + * array of all data up to and including the interesting byte. This + * is not efficient, but is easy to use. The version with the + * byteBuffer parameter is more memory and time efficient. It grabs + * the data in the buffer and puts it into the byte array passed in and + * returns an int value for the number of bytes read. If the byte buffer is + * not large enough, -1 is returned and an error is printed to the message * area. If nothing is in the buffer, 0 is returned. - * + * * @webref client * @usage application * @webBrief Reads from the buffer of bytes up to and including a particular character @@ -557,7 +557,7 @@ public class Client implements Runnable { * and an error message is printed on the console. * If nothing is in the buffer, zero is returned. * If 'interesting' byte is not in the buffer, then 0 is returned. - * + * * @param byteBuffer passed in byte array to be altered */ public int readBytesUntil(int interesting, byte[] byteBuffer) { @@ -601,7 +601,7 @@ public class Client implements Runnable { * * In 4.0 beta 3, changed to using UTF-8 as the encoding, * otherwise the behavior is platform-dependent. - * + * * @webref client * @usage application * @webBrief Returns the buffer as a String @@ -616,14 +616,14 @@ public class Client implements Runnable { /** - * - * Combination of readBytesUntil() and readString(). Returns + * + * Combination of readBytesUntil() and readString(). Returns * null if it doesn't find what you're looking for. - * + * *

Advanced

* In 4.0 beta 3, changed to using UTF-8 as the encoding, * otherwise the behavior is platform-dependent. - * + * * @webref client * @usage application * @webBrief Returns the buffer as a String up to and including a particular character @@ -641,9 +641,9 @@ public class Client implements Runnable { /** * * Writes data to a server specified when constructing the client, or writes - * data to the specific client obtained from the Server available() + * data to the specific client obtained from the Server available() * method. - * + * * @webref client * @usage application * @webBrief Writes bytes, chars, ints, bytes[], Strings diff --git a/java/libraries/net/src/processing/net/Server.java b/java/libraries/net/src/processing/net/Server.java index dc354df44..3e7535bb2 100644 --- a/java/libraries/net/src/processing/net/Server.java +++ b/java/libraries/net/src/processing/net/Server.java @@ -33,17 +33,17 @@ import java.net.*; /** - * - * A server sends and receives data to and from its associated clients - * (other programs connected to it). When a server is started, it begins - * listening for connections on the port specified by the port - * parameter. Computers have many ports for transferring data and some are - * commonly used so be sure to not select one of these. For example, web + * + * A server sends and receives data to and from its associated clients + * (other programs connected to it). When a server is started, it begins + * listening for connections on the port specified by the port + * parameter. Computers have many ports for transferring data and some are + * commonly used so be sure to not select one of these. For example, web * servers usually use port 80 and POP mail uses port 110. - * + * * @webref server * @usage application - * @webBrief The server class is used to create server objects which send + * @webBrief The server class is used to create server objects which send * and receives data to and from its associated clients (other programs connected to it) * @instanceName server any variable of type Server */ @@ -61,7 +61,7 @@ public class Server implements Runnable { /** Array of client objects, useful length is determined by clientCount. */ public Client[] clients; - + /** * @param parent typically use "this" * @param port port used to transfer data @@ -69,12 +69,12 @@ public class Server implements Runnable { public Server(PApplet parent, int port) { this(parent, port, null); } - - + + /** * @param parent typically use "this" * @param port port used to transfer data - * @param host when multiple NICs are in use, the ip (or name) to bind from + * @param host when multiple NICs are in use, the ip (or name) to bind from */ public Server(PApplet parent, int port, String host) { this.parent = parent; @@ -94,7 +94,7 @@ public class Server implements Runnable { parent.registerMethod("dispose", this); - // reflection to check whether host applet has a call for + // reflection to check whether host sketch has a call for // public void serverEvent(Server s, Client c); // which is called when a new guy connects try { @@ -114,9 +114,9 @@ public class Server implements Runnable { /** - * + * * Disconnect a particular client. - * + * * @webref server * @webBrief Disconnect a particular client * @param client the client to disconnect @@ -130,8 +130,8 @@ public class Server implements Runnable { } } } - - + + protected void removeIndex(int index) { synchronized (clientsLock) { clientCount--; @@ -143,8 +143,8 @@ public class Server implements Runnable { clients[clientCount] = null; } } - - + + protected void disconnectAll() { synchronized (clientsLock) { for (int i = 0; i < clientCount; i++) { @@ -158,8 +158,8 @@ public class Server implements Runnable { clientCount = 0; } } - - + + protected void addClient(Client client) { synchronized (clientsLock) { if (clientCount == clients.length) { @@ -168,8 +168,8 @@ public class Server implements Runnable { clients[clientCount++] = client; } } - - + + protected int clientIndex(Client client) { synchronized (clientsLock) { for (int i = 0; i < clientCount; i++) { @@ -181,20 +181,20 @@ public class Server implements Runnable { } } - + /** - * + * * Returns true if this server is still active and hasn't run * into any trouble. - * + * * @webref server * @webBrief Return true if this server is still active */ public boolean active() { return thread != null; } - - + + static public String ip() { try { return InetAddress.getLocalHost().getHostAddress(); @@ -211,9 +211,9 @@ public class Server implements Runnable { int lastAvailable = -1; /** - * + * * Returns the next client in line with a new message. - * + * * @webref server * @webBrief Returns the next client in line with a new message * @usage application @@ -247,13 +247,13 @@ public class Server implements Runnable { /** - * + * * Disconnects all clients and stops the server. - * + * *

Advanced

- * Use this to shut down the server if you finish using it while your applet - * is still running. Otherwise, it will be automatically be shut down by the - * host PApplet using dispose(), which is identical. + * Use this to shut down the server if you finish using it while your sketch + * is still running. Otherwise, it will be automatically be shut down by the + * host PApplet using dispose(), which is identical. * @webref server * @webBrief Disconnects all clients and stops the server * @usage application @@ -323,10 +323,10 @@ public class Server implements Runnable { /** - * - * Writes a value to all the connected clients. It sends bytes out from the + * + * Writes a value to all the connected clients. It sends bytes out from the * Server object. - * + * * @webref server * @webBrief Writes data to all connected clients * @param data data to write @@ -344,7 +344,7 @@ public class Server implements Runnable { } } } - + public void write(byte data[]) { synchronized (clientsLock) { @@ -359,7 +359,7 @@ public class Server implements Runnable { } } } - + public void write(String data) { synchronized (clientsLock) { diff --git a/java/libraries/serial/src/processing/serial/Serial.java b/java/libraries/serial/src/processing/serial/Serial.java index 6ff3909d8..a0b5f8462 100644 --- a/java/libraries/serial/src/processing/serial/Serial.java +++ b/java/libraries/serial/src/processing/serial/Serial.java @@ -34,9 +34,9 @@ import jssc.*; /** - * + * * Class for sending and receiving data using the serial communication protocol. - * + * * @webref serial * @webBrief Class for sending and receiving data using the serial communication protocol * @instanceName serial any variable of type Serial @@ -186,7 +186,7 @@ public class Serial implements SerialPortEventListener { /** * Returns the number of bytes available. - * + * * @generate Serial_available.xml * @webref serial * @webBrief Returns the number of bytes available @@ -212,7 +212,7 @@ public class Serial implements SerialPortEventListener { /** * Sets a specific byte to buffer until before calling serialEvent(). - * + * * @generate Serial_bufferUntil.xml * @webref serial * @webBrief Sets a specific byte to buffer until before calling serialEvent() @@ -266,7 +266,7 @@ public class Serial implements SerialPortEventListener { /** * Returns last byte received or -1 if there is none available. - * + * * @generate Serial_last.xml *

Advanced

* Same as read() but returns the very last value received @@ -292,7 +292,7 @@ public class Serial implements SerialPortEventListener { /** * Returns the last byte received as a char or -1 if there is none available. - * + * * @generate Serial_lastChar.xml * @webref serial * @webBrief Returns the last byte received as a char or -1 if there is none available @@ -304,9 +304,9 @@ public class Serial implements SerialPortEventListener { /** - * Gets a list of all available serial ports. Use println() to write the + * Gets a list of all available serial ports. Use println() to write the * information to the text window. - * + * * @generate Serial_list.xml * @webref serial * @webBrief Gets a list of all available serial ports @@ -320,10 +320,10 @@ public class Serial implements SerialPortEventListener { /** - * Returns a number between 0 and 255 for the next byte that's waiting in the buffer. - * Returns -1 if there is no byte, although this should be avoided by first cheacking + * Returns a number between 0 and 255 for the next byte that's waiting in the buffer. + * Returns -1 if there is no byte, although this should be avoided by first cheacking * available() to see if data is available. - * + * * @generate Serial_read.xml * @webref serial * @webBrief Returns a number between 0 and 255 for the next byte that's waiting in the buffer @@ -346,11 +346,11 @@ public class Serial implements SerialPortEventListener { /** - * Reads a group of bytes from the buffer or null if there are none available. The version - * with no parameters returns a byte array of all data in the buffer. This is not efficient, but - * is easy to use. The version with the byteBuffer parameter is more memory and time - * efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns - * an int value for the number of bytes read. If more bytes are available than can fit into the + * Reads a group of bytes from the buffer or null if there are none available. The version + * with no parameters returns a byte array of all data in the buffer. This is not efficient, but + * is easy to use. The version with the byteBuffer parameter is more memory and time + * efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns + * an int value for the number of bytes read. If more bytes are available than can fit into the * byteBuffer, only those that fit are read. * @generate Serial_readBytes.xml * @webref serial @@ -370,7 +370,7 @@ public class Serial implements SerialPortEventListener { return ret; } } - + /** *

Advanced

@@ -432,18 +432,18 @@ public class Serial implements SerialPortEventListener { return toCopy; } } - + /** - * Reads from the port into a buffer of bytes up to and including a particular character. If the - * character isn't in the buffer, null is returned. The version with without the - * byteBuffer parameter returns a byte array of all data up to and including the - * interesting byte. This is not efficient, but is easy to use. The version with the - * byteBuffer parameter is more memory and time efficient. It grabs the data in the buffer - * and puts it into the byte array passed in and returns an int value for the number of bytes read. - * If the byte buffer is not large enough, -1 is returned and an error is printed to the message + * Reads from the port into a buffer of bytes up to and including a particular character. If the + * character isn't in the buffer, null is returned. The version with without the + * byteBuffer parameter returns a byte array of all data up to and including the + * interesting byte. This is not efficient, but is easy to use. The version with the + * byteBuffer parameter is more memory and time efficient. It grabs the data in the buffer + * and puts it into the byte array passed in and returns an int value for the number of bytes read. + * If the byte buffer is not large enough, -1 is returned and an error is printed to the message * area. If nothing is in the buffer, 0 is returned. - * + * * @generate Serial_readBytesUntil.xml * @webref serial * @webBrief Reads from the port into a buffer of bytes up to and including a particular character @@ -527,7 +527,7 @@ public class Serial implements SerialPortEventListener { /** - * Returns the next byte in the buffer as a char. Returns -1 or 0xffff + * Returns the next byte in the buffer as a char. Returns -1 or 0xffff * if nothing is there. * * @generate Serial_readChar.xml @@ -541,9 +541,9 @@ public class Serial implements SerialPortEventListener { /** - * Returns all the data from the buffer as a String or null if there is nothing available. - * This method assumes the incoming characters are ASCII. If you want to transfer Unicode data, - * first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or + * Returns all the data from the buffer as a String or null if there is nothing available. + * This method assumes the incoming characters are ASCII. If you want to transfer Unicode data, + * first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or * two-byte Unicode data), and send it as a byte array. * * @generate Serial_readString.xml @@ -560,7 +560,7 @@ public class Serial implements SerialPortEventListener { /** - * Combination of readBytesUntil() and readString(). Returns null + * Combination of readBytesUntil() and readString(). Returns null * if it doesn't find what you're looking for. * * @generate Serial_readStringUntil.xml @@ -585,11 +585,11 @@ public class Serial implements SerialPortEventListener { /** - * Called when data is available. Use one of the read() methods to capture this data. - * The serialEvent() can be set with buffer() to only trigger after a certain - * number of data elements are read and can be set with bufferUntil() to only trigger - * after a specific character is read. The which parameter contains the name of the - * port where new data is available, but is only useful when there is more than one serial + * Called when data is available. Use one of the read() methods to capture this data. + * The serialEvent() can be set with buffer() to only trigger after a certain + * number of data elements are read and can be set with bufferUntil() to only trigger + * after a specific character is read. The which parameter contains the name of the + * port where new data is available, but is only useful when there is more than one serial * connection open and it's necessary to distinguish between the two. * * @generate serialEvent.xml @@ -630,7 +630,7 @@ public class Serial implements SerialPortEventListener { // serialAvailable() does not provide any real benefits over using // available() and read() inside draw - but this function has no // thread-safety issues since it's being invoked during pre in the context - // of the Processing applet + // of the Processing sketch serialEventMethod.invoke(parent, this); } catch (Exception e) { System.err.println("Error, disabling serialEvent() for "+port.getPortName()); @@ -676,7 +676,7 @@ public class Serial implements SerialPortEventListener { /** * Stops data communication on this port. Use to shut the connection when you're finished with the Serial. - * + * * @generate Serial_stop.xml * @webref serial * @webBrief Stops data communication on this port @@ -723,7 +723,7 @@ public class Serial implements SerialPortEventListener { /** * Writes bytes, chars, ints, bytes[], Strings to the serial port - * + * *

Advanced

* Write a String to the output. Note that this doesn't account * for Unicode (two bytes per char), nor will it send UTF8 diff --git a/todo.txt b/todo.txt index 7706da17e..4f66fb3d0 100755 --- a/todo.txt +++ b/todo.txt @@ -81,6 +81,7 @@ An unexpected error has been detected by HotSpot Virtual Machine: # EXCEPTION_ACCESS_VIOLATION all i can do is find things that might trigger them, but it's more likely than not to be a java problem, and not something that can be fixed +X search the source for 'applet' references (i.e. SVG docs) housekeeping X make sure the numbers scripts are working again before launch @@ -460,7 +461,6 @@ _ or for now, tell users how to do it manually _ batik and ant have both broken the build when old versions were removed _ save() and saveAs() need to be refactored _ https://github.com/processing/processing/issues/3843 -_ search the source for 'applet' references (i.e. SVG docs) _ move Library to LibraryContribution and into contrib? _ improve error message when creating a tab with the same name _ right now it's generic, based on "a file exists"