diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index d3a778a08..4edca955b 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -23,40 +23,29 @@ package processing.core; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; +import java.io.*; +import java.lang.reflect.*; +import java.net.*; +import java.text.NumberFormat; +import java.util.*; +import java.util.regex.*; +import java.util.zip.*; +import android.app.*; import android.content.*; import android.content.pm.ActivityInfo; import android.content.pm.ConfigurationInfo; import android.content.res.AssetManager; import android.content.res.Configuration; import android.graphics.*; - -import java.io.*; -import java.lang.reflect.*; -import java.net.MalformedURLException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.text.NumberFormat; -import java.util.*; -import java.util.regex.*; -import java.util.zip.*; - -import android.app.Activity; -import android.app.ActivityManager; import android.net.Uri; -import android.text.format.Time; -import android.util.*; -import android.view.MotionEvent; -import android.view.SurfaceView; import android.opengl.GLSurfaceView; -import android.view.WindowManager; import android.os.Bundle; import android.os.Handler; +import android.text.format.Time; +import android.util.*; import android.view.*; -import android.widget.LinearLayout; +import android.widget.*; import android.widget.RelativeLayout; import org.apache.http.client.HttpClient; @@ -65,9 +54,8 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.HttpResponse; import org.apache.http.HttpEntity; -import processing.opengl.PGraphicsOpenGL; - -import java.net.URI; +import processing.data.*; +import processing.opengl.*; public class PApplet extends Activity implements PConstants, Runnable { diff --git a/android/core/src/processing/core/PShapeSVG.java b/android/core/src/processing/core/PShapeSVG.java index 0d1cad8bd..23960f1e3 100644 --- a/android/core/src/processing/core/PShapeSVG.java +++ b/android/core/src/processing/core/PShapeSVG.java @@ -23,6 +23,8 @@ package processing.core; +import processing.data.*; + import java.util.HashMap; import android.graphics.*; diff --git a/android/core/src/processing/data/XML.java b/android/core/src/processing/data/XML.java index da734153d..5699d0808 100644 --- a/android/core/src/processing/data/XML.java +++ b/android/core/src/processing/data/XML.java @@ -20,7 +20,7 @@ Boston, MA 02111-1307 USA */ -package processing.core; +package processing.data; import java.io.*; diff --git a/app/src/processing/mode/android/AndroidPreprocessor.java b/app/src/processing/mode/android/AndroidPreprocessor.java index 2369dfcb2..906461bfc 100644 --- a/app/src/processing/mode/android/AndroidPreprocessor.java +++ b/app/src/processing/mode/android/AndroidPreprocessor.java @@ -40,21 +40,21 @@ import antlr.TokenStreamException; public class AndroidPreprocessor extends PdePreprocessor { Sketch sketch; String packageName; - + String sizeStatement; - String sketchWidth; + String sketchWidth; String sketchHeight; String sketchRenderer; - public AndroidPreprocessor(final Sketch sketch, + public AndroidPreprocessor(final Sketch sketch, final String packageName) throws IOException { super(sketch.getName()); this.sketch = sketch; this.packageName = packageName; } - + // TODO this needs to be a generic function inside Sketch or elsewhere protected boolean parseSketchSize() { @@ -70,7 +70,7 @@ public class AndroidPreprocessor extends PdePreprocessor { if (matches != null) { boolean badSize = false; - + if (!matches[1].equals("screenWidth") && !matches[1].equals("screenHeight") && PApplet.parseInt(matches[1], -1) == -1) { @@ -84,7 +84,7 @@ public class AndroidPreprocessor extends PdePreprocessor { if (badSize) { // found a reference to size, but it didn't seem to contain numbers - final String message = + final String message = "The size of this applet could not automatically be determined\n" + "from your code. Use only numeric values (not variables) for the\n" + "size() command. See the size() reference for more information."; @@ -116,7 +116,7 @@ public class AndroidPreprocessor extends PdePreprocessor { throws SketchException, RecognitionException, TokenStreamException { if (sizeStatement != null) { int start = program.indexOf(sizeStatement); - program = program.substring(0, start) + + program = program.substring(0, start) + program.substring(start + sizeStatement.length()); } // String[] found = PApplet.match(program, "import\\s+processing.opengl.*\\s*"); @@ -166,8 +166,9 @@ public class AndroidPreprocessor extends PdePreprocessor { @Override public String[] getCoreImports() { - return new String[] { - "processing.core.*" + return new String[] { + "processing.core.*", + "processing.data.*" }; } @@ -192,7 +193,7 @@ public class AndroidPreprocessor extends PdePreprocessor { //"java.util.zip.*", "java.util.regex.*" // not necessary w/ newer i/o }; - Preferences.set("android.preproc.imports.list", + Preferences.set("android.preproc.imports.list", PApplet.join(androidImports, ",")); return androidImports; diff --git a/app/src/processing/mode/android/Manifest.java b/app/src/processing/mode/android/Manifest.java index e35594711..1818538b2 100644 --- a/app/src/processing/mode/android/Manifest.java +++ b/app/src/processing/mode/android/Manifest.java @@ -29,28 +29,28 @@ import java.io.PrintWriter; import processing.app.*; import processing.core.PApplet; -import processing.core.XML; +import processing.data.XML; public class Manifest { static final String MANIFEST_XML = "AndroidManifest.xml"; - static final String WORLD_OF_HURT_COMING = - "Errors occurred while reading or writing " + MANIFEST_XML + ",\n" + + static final String WORLD_OF_HURT_COMING = + "Errors occurred while reading or writing " + MANIFEST_XML + ",\n" + "which means lots of things are likely to stop working properly.\n" + - "To prevent losing any data, it's recommended that you use “Save As”\n" + - "to save a separate copy of your sketch, and the restart Processing."; - static final String MULTIPLE_ACTIVITIES = + "To prevent losing any data, it's recommended that you use “Save As”\n" + + "to save a separate copy of your sketch, and the restart Processing."; + static final String MULTIPLE_ACTIVITIES = "Processing only supports a single Activity in the AndroidManifest.xml\n" + - "file. Only the first activity entry will be updated, and you better \n" + + "file. Only the first activity entry will be updated, and you better \n" + "hope that's the right one, smartypants."; // private Editor editor; private Sketch sketch; - + // entries we care about from the manifest file // private String packageName; - + /** the manifest data read from the file */ private XML xml; @@ -64,13 +64,13 @@ public class Manifest { this.sketch = sketch; load(); } - - + + private String defaultPackageName() { // Sketch sketch = editor.getSketch(); return AndroidBuild.basePackage + "." + sketch.getName().toLowerCase(); } - + // called by other classes who want an actual package name // internally, we'll figure this out ourselves whether it's filled or not @@ -78,20 +78,20 @@ public class Manifest { String pkg = xml.getString("package"); return pkg.length() == 0 ? defaultPackageName() : pkg; } - - + + public void setPackageName(String packageName) { // this.packageName = packageName; // this is the package attribute in the root object xml.setString("package", packageName); save(); } - - + + //writer.println(" "); //writer.println(" "); static final String PERMISSION_PREFIX = "android.permission."; - + public String[] getPermissions() { XML[] elements = xml.getChildren("uses-permission"); int count = elements.length; @@ -101,8 +101,8 @@ public class Manifest { } return names; } - - + + public void setPermissions(String[] names) { // just remove all the old ones for (XML kid : xml.getChildren("uses-permission")) { @@ -141,14 +141,14 @@ public class Manifest { writer.println(""); // pretty name // writer.println(" android:label=\"\">"); - // activity/android:name should be the full name (package + class name) of - // the actual activity class. or the package can be replaced by a single + // activity/android:name should be the full name (package + class name) of + // the actual activity class. or the package can be replaced by a single // dot as a prefix as an easier shorthand. writer.println(" "); @@ -186,14 +186,14 @@ public class Manifest { /** - * Save a new version of the manifest info to the build location. + * Save a new version of the manifest info to the build location. * Also fill in any missing attributes that aren't yet set properly. */ - protected void writeBuild(File file, String className, + protected void writeBuild(File file, String className, boolean debug) throws IOException { // write a copy to the build location save(file); - + // load the copy from the build location and start messing with it XML mf = new XML(new FileReader(file)); @@ -235,7 +235,7 @@ public class Manifest { } catch (Exception e) { e.printStackTrace(); System.err.println("Problem reading AndroidManifest.xml, creating a new version"); - + // remove the old manifest file, rename it with date stamp long lastModified = manifestFile.lastModified(); String stamp = AndroidMode.getDateStamp(lastModified); @@ -247,7 +247,7 @@ public class Manifest { return; } } - } + } if (xml == null) { writeBlankManifest(manifestFile); try { @@ -262,13 +262,13 @@ public class Manifest { } // return xml; } - - + + protected void save() { save(getManifestFile()); } - + /** * Save to the sketch folder, so that it can be copied in later. */ diff --git a/app/src/processing/mode/java/preproc/PdePreprocessor.java b/app/src/processing/mode/java/preproc/PdePreprocessor.java index 93b016fa4..d9aece7cd 100644 --- a/app/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/app/src/processing/mode/java/preproc/PdePreprocessor.java @@ -127,13 +127,13 @@ import antlr.collections.AST; * itself. The ANTLR manual goes into a fair amount of detail about the * what each type of file is for. *

- * + * * Hacked to death in 2010 by * @author Jonathan Feinberg <jdf@pobox.com> */ public class PdePreprocessor { - protected static final String UNICODE_ESCAPES = "0123456789abcdefABCDEF"; - + protected static final String UNICODE_ESCAPES = "0123456789abcdefABCDEF"; + // used for calling the ASTFactory to get the root node private static final int ROOT_ID = 0; @@ -271,7 +271,7 @@ public class PdePreprocessor { if (UNICODE_ESCAPES.indexOf(program.charAt(i)) == -1) { throw new SketchException("Bad or unfinished \\uXXXX sequence " + "(malformed Unicode character constant)", 0, - countNewlines(program.substring(0, i))); + countNewlines(program.substring(0, i))); } i++; } @@ -394,13 +394,13 @@ public class PdePreprocessor { return new String(p2, 0, index); } - private static final Pattern PUBLIC_CLASS = + private static final Pattern PUBLIC_CLASS = Pattern.compile("(^|;)\\s*public\\s+class\\s+\\S+\\s+extends\\s+PApplet", Pattern.MULTILINE); // Can't only match any 'public class', needs to be a PApplet - // http://code.google.com/p/processing/issues/detail?id=551 + // http://code.google.com/p/processing/issues/detail?id=551 //Pattern.compile("(^|;)\\s*public\\s+class", Pattern.MULTILINE); - private static final Pattern FUNCTION_DECL = + private static final Pattern FUNCTION_DECL = Pattern.compile("(^|;)\\s*((public|private|protected|final|static)\\s+)*" + "(void|int|float|double|String|char|byte)" + "(\\s*\\[\\s*\\])?\\s+[a-zA-Z0-9]+\\s*\\(", @@ -550,8 +550,8 @@ public class PdePreprocessor { final AST oldFirstMod = mods.getFirstChild(); for (AST mod = oldFirstMod; mod != null; mod = mod.getNextSibling()) { final int t = mod.getType(); - if (t == PdeTokenTypes.LITERAL_private || - t == PdeTokenTypes.LITERAL_protected || + if (t == PdeTokenTypes.LITERAL_private || + t == PdeTokenTypes.LITERAL_protected || t == PdeTokenTypes.LITERAL_public) { return; } @@ -559,7 +559,7 @@ public class PdePreprocessor { if (mods.getNextSibling().getType() == PdeTokenTypes.TYPE_PARAMETERS) { return; } - final CommonHiddenStreamToken publicToken = + final CommonHiddenStreamToken publicToken = new CommonHiddenStreamToken(PdeTokenTypes.LITERAL_public, "public") { { setHiddenAfter(new CommonHiddenStreamToken(PdeTokenTypes.WS, " ")); @@ -593,7 +593,7 @@ public class PdePreprocessor { } /** - * + * * @param out * @param programImports * @param codeFolderImports @@ -695,8 +695,9 @@ public class PdePreprocessor { } public String[] getCoreImports() { - return new String[] { - "processing.core.*" + return new String[] { + "processing.core.*", + "processing.data.*" }; } @@ -705,7 +706,7 @@ public class PdePreprocessor { String prefsLine = Preferences.get("preproc.imports.list"); return PApplet.splitTokens(prefsLine, ", "); } - + /** * Return true if this import should be removed from the code. This is used * for packages like processing.xml which no longer exist. diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 705ad4fee..716042a67 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -23,6 +23,8 @@ package processing.core; +import processing.data.*; + import java.applet.*; import java.awt.*; import java.awt.event.*; @@ -51,7 +53,7 @@ import javax.swing.SwingUtilities; *

* The * Window Size and Full Screen page on the Wiki has useful information - * about sizing, multiple displays, full screen, etc. + * about sizing, multiple displays, full screen, etc. *

* As of release 0145, Processing uses active mode rendering in all cases. * All animation tasks happen on the "Processing Animation Thread". The @@ -64,10 +66,10 @@ import javax.swing.SwingUtilities; * animation thread. Use of a callback function or the registerXxx() methods * in PApplet can help ensure that your code doesn't do something naughty. *

- * As of Processing 2.0, we have discontinued support for versions of Java + * As of Processing 2.0, we have discontinued support for versions of Java * prior to 1.6. We don't have enough people to support it, and for a - * project of our (tiny) size, we should be focusing on the future, rather - * than working around legacy Java code. + * project of our (tiny) size, we should be focusing on the future, rather + * than working around legacy Java code. *

* This class extends Applet instead of JApplet because 1) historically, * we supported Java 1.1, which does not include Swing (without an @@ -89,10 +91,10 @@ import javax.swing.SwingUtilities; * would any other Component. *

* Because the default animation thread will run at 60 frames per second, - * an embedded PApplet can make the parent application sluggish. You can use + * an embedded PApplet can make the parent application sluggish. You can use * frameRate() to make it update less often, or you can use noLoop() and loop() * to disable and then re-enable looping. If you want to only update the sketch - * intermittently, use noLoop() inside setup(), and redraw() whenever the + * intermittently, use noLoop() inside setup(), and redraw() whenever the * screen needs to be updated once (or loop() to re-enable the animation * thread). The following example embeds a sketch and also uses the noLoop() * and redraw() methods. You need not use noLoop() and redraw() when embedding @@ -233,14 +235,14 @@ public class PApplet extends Applet public Frame frame; // public JFrame frame; -// /** -// * Usually just 0, but with multiple displays, the X and Y coordinates of -// * the screen will depend on the current screen's position relative to -// * the other displays. +// /** +// * Usually just 0, but with multiple displays, the X and Y coordinates of +// * the screen will depend on the current screen's position relative to +// * the other displays. // */ -// public int screenX; +// public int screenX; // public int screenY; - + /** * ( begin auto-generated from screenWidth.xml ) * @@ -309,12 +311,12 @@ public class PApplet extends Applet static public final int MIN_WINDOW_WIDTH = 128; static public final int MIN_WINDOW_HEIGHT = 128; - /** + /** * Gets set by main() if --present (old) or --full-screen (newer) are used, - * and is returned by sketchFullscreen() when initializing in main(). + * and is returned by sketchFullscreen() when initializing in main(). */ -// protected boolean fullScreen = false; - +// protected boolean fullScreen = false; + /** * Exception thrown when size() is called the first time. *

@@ -751,7 +753,7 @@ public class PApplet extends Applet /** @deprecated use --full-screen instead. */ static public final String ARGS_PRESENT = "--present"; - + static public final String ARGS_FULL_SCREEN = "--full-screen"; // static public final String ARGS_EXCLUSIVE = "--exclusive"; @@ -888,8 +890,8 @@ public class PApplet extends Applet public String sketchRenderer() { return JAVA2D; } - - + + public boolean sketchFullScreen() { // return fullScreen; return false; @@ -1890,15 +1892,15 @@ public class PApplet extends Applet if (frameCount == 0) { GraphicsConfiguration gc = getGraphicsConfiguration(); if (gc == null) return; - GraphicsDevice displayDevice = + GraphicsDevice displayDevice = getGraphicsConfiguration().getDevice(); if (displayDevice == null) return; - Rectangle screenRect = + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); // screenX = screenRect.x; // screenY = screenRect.y; screenWidth = screenRect.width; - screenHeight = screenRect.height; + screenHeight = screenRect.height; try { //println("Calling setup()"); @@ -9286,7 +9288,7 @@ public class PApplet extends Applet applet.frame = frame; applet.sketchPath = folder; // If the applet doesn't call for full screen, but the command line does, - // enable it. Conversely, if the command line does not, don't disable it. + // enable it. Conversely, if the command line does not, don't disable it. // applet.fullScreen |= present; // Query the applet to see if it wants to be full screen all the time. present |= applet.sketchFullScreen(); @@ -9298,12 +9300,12 @@ public class PApplet extends Applet // Need to save the window bounds at full screen, // because pack() will cause the bounds to go to zero. // http://dev.processing.org/bugs/show_bug.cgi?id=923 - Rectangle screenRect = + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); // DisplayMode doesn't work here, because we can't get the upper-left // corner of the display, which is important for multi-display setups. - - // Sketch has already requested to be the same as the screen's + + // Sketch has already requested to be the same as the screen's // width and height, so let's roll with full screen mode. if (screenRect.width == applet.sketchWidth() && screenRect.height == applet.sketchHeight()) { @@ -9442,7 +9444,7 @@ public class PApplet extends Applet frame.setLocation(locationX, locationY); } } else { // just center on screen - // Can't use frame.setLocationRelativeTo(null) because it sends the + // 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 - applet.width) / 2, screenRect.y + (screenRect.height - applet.height) / 2); @@ -9518,11 +9520,11 @@ public class PApplet extends Applet runSketch(argsWithSketchName, this); } - + protected void runSketch() { runSketch(new String[0]); } - + ////////////////////////////////////////////////////////////// @@ -10254,15 +10256,15 @@ public class PApplet extends Applet /** * ( begin auto-generated from line.xml ) - * - * Draws a line (a direct path between two points) to the screen. The - * version of line() with four parameters draws the line in 2D. To - * color a line, use the stroke() function. A line cannot be filled, - * therefore the fill() function will not affect the color of a - * line. 2D lines are drawn with a width of one pixel by default, but this - * can be changed with the strokeWeight() function. The version with - * six parameters allows the line to be placed anywhere within XYZ space. - * Drawing this shape in 3D with the z parameter requires the P3D + * + * Draws a line (a direct path between two points) to the screen. The + * version of line() with four parameters draws the line in 2D. To + * color a line, use the stroke() function. A line cannot be filled, + * therefore the fill() function will not affect the color of a + * line. 2D lines are drawn with a width of one pixel by default, but this + * can be changed with the strokeWeight() function. The version with + * six parameters allows the line to be placed anywhere within XYZ space. + * Drawing this shape in 3D with the z parameter requires the P3D * parameter in combination with size() as shown in the above example. * * ( end auto-generated ) @@ -10384,7 +10386,7 @@ public class PApplet extends Applet * rectMode() function. * * ( end auto-generated ) - * + * * @webref shape:2d_primitives * @param a x-coordinate of the rectangle by default * @param b y-coordinate of the rectangle by default @@ -10423,16 +10425,16 @@ public class PApplet extends Applet /** * ( begin auto-generated from ellipseMode.xml ) - * - * The origin of the ellipse is modified by the ellipseMode() - * function. The default configuration is ellipseMode(CENTER), which - * specifies the location of the ellipse as the center of the shape. The - * RADIUS mode is the same, but the width and height parameters to - * ellipse() specify the radius of the ellipse, rather than the - * diameter. The CORNER mode draws the shape from the upper-left - * corner of its bounding box. The CORNERS mode uses the four - * parameters to ellipse() to set two opposing corners of the - * ellipse's bounding box. The parameter must be written in ALL CAPS + * + * The origin of the ellipse is modified by the ellipseMode() + * function. The default configuration is ellipseMode(CENTER), which + * specifies the location of the ellipse as the center of the shape. The + * RADIUS mode is the same, but the width and height parameters to + * ellipse() specify the radius of the ellipse, rather than the + * diameter. The CORNER mode draws the shape from the upper-left + * corner of its bounding box. The CORNERS mode uses the four + * parameters to ellipse() to set two opposing corners of the + * ellipse's bounding box. The parameter must be written in ALL CAPS * because Processing is a case-sensitive language. * * ( end auto-generated ) @@ -10543,7 +10545,7 @@ public class PApplet extends Applet * with two parameters. * * ( end auto-generated ) - * + * *

Advanced

* Code for sphereDetail() submitted by toxi [031031]. * Code for enhanced u/v version from davbol [080801]. @@ -10574,7 +10576,7 @@ public class PApplet extends Applet * A sphere is a hollow ball made from tessellated triangles. * * ( end auto-generated ) - * + * *

Advanced

*

* Implementation notes: @@ -10616,7 +10618,7 @@ public class PApplet extends Applet * at t. * * ( end auto-generated ) - * + * *

Advanced

* For instance, to convert the following example:
    * stroke(255, 102, 0);
@@ -10661,7 +10663,7 @@ public class PApplet extends Applet
    * target="new">tangent on Wikipedia.
    *
    * ( end auto-generated )
-   * 
+   *
    * 

Advanced

* Code submitted by Dave Bollinger (davol) for release 0136. * @@ -10688,7 +10690,7 @@ public class PApplet extends Applet * P2D renderer does not use this information. * * ( end auto-generated ) - * + * * @webref shape:curves * @param detail resolution of the curves * @see PGraphics#curve(float, float, float, float, float, float, float, float, float, float, float, float) @@ -10722,7 +10724,7 @@ public class PApplet extends Applet * Environment reference for more information). * * ( end auto-generated ) - * + * *

Advanced

* Draw a cubic bezier curve. The first and last points are * the on-curve points. The middle two are the 'control' points, @@ -10833,7 +10835,7 @@ public class PApplet extends Applet * P2D renderer does not use this information. * * ( end auto-generated ) - * + * * @webref shape:curves * @param detail resolution of the curves * @see PGraphics#curve(float, float, float, float, float, float, float, float, float, float, float, float) @@ -10858,7 +10860,7 @@ public class PApplet extends Applet * recognizable and as values increase in magnitude, they will continue to deform. * * ( end auto-generated ) - * + * * @webref shape:curves * @param tightness amount of deformation from the original vertices * @see PGraphics#curve(float, float, float, float, float, float, float, float, float, float, float, float) @@ -10946,7 +10948,7 @@ public class PApplet extends Applet * smoothing altogether. * * ( end auto-generated ) - * + * * @webref shape:attributes * @see PGraphics#noSmooth() * @see PGraphics#hint(int) @@ -10996,7 +10998,7 @@ public class PApplet extends Applet * Processing is a case-sensitive language. * * ( end auto-generated ) - * + * * @webref image:loading_displaying * @param mode either CORNER, CORNERS, or CENTER * @see PApplet#loadImage(String, String) @@ -11037,7 +11039,7 @@ public class PApplet extends Applet * This function will maintain transparency for GIF and PNG images. * * ( end auto-generated ) - * + * *

Advanced

* Starting with release 0124, when using the default (JAVA2D) renderer, * smooth() will also improve image quality of resized images. @@ -11092,7 +11094,7 @@ public class PApplet extends Applet * Processing is a case sensitive language. * * ( end auto-generated ) - * + * * @webref shape:loading_displaying * @param mode either CORNER, CORNERS, CENTER * @see PGraphics#shape(PShape) @@ -11138,7 +11140,7 @@ public class PApplet extends Applet * yet support shapes that have holes or complicated breaks. * * ( end auto-generated ) - * + * * @webref shape:loading_displaying * @param shape the shape to display * @param x x-coordinate of the shape @@ -11190,7 +11192,7 @@ public class PApplet extends Applet * if you change the size of the font. * * ( end auto-generated ) - * + * * @webref typography:attributes * @param alignX horizontal alignment, either LEFT, CENTER, or RIGHT * @param alignY vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE @@ -11213,7 +11215,7 @@ public class PApplet extends Applet * will give you the total height of the line. * * ( end auto-generated ) - * + * * @webref typography:metrics * @see PGraphics#textDescent() */ @@ -11231,7 +11233,7 @@ public class PApplet extends Applet * textDescent() values will give you the total height of the line. * * ( end auto-generated ) - * + * * @webref typography:metrics * @see PGraphics#textAscent() */ @@ -11290,7 +11292,7 @@ public class PApplet extends Applet * will be used in all subsequent calls to the text() function. * * ( end auto-generated ) - * + * * @webref typography:attributes * @param leading the size in pixels for spacing between lines * @see PApplet#loadFont(String) @@ -11306,23 +11308,23 @@ public class PApplet extends Applet /** * ( begin auto-generated from textMode.xml ) - * - * Sets the way text draws to the screen. In the default configuration, the - * MODEL mode, it's possible to rotate, scale, and place letters in + * + * Sets the way text draws to the screen. In the default configuration, the + * MODEL mode, it's possible to rotate, scale, and place letters in * two and three dimensional space.
*
- * The SHAPE mode draws text using the the glyph outlines of - * individual characters rather than as textures. This mode is only - * supported with the PDF and P3D renderer settings. With the - * PDF renderer, you must call textMode(SHAPE) before any - * other drawing occurs. If the outlines are not available, then - * textMode(SHAPE) will be ignored and textMode(MODEL) will + * The SHAPE mode draws text using the the glyph outlines of + * individual characters rather than as textures. This mode is only + * supported with the PDF and P3D renderer settings. With the + * PDF renderer, you must call textMode(SHAPE) before any + * other drawing occurs. If the outlines are not available, then + * textMode(SHAPE) will be ignored and textMode(MODEL) will * be used instead.
*
- * The textMode(SHAPE) option in P3D can be combined with - * beginRaw() to write vector-accurate text to 2D and 3D output - * files, for instance DXF or PDF. The SHAPE mode is - * not currently optimized for P3D, so if recording shape data, use + * The textMode(SHAPE) option in P3D can be combined with + * beginRaw() to write vector-accurate text to 2D and 3D output + * files, for instance DXF or PDF. The SHAPE mode is + * not currently optimized for P3D, so if recording shape data, use * textMode(MODEL) until you're ready to capture the geometry with beginRaw(). * * ( end auto-generated ) @@ -11349,7 +11351,7 @@ public class PApplet extends Applet * calls to the text() function. Font size is measured in units of pixels. * * ( end auto-generated ) - * + * * @webref typography:attributes * @param size the size of the letters in units of pixels * @see PApplet#loadFont(String) @@ -11574,18 +11576,18 @@ public class PApplet extends Applet /** * ( begin auto-generated from pushMatrix.xml ) - * - * Pushes the current transformation matrix onto the matrix stack. - * Understanding pushMatrix() and popMatrix() requires - * understanding the concept of a matrix stack. The pushMatrix() - * function saves the current coordinate system to the stack and - * popMatrix() restores the prior coordinate system. - * pushMatrix() and popMatrix() are used in conjuction with - * the other transformation functions and may be embedded to control the + * + * Pushes the current transformation matrix onto the matrix stack. + * Understanding pushMatrix() and popMatrix() requires + * understanding the concept of a matrix stack. The pushMatrix() + * function saves the current coordinate system to the stack and + * popMatrix() restores the prior coordinate system. + * pushMatrix() and popMatrix() are used in conjuction with + * the other transformation functions and may be embedded to control the * scope of the transformations. * * ( end auto-generated ) - * + * * @webref transform * @see PGraphics#popMatrix() * @see PGraphics#translate(float, float, float) @@ -11602,17 +11604,17 @@ public class PApplet extends Applet /** * ( begin auto-generated from popMatrix.xml ) - * - * Pops the current transformation matrix off the matrix stack. - * Understanding pushing and popping requires understanding the concept of - * a matrix stack. The pushMatrix() function saves the current - * coordinate system to the stack and popMatrix() restores the prior - * coordinate system. pushMatrix() and popMatrix() are used - * in conjuction with the other transformation functions and may be + * + * Pops the current transformation matrix off the matrix stack. + * Understanding pushing and popping requires understanding the concept of + * a matrix stack. The pushMatrix() function saves the current + * coordinate system to the stack and popMatrix() restores the prior + * coordinate system. pushMatrix() and popMatrix() are used + * in conjuction with the other transformation functions and may be * embedded to control the scope of the transformations. * * ( end auto-generated ) - * + * * @webref transform * @see PGraphics#pushMatrix() */ @@ -11639,7 +11641,7 @@ public class PApplet extends Applet * further controlled by the pushMatrix() and popMatrix(). * * ( end auto-generated ) - * + * * @webref transform * @param tx left/right translation * @param ty up/down translation @@ -11686,7 +11688,7 @@ public class PApplet extends Applet * the pushMatrix() and popMatrix(). * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of rotation specified in radians * @see PGraphics#popMatrix() @@ -11720,7 +11722,7 @@ public class PApplet extends Applet * as shown in the example above. * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of rotation specified in radians * @see PGraphics#popMatrix() @@ -11754,7 +11756,7 @@ public class PApplet extends Applet * as shown in the examples above. * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of rotation specified in radians * @see PGraphics#popMatrix() @@ -11788,7 +11790,7 @@ public class PApplet extends Applet * as shown in the examples above. * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of rotation specified in radians * @see PGraphics#popMatrix() @@ -11808,9 +11810,9 @@ public class PApplet extends Applet /** *

Advanced

* Rotate about a vector in space. Same as the glRotatef() function. - * @param vx - * @param vy - * @param vz + * @param vx + * @param vy + * @param vz */ public void rotate(float angle, float vx, float vy, float vz) { if (recorder != null) recorder.rotate(angle, vx, vy, vz); @@ -11835,7 +11837,7 @@ public class PApplet extends Applet * can be further controlled by pushMatrix() and popMatrix(). * * ( end auto-generated ) - * + * * @webref transform * @param s percentage to scale the object * @see PGraphics#popMatrix() @@ -11898,7 +11900,7 @@ public class PApplet extends Applet * the pushMatrix() and popMatrix() functions. * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of shear specified in radians * @see PGraphics#popMatrix() @@ -11933,7 +11935,7 @@ public class PApplet extends Applet * the pushMatrix() and popMatrix() functions. * * ( end auto-generated ) - * + * * @webref transform * @param angle angle of shear specified in radians * @see PGraphics#popMatrix() @@ -11956,7 +11958,7 @@ public class PApplet extends Applet * function in OpenGL is glLoadIdentity(). * * ( end auto-generated ) - * + * * @webref transform * @see PGraphics#pushMatrix() * @see PGraphics#popMatrix() @@ -11978,7 +11980,7 @@ public class PApplet extends Applet * function in OpenGL is glMultMatrix(). * * ( end auto-generated ) - * + * * @webref transform * @source * @see PGraphics#pushMatrix() @@ -12096,7 +12098,7 @@ public class PApplet extends Applet * of Processing). * * ( end auto-generated ) - * + * * @webref transform * @see PGraphics#pushMatrix() * @see PGraphics#popMatrix() @@ -12130,7 +12132,7 @@ public class PApplet extends Applet * endCamera() cannot be nested. * * ( end auto-generated ) - * + * * @webref lights_camera:camera * @see PGraphics#camera() * @see PGraphics#endCamera() @@ -12153,7 +12155,7 @@ public class PApplet extends Applet * beginCamera() for a description of how the functions are used. * * ( end auto-generated ) - * + * * @webref lights_camera:camera * @see PGraphics#camera(float, float, float, float, float, float, float, float, float) */ @@ -12165,19 +12167,19 @@ public class PApplet extends Applet /** * ( begin auto-generated from camera.xml ) - * - * Sets the position of the camera through setting the eye position, the - * center of the scene, and which axis is facing upward. Moving the eye - * position and the direction it is pointing (the center of the scene) - * allows the images to be seen from different angles. The version without - * any parameters sets the camera to the default position, pointing to the - * center of the display window with the Y axis as up. The default values - * are camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / - * 180.0), width/2.0, height/2.0, 0, 0, 1, 0). This function is similar + * + * Sets the position of the camera through setting the eye position, the + * center of the scene, and which axis is facing upward. Moving the eye + * position and the direction it is pointing (the center of the scene) + * allows the images to be seen from different angles. The version without + * any parameters sets the camera to the default position, pointing to the + * center of the display window with the Y axis as up. The default values + * are camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / + * 180.0), width/2.0, height/2.0, 0, 0, 1, 0). This function is similar * to gluLookAt() in OpenGL, but it first clears the current camera settings. * * ( end auto-generated ) - * + * * @webref lights_camera:camera * @see PGraphics#endCamera() * @see PGraphics#frustum(float, float, float, float, float, float) @@ -12236,7 +12238,7 @@ public class PApplet extends Applet * -10, 10). * * ( end auto-generated ) - * + * * @webref lights_camera:camera */ public void ortho() { @@ -12285,7 +12287,7 @@ public class PApplet extends Applet * cameraZ*10.0) where cameraZ is ((height/2.0) / tan(PI*60.0/360.0)); * * ( end auto-generated ) - * + * * @webref lights_camera:camera */ public void perspective() { @@ -12314,7 +12316,7 @@ public class PApplet extends Applet * than muliplying itself with it. * * ( end auto-generated ) - * + * * @webref lights_camera:camera * @param left left coordinate of the clipping plane * @param right right coordinate of the clipping plane @@ -12341,7 +12343,7 @@ public class PApplet extends Applet * the bottom of Processing). * * ( end auto-generated ) - * + * * @webref lights_camera:camera * @see PGraphics#camera(float, float, float, float, float, float, float, float, float) */ @@ -12358,7 +12360,7 @@ public class PApplet extends Applet * where it will appear on a (two-dimensional) screen. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12377,7 +12379,7 @@ public class PApplet extends Applet * where it will appear on a (two-dimensional) screen. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12412,7 +12414,7 @@ public class PApplet extends Applet * where it will appear on a (two-dimensional) screen. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12434,15 +12436,15 @@ public class PApplet extends Applet * to place an object in space relative to the location of the original * point once the transformations are no longer in use. *

- * In the example, the modelX(), modelY(), and - * modelZ() functions record the location of a box in space after - * being placed using a series of translate and rotate commands. After - * popMatrix() is called, those transformations no longer apply, but the - * (x, y, z) coordinate returned by the model functions is used to place + * In the example, the modelX(), modelY(), and + * modelZ() functions record the location of a box in space after + * being placed using a series of translate and rotate commands. After + * popMatrix() is called, those transformations no longer apply, but the + * (x, y, z) coordinate returned by the model functions is used to place * another box in the same location. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12457,22 +12459,22 @@ public class PApplet extends Applet /** * ( begin auto-generated from modelY.xml ) - * - * Returns the three-dimensional X, Y, Z position in model space. This - * returns the Y value for a given coordinate based on the current set of - * transformations (scale, rotate, translate, etc.) The Y value can be used - * to place an object in space relative to the location of the original - * point once the transformations are no longer in use.
+ * + * Returns the three-dimensional X, Y, Z position in model space. This + * returns the Y value for a given coordinate based on the current set of + * transformations (scale, rotate, translate, etc.) The Y value can be used + * to place an object in space relative to the location of the original + * point once the transformations are no longer in use.
*
- * In the example, the modelX(), modelY(), and - * modelZ() functions record the location of a box in space after - * being placed using a series of translate and rotate commands. After - * popMatrix() is called, those transformations no longer apply, but the - * (x, y, z) coordinate returned by the model functions is used to place + * In the example, the modelX(), modelY(), and + * modelZ() functions record the location of a box in space after + * being placed using a series of translate and rotate commands. After + * popMatrix() is called, those transformations no longer apply, but the + * (x, y, z) coordinate returned by the model functions is used to place * another box in the same location. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12487,22 +12489,22 @@ public class PApplet extends Applet /** * ( begin auto-generated from modelZ.xml ) - * - * Returns the three-dimensional X, Y, Z position in model space. This - * returns the Z value for a given coordinate based on the current set of - * transformations (scale, rotate, translate, etc.) The Z value can be used - * to place an object in space relative to the location of the original + * + * Returns the three-dimensional X, Y, Z position in model space. This + * returns the Z value for a given coordinate based on the current set of + * transformations (scale, rotate, translate, etc.) The Z value can be used + * to place an object in space relative to the location of the original * point once the transformations are no longer in use.
*
- * In the example, the modelX(), modelY(), and - * modelZ() functions record the location of a box in space after - * being placed using a series of translate and rotate commands. After - * popMatrix() is called, those transformations no longer apply, but the - * (x, y, z) coordinate returned by the model functions is used to place + * In the example, the modelX(), modelY(), and + * modelZ() functions record the location of a box in space after + * being placed using a series of translate and rotate commands. After + * popMatrix() is called, those transformations no longer apply, but the + * (x, y, z) coordinate returned by the model functions is used to place * another box in the same location. * * ( end auto-generated ) - * + * * @webref lights_camera:coordinates * @param x 3D x-coordinate to be mapped * @param y 3D y-coordinate to be mapped @@ -12534,7 +12536,7 @@ public class PApplet extends Applet * emissive(), specular(), shininess(), ambient() * * ( end auto-generated ) - * + * * @webref structure * @see PGraphics#popStyle() */ @@ -12556,7 +12558,7 @@ public class PApplet extends Applet * provide more control (see the second example above for a demonstration.) * * ( end auto-generated ) - * + * * @webref structure * @see PGraphics#pushStyle() */ @@ -12588,7 +12590,7 @@ public class PApplet extends Applet * may not go higher than 10 pixels. * * ( end auto-generated ) - * + * * @webref shape:attributes * @param weight the weight (in pixels) of the stroke * @see PGraphics#stroke(int, float) @@ -12615,7 +12617,7 @@ public class PApplet extends Applet * size() reference. * * ( end auto-generated ) - * + * * @webref shape:attributes * @param join either MITER, BEVEL, ROUND * @see PGraphics#stroke(int, float) @@ -12693,7 +12695,7 @@ public class PApplet extends Applet * maximum value is 255. * * ( end auto-generated ) - * + * * @param rgb color value in hexadecimal notation * @see PGraphics#noStroke() * @see PGraphics#fill(int, float) @@ -12756,7 +12758,7 @@ public class PApplet extends Applet * displaying images with their original hues. * * ( end auto-generated ) - * + * * @webref image:loading_displaying * @usage web_application * @see PGraphics#tint(float, float, float, float) @@ -12772,30 +12774,30 @@ public class PApplet extends Applet * ( begin auto-generated from tint.xml ) * * Sets the fill value for displaying images. Images can be tinted to - * specified colors or made transparent by setting the alpha.
+ * specified colors or made transparent by setting the alpha.
*
* To make an image transparent, but not change it's color, use white as * the tint color and specify an alpha value. For instance, tint(255, 128) - * will make an image 50% transparent (unless colorMode() has been + * will make an image 50% transparent (unless colorMode() has been * used).
*
- * When using hexadecimal notation to specify a color, use "#" or "0x" - * before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six - * digits to specify a color (the way colors are specified in HTML and - * CSS). When using the hexadecimal notation starting with "0x", the - * hexadecimal value must be specified with eight characters; the first two - * characters define the alpha component and the remainder the red, green, + * When using hexadecimal notation to specify a color, use "#" or "0x" + * before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six + * digits to specify a color (the way colors are specified in HTML and + * CSS). When using the hexadecimal notation starting with "0x", the + * hexadecimal value must be specified with eight characters; the first two + * characters define the alpha component and the remainder the red, green, * and blue components.
*
* The value for the parameter "gray" must be less than or equal to the * current maximum value as specified by colorMode(). The default - * maximum value is 255.
+ * maximum value is 255.
*
- * The tint() function is also used to control the coloring of - * textures in 3D. - * + * The tint() function is also used to control the coloring of + * textures in 3D. + * * ( end auto-generated ) - * + * * @webref image:loading_displaying * @usage web_application * @param rgb color value in hexadecimal notation @@ -12860,7 +12862,7 @@ public class PApplet extends Applet * are called, nothing will be drawn to the screen. * * ( end auto-generated ) - * + * * @webref color:setting * @usage web_application * @see PGraphics#fill(float, float, float, float) @@ -12962,7 +12964,7 @@ public class PApplet extends Applet * and shininess() in setting the material properties of shapes. * * ( end auto-generated ) - * + * * @webref lights_camera:material_properties * @usage web_application * @param rgb any value of the color datatype @@ -13007,7 +13009,7 @@ public class PApplet extends Applet * setting the material properties of shapes. * * ( end auto-generated ) - * + * * @webref lights_camera:material_properties * @usage web_application * @param rgb color to set @@ -13050,7 +13052,7 @@ public class PApplet extends Applet * setting the material properties of shapes. * * ( end auto-generated ) - * + * * @webref lights_camera:material_properties * @usage web_application * @param shine degree of shininess @@ -13073,7 +13075,7 @@ public class PApplet extends Applet * properties of shapes. * * ( end auto-generated ) - * + * * @webref lights_camera:material_properties * @usage web_application * @param rgb color to set @@ -13119,7 +13121,7 @@ public class PApplet extends Applet * through the loop. * * ( end auto-generated ) - * + * * @webref lights_camera:lights * @usage web_application * @see PGraphics#ambientLight(float, float, float, float, float, float) @@ -13136,14 +13138,14 @@ public class PApplet extends Applet /** * ( begin auto-generated from noLights.xml ) - * - * Disable all lighting. Lighting is turned off by default and enabled with - * the lights() function. This function can be used to disable - * lighting so that 2D geometry (which does not require lighting) can be + * + * Disable all lighting. Lighting is turned off by default and enabled with + * the lights() function. This function can be used to disable + * lighting so that 2D geometry (which does not require lighting) can be * drawn after a set of lighted 3D geometry. * * ( end auto-generated ) - * + * * @webref lights_camera:lights * @usage web_application * @see PGraphics#lights() @@ -13167,7 +13169,7 @@ public class PApplet extends Applet * parameters is determined by the current color mode. * * ( end auto-generated ) - * + * * @webref lights_camera:lights * @usage web_application * @param red red or hue value (depending on current color mode) @@ -13391,7 +13393,7 @@ public class PApplet extends Applet * the main drawing surface, however they will work properly with createGraphics(). * * ( end auto-generated ) - * + * *

Advanced

*

Clear the background with a color that includes an alpha value. This can * only be used with objects created by createGraphics(), because the main @@ -13571,7 +13573,7 @@ public class PApplet extends Applet * & 0xFF;

* * ( end auto-generated ) - * + * * @webref color:creating_reading * @usage web_application * @param what any value of the color datatype @@ -13602,7 +13604,7 @@ public class PApplet extends Applet * myColor >> 8 & 0xFF; * * ( end auto-generated ) - * + * * @webref color:creating_reading * @usage web_application * @param what any value of the color datatype @@ -13633,7 +13635,7 @@ public class PApplet extends Applet * & 0xFF; * * ( end auto-generated ) - * + * * @webref color:creating_reading * @usage web_application * @param what any value of the color datatype @@ -13698,7 +13700,7 @@ public class PApplet extends Applet * Extracts the brightness value from a color. * * ( end auto-generated ) - * + * * @webref color:creating_reading * @usage web_application * @param what any value of the color datatype @@ -13723,7 +13725,7 @@ public class PApplet extends Applet * point, 0.5 is half-way in between, etc. * * ( end auto-generated ) - * + * * @webref color:creating_reading * @usage web_application * @param c1 interpolate from this color @@ -13809,7 +13811,7 @@ public class PApplet extends Applet /** * Return true if this renderer does rendering through OpenGL. Defaults to false. - */ + */ public boolean isGL() { return g.isGL(); } @@ -13849,7 +13851,7 @@ public class PApplet extends Applet * PGraphicsJava2D, or resized image data and OpenGL texture indices for * PGraphicsOpenGL. * @param renderer The PGraphics renderer associated to the image - * @param storage The metadata required by the renderer + * @param storage The metadata required by the renderer */ public void setCache(PGraphics renderer, Object storage) { if (recorder != null) recorder.setCache(renderer, storage); @@ -13884,7 +13886,7 @@ public class PApplet extends Applet * Store parameters for a renderer that requires extra metadata of * some kind. * @param renderer The PGraphics renderer associated to the image - * @param storage The parameters required by the renderer + * @param storage The parameters required by the renderer */ public void setParams(PGraphics renderer, Object params) { if (recorder != null) recorder.setParams(renderer, params); @@ -13914,26 +13916,26 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_get.xml ) - * - * Reads the color of any pixel or grabs a section of an image. If no - * parameters are specified, the entire image is returned. Use the x - * and y parameters to get the value of one pixel. Get a section of - * the display window by specifying an additional width and - * height parameter. When getting an image, the x and - * y parameters define the coordinates for the upper-left corner of + * + * Reads the color of any pixel or grabs a section of an image. If no + * parameters are specified, the entire image is returned. Use the x + * and y parameters to get the value of one pixel. Get a section of + * the display window by specifying an additional width and + * height parameter. When getting an image, the x and + * y parameters define the coordinates for the upper-left corner of * the image, regardless of the current imageMode().
*
- * If the pixel requested is outside of the image window, black is - * returned. The numbers returned are scaled according to the current color - * ranges, but only RGB values are returned by this function. For example, - * even though you may have drawn a shape with colorMode(HSB), the + * If the pixel requested is outside of the image window, black is + * returned. The numbers returned are scaled according to the current color + * ranges, but only RGB values are returned by this function. For example, + * even though you may have drawn a shape with colorMode(HSB), the * numbers returned will be in RGB format.
*
- * Getting the color of a single pixel with get(x, y) is easy, but - * not as fast as grabbing the data directly from pixels[]. The - * equivalent statement to get(x, y) using pixels[] is + * Getting the color of a single pixel with get(x, y) is easy, but + * not as fast as grabbing the data directly from pixels[]. The + * equivalent statement to get(x, y) using pixels[] is * pixels[y*width+x]. See the reference for pixels[] for more information. - * + * * ( end auto-generated ) * *

Advanced

@@ -13953,7 +13955,7 @@ public class PApplet extends Applet * is inside the bounds, and then has to check to see what image * type it is. If you want things to be more efficient, access the * pixels[] array directly. - * + * * @webref image:pixels * @brief Reads the color of any pixel or grabs a rectangle of pixels * @usage web_application @@ -13987,25 +13989,25 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_set.xml ) - * - * Changes the color of any pixel or writes an image directly into the + * + * Changes the color of any pixel or writes an image directly into the * display window.
*
- * The x and y parameters specify the pixel to change and the - * color parameter specifies the color value. The color parameter is - * affected by the current color mode (the default is RGB values from 0 to - * 255). When setting an image, the x and y parameters define - * the coordinates for the upper-left corner of the image, regardless of + * The x and y parameters specify the pixel to change and the + * color parameter specifies the color value. The color parameter is + * affected by the current color mode (the default is RGB values from 0 to + * 255). When setting an image, the x and y parameters define + * the coordinates for the upper-left corner of the image, regardless of * the current imageMode(). *

- * Setting the color of a single pixel with set(x, y) is easy, but - * not as fast as putting the data directly into pixels[]. The - * equivalent statement to set(x, y, #000000) using pixels[] - * is pixels[y*width+x] = #000000. See the reference for + * Setting the color of a single pixel with set(x, y) is easy, but + * not as fast as putting the data directly into pixels[]. The + * equivalent statement to set(x, y, #000000) using pixels[] + * is pixels[y*width+x] = #000000. See the reference for * pixels[] for more information. - * + * * ( end auto-generated ) - * + * * @webref image:pixels * @brief writes a color to any pixel or writes an image into another * @usage web_application @@ -14038,18 +14040,18 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_mask.xml ) - * - * Masks part of an image from displaying by loading another image and - * using it as an alpha channel. This mask image should only contain - * grayscale data, but only the blue color channel is used. The mask image + * + * Masks part of an image from displaying by loading another image and + * using it as an alpha channel. This mask image should only contain + * grayscale data, but only the blue color channel is used. The mask image * needs to be the same size as the image to which it is applied.
*
- * In addition to using a mask image, an integer array containing the alpha - * channel data can be specified directly. This method is useful for - * creating dynamically generated alpha masks. This array must be of the - * same length as the target image's pixels array and should contain only + * In addition to using a mask image, an integer array containing the alpha + * channel data can be specified directly. This method is useful for + * creating dynamically generated alpha masks. This array must be of the + * same length as the target image's pixels array and should contain only * grayscale data of values between 0-255. - * + * * ( end auto-generated ) * *

Advanced

@@ -14094,31 +14096,31 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_filter.xml ) - * - * Filters an image as defined by one of the following modes:

THRESHOLD - converts the image to black and white pixels depending if - * they are above or below the threshold defined by the level parameter. - * The level must be between 0.0 (black) and 1.0(white). If no level is + * + * Filters an image as defined by one of the following modes:

THRESHOLD - converts the image to black and white pixels depending if + * they are above or below the threshold defined by the level parameter. + * The level must be between 0.0 (black) and 1.0(white). If no level is * specified, 0.5 is used.
*
* GRAY - converts any colors in the image to grayscale equivalents
*
* INVERT - sets each pixel to its inverse value
*
- * POSTERIZE - limits each channel of the image to the number of colors + * POSTERIZE - limits each channel of the image to the number of colors * specified as the level parameter
*
- * BLUR - executes a Guassian blur with the level parameter specifying the - * extent of the blurring. If no level parameter is used, the blur is + * BLUR - executes a Guassian blur with the level parameter specifying the + * extent of the blurring. If no level parameter is used, the blur is * equivalent to Guassian blur of radius 1
*
* OPAQUE - sets the alpha channel to entirely opaque
*
- * ERODE - reduces the light areas with the amount defined by the level + * ERODE - reduces the light areas with the amount defined by the level * parameter
*
* DILATE - increases the light areas with the amount defined by the level parameter - * + * * ( end auto-generated ) * *

Advanced

@@ -14153,17 +14155,17 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_copy.xml ) - * - * Copies a region of pixels from one image into another. If the source and - * destination regions aren't the same size, it will automatically resize - * source pixels to fit the specified target region. No alpha information - * is used in the process, however if the source image has an alpha channel + * + * Copies a region of pixels from one image into another. If the source and + * destination regions aren't the same size, it will automatically resize + * source pixels to fit the specified target region. No alpha information + * is used in the process, however if the source image has an alpha channel * set, it will be copied as well. *

* As of release 0149, this function ignores imageMode(). - * + * * ( end auto-generated ) - * + * * @webref image:pixels * @brief Copies the entire image * @usage web_application @@ -14198,11 +14200,11 @@ public class PApplet extends Applet /** * ( begin auto-generated from blendColor.xml ) - * - * Blends two color values together based on the blending mode given as the - * MODE parameter. The possible modes are described in the reference + * + * Blends two color values together based on the blending mode given as the + * MODE parameter. The possible modes are described in the reference * for the blend() function. - * + * * ( end auto-generated ) *

Advanced

*
    @@ -14289,17 +14291,17 @@ public class PApplet extends Applet /** * ( begin auto-generated from PImage_blend.xml ) - * - * Blends a region of pixels into the image specified by the img - * parameter. These copies utilize full alpha channel support and a choice - * of the following modes to blend the colors of source pixels (A) with the + * + * Blends a region of pixels into the image specified by the img + * parameter. These copies utilize full alpha channel support and a choice + * of the following modes to blend the colors of source pixels (A) with the * ones of pixels in the destination image (B):
    *
    * BLEND - linear interpolation of colours: C = A*factor + B
    *
    * ADD - additive blending with white clip: C = min(A*factor + B, 255)
    *
    - * SUBTRACT - subtractive blending with black clip: C = max(B - A*factor, + * SUBTRACT - subtractive blending with black clip: C = max(B - A*factor, * 0)
    *
    * DARKEST - only the darkest colour succeeds: C = min(A*factor, B)
    @@ -14319,7 +14321,7 @@ public class PApplet extends Applet *
    * HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY when lower.
    *
    - * SOFT_LIGHT - Mix of DARKEST and LIGHTEST. + * SOFT_LIGHT - Mix of DARKEST and LIGHTEST. * Works like OVERLAY, but not as harsh.
    *
    * DODGE - Lightens light tones and increases contrast, ignores darks. @@ -14328,14 +14330,14 @@ public class PApplet extends Applet * BURN - Darker areas are applied, increasing contrast, ignores lights. * Called "Color Burn" in Illustrator and Photoshop.
    *
    - * All modes use the alpha information (highest byte) of source image - * pixels as the blending factor. If the source and destination regions are - * different sizes, the image will be automatically resized to match the - * destination size. If the srcImg parameter is not used, the + * All modes use the alpha information (highest byte) of source image + * pixels as the blending factor. If the source and destination regions are + * different sizes, the image will be automatically resized to match the + * destination size. If the srcImg parameter is not used, the * display window is used as the source image.
    *
    * As of release 0149, this function ignores imageMode(). - * + * * ( end auto-generated ) * * @webref image:pixels diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index 486a706f6..6df9757d8 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -23,6 +23,8 @@ package processing.core; +import processing.data.*; + import java.awt.Paint; import java.awt.PaintContext; import java.awt.Rectangle; @@ -1662,7 +1664,7 @@ public class PShapeSVG extends PShape { String name = elements[i].getName(); XML elem = elements[i]; if (name == null) { - // skip it + // skip it } else if (name.equals("glyph")) { FontGlyph fg = new FontGlyph(this, elem, this); if (fg.isLegit()) { diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 290beccce..8318b5a5c 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -21,7 +21,7 @@ Boston, MA 02111-1307 USA */ -package processing.core; +package processing.data; import java.io.*; import java.lang.reflect.Array; @@ -29,11 +29,12 @@ import java.sql.*; import java.util.*; import processing.core.PApplet; +import processing.core.PConstants; // function that will convert awful CSV to TSV.. or something else? // maybe to write binary instead? then read the binary file once it's ok? -// if loading from a File object (or PApplet is passed in and we can check online) +// if loading from a File object (or PApplet is passed in and we can check online) // then check the (probable) size of the file before loading // implement binary tables @@ -51,22 +52,22 @@ import processing.core.PApplet; /** - *

    Generic class for handling tabular data, typically from a CSV, TSV, or - * other sort of spreadsheet file.

    - *

    CSV files are - * comma separated values, + *

    Generic class for handling tabular data, typically from a CSV, TSV, or + * other sort of spreadsheet file.

    + *

    CSV files are + * comma separated values, * often with the data in quotes. TSV files use tabs as separators, and usually - * don't bother with the quotes.

    + * don't bother with the quotes.

    *

    File names should end with .csv if they're comma separated.

    */ public class Table implements Iterable { protected int rowCount; - + // protected boolean skipEmptyRows = true; // protected boolean skipCommentLines = true; protected boolean commaSeparatedValues = false; protected boolean awfulCSV = false; - + protected String missingString = null; protected int missingInt = 0; protected long missingLong = 0; @@ -75,14 +76,14 @@ public class Table implements Iterable { protected int missingCategory = -1; String[] columnTitles; - HashMapBlows[] columnCategories; + HashMapBlows[] columnCategories; HashMap columnIndices; // static final int TSV = 1; // static final int CSV = 2; // static final int AWFUL_CSV = 3; -// boolean typed; +// boolean typed; // untyped data // protected String[][] data; @@ -106,7 +107,7 @@ public class Table implements Iterable { // Object[][] objectData; - /** + /** * Creates a new, empty table. Use addRow() to add additional rows. */ public Table() { @@ -129,8 +130,8 @@ public class Table implements Iterable { public Table(PApplet parent, String filename) { this(parent.createReader(filename)); } - - + + public Table(BufferedReader reader) { columns = new Object[0]; columnTypes = new int[0]; @@ -146,36 +147,36 @@ public class Table implements Iterable { e.printStackTrace(); } } - - + + public Table(ResultSet rs) { this(); try { ResultSetMetaData rsmd = rs.getMetaData(); - + int columnCount = rsmd.getColumnCount(); setColumnCount(columnCount); - + for (int col = 0; col < columnCount; col++) { setColumnTitle(col, rsmd.getColumnName(col + 1)); - + int type = rsmd.getColumnType(col + 1); switch (type) { // TODO these aren't tested. nor are they complete. - case Types.INTEGER: + case Types.INTEGER: case Types.TINYINT: case Types.SMALLINT: - setColumnType(col, INT); + setColumnType(col, INT); break; - case Types.BIGINT: - setColumnType(col, LONG); + case Types.BIGINT: + setColumnType(col, LONG); break; case Types.FLOAT: - setColumnType(col, FLOAT); + setColumnType(col, FLOAT); break; - case Types.DECIMAL: - case Types.DOUBLE: - case Types.REAL: - setColumnType(col, DOUBLE); + case Types.DECIMAL: + case Types.DOUBLE: + case Types.REAL: + setColumnType(col, DOUBLE); break; } } @@ -204,11 +205,11 @@ public class Table implements Iterable { throw new RuntimeException(s); } } - - + + /** * Guess whether this file is tab separated or comma separated by checking - * whether there are more tabs or commas in the first 100 characters. + * whether there are more tabs or commas in the first 100 characters. */ protected boolean peekCSV(BufferedReader reader) throws IOException { char[] buffer = new char[100]; @@ -239,8 +240,8 @@ public class Table implements Iterable { parseTSV(reader); } } - - + + public void parseTSV(BufferedReader reader) throws IOException { parseBasic(reader, true); // String line = null; @@ -260,12 +261,12 @@ public class Table implements Iterable { // setRowCount(row); // } } - - + + public void parseCSV(BufferedReader reader) throws IOException { parseBasic(reader, false); // String line = null; -// int row = 0; +// int row = 0; // if (rowCount == 0) { // setRowCount(10); // } @@ -281,8 +282,8 @@ public class Table implements Iterable { // setRowCount(row); // } } - - + + protected void parseBasic(BufferedReader reader, boolean tsv) throws IOException { String line = null; int row = 0; @@ -296,7 +297,7 @@ public class Table implements Iterable { } setRow(row, tsv ? PApplet.split(line, '\t') : splitLineCSV(line)); row++; - + if (row % 10000 == 0) { if (row < rowCount) { int pct = (100 * row) / rowCount; @@ -390,14 +391,14 @@ public class Table implements Iterable { output.flush(); output.close(); - + // come back and write the row count RandomAccessFile raf = new RandomAccessFile(outputFile, "rw"); raf.writeInt(rowCount); raf.close(); } - - + + public void parseAwfulCSV(BufferedReader reader) throws IOException { char[] c = new char[100]; int count = 0; @@ -411,16 +412,16 @@ public class Table implements Iterable { // this is either the end of a quoted entry, or a quote character reader.mark(1); if (reader.read() == '\"') { - // it's "", which means a quote character + // it's "", which means a quote character if (count == c.length) { c = PApplet.expand(c); } c[count++] = '\"'; } else { - // nope, just the end of a quoted csv entry + // nope, just the end of a quoted csv entry reader.reset(); insideQuote = false; - // TODO nothing here that prevents bad csv data from showing up + // TODO nothing here that prevents bad csv data from showing up // after the quote and before the comma... // setString(row, col, new String(c, 0, count)); // count = 0; @@ -432,7 +433,7 @@ public class Table implements Iterable { c = PApplet.expand(c); } c[count++] = (char) ch; - } + } } else { // not inside a quote if (ch == '\"') { insideQuote = true; @@ -460,7 +461,7 @@ public class Table implements Iterable { // starting a new column, make sure we have room col++; checkColumn(col); - + } else { // just a regular character, add it if (count == c.length) { c = PApplet.expand(c); @@ -474,15 +475,15 @@ public class Table implements Iterable { setString(row, col, new String(c, 0, count)); } } - + protected String[] splitLine(String line) { return commaSeparatedValues ? splitLineCSV(line) : PApplet.split(line, '\t'); } - + /** - * Parse a line of text as comma-separated values, returning each value as + * Parse a line of text as comma-separated values, returning each value as * one entry in an array of String objects. Remove quotes from entries that * begin and end with them, and convert 'escaped' quotes to actual quotes. * @param line line of text to be parsed @@ -501,7 +502,7 @@ public class Table implements Iterable { } String[] pieces = new String[rough]; int pieceCount = 0; - int offset = 0; + int offset = 0; while (offset < c.length) { int start = offset; int stop = nextComma(c, offset); @@ -528,12 +529,12 @@ public class Table implements Iterable { // make any remaining entries blanks instead of nulls for (int i = pieceCount; i < pieces.length; i++) { pieces[i] = ""; - + } return pieces; } - - + + static int nextComma(char[] c, int index) { boolean quote = false; for (int i = index; i < c.length; i++) { @@ -565,7 +566,7 @@ public class Table implements Iterable { writer.print('\t'); } String entry = getString(row, col); - // just write null entries as blanks, rather than spewing 'null' + // just write null entries as blanks, rather than spewing 'null' // all over the spreadsheet file. if (entry != null) { writer.print(entry); @@ -575,8 +576,8 @@ public class Table implements Iterable { } writer.flush(); } - - + + public void writeCSV(PrintWriter writer) { if (columnTitles != null) { for (int col = 0; col < columns.length; col++) { @@ -595,7 +596,7 @@ public class Table implements Iterable { writer.print(','); } String entry = getString(row, col); - // just write null entries as blanks, rather than spewing 'null' + // just write null entries as blanks, rather than spewing 'null' // all over the spreadsheet file. if (entry != null) { writeEntryCSV(writer, entry); @@ -606,8 +607,8 @@ public class Table implements Iterable { } writer.flush(); } - - + + protected void writeEntryCSV(PrintWriter writer, String entry) { if (entry != null) { if (entry.indexOf('\"') != -1) { // convert quotes to double quotes @@ -621,19 +622,19 @@ public class Table implements Iterable { } } writer.print('\"'); - + // add quotes if commas or CR/LF are in the entry - } else if (entry.indexOf(',') != -1 || - entry.indexOf('\n') != -1 || + } else if (entry.indexOf(',') != -1 || + entry.indexOf('\n') != -1 || entry.indexOf('\r') != -1) { writer.print('\"'); writer.print(entry); writer.print('\"'); - - + + // add quotes if leading or trailing space - } else if ((entry.length() > 0) && - (entry.charAt(0) == ' ' || + } else if ((entry.length() > 0) && + (entry.charAt(0) == ' ' || entry.charAt(entry.length() - 1) == ' ')) { writer.print('\"'); writer.print(entry); @@ -644,8 +645,8 @@ public class Table implements Iterable { } } } - - + + public void writeHTML(PrintWriter writer) { writer.println(""); for (int row = 0; row < getRowCount(); row++) { @@ -663,8 +664,8 @@ public class Table implements Iterable { writer.println("
    "); writer.flush(); } - - + + protected void writeEntryHTML(PrintWriter writer, String entry) { //char[] chars = entry.toCharArray(); for (char c : entry.toCharArray()) { //chars) { @@ -680,9 +681,9 @@ public class Table implements Iterable { /** - * Write this table as a TSV file. + * Write this table as a TSV file. * Exceptions will be printed, but not thrown. - * @param file the location to write to. + * @param file the location to write to. * @return true if written successfully */ public boolean writeCSV(File file) { @@ -695,7 +696,7 @@ public class Table implements Iterable { return true; } - + public boolean writeTSV(File file) { try { writeTSV(new PrintWriter(new FileWriter(file))); @@ -709,7 +710,7 @@ public class Table implements Iterable { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + public void addColumn() { addColumn(null, STRING); } @@ -721,10 +722,10 @@ public class Table implements Iterable { public void addColumn(String title, int type) { - insertColumn(columns.length, title, type); + insertColumn(columns.length, title, type); } - + public void insertColumn(int index) { insertColumn(index, null, STRING); } @@ -744,8 +745,8 @@ public class Table implements Iterable { columnIndices = null; } columnTypes = PApplet.splice(columnTypes, type, index); - -// columnCategories = (HashMapBlows[]) + +// columnCategories = (HashMapBlows[]) // PApplet.splice(columnCategories, new HashMapBlows(), index); HashMapBlows[] catTemp = new HashMapBlows[columns.length + 1]; // Faster than arrayCopy for a dozen or so entries @@ -757,7 +758,7 @@ public class Table implements Iterable { catTemp[i+1] = columnCategories[i]; } columnCategories = catTemp; - + Object[] temp = new Object[columns.length + 1]; System.arraycopy(columns, 0, temp, 0, index); System.arraycopy(columns, index, temp, index+1, columns.length - index); @@ -794,7 +795,7 @@ public class Table implements Iterable { /** * Change the number of columns in this table. Resizes all rows to ensure - * the same number of columns in each row. Entries in the additional (empty) + * the same number of columns in each row. Entries in the additional (empty) * columns will be set to null. * @param newCount */ @@ -806,7 +807,7 @@ public class Table implements Iterable { for (int c = oldCount; c < newCount; c++) { columns[c] = new String[rowCount]; } - + if (columnTitles != null) { columnTitles = PApplet.expand(columnTitles, newCount); } @@ -823,9 +824,9 @@ public class Table implements Iterable { /** - * Set the data type for a column so that using it is more efficient. + * Set the data type for a column so that using it is more efficient. * @param column the column to change - * @param columnType One of int, long, float, double, or String. + * @param columnType One of int, long, float, double, or String. */ public void setColumnType(int column, String columnType) { int type = -1; @@ -846,16 +847,16 @@ public class Table implements Iterable { } setColumnType(column, type); } - - + + protected void setColumnType(String columnName, int newType) { setColumnType(getColumnIndex(columnName), newType); } - - + + /** - * Sets the column type. If data already exists, then it'll be converted to - * the new type. + * Sets the column type. If data already exists, then it'll be converted to + * the new type. * @param column the column whose type should be changed * @param newType something fresh, maybe try an int or a float for size? */ @@ -933,8 +934,8 @@ public class Table implements Iterable { // System.out.println("new type is " + newType); columnTypes[column] = newType; } - - + + /** * Set the entire table to a specific data type. */ @@ -947,7 +948,7 @@ public class Table implements Iterable { /** * Set the titles (and if a second column is present) the data types for - * this table based on a file loaded separately. + * this table based on a file loaded separately. * @param dictionary */ public void setColumnTypes(Table dictionary) { @@ -958,8 +959,8 @@ public class Table implements Iterable { } } } - - + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -972,7 +973,7 @@ public class Table implements Iterable { setColumnTitles(titles); return titles; } - + public void setColumnTitles(String[] titles) { if (titles != null) { @@ -982,7 +983,7 @@ public class Table implements Iterable { columnIndices = null; // remove the cache } - + public void setColumnTitle(int column, String title) { checkColumn(column); if (columnTitles == null) { @@ -1020,7 +1021,7 @@ public class Table implements Iterable { return -1; } // only create this on first get(). subsequent calls to set the title will - // also update this array, but only if it exists. + // also update this array, but only if it exists. if (columnIndices == null) { columnIndices = new HashMap(); for (int col = 0; col < columns.length; col++) { @@ -1036,8 +1037,8 @@ public class Table implements Iterable { } return index.intValue(); } - - + + /** * Same as getColumnIndex(), but creates the column if it doesn't exist. * Named this way to not conflict with checkColumn(), an internal function @@ -1058,7 +1059,7 @@ public class Table implements Iterable { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + public int getRowCount() { return rowCount; } @@ -1215,8 +1216,8 @@ public class Table implements Iterable { setRowCol(row, col, pieces[col]); } } - - + + protected void setRowCol(int row, int col, String piece) { switch (columnTypes[col]) { case STRING: @@ -1251,15 +1252,15 @@ public class Table implements Iterable { int[] indexData = (int[]) columns[col]; indexData[row] = columnCategories[col].index(piece); break; - default: + default: throw new IllegalArgumentException("That's not a valid column type."); } } - - + + public void convertRow(DataOutputStream output, String[] pieces) throws IOException { if (pieces.length > getColumnCount()) { - throw new IllegalArgumentException("Row with too many columns: " + + throw new IllegalArgumentException("Row with too many columns: " + PApplet.join(pieces, ",")); } // pieces.length may be less than columns.length, so loop over pieces @@ -1317,8 +1318,8 @@ public class Table implements Iterable { } } } - - + + protected void convertRowCol(DataOutputStream output, int row, int col, String piece) { switch (columnTypes[col]) { case STRING: @@ -1349,7 +1350,7 @@ public class Table implements Iterable { doubleData[row] = missingDouble; } break; - default: + default: throw new IllegalArgumentException("That's not a valid column type."); } } @@ -1357,7 +1358,7 @@ public class Table implements Iterable { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + public interface Row { public String getString(int column); @@ -1372,13 +1373,13 @@ public class Table implements Iterable { public double getDouble(String columnName); } - + protected RowIterator rowIterator; /** * Note that this one iterator instance is shared by any calls to iterate the * rows of this table. This is very efficient, but not very thread-safe. If - * you want to iterate in a multi-threaded manner, use createIterator(). + * you want to iterate in a multi-threaded manner, use createIterator(). */ public Iterator iterator() { if (rowIterator == null) { @@ -1394,7 +1395,7 @@ public class Table implements Iterable { } - // temporary objects inside loop! garbage collection! argh! + // temporary objects inside loop! garbage collection! argh! // public Iterator iterator() { // return new RowIterator(); // } @@ -1433,7 +1434,7 @@ public class Table implements Iterable { public float getFloat(String columnName) { return Table.this.getFloat(row, columnName); - } + } public double getDouble(int column) { return Table.this.getDouble(row, column); @@ -1441,7 +1442,7 @@ public class Table implements Iterable { public double getDouble(String columnName) { return Table.this.getDouble(row, columnName); - } + } }; public void remove() { @@ -1458,7 +1459,7 @@ public class Table implements Iterable { public boolean hasNext() { return row+1 < getRowCount(); } - + public void reset() { row = -1; } @@ -1467,7 +1468,7 @@ public class Table implements Iterable { static public Iterator createIterator(final ResultSet rs) { return new Iterator() { - boolean already; + boolean already; public boolean hasNext() { already = true; @@ -1477,8 +1478,8 @@ public class Table implements Iterable { throw new RuntimeException(e); } } - - + + public Row next() { if (!already) { try { @@ -1582,29 +1583,29 @@ public class Table implements Iterable { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + public int getInt(int row, int column) { checkBounds(row, column); if (columnTypes[column] == INT) { int[] intData = (int[]) columns[column]; - return intData[row]; + return intData[row]; } String str = getString(row, column); - return (str == null || str.equals(missingString)) ? + return (str == null || str.equals(missingString)) ? missingInt : PApplet.parseInt(str, missingInt); } - - + + public int getInt(int row, String columnName) { return getInt(row, getColumnIndex(columnName)); } - - + + public void setMissingInt(int value) { missingInt = value; } - - + + public void setInt(int row, int column, int what) { if (columnTypes[column] == STRING) { setString(row, column, String.valueOf(what)); @@ -1624,7 +1625,7 @@ public class Table implements Iterable { int col = getColumnIndex(name); return (col == -1) ? null : getIntColumn(col); } - + public int[] getIntColumn(int col) { int[] outgoing = new int[rowCount]; @@ -1633,8 +1634,8 @@ public class Table implements Iterable { } return outgoing; } - - + + public int[] getIntRow(int row) { int[] outgoing = new int[columns.length]; for (int col = 0; col < columns.length; col++) { @@ -1642,7 +1643,7 @@ public class Table implements Iterable { } return outgoing; } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -1651,7 +1652,7 @@ public class Table implements Iterable { checkBounds(row, column); if (columnTypes[column] == LONG) { long[] longData = (long[]) columns[column]; - return longData[row]; + return longData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { @@ -1664,7 +1665,7 @@ public class Table implements Iterable { } } - + public long getLong(int row, String columnName) { return getLong(row, getColumnIndex(columnName)); } @@ -1673,7 +1674,7 @@ public class Table implements Iterable { public void setMissingLong(long value) { missingLong = value; } - + public void setLong(int row, int column, long what) { if (columnTypes[column] == STRING) { @@ -1703,8 +1704,8 @@ public class Table implements Iterable { } return outgoing; } - - + + public long[] getLongRow(int row) { long[] outgoing = new long[columns.length]; for (int col = 0; col < columns.length; col++) { @@ -1713,20 +1714,20 @@ public class Table implements Iterable { return outgoing; } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Get a float value from the specified row and column. If the value is null - * or not parseable as a float, the "missing" value is returned. By default, + * or not parseable as a float, the "missing" value is returned. By default, * this is Float.NaN, but can be controlled with setMissingFloat(). */ public float getFloat(int row, int column) { checkBounds(row, column); if (columnTypes[column] == FLOAT) { float[] floatData = (float[]) columns[column]; - return floatData[row]; + return floatData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { @@ -1734,13 +1735,13 @@ public class Table implements Iterable { } return PApplet.parseFloat(str, missingFloat); } - + public float getFloat(int row, String columnName) { return getFloat(row, getColumnIndex(columnName)); } - + public void setMissingFloat(float value) { missingFloat = value; } @@ -1765,8 +1766,8 @@ public class Table implements Iterable { int col = getColumnIndex(name); return (col == -1) ? null : getFloatColumn(col); } - - + + public float[] getFloatColumn(int col) { float[] outgoing = new float[rowCount]; for (int row = 0; row < rowCount; row++) { @@ -1774,8 +1775,8 @@ public class Table implements Iterable { } return outgoing; } - - + + public float[] getFloatRow(int row) { float[] outgoing = new float[columns.length]; for (int col = 0; col < columns.length; col++) { @@ -1792,7 +1793,7 @@ public class Table implements Iterable { checkBounds(row, column); if (columnTypes[column] == DOUBLE) { double[] doubleData = (double[]) columns[column]; - return doubleData[row]; + return doubleData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { @@ -1810,12 +1811,12 @@ public class Table implements Iterable { return getDouble(row, getColumnIndex(columnName)); } - + public void setMissingDouble(double value) { missingDouble = value; } - + public void setDouble(int row, int column, double what) { if (columnTypes[column] == STRING) { setString(row, column, String.valueOf(what)); @@ -1829,14 +1830,14 @@ public class Table implements Iterable { doubleData[row] = what; } } - - + + public double[] getDoubleColumn(String name) { int col = getColumnIndex(name); return (col == -1) ? null : getDoubleColumn(col); } - - + + public double[] getDoubleColumn(int col) { double[] outgoing = new double[rowCount]; for (int row = 0; row < rowCount; row++) { @@ -1854,10 +1855,10 @@ public class Table implements Iterable { return outgoing; } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + //public long getTimestamp(String rowName, int column) { //return getTimestamp(getRowIndex(rowName), column); //} @@ -1871,13 +1872,13 @@ public class Table implements Iterable { // java.sql.Timestamp timestamp = java.sql.Timestamp.valueOf(str); // return timestamp.getTime(); // } - - + + // public long getExcelTimestamp(int row, int column) { // return parseExcelTimestamp(getString(row, column)); // } - - + + // static protected DateFormat excelDateFormat; // static public long parseExcelTimestamp(String timestamp) { @@ -1901,9 +1902,9 @@ public class Table implements Iterable { // data[row][column] = null; // } else if (value instanceof String) { // setString(row, column, (String) value); -// } else if (value instanceof Float) { +// } else if (value instanceof Float) { // setFloat(row, column, ((Float) value).floatValue()); -// } else if (value instanceof Integer) { +// } else if (value instanceof Integer) { // setInt(row, column, ((Integer) value).intValue()); // } else { // setString(row, column, value.toString()); @@ -1915,7 +1916,7 @@ public class Table implements Iterable { /** - * Get a String value from the table. If the row is longer than the table + * Get a String value from the table. If the row is longer than the table * @param row * @param col * @return @@ -1937,13 +1938,13 @@ public class Table implements Iterable { public String getString(int row, String columnName) { return getString(row, getColumnIndex(columnName)); } - - + + public void setMissingString(String value) { missingString = value; } - - + + public void setString(int row, int column, String what) { checkSize(row, column); if (columnTypes[column] != STRING) { @@ -1959,12 +1960,12 @@ public class Table implements Iterable { setString(row, column, what); } - + public String[] getStringColumn(String name) { int col = getColumnIndex(name); return (col == -1) ? null : getStringColumn(col); } - + public String[] getStringColumn(int col) { String[] outgoing = new String[rowCount]; @@ -1973,21 +1974,21 @@ public class Table implements Iterable { } return outgoing; } - - + + public String[] getStringRow(int row) { String[] outgoing = new String[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getString(row, col); } return outgoing; - } + } + - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - /** + + /** * Set all 'null' entries to "" (zero length String objects). * If columns are typed, then this will only apply to String columns. */ @@ -2004,8 +2005,8 @@ public class Table implements Iterable { } } - - /** + + /** * Set all "" entries (zero length String objects) to null values. * If columns are typed, then this will only apply to String columns. */ @@ -2025,7 +2026,7 @@ public class Table implements Iterable { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Searches the entire table for float values. * Returns missing float (Float.NaN by default) if no valid numbers found. @@ -2048,11 +2049,11 @@ public class Table implements Iterable { } return found ? max : missingFloat; } - - + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Remove any of the specified characters from the entire table. */ @@ -2061,11 +2062,11 @@ public class Table implements Iterable { removeTokens(tokens, col); } } - - + + /** * Removed any of the specified characters from a column. For instance, - * the following code removes dollar signs and commas from column 2: + * the following code removes dollar signs and commas from column 2: *
        * table.removeTokens(",$", 2);
        * 
    @@ -2090,23 +2091,23 @@ public class Table implements Iterable { } } } - - + + public void removeTokens(String tokens, String column) { removeTokens(tokens, getColumnIndex(column)); } - - + + // TODO this isn't i18n correct, and it's a dumb implementation // public void removeLetters(int column) { // String alphabet = "abcdefghijklmnopqrstuvwxyz"; // removeTokens(alphabet + alphabet.toUpperCase(), column); // } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Return the row that contains the first String that matches. * @param what the String to match @@ -2141,8 +2142,8 @@ public class Table implements Iterable { } return -1; } - - + + /** * Return the row that contains the first String that matches. * @param what the String to match @@ -2162,7 +2163,7 @@ public class Table implements Iterable { public int[] findRows(String what, int column) { int[] outgoing = new int[rowCount]; int count = 0; - + checkBounds(-1, column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; @@ -2193,8 +2194,8 @@ public class Table implements Iterable { } return PApplet.subset(outgoing, 0, count); } - - + + /** * Return a list of rows that contain the String passed in. If there are no * matches, a zero length array will be returned (not a null array). @@ -2204,11 +2205,11 @@ public class Table implements Iterable { public int[] findRows(String what, String columnName) { return findRows(what, getColumnIndex(columnName)); } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Return the row that contains the first String that matches. * @param what the String to match @@ -2219,7 +2220,7 @@ public class Table implements Iterable { if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { - if (stringData[row] != null && + if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { return row; } @@ -2227,7 +2228,7 @@ public class Table implements Iterable { } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); - if (str != null && + if (str != null && PApplet.match(str, regexp) != null) { return row; } @@ -2235,8 +2236,8 @@ public class Table implements Iterable { } return -1; } - - + + /** * Return the row that contains the first String that matches. * @param what the String to match @@ -2256,12 +2257,12 @@ public class Table implements Iterable { public int[] matchRows(String regexp, int column) { int[] outgoing = new int[rowCount]; int count = 0; - + checkBounds(-1, column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { - if (stringData[row] != null && + if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { outgoing[count++] = row; } @@ -2269,7 +2270,7 @@ public class Table implements Iterable { } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); - if (str != null && + if (str != null && PApplet.match(str, regexp) != null) { outgoing[count++] = row; } @@ -2277,8 +2278,8 @@ public class Table implements Iterable { } return PApplet.subset(outgoing, 0, count); } - - + + /** * Return a list of rows that match the regex passed in. If there are no * matches, a zero length array will be returned (not a null array). @@ -2288,11 +2289,11 @@ public class Table implements Iterable { public int[] matchRows(String what, String columnName) { return matchRows(what, getColumnIndex(columnName)); } - - + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + /** * Return a list of rows that contain the String passed in. If there are no * matches, a zero length array will be returned (not a null array). @@ -2315,7 +2316,7 @@ public class Table implements Iterable { /** - * Run String.replaceAll() on all entries in a column. + * Run String.replaceAll() on all entries in a column. * Only works with columns that are already String values. * @param what the String to match * @param columnName the column to search @@ -2324,7 +2325,7 @@ public class Table implements Iterable { replaceAll(regex, replacement, getColumnIndex(columnName)); } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -2333,20 +2334,20 @@ public class Table implements Iterable { setColumnCount(col + 1); } } - - + + protected void checkRow(int row) { if (row >= rowCount) { setRowCount(row + 1); } } - - + + protected void checkSize(int row, int col) { checkRow(row); checkColumn(col); } - + protected void checkBounds(int row, int column) { if (row < 0 || row >= rowCount) { @@ -2357,7 +2358,7 @@ public class Table implements Iterable { } } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -2381,8 +2382,8 @@ public class Table implements Iterable { } return newbie; } - - + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -2410,11 +2411,11 @@ public class Table implements Iterable { String key(int index) { return indexToData.get(index); } - + int size() { return dataToIndex.size(); } - + void write(DataOutputStream output) throws IOException { output.writeInt(size()); for (String str : indexToData) { @@ -2442,7 +2443,7 @@ public class Table implements Iterable { } // class HashMapBlows extends HashMap { -// +// // int index(String what) { // Integer value = get(what); // if (value != null) { @@ -2454,10 +2455,10 @@ public class Table implements Iterable { // return v; // } // } - - + + class HashMapSucks extends HashMap { - + void increment(String what) { Integer value = get(what); if (value == null) { @@ -2466,15 +2467,15 @@ public class Table implements Iterable { put(what, value + 1); } } - + void check(String what) { if (get(what) == null) { put(what, 0); } } } - - + + public String[] getUniqueEntries(int column) { HashMapSucks found = new HashMapSucks(); for (int row = 0; row < getRowCount(); row++) { @@ -2504,10 +2505,10 @@ public class Table implements Iterable { /** - * Return an object that maps the String values in one column back to the - * row from which they came. For instance, if the "name" of each row is + * Return an object that maps the String values in one column back to the + * row from which they came. For instance, if the "name" of each row is * found in the first column, getColumnRowLookup(0) would return an object - * that would map each name back to its row. + * that would map each name back to its row. */ public HashMap getRowLookup(int col) { HashMap outgoing = new HashMap(); @@ -2521,7 +2522,7 @@ public class Table implements Iterable { // incomplete, basically this is silly to write all this repetitive code when // it can be implemented in ~3 lines of code... // /** -// * Return an object that maps the data from one column to the data of found +// * Return an object that maps the data from one column to the data of found // * in another column. // */ // public HashMap getLookup(int col1, int col2) { @@ -2561,7 +2562,7 @@ public class Table implements Iterable { // return outgoing; // } - + // public StringIntPairs getColumnRowLookup(int col) { // StringIntPairs sc = new StringIntPairs(); // String[] column = getStringColumn(col); @@ -2580,13 +2581,13 @@ public class Table implements Iterable { // StringIntPairs sc = getStringCount(column); // return sc.keys(); // } -// -// +// +// // public StringIntPairs getStringCount(String columnName) { // return getStringCount(getColumnIndex(columnName)); // } -// -// +// +// // public StringIntPairs getStringCount(int column) { // StringIntPairs outgoing = new StringIntPairs(); // for (int row = 0; row < rowCount; row++) { @@ -2598,12 +2599,12 @@ public class Table implements Iterable { // return outgoing; // } // -// +// // /** -// * Return an object that maps the String values in one column back to the -// * row from which they came. For instance, if the "name" of each row is +// * Return an object that maps the String values in one column back to the +// * row from which they came. For instance, if the "name" of each row is // * found in the first column, getColumnRowLookup(0) would return an object -// * that would map each name back to its row. +// * that would map each name back to its row. // */ // public StringIntPairs getColumnRowLookup(int col) { // StringIntPairs sc = new StringIntPairs(); diff --git a/core/src/processing/data/XML.java b/core/src/processing/data/XML.java index da734153d..5699d0808 100644 --- a/core/src/processing/data/XML.java +++ b/core/src/processing/data/XML.java @@ -20,7 +20,7 @@ Boston, MA 02111-1307 USA */ -package processing.core; +package processing.data; import java.io.*; diff --git a/core/todo.txt b/core/todo.txt index 93a239a2b..2286079ec 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -47,8 +47,8 @@ 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 -_ move to processing.data.* package -_ update the internal code for Android and desktop to add the import +X move to processing.data.* package +X update the internal code for Android and desktop to add the import _ change screenWidth/Height to displayWidth/Height _ also fix the Android etc docs