mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Updated descriptions in comments for processing core and libraries
This commit is contained in:
+2798
-2339
File diff suppressed because it is too large
Load Diff
@@ -127,41 +127,42 @@ public interface PConstants {
|
||||
|
||||
// useful goodness
|
||||
|
||||
/**
|
||||
*
|
||||
* PI is a mathematical constant with the value 3.14159265358979323846. It
|
||||
* is the ratio of the circumference of a circle to its diameter. It is
|
||||
* useful in combination with the trigonometric functions <b>sin()</b> and
|
||||
* <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief PI is a mathematical constant with the value 3.14159265358979323846.
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#TAU
|
||||
* @see PConstants#HALF_PI
|
||||
* @see PConstants#QUARTER_PI
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* <b>PI</b> is a mathematical constant with the value 3.1415927. It is the
|
||||
* ratio of the circumference of a circle to its diameter. It is useful in
|
||||
* combination with the trigonometric functions <b>sin()</b> and <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief PI is a mathematical constant with the value
|
||||
* 3.14159265358979323846.
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#TAU
|
||||
* @see PConstants#HALF_PI
|
||||
* @see PConstants#QUARTER_PI
|
||||
*
|
||||
*/
|
||||
static final float PI = (float) Math.PI;
|
||||
/**
|
||||
*
|
||||
* HALF_PI is a mathematical constant with the value
|
||||
* 1.57079632679489661923. It is half the ratio of the circumference of a
|
||||
* circle to its diameter. It is useful in combination with the
|
||||
* trigonometric functions <b>sin()</b> and <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief HALF_PI is a mathematical constant with the value 1.57079632679489661923.
|
||||
* @see PConstants#PI
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#TAU
|
||||
* @see PConstants#QUARTER_PI
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* <b>HALF_PI</b> is a mathematical constant with the value 1.5707964. It is
|
||||
* half the ratio of the circumference of a circle to its diameter. It is useful
|
||||
* in combination with the trigonometric functions <b>sin()</b> and
|
||||
* <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief HALF_PI is a mathematical constant with the value
|
||||
* 1.57079632679489661923.
|
||||
* @see PConstants#PI
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#TAU
|
||||
* @see PConstants#QUARTER_PI
|
||||
*/
|
||||
static final float HALF_PI = (float) (Math.PI / 2.0);
|
||||
static final float THIRD_PI = (float) (Math.PI / 3.0);
|
||||
/**
|
||||
*
|
||||
* QUARTER_PI is a mathematical constant with the value 0.7853982. It is
|
||||
* <b>QUARTER_PI</b> is a mathematical constant with the value 0.7853982. It is
|
||||
* one quarter the ratio of the circumference of a circle to its diameter.
|
||||
* It is useful in combination with the trigonometric functions
|
||||
* <b>sin()</b> and <b>cos()</b>.
|
||||
@@ -176,7 +177,7 @@ public interface PConstants {
|
||||
static final float QUARTER_PI = (float) (Math.PI / 4.0);
|
||||
/**
|
||||
*
|
||||
* TWO_PI is a mathematical constant with the value 6.28318530717958647693.
|
||||
* <b>TWO_PI</b> is a mathematical constant with the value 6.2831855.
|
||||
* It is twice the ratio of the circumference of a circle to its diameter.
|
||||
* It is useful in combination with the trigonometric functions
|
||||
* <b>sin()</b> and <b>cos()</b>.
|
||||
@@ -189,20 +190,21 @@ public interface PConstants {
|
||||
* @see PConstants#QUARTER_PI
|
||||
*/
|
||||
static final float TWO_PI = (float) (2.0 * Math.PI);
|
||||
/**
|
||||
*
|
||||
* TAU is an alias for TWO_PI, a mathematical constant with the value
|
||||
* 6.28318530717958647693. It is twice the ratio of the circumference
|
||||
* of a circle to its diameter. It is useful in combination with the
|
||||
* trigonometric functions <b>sin()</b> and <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief An alias for TWO_PI
|
||||
* @see PConstants#PI
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#HALF_PI
|
||||
* @see PConstants#QUARTER_PI
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* <b>TAU</b> is a mathematical constant with the value 6.2831855. It is the
|
||||
* circle constant relating the circumference of a circle to its linear
|
||||
* dimension, the ratio of the circumference of a circle to its radius. It is
|
||||
* useful in combination with trigonometric functions such as <b>sin()</b> and
|
||||
* <b>cos()</b>.
|
||||
*
|
||||
* @webref constants
|
||||
* @webBrief An alias for TWO_PI
|
||||
* @see PConstants#PI
|
||||
* @see PConstants#TWO_PI
|
||||
* @see PConstants#HALF_PI
|
||||
* @see PConstants#QUARTER_PI
|
||||
*/
|
||||
static final float TAU = (float) (2.0 * Math.PI);
|
||||
|
||||
static final float DEG_TO_RAD = PI/180.0f;
|
||||
|
||||
@@ -35,9 +35,23 @@ import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Grayscale bitmap font class used by Processing.
|
||||
* PFont is the font class for Processing. To create a font to use with
|
||||
* Processing, select "Create Font..." from the Tools menu. This will create a
|
||||
* font in the format Processing requires and also adds it to the current
|
||||
* sketch's data directory. Processing displays fonts using the .vlw font
|
||||
* format, which uses images for each letter, rather than defining them through
|
||||
* vector data. The <b>loadFont()</b> function constructs a new font and
|
||||
* <b>textFont()</b> makes a font active. The <b>list()</b> method creates a
|
||||
* list of the fonts installed on the computer, which is useful information to
|
||||
* use with the <b>createFont()</b> function for dynamically converting fonts
|
||||
* into a format to use with Processing.<br />
|
||||
* <br />
|
||||
* To create a new font dynamically, use the <b>createFont()</b> function. Do
|
||||
* not use the syntax <b>new PFont()</b>.
|
||||
*
|
||||
* <P>
|
||||
* Awful (and by that, I mean awesome) ASCII (non-)art for how this works:
|
||||
*
|
||||
* <PRE>
|
||||
* |
|
||||
* | height is the full used height of the image
|
||||
@@ -55,6 +69,7 @@ import java.util.HashMap;
|
||||
*
|
||||
* ^^^^^^^^^^^^^^ setWidth (width displaced by char)
|
||||
* </PRE>
|
||||
*
|
||||
* @webref typography
|
||||
* @webBrief Grayscale bitmap font class used by Processing.
|
||||
* @see PApplet#loadFont(String)
|
||||
@@ -869,20 +884,18 @@ public class PFont implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets a list of the fonts installed on the system. The data is returned
|
||||
* as a String array. This list provides the names of each font for input
|
||||
* into <b>createFont()</b>, which allows Processing to dynamically format
|
||||
* fonts. This function is meant as a tool for programming local
|
||||
* applications and is not recommended for use in applets.
|
||||
*
|
||||
*
|
||||
* @webref pfont
|
||||
* @webBrief Gets a list of the fonts installed on the system.
|
||||
* @usage application
|
||||
* @brief Gets a list of the fonts installed on the system
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Gets a list of the fonts installed on the system. The data is returned as a
|
||||
* String array. This list provides the names of each font for input into
|
||||
* <b>createFont()</b>, which allows Processing to dynamically format fonts.
|
||||
*
|
||||
*
|
||||
* @webref pfont
|
||||
* @webBrief Gets a list of the fonts installed on the system.
|
||||
* @usage application
|
||||
* @brief Gets a list of the fonts installed on the system
|
||||
*/
|
||||
static public String[] list() {
|
||||
loadFonts();
|
||||
String[] list = new String[fonts.length];
|
||||
|
||||
+1247
-1123
File diff suppressed because it is too large
Load Diff
@@ -35,22 +35,24 @@ import processing.awt.ShimAWT;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Datatype for storing images. Processing can display <b>.gif</b>,
|
||||
* <b>.jpg</b>, <b>.tga</b>, and <b>.png</b> images. Images may be
|
||||
* displayed in 2D and 3D space. Before an image is used, it must be loaded
|
||||
* with the <b>loadImage()</b> function. The <b>PImage</b> class contains
|
||||
* fields for the <b>width</b> and <b>height</b> of the image, as well as
|
||||
* an array called <b>pixels[]</b> that contains the values for every pixel
|
||||
* in the image. The methods described below allow easy access to the
|
||||
* image's pixels and alpha channel and simplify the process of compositing.<br/>
|
||||
* <br/> using the <b>pixels[]</b> array, be sure to use the
|
||||
* <b>loadPixels()</b> method on the image to make sure that the pixel data
|
||||
* is properly loaded.<br/>
|
||||
* <br/> create a new image, use the <b>createImage()</b> function. Do not
|
||||
* use the syntax <b>new PImage()</b>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Datatype for storing images. Processing can display <b>.gif</b>, <b>.jpg</b>,
|
||||
* <b>.tga</b>, and <b>.png</b> images. Images may be displayed in 2D and 3D
|
||||
* space. Before an image is used, it must be loaded with the <b>loadImage()</b>
|
||||
* function. The <b>PImage</b> class contains fields for the <b>width</b> and
|
||||
* <b>height</b> of the image, as well as an array called <b>pixels[]</b> that
|
||||
* contains the values for every pixel in the image. The methods described below
|
||||
* allow easy access to the image's pixels and alpha channel and simplify the
|
||||
* process of compositing.<br />
|
||||
* <br />
|
||||
* Before using the <b>pixels[]</b> array, be sure to use the
|
||||
* <b>loadPixels()</b> method on the image to make sure that the pixel data is
|
||||
* properly loaded.<br />
|
||||
* <br />
|
||||
* To create a new image, use the <b>createImage()</b> function. Do not use the
|
||||
* syntax <b>new PImage()</b>.
|
||||
*
|
||||
*
|
||||
* @webref image
|
||||
* @webBrief Datatype for storing images.
|
||||
* @usage Web & Application
|
||||
@@ -79,28 +81,24 @@ public class PImage implements PConstants, Cloneable {
|
||||
*/
|
||||
public int format;
|
||||
|
||||
/**
|
||||
*
|
||||
* Array containing the values for all the pixels in the display window.
|
||||
* These values are of the color datatype. This array is the size of the
|
||||
* display window. For example, if the image is 100x100 pixels, there will
|
||||
* be 10000 values and if the window is 200x300 pixels, there will be 60000
|
||||
* values. The <b>index</b> value defines the position of a value within
|
||||
* the array. For example, the statement <b>color b = pixels[230]</b> will
|
||||
* set the variable <b>b</b> to be equal to the value at that location in
|
||||
* the array.<br />
|
||||
* <br />
|
||||
* Before accessing this array, the data must loaded with the
|
||||
* <b>loadPixels()</b> function. After the array data has been modified,
|
||||
* the <b>updatePixels()</b> function must be run to update the changes.
|
||||
* Without <b>loadPixels()</b>, running the code may (or will in future
|
||||
* releases) result in a NullPointerException.
|
||||
*
|
||||
*
|
||||
* @webref image:pixels
|
||||
* @webBrief Array containing the color of every pixel in the image.
|
||||
* @usage web_application
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* The pixels[] array contains the values for all the pixels in the image. These
|
||||
* values are of the color datatype. This array is the size of the image,
|
||||
* meaning if the image is 100 x 100 pixels, there will be 10,000 values and if
|
||||
* the window is 200 x 300 pixels, there will be 60,000 values. <br />
|
||||
* <br />
|
||||
* Before accessing this array, the data must loaded with the
|
||||
* <b>loadPixels()</b> method. Failure to do so may result in a
|
||||
* NullPointerException. After the array data has been modified, the
|
||||
* <b>updatePixels()</b> method must be run to update the content of the display
|
||||
* window.
|
||||
*
|
||||
*
|
||||
* @webref image:pixels
|
||||
* @webBrief Array containing the color of every pixel in the image.
|
||||
* @usage web_application
|
||||
*/
|
||||
public int[] pixels;
|
||||
|
||||
/** 1 for most images, 2 for hi-dpi/retina */
|
||||
@@ -375,29 +373,23 @@ public class PImage implements PConstants, Cloneable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads the pixel data for the image into its <b>pixels[]</b> array. This
|
||||
* function must always be called before reading from or writing to <b>pixels[]</b>.
|
||||
* <br/><br/> renderers may or may not seem to require <b>loadPixels()</b>
|
||||
* or <b>updatePixels()</b>. However, the rule is that any time you want to
|
||||
* manipulate the <b>pixels[]</b> array, you must first call
|
||||
* <b>loadPixels()</b>, and after changes have been made, call
|
||||
* <b>updatePixels()</b>. Even if the renderer may not seem to use this
|
||||
* function in the current Processing release, this will always be subject
|
||||
* to change.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Call this when you want to mess with the pixels[] array.
|
||||
* <p/>
|
||||
* For subclasses where the pixels[] buffer isn't set by default,
|
||||
* this should copy all data into the pixels[] array
|
||||
*
|
||||
* @webref pimage:pixels
|
||||
* @webBrief Loads the pixel data for the image into its <b>pixels[]</b> array.
|
||||
* @usage web_application
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Loads the pixel data of the current display window into the <b>pixels[]</b>
|
||||
* array. This function must always be called before reading from or writing to
|
||||
* <b>pixels[]</b>. Subsequent changes to the display window will not be
|
||||
* reflected in <b>pixels</b> until <b>loadPixels()</b> is called again.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3> Call this when you want to mess with the pixels[] array.
|
||||
* <p/>
|
||||
* For subclasses where the pixels[] buffer isn't set by default, this should
|
||||
* copy all data into the pixels[] array
|
||||
*
|
||||
* @webref pimage:pixels
|
||||
* @webBrief Loads the pixel data for the image into its <b>pixels[]</b> array.
|
||||
* @usage web_application
|
||||
*/
|
||||
public void loadPixels() { // ignore
|
||||
if (pixels == null || pixels.length != pixelWidth*pixelHeight) {
|
||||
pixels = new int[pixelWidth*pixelHeight];
|
||||
@@ -411,35 +403,26 @@ public class PImage implements PConstants, Cloneable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Updates the image with the data in its <b>pixels[]</b> array. Use in
|
||||
* conjunction with <b>loadPixels()</b>. If you're only reading pixels from
|
||||
* the array, there's no need to call <b>updatePixels()</b>.
|
||||
* <br/><br/> renderers may or may not seem to require <b>loadPixels()</b>
|
||||
* or <b>updatePixels()</b>. However, the rule is that any time you want to
|
||||
* manipulate the <b>pixels[]</b> array, you must first call
|
||||
* <b>loadPixels()</b>, and after changes have been made, call
|
||||
* <b>updatePixels()</b>. Even if the renderer may not seem to use this
|
||||
* function in the current Processing release, this will always be subject
|
||||
* to change.
|
||||
* <br/> <br/>
|
||||
* Currently, none of the renderers use the additional parameters to
|
||||
* <b>updatePixels()</b>, however this may be implemented in the future.
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Mark the pixels in this region as needing an update.
|
||||
* This is not currently used by any of the renderers, however the api
|
||||
* is structured this way in the hope of being able to use this to
|
||||
* speed things up in the future.
|
||||
* @webref pimage:pixels
|
||||
* @webBrief Updates the image with the data in its <b>pixels[]</b> array.
|
||||
* @usage web_application
|
||||
* @param x x-coordinate of the upper-left corner
|
||||
* @param y y-coordinate of the upper-left corner
|
||||
* @param w width
|
||||
* @param h height
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Updates the display window with the data in the <b>pixels[]</b> array. Use in
|
||||
* conjunction with <b>loadPixels()</b>. If you're only reading pixels from the
|
||||
* array, there's no need to call <b>updatePixels()</b> — updating is only
|
||||
* necessary to apply changes.
|
||||
*
|
||||
* <h3>Advanced</h3> Mark the pixels in this region as needing an update. This
|
||||
* is not currently used by any of the renderers, however the api is structured
|
||||
* this way in the hope of being able to use this to speed things up in the
|
||||
* future.
|
||||
*
|
||||
* @webref pimage:pixels
|
||||
* @webBrief Updates the image with the data in its <b>pixels[]</b> array.
|
||||
* @usage web_application
|
||||
* @param x x-coordinate of the upper-left corner
|
||||
* @param y y-coordinate of the upper-left corner
|
||||
* @param w width
|
||||
* @param h height
|
||||
*/
|
||||
public void updatePixels(int x, int y, int w, int h) { // ignore
|
||||
int x2 = x + w;
|
||||
int y2 = y + h;
|
||||
@@ -928,57 +911,67 @@ public class PImage implements PConstants, Cloneable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Filters an image as defined by one of the following modes:<br /><br
|
||||
* />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.<br />
|
||||
* <br />
|
||||
* GRAY - converts any colors in the image to grayscale equivalents<br />
|
||||
* <br />
|
||||
* INVERT - sets each pixel to its inverse value<br />
|
||||
* <br />
|
||||
* POSTERIZE - limits each channel of the image to the number of colors
|
||||
* specified as the level parameter<br />
|
||||
* <br />
|
||||
* 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<br />
|
||||
* <br />
|
||||
* OPAQUE - sets the alpha channel to entirely opaque<br />
|
||||
* <br />
|
||||
* ERODE - reduces the light areas with the amount defined by the level
|
||||
* parameter<br />
|
||||
* <br />
|
||||
* DILATE - increases the light areas with the amount defined by the level parameter
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Method to apply a variety of basic filters to this image.
|
||||
* <P>
|
||||
* <UL>
|
||||
* <LI>filter(BLUR) provides a basic blur.
|
||||
* <LI>filter(GRAY) converts the image to grayscale based on luminance.
|
||||
* <LI>filter(INVERT) will invert the color components in the image.
|
||||
* <LI>filter(OPAQUE) set all the high bits in the image to opaque
|
||||
* <LI>filter(THRESHOLD) converts the image to black and white.
|
||||
* <LI>filter(DILATE) grow white/light areas
|
||||
* <LI>filter(ERODE) shrink white/light areas
|
||||
* </UL>
|
||||
* Luminance conversion code contributed by
|
||||
* <A HREF="http://www.toxi.co.uk">toxi</A>
|
||||
* <P/>
|
||||
* Gaussian blur code contributed by
|
||||
* <A HREF="http://incubator.quasimondo.com">Mario Klingemann</A>
|
||||
*
|
||||
* @webref image:pixels
|
||||
* @webBrief Converts the image to grayscale or black and white
|
||||
* @usage web_application
|
||||
* @param kind Either THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE, or DILATE
|
||||
* @param param unique for each, see above
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Filters the image as defined by one of the following modes:<br />
|
||||
* <br />
|
||||
* THRESHOLD<br />
|
||||
* Converts the image to black and white pixels depending if they are above or
|
||||
* below the threshold defined by the level parameter. The parameter must be
|
||||
* between 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is
|
||||
* used.<br />
|
||||
* <br />
|
||||
* GRAY<br />
|
||||
* Converts any colors in the image to grayscale equivalents. No parameter is
|
||||
* used.<br />
|
||||
* <br />
|
||||
* OPAQUE<br />
|
||||
* Sets the alpha channel to entirely opaque. No parameter is used.<br />
|
||||
* <br />
|
||||
* INVERT<br />
|
||||
* Sets each pixel to its inverse value. No parameter is used.<br />
|
||||
* <br />
|
||||
* POSTERIZE<br />
|
||||
* Limits each channel of the image to the number of colors specified as the
|
||||
* parameter. The parameter can be set to values between 2 and 255, but results
|
||||
* are most noticeable in the lower ranges.<br />
|
||||
* <br />
|
||||
* BLUR<br />
|
||||
* Executes a Gaussian blur with the level parameter specifying the extent of
|
||||
* the blurring. If no parameter is used, the blur is equivalent to Gaussian
|
||||
* blur of radius 1. Larger values increase the blur.<br />
|
||||
* <br />
|
||||
* ERODE<br />
|
||||
* Reduces the light areas. No parameter is used.<br />
|
||||
* <br />
|
||||
* DILATE<br />
|
||||
* Increases the light areas. No parameter is used.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3> Method to apply a variety of basic filters to this image.
|
||||
* <P>
|
||||
* <UL>
|
||||
* <LI>filter(BLUR) provides a basic blur.
|
||||
* <LI>filter(GRAY) converts the image to grayscale based on luminance.
|
||||
* <LI>filter(INVERT) will invert the color components in the image.
|
||||
* <LI>filter(OPAQUE) set all the high bits in the image to opaque
|
||||
* <LI>filter(THRESHOLD) converts the image to black and white.
|
||||
* <LI>filter(DILATE) grow white/light areas
|
||||
* <LI>filter(ERODE) shrink white/light areas
|
||||
* </UL>
|
||||
* Luminance conversion code contributed by
|
||||
* <A HREF="http://www.toxi.co.uk">toxi</A>
|
||||
* <P/>
|
||||
* Gaussian blur code contributed by
|
||||
* <A HREF="http://incubator.quasimondo.com">Mario Klingemann</A>
|
||||
*
|
||||
* @webref image:pixels
|
||||
* @webBrief Converts the image to grayscale or black and white
|
||||
* @usage web_application
|
||||
* @param kind Either THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE,
|
||||
* or DILATE
|
||||
* @param param unique for each, see above
|
||||
*/
|
||||
public void filter(int kind, float param) {
|
||||
loadPixels();
|
||||
|
||||
|
||||
@@ -37,43 +37,54 @@ import java.util.Base64;
|
||||
|
||||
/**
|
||||
*
|
||||
* Datatype for storing shapes. Processing can currently load and display
|
||||
* SVG (Scalable Vector Graphics) shapes. Before a shape is used, it must
|
||||
* be loaded with the <b>loadShape()</b> function. The <b>shape()</b>
|
||||
* function is used to draw the shape to the display window. The
|
||||
* <b>PShape</b> object contain a group of methods, linked below, that can
|
||||
* operate on the shape data.
|
||||
* <br /><br />
|
||||
* The <b>loadShape()</b> function supports SVG files created with Inkscape
|
||||
* and Adobe Illustrator. It is not a full SVG implementation, but offers
|
||||
* some straightforward support for handling vector data.
|
||||
* Datatype for storing shapes. Before a shape is used, it must be loaded with
|
||||
* the <b>loadShape()</b> or created with the <b>createShape()</b>. The
|
||||
* <b>shape()</b> function is used to draw the shape to the display window.
|
||||
* Processing can currently load and display SVG (Scalable Vector Graphics) and
|
||||
* OBJ shapes. OBJ files can only be opened using the <b>P3D</b> renderer. The
|
||||
* <b>loadShape()</b> function supports SVG files created with Inkscape and
|
||||
* Adobe Illustrator. It is not a full SVG implementation, but offers some
|
||||
* straightforward support for handling vector data. <br />
|
||||
* <br />
|
||||
* The <b>PShape</b> object contains a group of methods that can operate on the
|
||||
* shape data. Some of the methods are listed below, but the full list used for
|
||||
* creating and modifying shapes is
|
||||
* <a href="http://processing.github.io/processing-javadocs/core/">available
|
||||
* here in the Processing Javadoc</a>.<br />
|
||||
* <br />
|
||||
* To create a new shape, use the <b>createShape()</b> function. Do not use the
|
||||
* syntax <b>new PShape()</b>.
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
*
|
||||
* In-progress class to handle shape data, currently to be considered of
|
||||
* alpha or beta quality. Major structural work may be performed on this class
|
||||
* after the release of Processing 1.0. Such changes may include:
|
||||
* In-progress class to handle shape data, currently to be considered of alpha
|
||||
* or beta quality. Major structural work may be performed on this class after
|
||||
* the release of Processing 1.0. Such changes may include:
|
||||
*
|
||||
* <ul>
|
||||
* <li> addition of proper accessors to read shape vertex and coloring data
|
||||
* (this is the second most important part of having a PShape class after all).
|
||||
* <li> a means of creating PShape objects ala beginShape() and endShape().
|
||||
* <li> load(), update(), and cache methods ala PImage, so that shapes can
|
||||
* have renderer-specific optimizations, such as vertex arrays in OpenGL.
|
||||
* <li> splitting this class into multiple classes to handle different
|
||||
* varieties of shape data (primitives vs collections of vertices vs paths)
|
||||
* <li> change of package declaration, for instance moving the code into
|
||||
* package processing.shape (if the code grows too much).
|
||||
* <li>addition of proper accessors to read shape vertex and coloring data (this
|
||||
* is the second most important part of having a PShape class after all).
|
||||
* <li>a means of creating PShape objects ala beginShape() and endShape().
|
||||
* <li>load(), update(), and cache methods ala PImage, so that shapes can have
|
||||
* renderer-specific optimizations, such as vertex arrays in OpenGL.
|
||||
* <li>splitting this class into multiple classes to handle different varieties
|
||||
* of shape data (primitives vs collections of vertices vs paths)
|
||||
* <li>change of package declaration, for instance moving the code into package
|
||||
* processing.shape (if the code grows too much).
|
||||
* </ul>
|
||||
*
|
||||
* <p>For the time being, this class and its shape() and loadShape() friends in
|
||||
* PApplet exist as placeholders for more exciting things to come. If you'd
|
||||
* like to work with this class, make a subclass (see how PShapeSVG works)
|
||||
* and you can play with its internal methods all you like.</p>
|
||||
* <p>
|
||||
* For the time being, this class and its shape() and loadShape() friends in
|
||||
* PApplet exist as placeholders for more exciting things to come. If you'd like
|
||||
* to work with this class, make a subclass (see how PShapeSVG works) and you
|
||||
* can play with its internal methods all you like.
|
||||
* </p>
|
||||
*
|
||||
* <p>Library developers are encouraged to create PShape objects when loading
|
||||
* shape data, so that they can eventually hook into the bounty that will be
|
||||
* the PShape interface, and the ease of loadShape() and shape().</p>
|
||||
* <p>
|
||||
* Library developers are encouraged to create PShape objects when loading shape
|
||||
* data, so that they can eventually hook into the bounty that will be the
|
||||
* PShape interface, and the ease of loadShape() and shape().
|
||||
* </p>
|
||||
*
|
||||
* @webref shape
|
||||
* @webBrief Datatype for storing shapes.
|
||||
@@ -387,40 +398,41 @@ public class PShape implements PConstants {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a boolean value "true" if the image is set to be visible,
|
||||
* "false" if not. This is modified with the <b>setVisible()</b> parameter.
|
||||
* <br/> <br/>
|
||||
* The visibility of a shape is usually controlled by whatever program
|
||||
* created the SVG file. For instance, this parameter is controlled by
|
||||
* showing or hiding the shape in the layers palette in Adobe Illustrator.
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @usage web_application
|
||||
* @webBrief Returns a boolean value "true" if the image is set to be visible, "false" if not
|
||||
* @see PShape#setVisible(boolean)
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Returns a boolean value "true" if the image is set to be visible, "false" if
|
||||
* not. This value can be modified with the <b>setVisible()</b> method.<br />
|
||||
* <br />
|
||||
* The default visibility of a shape is usually controlled by whatever program
|
||||
* created the SVG file. For instance, this parameter is controlled by showing
|
||||
* or hiding the shape in the layers palette in Adobe Illustrator.
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @usage web_application
|
||||
* @webBrief Returns a boolean value "true" if the image is set to be visible,
|
||||
* "false" if not
|
||||
* @see PShape#setVisible(boolean)
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets the shape to be visible or invisible. This is determined by the
|
||||
* value of the <b>visible</b> parameter.
|
||||
* <br/> <br/>
|
||||
* The visibility of a shape is usually controlled by whatever program
|
||||
* created the SVG file. For instance, this parameter is controlled by
|
||||
* showing or hiding the shape in the layers palette in Adobe Illustrator.
|
||||
*
|
||||
* @webref pshape:mathod
|
||||
* @usage web_application
|
||||
* @webBrief Sets the shape to be visible or invisible
|
||||
* @param visible "false" makes the shape invisible and "true" makes it visible
|
||||
* @see PShape#isVisible()
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Sets the shape to be visible or invisible. This is determined by the value of
|
||||
* the <b>visible</b> parameter.<br />
|
||||
* <br />
|
||||
* The default visibility of a shape is usually controlled by whatever program
|
||||
* created the SVG file. For instance, this parameter is controlled by showing
|
||||
* or hiding the shape in the layers palette in Adobe Illustrator.
|
||||
*
|
||||
* @webref pshape:mathod
|
||||
* @usage web_application
|
||||
* @webBrief Sets the shape to be visible or invisible
|
||||
* @param visible "false" makes the shape invisible and "true" makes it visible
|
||||
* @see PShape#isVisible()
|
||||
*/
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@@ -29,38 +29,37 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* A class to describe a two or three dimensional vector. This datatype
|
||||
* stores two or three variables that are commonly used as a position,
|
||||
* velocity, and/or acceleration. Technically, <em>position</em> is a point
|
||||
* and <em>velocity</em> and <em>acceleration</em> are vectors, but this is
|
||||
* often simplified to consider all three as vectors. For example, if you
|
||||
* consider a rectangle moving across the screen, at any given instant it
|
||||
* has a position (the object's location, expressed as a point.), a
|
||||
* velocity (the rate at which the object's position changes per time unit,
|
||||
* expressed as a vector), and acceleration (the rate at which the object's
|
||||
* velocity changes per time unit, expressed as a vector). Since vectors
|
||||
* represent groupings of values, we cannot simply use traditional
|
||||
* addition/multiplication/etc. Instead, we'll need to do some "vector"
|
||||
* math, which is made easy by the methods inside the <b>PVector</b>
|
||||
* class.<br />
|
||||
* A class to describe a two or three dimensional vector, specifically a
|
||||
* Euclidean (also known as geometric) vector. A vector is an entity that has
|
||||
* both magnitude and direction. The datatype, however, stores the components of
|
||||
* the vector (x,y for 2D, and x,y,z for 3D). The magnitude and direction can be
|
||||
* accessed via the methods <b>mag()</b> and <b>heading()</b>.<br />
|
||||
* <br />
|
||||
* The methods for this class are extensive. For a complete list, visit the
|
||||
* <a
|
||||
* href="http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/">developer's reference.</a>
|
||||
* In many of the Processing examples, you will see <b>PVector</b> used to
|
||||
* describe a position, velocity, or acceleration. For example, if you consider
|
||||
* a rectangle moving across the screen, at any given instant it has a position
|
||||
* (a vector that points from the origin to its location), a velocity (the rate
|
||||
* at which the object's position changes per time unit, expressed as a vector),
|
||||
* and acceleration (the rate at which the object's velocity changes per time
|
||||
* unit, expressed as a vector). Since vectors represent groupings of values, we
|
||||
* cannot simply use traditional addition/multiplication/etc. Instead, we'll
|
||||
* need to do some "vector" math, which is made easy by the methods inside the
|
||||
* <b>PVector</b> class.
|
||||
*
|
||||
*
|
||||
* A class to describe a two or three dimensional vector.
|
||||
* <p>
|
||||
* The result of all functions are applied to the vector itself, with the
|
||||
* exception of cross(), which returns a new PVector (or writes to a specified
|
||||
* 'target' PVector). That is, add() will add the contents of one vector to
|
||||
* this one. Using add() with additional parameters allows you to put the
|
||||
* result into a new PVector. Functions that act on multiple vectors also
|
||||
* include static versions. Because creating new objects can be computationally
|
||||
* expensive, most functions include an optional 'target' PVector, so that a
|
||||
* new PVector object is not created with each operation.
|
||||
* 'target' PVector). That is, add() will add the contents of one vector to this
|
||||
* one. Using add() with additional parameters allows you to put the result into
|
||||
* a new PVector. Functions that act on multiple vectors also include static
|
||||
* versions. Because creating new objects can be computationally expensive, most
|
||||
* functions include an optional 'target' PVector, so that a new PVector object
|
||||
* is not created with each operation.
|
||||
* <p>
|
||||
* Initially based on the Vector3D class by <a href="http://www.shiffman.net">Dan Shiffman</a>.
|
||||
* Initially based on the Vector3D class by
|
||||
* <a href="http://www.shiffman.net">Dan Shiffman</a>.
|
||||
*
|
||||
* @webref math
|
||||
* @webBrief A class to describe a two or three dimensional vector.
|
||||
@@ -197,18 +196,18 @@ public class PVector implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Make a new 2D unit vector with a random direction. If you pass in "this"
|
||||
* as an argument, it will use the PApplet's random number generator. You can
|
||||
* also pass in a target PVector to fill.
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @return the random PVector
|
||||
* @webBrief Make a new 2D unit vector with a random direction.
|
||||
* @see PVector#random3D()
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Returns a new 2D unit vector with a random direction. If you pass in
|
||||
* <b>this</b> as an argument, it will use the PApplet's random number
|
||||
* generator.
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @return the random PVector
|
||||
* @webBrief Make a new 2D unit vector with a random direction.
|
||||
* @see PVector#random3D()
|
||||
*/
|
||||
static public PVector random2D() {
|
||||
return random2D(null, null);
|
||||
}
|
||||
@@ -247,18 +246,18 @@ public class PVector implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Make a new 3D unit vector with a random direction. If you pass in "this"
|
||||
* as an argument, it will use the PApplet's random number generator. You can
|
||||
* also pass in a target PVector to fill.
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @return the random PVector
|
||||
* @webBrief Make a new 3D unit vector with a random direction.
|
||||
* @see PVector#random2D()
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Returns a new 3D unit vector with a random direction. If you pass in
|
||||
* <b>this</b> as an argument, it will use the PApplet's random number
|
||||
* generator.
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @return the random PVector
|
||||
* @webBrief Make a new 3D unit vector with a random direction.
|
||||
* @see PVector#random2D()
|
||||
*/
|
||||
static public PVector random3D() {
|
||||
return random3D(null, null);
|
||||
}
|
||||
@@ -313,12 +312,13 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Make a new 2D unit vector from an angle.
|
||||
* Calculates and returns a new 2D unit vector from the specified angle value
|
||||
* (in radians).
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Make a new 2D unit vector from an angle
|
||||
* @webBrief Make a new 2D unit vector from an angle
|
||||
* @param angle the angle in radians
|
||||
* @return the new unit PVector
|
||||
*/
|
||||
@@ -345,7 +345,7 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets a copy of the vector, returns a PVector object.
|
||||
* Copies the components of the vector and returns the result as a PVector.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
@@ -400,15 +400,14 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Calculates the squared magnitude of the vector and returns the result
|
||||
* as a float (this is simply the equation <em>(x*x + y*y + z*z)</em>.)
|
||||
* Faster if the real length is not required in the
|
||||
* case of comparing vectors, etc.
|
||||
* Calculates the magnitude (length) of the vector, squared. This method is
|
||||
* often used to improve performance since, unlike <b>mag()</b>, it does not
|
||||
* require a <b>sqrt()</b> operation.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Calculate the magnitude of the vector, squared
|
||||
* @webBrief Calculate the magnitude of the vector, squared
|
||||
* @return squared magnitude of the vector
|
||||
* @see PVector#mag()
|
||||
*/
|
||||
@@ -419,17 +418,17 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Adds x, y, and z components to a vector, adds one vector to another, or
|
||||
* adds two independent vectors together. The version of the method that
|
||||
* adds two vectors together is a static method and returns a PVector, the
|
||||
* others have no return value -- they act directly on the vector. See the
|
||||
* examples for more context.
|
||||
* Adds x, y, and z components to a vector, adds one vector to another, or adds
|
||||
* two independent vectors together. The version of the method that adds two
|
||||
* vectors together is a static method and returns a new PVector, the others act
|
||||
* directly on the vector itself. See the examples for more context.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @param v the vector to be added
|
||||
* @webBrief Adds x, y, and z components to a vector, one vector to another, or two independent vectors
|
||||
* @webBrief Adds x, y, and z components to a vector, one vector to another, or
|
||||
* two independent vectors
|
||||
*/
|
||||
public PVector add(PVector v) {
|
||||
x += v.x;
|
||||
@@ -487,17 +486,18 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Subtracts x, y, and z components from a vector, subtracts one vector
|
||||
* from another, or subtracts two independent vectors. The version of the
|
||||
* method that subtracts two vectors is a static method and returns a
|
||||
* PVector, the others have no return value -- they act directly on the
|
||||
* vector. See the examples for more context.
|
||||
* Subtracts x, y, and z components from a vector, subtracts one vector from
|
||||
* another, or subtracts two independent vectors. The version of the method that
|
||||
* substracts two vectors is a static method and returns a PVector, the others
|
||||
* act directly on the vector. See the examples for more context. In all cases,
|
||||
* the second vector (v2) is subtracted from the first (v1), resulting in v1-v2.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @param v any variable of type PVector
|
||||
* @webBrief Subtract x, y, and z components from a vector, one vector from another, or two independent vectors
|
||||
* @webBrief Subtract x, y, and z components from a vector, one vector from
|
||||
* another, or two independent vectors
|
||||
*/
|
||||
public PVector sub(PVector v) {
|
||||
x -= v.x;
|
||||
@@ -555,12 +555,16 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Multiplies a vector by a scalar or multiplies one vector by another.
|
||||
* Multiplies a vector by a scalar. The version of the method that uses a float
|
||||
* acts directly on the vector upon which it is called (as in the first example
|
||||
* above). The versions that receive both a PVector and a float as arguments are
|
||||
* static methods, and each returns a new PVector that is the result of the
|
||||
* multiplication operation. Both examples above produce the same visual output.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Multiply a vector by a scalar
|
||||
* @webBrief Multiply a vector by a scalar
|
||||
* @param n the number to multiply with the vector
|
||||
*/
|
||||
public PVector mult(float n) {
|
||||
@@ -595,12 +599,15 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Divides a vector by a scalar or divides one vector by another.
|
||||
*
|
||||
* Divides a vector by a scalar. The version of the method that uses a float
|
||||
* acts directly on the vector upon which it is called (as in the first example
|
||||
* above). The version that receives both a PVector and a float as arguments is
|
||||
* a static methods, and returns a new PVector that is the result of the
|
||||
* division operation. Both examples above produce the same visual output.
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Divide a vector by a scalar
|
||||
* @webBrief Divide a vector by a scalar
|
||||
* @param n the number by which to divide the vector
|
||||
*/
|
||||
public PVector div(float n) {
|
||||
@@ -880,18 +887,32 @@ public class PVector implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Linear interpolate the vector to another vector
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Linear interpolate the vector to another vector
|
||||
* @param v the vector to lerp to
|
||||
* @param amt The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). 0.1 is very near the old vector; 0.5 is halfway in between.
|
||||
* @see PApplet#lerp(float, float, float)
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Calculates linear interpolation from one vector to another vector. (Just like
|
||||
* regular <b>lerp()</b>, but for vectors.)<br />
|
||||
* <br />
|
||||
* Note that there is one <em>static</em> version of this method, and two
|
||||
* <em>non-static</em> versions. The static version, <b>lerp(v1, v2, amt)</b> is
|
||||
* given the two vectors to interpolate and returns a new PVector object. The
|
||||
* static version is used by referencing the PVector class directly. (See the
|
||||
* middle example above.) The non-static versions, <b>lerp(v, amt)</b> and
|
||||
* <b>lerp(x, y, z, amt)</b>, do not create a new PVector, but transform the
|
||||
* values of the PVector on which they are called. These non-static versions
|
||||
* perform the same operation, but the former takes another vector as input,
|
||||
* while the latter takes three float values. (See the top and bottom examples
|
||||
* above, respectively.)
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage web_application
|
||||
* @webBrief Linear interpolate the vector to another vector
|
||||
* @param v the vector to lerp to
|
||||
* @param amt The amount of interpolation; some value between 0.0 (old vector)
|
||||
* and 1.0 (new vector). 0.1 is very near the old vector; 0.5 is
|
||||
* halfway in between.
|
||||
* @see PApplet#lerp(float, float, float)
|
||||
*/
|
||||
public PVector lerp(PVector v, float amt) {
|
||||
x = PApplet.lerp(x, v.x, amt);
|
||||
y = PApplet.lerp(y, v.y, amt);
|
||||
@@ -971,14 +992,14 @@ public class PVector implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Return a representation of this vector as a float array. This is only
|
||||
* for temporary use. If used in any other fashion, the contents should be
|
||||
* copied by using the <b>PVector.get()</b> method to copy into your own array.
|
||||
* Return a representation of this vector as a float array. This is only for
|
||||
* temporary use. If used in any other fashion, the contents should be copied by
|
||||
* using the <b>copy()</b> method to copy into your own array.
|
||||
*
|
||||
*
|
||||
* @webref pvector:method
|
||||
* @usage: web_application
|
||||
* @webBrief Return a representation of the vector as a float array
|
||||
* @webBrief Return a representation of the vector as a float array
|
||||
*/
|
||||
public float[] array() {
|
||||
if (array == null) {
|
||||
|
||||
@@ -9,10 +9,12 @@ import processing.core.PApplet;
|
||||
|
||||
|
||||
/**
|
||||
* A simple table class to use a String as a lookup for an float value.
|
||||
* A simple class to use a String as a lookup for an float value. String "keys"
|
||||
* are associated with floating-point values.
|
||||
*
|
||||
* @webref data:composite
|
||||
* @webBrief A simple table class to use a String as a lookup for an float value.
|
||||
* @webBrief A simple table class to use a String as a lookup for an float
|
||||
* value.
|
||||
* @see IntDict
|
||||
* @see StringDict
|
||||
*/
|
||||
@@ -109,7 +111,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of key/value pairs
|
||||
* Returns the number of key/value pairs.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Returns the number of key/value pairs
|
||||
@@ -145,7 +147,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Remove all entries.
|
||||
* Remove all entries from the data structure.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Remove all entries
|
||||
@@ -258,12 +260,13 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Return a copy of the internal keys array
|
||||
*/
|
||||
/**
|
||||
* Return a copy of the internal keys array. In contrast to the <b>keys()</b>
|
||||
* method, this array can be modified.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Return a copy of the internal keys array
|
||||
*/
|
||||
public String[] keyArray() {
|
||||
crop();
|
||||
return keyArray(null);
|
||||
@@ -285,7 +288,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Return the internal array being used to store the values
|
||||
* Return the internal array being used to store the values.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Return the internal array being used to store the values
|
||||
@@ -321,12 +324,16 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new array and copy each of the values into it.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Create a new array and copy each of the values into it
|
||||
*/
|
||||
/**
|
||||
* The version of this method without a parameter creates a new array and copies
|
||||
* each of the values into it. The version with the <b>float[]</b> parameters
|
||||
* fills an already-allocated array with the values (more efficient than
|
||||
* creating a new array each time). If 'array' is null, or not the same size as
|
||||
* the number of values, a new array will be allocated and returned.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Create a new array and copy each of the values into it
|
||||
*/
|
||||
public float[] valueArray() {
|
||||
crop();
|
||||
return valueArray(null);
|
||||
@@ -372,7 +379,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new key/value pair or change the value of one
|
||||
* Create a new key/value pair or change the value of one.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Create a new key/value pair or change the value of one
|
||||
@@ -397,7 +404,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key is a part of the data structure
|
||||
* Check if a key is a part of the data structure.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Check if a key is a part of the data structure
|
||||
@@ -407,12 +414,13 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add to a value
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Add to a value
|
||||
*/
|
||||
/**
|
||||
* Add to a value. If the key does not exist, an new pair is initialized with
|
||||
* the value supplied.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Add to a value
|
||||
*/
|
||||
public void add(String key, float amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -424,7 +432,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Subtract from a value
|
||||
* Subtract from a value.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Subtract from a value
|
||||
@@ -435,7 +443,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Multiply a value
|
||||
* Multiply a value.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Multiply a value
|
||||
@@ -449,7 +457,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Divide a value
|
||||
* Divide a value.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Divide a value
|
||||
@@ -626,7 +634,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Remove a key/value pair
|
||||
* Remove a key/value pair.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Remove a key/value pair
|
||||
@@ -685,19 +693,20 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort the keys alphabetically in reverse
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Sort the keys alphabetically in reverse
|
||||
*/
|
||||
/**
|
||||
* Sort the keys alphabetically in reverse (ignoring case). Uses the value as a
|
||||
* tie-breaker (only really possible with a key that has a case change).
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Sort the keys alphabetically in reverse
|
||||
*/
|
||||
public void sortKeysReverse() {
|
||||
sortImpl(true, true, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort by values in descending order (largest value will be at [0]).
|
||||
* Sort by values in ascending order (largest value will be at [0]).
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Sort by values in ascending order
|
||||
@@ -718,7 +727,7 @@ public class FloatDict {
|
||||
|
||||
|
||||
/**
|
||||
* Sort by values in descending order
|
||||
* Sort by values in descending order. The largest value will be at [0].
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @webBrief Sort by values in descending order
|
||||
|
||||
@@ -159,9 +159,7 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
* Set the entry at a particular index.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Set the entry at a particular index
|
||||
@@ -467,7 +465,7 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Check if a number is a part of the list
|
||||
* Check if a number is a part of the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Check if a number is a part of the list
|
||||
@@ -498,7 +496,7 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Add to a value
|
||||
* Add to a value.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Add to a value
|
||||
@@ -665,7 +663,7 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Sorts the array in place.
|
||||
* Sorts an array, lowest to highest
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Sorts an array, lowest to highest
|
||||
@@ -676,10 +674,11 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest
|
||||
* A sort in reverse. It's equivalent to running <b>sort()</b> and then
|
||||
* <b>reverse()</b>, but is more efficient than running each separately.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Reverse sort, orders values from highest to lowest
|
||||
* @webBrief A sort in reverse.
|
||||
*/
|
||||
public void sortReverse() {
|
||||
new Sort() {
|
||||
@@ -743,10 +742,10 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the order of the list elements
|
||||
* Reverse the order of the list
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Reverse the order of the list elements
|
||||
* @webBrief Reverse the order of the list
|
||||
*/
|
||||
public void reverse() {
|
||||
int ii = count - 1;
|
||||
@@ -760,8 +759,7 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
* Randomize the order of the list elements.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @webBrief Randomize the order of the list elements
|
||||
|
||||
@@ -9,7 +9,8 @@ import processing.core.PApplet;
|
||||
|
||||
|
||||
/**
|
||||
* A simple class to use a String as a lookup for an int value.
|
||||
* A simple class to use a String as a lookup for an int value. String "keys" are
|
||||
* associated with integer values.
|
||||
*
|
||||
* @webref data:composite
|
||||
* @webBrief A simple class to use a String as a lookup for an int value.
|
||||
@@ -142,10 +143,10 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Remove all entries.
|
||||
* Remove all entries from the data structure.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Remove all entries
|
||||
* @webBrief Remove all entries from the data structure
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
@@ -256,7 +257,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
* Return a copy of the internal keys array. In contrast to the <b>keys()</b>
|
||||
* method, this array can be modified.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Return a copy of the internal keys array
|
||||
@@ -282,6 +284,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Return the internal array being used to store the values.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Return the internal array being used to store the values
|
||||
*/
|
||||
@@ -316,12 +320,16 @@ public class IntDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new array and copy each of the values into it.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Create a new array and copy each of the values into it
|
||||
*/
|
||||
/**
|
||||
* The version of this method without a parameter creates a new array and copies
|
||||
* each of the values into it. The version with the <b>int[]</b> parameters
|
||||
* fills an already-allocated array with the values (more efficient than
|
||||
* creating a new array each time). If 'array' is null, or not the same size as
|
||||
* the number of values, a new array will be allocated and returned.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Create a new array and copy each of the values into it
|
||||
*/
|
||||
public int[] valueArray() {
|
||||
crop();
|
||||
return valueArray(null);
|
||||
@@ -392,6 +400,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key is a part of the data structure.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Check if a key is a part of the data structure
|
||||
*/
|
||||
@@ -401,7 +411,7 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value associated with a specific key by 1.
|
||||
* Increase the value of a specific key value by 1
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Increase the value of a specific key value by 1
|
||||
@@ -424,6 +434,9 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Add to a value. If the key does not exist, an new pair is initialized
|
||||
* with the value supplied.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Add to a value
|
||||
*/
|
||||
@@ -438,6 +451,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Subtract from a value.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Subtract from a value
|
||||
*/
|
||||
@@ -447,6 +462,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Multiply a value.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Multiply a value
|
||||
*/
|
||||
@@ -459,6 +476,8 @@ public class IntDict {
|
||||
|
||||
|
||||
/**
|
||||
* Divide a value.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Divide a value
|
||||
*/
|
||||
@@ -590,6 +609,8 @@ public class IntDict {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a key/value pair.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @webBrief Remove a key/value pair
|
||||
*/
|
||||
|
||||
@@ -178,9 +178,7 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
* Set the entry at a particular index.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Set the entry at a particular index
|
||||
@@ -444,6 +442,8 @@ public class IntList implements Iterable<Integer> {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Check if a number is a part of the data structure.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Check if a number is a part of the list
|
||||
*/
|
||||
@@ -461,6 +461,8 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one to a value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Add one to a value
|
||||
*/
|
||||
@@ -480,6 +482,8 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Add to a value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Add to a value
|
||||
*/
|
||||
@@ -492,6 +496,8 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract from a value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Subtract from a value
|
||||
*/
|
||||
@@ -504,6 +510,8 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply a value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Multiply a value
|
||||
*/
|
||||
@@ -516,6 +524,8 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide a value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Divide a value
|
||||
*/
|
||||
@@ -539,6 +549,8 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Return the smallest value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Return the smallest value
|
||||
*/
|
||||
@@ -569,6 +581,8 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Return the largest value.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Return the largest value
|
||||
*/
|
||||
@@ -620,7 +634,7 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Sorts the array in place.
|
||||
* Sorts the array, lowest to highest.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Sorts the array, lowest to highest
|
||||
@@ -631,7 +645,8 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest.
|
||||
* A sort in reverse. It's equivalent to running <b>sort()</b> and then
|
||||
* <b>reverse()</b>, but is more efficient than running each separately.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Reverse sort, orders values from highest to lowest
|
||||
@@ -676,6 +691,8 @@ public class IntList implements Iterable<Integer> {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Reverse the order of the list.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Reverse the order of the list elements
|
||||
*/
|
||||
@@ -691,8 +708,7 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
* Randomize the order of the list elements.
|
||||
*
|
||||
* @webref intlist:method
|
||||
* @webBrief Randomize the order of the list elements
|
||||
|
||||
@@ -46,6 +46,10 @@ import java.util.ArrayList;
|
||||
import processing.core.PApplet;
|
||||
|
||||
/**
|
||||
* A <b>JSONArray</b> stores an array of JSON objects. <b>JSONArray</b>s can
|
||||
* be generated from scratch, dynamically, or using data from an existing file.
|
||||
* JSON can also be output and saved to disk, as in the example above.
|
||||
*
|
||||
* A JSONArray is an ordered sequence of values. Its external text form is a
|
||||
* string wrapped in square brackets with commas separating the values. The
|
||||
* internal form is an object having <code>get</code> and <code>opt</code>
|
||||
@@ -274,7 +278,7 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the string associated with an index.
|
||||
* Gets the String value associated with the specified index.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the String value associated with an index
|
||||
@@ -309,10 +313,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the int value associated with an index.
|
||||
* Gets the int value associated with the specified index.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the int value associated with an index
|
||||
* @webBrief Gets the int value associated with the specified index.
|
||||
* @param index must be between 0 and length() - 1
|
||||
* @return The value.
|
||||
* @throws RuntimeException If the key is not found or if the value is not a number.
|
||||
@@ -387,11 +391,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get a value from an index as a float. JSON uses 'double' values
|
||||
* internally, so this is simply getDouble() cast to a float.
|
||||
* Gets the float value associated with the specified index.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the float value associated with an index
|
||||
* @webBrief Gets the float value associated with the specified index.
|
||||
* @param index must be between 0 and length() - 1
|
||||
* @see JSONArray#getInt(int)
|
||||
* @see JSONArray#getString(int)
|
||||
@@ -450,11 +453,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the boolean value associated with an index.
|
||||
* The string values "true" and "false" are converted to boolean.
|
||||
* Gets the boolean value associated with the specified index.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the boolean value associated with an index
|
||||
* @webBrief Gets the boolean value associated with the specified index.
|
||||
* @param index must be between 0 and length() - 1
|
||||
* @return The truth.
|
||||
* @throws RuntimeException If there is no value for the index or if the
|
||||
@@ -497,10 +499,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the JSONArray associated with an index.
|
||||
* Retrieves the <b>JSONArray</b> with the associated index value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the JSONArray associated with an index value
|
||||
* @webBrief Retrieves the <b>JSONArray</b> with the associated index value.
|
||||
* @param index must be between 0 and length() - 1
|
||||
* @return A JSONArray value.
|
||||
* @throws RuntimeException If there is no value for the index. or if the
|
||||
@@ -528,10 +530,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the JSONObject associated with an index.
|
||||
* Retrieves the <b>JSONObject</b> with the associated index value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the JSONObject associated with an index value
|
||||
* @webBrief Retrieves the <b>JSONObject</b> with the associated index value.
|
||||
* @param index the index value of the object to get
|
||||
* @return A JSONObject value.
|
||||
* @throws RuntimeException If there is no value for the index or if the
|
||||
@@ -559,10 +561,11 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get this entire array as a String array.
|
||||
* Returns the entire <b>JSONArray</b> as an array of Strings.
|
||||
* (All values in the array must be of the String type.)
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the entire array as an array of Strings
|
||||
* @webBrief Returns the entire <b>JSONArray</b> as an array of Strings
|
||||
* @see JSONArray#getIntArray()
|
||||
*/
|
||||
public String[] getStringArray() {
|
||||
@@ -575,10 +578,11 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get this entire array as an int array. Everything must be an int.
|
||||
* Returns the entire <b>JSONArray</b> as an array of ints.
|
||||
* (All values in the array must be of the int type.)
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the entire array as array of ints
|
||||
* @webBrief Returns the entire <b>JSONArray</b> as an array of ints
|
||||
* @see JSONArray#getStringArray()
|
||||
*/
|
||||
public int[] getIntArray() {
|
||||
@@ -696,7 +700,9 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Append an String value. This increases the array's length by one.
|
||||
* Appends a new value to the <b>JSONArray</b>, increasing the array's length
|
||||
* by one. New values may be of the following types: int, float, String,
|
||||
* boolean, <b>JSONObject</b>, or <b>JSONArray</b>.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Appends a value, increasing the array's length by one
|
||||
@@ -848,12 +854,14 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Put or replace a String value. If the index is greater than the length of
|
||||
* the JSONArray, then null elements will be added as necessary to pad
|
||||
* it out.
|
||||
* Inserts a new value into the <b>JSONArray</b> at the specified index
|
||||
* position. If a value already exists in the specified position, the new
|
||||
* value overwrites the old value. If the given index is greater than the
|
||||
* length of the <b>JSONArray</b>, then null elements will be added as
|
||||
* necessary to pad it out.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Put a String value in the JSONArray
|
||||
* @webBrief Inserts a new value into the <b>JSONArray</b> at the specified index position.
|
||||
* @param index an index value
|
||||
* @param value the value to assign
|
||||
* @return this.
|
||||
@@ -869,9 +877,11 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Put or replace an int value. If the index is greater than the length of
|
||||
* the JSONArray, then null elements will be added as necessary to pad
|
||||
* it out.
|
||||
* Inserts a new value into the <b>JSONArray</b> at the specified index
|
||||
* position. If a value already exists in the specified position, the
|
||||
* new value overwrites the old value. If the given index is greater
|
||||
* than the length of the <b>JSONArray</b>, then null elements will be
|
||||
* added as necessary to pad it out.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Put an int value in the JSONArray
|
||||
@@ -904,10 +914,11 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Put or replace a float value. If the index is greater than the length
|
||||
* of the JSONArray, then null elements will be added as necessary to pad
|
||||
* it out. There are no 'double' values in JSON, so this is passed to
|
||||
* setDouble(value).
|
||||
* Inserts a new value into the <b>JSONArray</b> at the specified index
|
||||
* position. If a value already exists in the specified position, the
|
||||
* new value overwrites the old value. If the given index is greater
|
||||
* than the length of the <b>JSONArray</b>, then null elements will be
|
||||
* added as necessary to pad it out.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Put a float value in the JSONArray
|
||||
@@ -941,12 +952,14 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Put or replace a boolean value in the JSONArray. If the index is greater
|
||||
* than the length of the JSONArray, then null elements will be added as
|
||||
* necessary to pad it out.
|
||||
* Inserts a new value into the <b>JSONArray</b> at the specified index
|
||||
* position. If a value already exists in the specified position, the
|
||||
* new value overwrites the old value. If the given index is greater
|
||||
* than the length of the <b>JSONArray</b>, then null elements will be
|
||||
* added as necessary to pad it out.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Put a boolean value in the JSONArray
|
||||
* @webBrief Inserts a new value into the <b>JSONArray</b> at the specified index position
|
||||
* @param index an index value
|
||||
* @param value the value to assign
|
||||
* @return this.
|
||||
@@ -975,10 +988,10 @@ public class JSONArray {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the JSONArray value associated with an index value
|
||||
* Sets the value of the <b>JSONArray</b> with the associated index value.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Sets the JSONArray value associated with an index value
|
||||
* @webBrief Sets the value of the <b>JSONArray</b> with the associated index value
|
||||
* @param index the index value to target
|
||||
* @param value the value to assign
|
||||
* @see JSONArray#setJSONObject(int, JSONObject)
|
||||
@@ -991,10 +1004,10 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JSONObject value associated with an index value
|
||||
* Sets the value of the <b>JSONObject</b> with the index value.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Sets the JSONObject value associated with an index value
|
||||
* @webBrief Sets the value of the <b>JSONObject</b> with the index value
|
||||
* @param index the index value to target
|
||||
* @param value the value to assign
|
||||
* @see JSONArray#setJSONArray(int, JSONArray)
|
||||
@@ -1037,10 +1050,10 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of elements in the JSONArray, included nulls.
|
||||
* Gets the total number of elements in a <b>JSONArray</b> (inclusive of null elements).
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Gets the number of elements in the JSONArray
|
||||
* @webBrief Gets the total number of elements in a <b>JSONArray</b>
|
||||
* @return The length (or size).
|
||||
* @see JSONArray#append(String)
|
||||
* @see JSONArray#remove(int)
|
||||
@@ -1051,9 +1064,11 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the value is null.
|
||||
* Determines if the value associated with the index is <b>null</b>, that is has
|
||||
* no defined value (<b>false</b>) or if it has a value (<b>true</b>).
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Determine if the value is null.
|
||||
* @webBrief Determines if the value associated with the index is <b>null</b>
|
||||
* @param index must be between 0 and length() - 1
|
||||
* @return true if the value at the index is null, or if there is no value.
|
||||
*/
|
||||
@@ -1063,10 +1078,12 @@ public class JSONArray {
|
||||
|
||||
|
||||
/**
|
||||
* Remove an index and close the hole.
|
||||
* Removes the element from a <b>JSONArray</b> in the specified index position.
|
||||
* Returns either the value associated with the given index, or null, if there
|
||||
* is no value.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @webBrief Removes an element
|
||||
* @webBrief Removes the element from a <b>JSONArray</b> in the specified index position
|
||||
* @param index the index value of the element to be removed
|
||||
* @return The value that was associated with the index, or null if there was no value.
|
||||
* @see JSONArray#size()
|
||||
|
||||
@@ -51,6 +51,18 @@ import java.util.Set;
|
||||
import processing.core.PApplet;
|
||||
|
||||
/**
|
||||
* A <b>JSONObject</b> stores JSON data with multiple name/value pairs. Values
|
||||
* can be numeric, Strings, booleans, other <b>JSONObject</b>s or
|
||||
* <b>JSONArray</b>s, or null. <b>JSONObject</b> and <b>JSONArray</b> objects
|
||||
* are quite similar and share most of the same methods; the primary difference
|
||||
* is that the latter stores an array of JSON objects, while the former
|
||||
* represents a single JSON object.<br />
|
||||
* <br />
|
||||
* JSON can be generated from scratch, dynamically, or using data from an
|
||||
* existing file. JSON can also be output and saved to disk, as in the example
|
||||
* above.
|
||||
*
|
||||
*
|
||||
* A JSONObject is an unordered collection of name/value pairs. Its external
|
||||
* form is a string wrapped in curly braces with colons between the names and
|
||||
* values, and commas between the values and names. The internal form is an
|
||||
@@ -555,10 +567,10 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the String associated with a key
|
||||
* Gets the String value associated with the specified key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the string value associated with a key
|
||||
* @webBrief Gets the String value associated with the specified key
|
||||
* @param key a key string
|
||||
* @return A string which is the value.
|
||||
* @throws RuntimeException if there is no string value for the key.
|
||||
@@ -594,10 +606,10 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the int value associated with a key
|
||||
* Gets the int value associated with the specified key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the int value associated with a key
|
||||
* @webBrief Gets the int value associated with the specified key
|
||||
* @param key A key string.
|
||||
* @return The integer value.
|
||||
* @throws RuntimeException if the key is not found or if the value cannot
|
||||
@@ -679,7 +691,7 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the float value associated with a key
|
||||
* Gets the float value associated with the specified key
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the float value associated with a key
|
||||
@@ -741,10 +753,10 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Get the boolean value associated with a key.
|
||||
* Gets the boolean value associated with the specified key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the boolean value associated with a key
|
||||
* @webBrief Gets the boolean value associated with the specified key
|
||||
* @param key a key string
|
||||
* @return The truth.
|
||||
* @throws RuntimeException if the value is not a Boolean or the String "true" or "false".
|
||||
@@ -786,10 +798,10 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Get the JSONArray value associated with a key.
|
||||
* Retrieves the <b>JSONArray</b> with the associated key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the JSONArray value associated with a key
|
||||
* @webBrief Retrieves the <b>JSONArray</b> with the associated key
|
||||
* @param key a key string
|
||||
* @return A JSONArray which is the value, or null if not present
|
||||
* @throws RuntimeException if the value is not a JSONArray.
|
||||
@@ -810,10 +822,10 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Get the JSONObject value associated with a key.
|
||||
* Given a key value, retrieves the associated <b>JSONObject</b>.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Gets the JSONObject value associated with a key
|
||||
* @webBrief Given a key value, retrieves the associated <b>JSONObject</b>
|
||||
* @param key a key string
|
||||
* @return A JSONObject which is the value or null if not available.
|
||||
* @throws RuntimeException if the value is not a JSONObject.
|
||||
@@ -916,12 +928,12 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the value associated with the key is null or if there is
|
||||
* no value.
|
||||
* Determines if the value associated with the key is <b>null</b>, that is has
|
||||
* no defined value (<b>false</b>) or if it has a value (<b>true</b>).
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Determine if the value associated with the key is null or if there is
|
||||
* no value.
|
||||
* @webBrief Determines if the value associated with the key is <b>null</b>, that is has
|
||||
* no defined value (<b>false</b>) or if it has a value (<b>true</b>).
|
||||
* @param key A key string.
|
||||
* @return true if there is no value associated with the key or if
|
||||
* the value is the JSONObject.NULL object.
|
||||
@@ -1161,8 +1173,11 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a new key/String pair into the <b>JSONObject</b> or, if a value with
|
||||
* the specified key already exists, assigns a new value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Put a key/String pair in the JSONObject
|
||||
* @webBrief Inserts a new key/String pair into the <b>JSONObject</b>
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
* @see JSONObject#setInt(String, int)
|
||||
@@ -1175,10 +1190,11 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Put a key/int pair in the JSONObject.
|
||||
*
|
||||
* Inserts a new key/int pair into the <b>JSONObject</b> or, if a value with
|
||||
* the specified key already exists, assigns a new value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Put a key/int pair in the JSONObject
|
||||
* @webBrief Inserts a new key/int pair into the <b>JSONObject</b>
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
* @return this.
|
||||
@@ -1207,7 +1223,8 @@ public class JSONObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a key/float pair in the JSONObject
|
||||
* Inserts a new key/float pair into the <b>JSONObject</b> or, if a value with
|
||||
* the specified key already exists, assigns a new value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Put a key/float pair in the JSONObject
|
||||
@@ -1239,7 +1256,8 @@ public class JSONObject {
|
||||
|
||||
|
||||
/**
|
||||
* Put a key/boolean pair in the JSONObject.
|
||||
* Inserts a new key/boolean pair into the <b>JSONObject</b> or, if a value
|
||||
* with the specified key already exists, assigns a new value.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Put a key/boolean pair in the JSONObject
|
||||
@@ -1257,10 +1275,10 @@ public class JSONObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JSONObject value associated with a key
|
||||
* Sets the value of the <b>JSONObject</b> with the associated key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Sets the JSONObject value associated with a key
|
||||
* @webBrief Sets the value of the <b>JSONObject</b> with the associated key
|
||||
* @param key a key string
|
||||
* @param value value to assign
|
||||
* @see JSONObject#setJSONArray(String, JSONArray)
|
||||
@@ -1272,10 +1290,10 @@ public class JSONObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JSONArray value associated with a key
|
||||
* Sets the value of the <b>JSONArray</b> with the associated key.
|
||||
*
|
||||
* @webref jsonobject:method
|
||||
* @webBrief Sets the JSONArray value associated with a key
|
||||
* @webBrief Sets the value of the <b>JSONArray</b> with the associated key
|
||||
* @param key a key string
|
||||
* @param value value to assign
|
||||
* @see JSONObject#setJSONObject(String, JSONObject)
|
||||
|
||||
@@ -9,10 +9,11 @@ import processing.core.PApplet;
|
||||
|
||||
|
||||
/**
|
||||
* A simple table class to use a String as a lookup for another String value.
|
||||
* A simple class to use a String as a lookup for an String value. String "keys"
|
||||
* are associated with String values.
|
||||
*
|
||||
* @webref data:composite
|
||||
* @webBrief A simple table class to use a String as a lookup for another String value.
|
||||
* @webBrief A simple class to use a String as a lookup for an String value
|
||||
* @see IntDict
|
||||
* @see FloatDict
|
||||
*/
|
||||
@@ -279,7 +280,7 @@ public class StringDict {
|
||||
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
* Return a copy of the internal keys array.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @webBrief Return a copy of the internal keys array
|
||||
@@ -489,8 +490,7 @@ public class StringDict {
|
||||
|
||||
|
||||
/**
|
||||
* Sort the keys alphabetically (ignoring case). Uses the value as a
|
||||
* tie-breaker (only really possible with a key that has a case change).
|
||||
* Sort the keys alphabetically.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @webBrief Sort the keys alphabetically
|
||||
@@ -511,10 +511,10 @@ public class StringDict {
|
||||
|
||||
|
||||
/**
|
||||
* Sort by values in descending order (largest value will be at [0]).
|
||||
* Sort by values in descending order.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @webBrief Sort by values in ascending order
|
||||
* @webBrief Sort by values in descending order
|
||||
*/
|
||||
public void sortValues() {
|
||||
sortImpl(false, false);
|
||||
|
||||
@@ -149,7 +149,7 @@ public class StringList implements Iterable<String> {
|
||||
/**
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
* entries with "null".
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @webBrief Set an entry at a particular index
|
||||
@@ -503,10 +503,11 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest.
|
||||
* A sort in reverse. It's equivalent to running <b>sort()</b> and then
|
||||
* <b>reverse()</b>, but is more efficient than running each separately.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @webBrief Reverse sort, orders values from highest to lowest
|
||||
* @webBrief A sort in reverse
|
||||
*/
|
||||
public void sortReverse() {
|
||||
sortImpl(true);
|
||||
@@ -554,10 +555,10 @@ public class StringList implements Iterable<String> {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Reverse the order of the list elements
|
||||
* Reverse the order of the list
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @webBrief Reverse the order of the list elements
|
||||
* @webBrief Reverse the order of the list
|
||||
*/
|
||||
public void reverse() {
|
||||
int ii = count - 1;
|
||||
@@ -571,8 +572,7 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
* Randomize the order of the list elements.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @webBrief Randomize the order of the list elements
|
||||
|
||||
@@ -46,18 +46,36 @@ import processing.core.PConstants;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Generic class for handling tabular data, typically from a CSV, TSV, or
|
||||
* other sort of spreadsheet file.</p>
|
||||
* <p>CSV files are
|
||||
* <a href="http://en.wikipedia.org/wiki/Comma-separated_values">comma separated values</a>,
|
||||
* often with the data in quotes. TSV files use tabs as separators, and usually
|
||||
* don't bother with the quotes.</p>
|
||||
* <p>File names should end with .csv if they're comma separated.</p>
|
||||
* <p>A rough "spec" for CSV can be found <a href="http://tools.ietf.org/html/rfc4180">here</a>.</p>
|
||||
* <b>Table</b> objects store data with multiple rows and columns, much like in
|
||||
* a traditional spreadsheet. Tables can be generated from scratch, dynamically,
|
||||
* or using data from an existing file. Tables can also be output and saved to
|
||||
* disk, as in the example above.<br />
|
||||
* <br />
|
||||
* Additional <b>Table</b> methods are documented in the <a href=
|
||||
* "http://processing.github.io/processing-javadocs/core/processing/data/Table.html">Processing
|
||||
* Table Javadoc</a>.
|
||||
*
|
||||
* <p>
|
||||
* Generic class for handling tabular data, typically from a CSV, TSV, or other
|
||||
* sort of spreadsheet file.
|
||||
* </p>
|
||||
* <p>
|
||||
* CSV files are
|
||||
* <a href="http://en.wikipedia.org/wiki/Comma-separated_values">comma separated
|
||||
* values</a>, often with the data in quotes. TSV files use tabs as separators,
|
||||
* and usually don't bother with the quotes.
|
||||
* </p>
|
||||
* <p>
|
||||
* File names should end with .csv if they're comma separated.
|
||||
* </p>
|
||||
* <p>
|
||||
* A rough "spec" for CSV can be found
|
||||
* <a href="http://tools.ietf.org/html/rfc4180">here</a>.
|
||||
* </p>
|
||||
*
|
||||
* @webref data:composite
|
||||
* @webBrief Generic class for handling tabular data, typically from a CSV, TSV, or
|
||||
* other sort of spreadsheet file.
|
||||
* @webBrief Generic class for handling tabular data, typically from a CSV, TSV,
|
||||
* or other sort of spreadsheet file.
|
||||
* @see PApplet#loadTable(String)
|
||||
* @see PApplet#saveTable(Table, String)
|
||||
* @see TableRow
|
||||
@@ -1790,13 +1808,18 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new column to a table
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Adds a new column to a table
|
||||
* @see Table#removeColumn(String)
|
||||
*/
|
||||
/**
|
||||
* Use <b>addColumn()</b> to add a new column to a <b>Table</b> object.
|
||||
* Typically, you will want to specify a title, so the column may be easily
|
||||
* referenced later by name. (If no title is specified, the new column's title
|
||||
* will be null.) A column type may also be specified, in which case all values
|
||||
* stored in this column must be of the same type (e.g., Table.INT or
|
||||
* Table.FLOAT). If no type is specified, the default type of STRING is used.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Adds a new column to a table
|
||||
* @see Table#removeColumn(String)
|
||||
*/
|
||||
public void addColumn() {
|
||||
addColumn(null, STRING);
|
||||
}
|
||||
@@ -1866,14 +1889,18 @@ public class Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a column from a table
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes a column from a table
|
||||
* @param columnName the title of the column to be removed
|
||||
* @see Table#addColumn()
|
||||
*/
|
||||
/**
|
||||
* Use <b>removeColumn()</b> to remove an existing column from a <b>Table</b>
|
||||
* object. The column to be removed may be identified by either its title (a
|
||||
* String) or its index value (an int). <b>removeColumn(0)</b> would remove the
|
||||
* first column, <b>removeColumn(1)</b> would remove the second column, and so
|
||||
* on.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes a column from a table
|
||||
* @param columnName the title of the column to be removed
|
||||
* @see Table#addColumn()
|
||||
*/
|
||||
public void removeColumn(String columnName) {
|
||||
removeColumn(getColumnIndex(columnName));
|
||||
}
|
||||
@@ -1914,10 +1941,10 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of columns in a table
|
||||
* Returns the total number of columns in a table.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Gets the number of columns in a table
|
||||
* @webBrief Returns the total number of columns in a table
|
||||
* @see Table#getRowCount()
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
@@ -2264,10 +2291,10 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
/**
|
||||
* Gets the number of rows in a table
|
||||
* Returns the total number of rows in a table.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Gets the number of rows in a table
|
||||
* @webBrief Returns the total number of rows in a table
|
||||
* @see Table#getColumnCount()
|
||||
*/
|
||||
public int getRowCount() {
|
||||
@@ -2281,10 +2308,11 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Removes all rows from a table
|
||||
* Removes all rows from a <b>Table</b>. While all rows are removed, columns
|
||||
* and column titles are maintained.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes all rows from a table
|
||||
* @webBrief Removes all rows from a <b>Table</b>
|
||||
* @see Table#addRow()
|
||||
* @see Table#removeRow(int)
|
||||
*/
|
||||
@@ -2325,14 +2353,19 @@ public class Table {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a row to a table
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Adds a row to a table
|
||||
* @see Table#removeRow(int)
|
||||
* @see Table#clearRows()
|
||||
*/
|
||||
/**
|
||||
* Use <b>addRow()</b> to add a new row of data to a <b>Table</b> object. By
|
||||
* default, an empty row is created. Typically, you would store a reference to
|
||||
* the new row in a <b>TableRow</b> object (see <b>newRow</b> in the example
|
||||
* above), and then set individual values using <b>setInt()</b>,
|
||||
* <b>setFloat()</b>, or <b>setString()</b>. If a <b>TableRow</b> object is
|
||||
* included as a parameter, then that row is duplicated and added to the table.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Adds a new row of data to a <b>Table</b> object
|
||||
* @see Table#removeRow(int)
|
||||
* @see Table#clearRows()
|
||||
*/
|
||||
public TableRow addRow() {
|
||||
//if (rowIncrement == 0) {
|
||||
setRowCount(rowCount + 1);
|
||||
@@ -2452,10 +2485,10 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Removes a row from a table
|
||||
* Removes a row from a <b>Table</b> object
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes a row from a table
|
||||
* @webBrief Removes a row from a <b>Table</b> object
|
||||
* @param row ID number of the row to remove
|
||||
* @see Table#addRow()
|
||||
* @see Table#clearRows()
|
||||
@@ -2660,10 +2693,11 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
/**
|
||||
* Gets a row from a table
|
||||
* Returns a reference to the specified <b>TableRow</b>. The reference can then
|
||||
* be used to get and set values of the selected row, as illustrated in the example above.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Gets a row from a table
|
||||
* @webBrief Returns a reference to the specified <b>TableRow</b>
|
||||
* @param row ID number of the row to get
|
||||
* @see Table#rows()
|
||||
* @see Table#findRow(String, int)
|
||||
@@ -2677,12 +2711,11 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Note that this one iterator instance is shared by any calls to iterate
|
||||
* the rows of this table. This is very efficient, but not thread-safe.
|
||||
* If you want to iterate in a multi-threaded manner, don't use the iterator.
|
||||
* Gets all rows from the table. Returns an iterator, so <b>for</b> must be
|
||||
* used to iterate through all the rows, as shown in the example above.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Gets multiple rows from a table
|
||||
* @webBrief Gets all rows from the table
|
||||
* @see Table#getRow(int)
|
||||
* @see Table#findRow(String, int)
|
||||
* @see Table#findRows(String, int)
|
||||
@@ -3069,10 +3102,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Get an integer value from the specified row and column
|
||||
* Retrieves an integer value from the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by either
|
||||
* its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Get an integer value from the specified row and column
|
||||
* @webBrief Retrieves an integer value from the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the row to reference
|
||||
* @param column ID number of the column to reference
|
||||
* @see Table#getFloat(int, int)
|
||||
@@ -3108,10 +3143,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Store an integer value in the specified row and column
|
||||
* Stores an integer value in the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by
|
||||
* either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Store an integer value in the specified row and column
|
||||
* @webBrief Stores an integer value in the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the target row
|
||||
* @param column ID number of the target column
|
||||
* @param value value to assign
|
||||
@@ -3249,12 +3286,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* 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,
|
||||
* this is Float.NaN, but can be controlled with setMissingFloat().
|
||||
* Retrieves a float value from the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by either
|
||||
* its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Get a float value from the specified row and column
|
||||
* @webBrief Retrieves a float value from the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the row to reference
|
||||
* @param column ID number of the column to reference
|
||||
* @see Table#getInt(int, int)
|
||||
@@ -3291,10 +3328,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Store a float value in the specified row and column
|
||||
* Stores a float value in the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by
|
||||
* either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Store a float value in the specified row and column
|
||||
* @webBrief Stores a float value in the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the target row
|
||||
* @param column ID number of the target column
|
||||
* @param value value to assign
|
||||
@@ -3486,10 +3525,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Get a String value from the table. If the row is longer than the table
|
||||
* Retrieves a String value from the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by either
|
||||
* its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Get an String value from the specified row and column
|
||||
* @webBrief Retrieves a String value from the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the row to reference
|
||||
* @param column ID number of the column to reference
|
||||
* @see Table#getInt(int, int)
|
||||
@@ -3540,10 +3581,12 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Store a float value in the specified row and column
|
||||
* Stores a String value in the <b>Table</b>'s specified row and column.
|
||||
* The row is specified by its ID, while the column may be specified by
|
||||
* either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Store a String value in the specified row and column
|
||||
* @webBrief Stores a String value in the <b>Table</b>'s specified row and column
|
||||
* @param row ID number of the target row
|
||||
* @param column ID number of the target column
|
||||
* @param value value to assign
|
||||
@@ -3572,10 +3615,11 @@ public class Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all values in the specified column
|
||||
* Retrieves all values in the specified column, and returns them as a String
|
||||
* array. The column may be specified by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Gets all values in the specified column
|
||||
* @webBrief Retrieves all values in the specified column
|
||||
* @param columnName title of the column to search
|
||||
* @see Table#getInt(int, int)
|
||||
* @see Table#getFloat(int, int)
|
||||
@@ -3716,7 +3760,10 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
/**
|
||||
* Finds a row that contains the given value
|
||||
* Finds the first row in the <b>Table</b> that contains the value provided,
|
||||
* and returns a reference to that row. Even if multiple rows are possible
|
||||
* matches, only the first matching row is returned. The column to search may
|
||||
* be specified by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Finds a row that contains the given value
|
||||
@@ -3743,7 +3790,10 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Finds multiple rows that contain the given value
|
||||
* Finds the rows in the <b>Table</b> that contain the value provided,
|
||||
* and returns references to those rows. Returns an iterator, so <b>for</b>
|
||||
* must be used to iterate through all the rows, as shown in the example above.
|
||||
* The column to search may be specified by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Finds multiple rows that contain the given value
|
||||
@@ -3877,7 +3927,10 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
/**
|
||||
* Finds a row that matches the given expression
|
||||
* Finds the first row in the <b>Table</b> that matches the regular expression
|
||||
* provided, and returns a reference to that row. Even if multiple rows are
|
||||
* possible matches, only the first matching row is returned. The column to
|
||||
* search may be specified by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Finds a row that matches the given expression
|
||||
@@ -3904,7 +3957,10 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Finds multiple rows that match the given expression
|
||||
* Finds the rows in the <b>Table</b> that match the regular expression provided,
|
||||
* and returns references to those rows. Returns an iterator, so <b>for</b>
|
||||
* must be used to iterate through all the rows, as shown in the example above.
|
||||
* The column to search may be specified by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Finds multiple rows that match the given expression
|
||||
@@ -4036,14 +4092,18 @@ public class Table {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
/**
|
||||
* Remove any of the specified characters from the entire table.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes characters from the table
|
||||
* @param tokens a list of individual characters to be removed
|
||||
* @see Table#trim()
|
||||
*/
|
||||
/**
|
||||
* Removes any of the specified characters (or "tokens"). The example above
|
||||
* removes all commas, dollar signs, and spaces from the table.<br />
|
||||
* <br />
|
||||
* If no column is specified, then the values in all columns and rows are
|
||||
* processed. A specific column may be referenced by either its ID or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Removes characters from the table
|
||||
* @param tokens a list of individual characters to be removed
|
||||
* @see Table#trim()
|
||||
*/
|
||||
public void removeTokens(String tokens) {
|
||||
for (int col = 0; col < getColumnCount(); col++) {
|
||||
removeTokens(tokens, col);
|
||||
@@ -4093,7 +4153,10 @@ public class Table {
|
||||
|
||||
|
||||
/**
|
||||
* Trims whitespace from values
|
||||
* Trims leading and trailing whitespace, such as spaces and tabs, from String
|
||||
* table values. If no column is specified, then the values in all columns
|
||||
* and rows are trimmed. A specific column may be referenced by either its ID
|
||||
* or title.
|
||||
*
|
||||
* @webref table:method
|
||||
* @webBrief Trims whitespace from values
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.io.PrintWriter;
|
||||
public interface TableRow {
|
||||
|
||||
/**
|
||||
* Get an String value from the specified column
|
||||
* Retrieves a String value from the <b>TableRow</b>'s specified column.
|
||||
* The column may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Get an String value from the specified column
|
||||
@@ -37,7 +38,8 @@ public interface TableRow {
|
||||
public String getString(String columnName);
|
||||
|
||||
/**
|
||||
* Get an integer value from the specified column
|
||||
* Retrieves an integer value from the <b>TableRow</b>'s specified column.
|
||||
* The column may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Get an integer value from the specified column
|
||||
@@ -67,7 +69,8 @@ public interface TableRow {
|
||||
public long getLong(String columnName);
|
||||
|
||||
/**
|
||||
* Get a float value from the specified column
|
||||
* Retrieves a float value from the <b>TableRow</b>'s specified column.
|
||||
* The column may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Get a float value from the specified column
|
||||
@@ -96,7 +99,8 @@ public interface TableRow {
|
||||
public double getDouble(String columnName);
|
||||
|
||||
/**
|
||||
* Store a String value in the specified column
|
||||
* Stores a String value in the <b>TableRow</b>'s specified column. The column
|
||||
* may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Store a String value in the specified column
|
||||
@@ -112,8 +116,9 @@ public interface TableRow {
|
||||
public void setString(String columnName, String value);
|
||||
|
||||
/**
|
||||
* Store an integer value in the specified column
|
||||
*
|
||||
* Stores an integer value in the <b>TableRow</b>'s specified column. The column
|
||||
* may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Store an integer value in the specified column
|
||||
* @param column ID number of the target column
|
||||
@@ -143,7 +148,8 @@ public interface TableRow {
|
||||
public void setLong(String columnName, long value);
|
||||
|
||||
/**
|
||||
* Store a float value in the specified column
|
||||
* Stores a float value in the <b>TableRow</b>'s specified column. The column
|
||||
* may be specified by either its ID or title.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Store a float value in the specified column
|
||||
@@ -174,7 +180,7 @@ public interface TableRow {
|
||||
public void setDouble(String columnName, double value);
|
||||
|
||||
/**
|
||||
* Get the column count.
|
||||
* Returns the number of columns in a <b>TableRow</b>.
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Get the column count.
|
||||
@@ -201,7 +207,7 @@ public interface TableRow {
|
||||
public int[] getColumnTypes();
|
||||
|
||||
/**
|
||||
* Get the column title.
|
||||
* Returns the name for a column in a <b>TableRow</b> based on its ID (e.g. 0, 1, 2, etc.)
|
||||
*
|
||||
* @webref tablerow:method
|
||||
* @webBrief Get the column title.
|
||||
|
||||
@@ -41,12 +41,16 @@ import processing.core.PApplet;
|
||||
|
||||
|
||||
/**
|
||||
* This is the base class used for the Processing XML library,
|
||||
* representing a single node of an XML tree.
|
||||
* <b>XML</b> is a representation of an XML object, able to parse XML code. Use
|
||||
* <b>loadXML()</b> to load external XML files and create <b>XML</b>
|
||||
* objects.<br />
|
||||
* <br />
|
||||
* Only files encoded as UTF-8 (or plain ASCII) are parsed properly; the
|
||||
* encoding parameter inside XML files is ignored.
|
||||
*
|
||||
* @webref data:composite
|
||||
* @webBrief This is the base class used for the Processing XML library,
|
||||
* representing a single node of an XML tree.
|
||||
* representing a single node of an XML tree.
|
||||
* @see PApplet#loadXML(String)
|
||||
* @see PApplet#parseXML(String)
|
||||
* @see PApplet#saveXML(XML, String)
|
||||
@@ -301,8 +305,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parent element. This method returns null for the root
|
||||
* element.
|
||||
* Gets a copy of the element's parent. Returns the parent as another XML object.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets a copy of the element's parent
|
||||
@@ -320,8 +323,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the full name (i.e. the name including an eventual namespace
|
||||
* prefix) of the element.
|
||||
* Gets the element's full name, which is returned as a String.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the element's full name
|
||||
@@ -333,7 +335,7 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the element's name
|
||||
* Sets the element's name, which is specified as a String.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Sets the element's name
|
||||
@@ -386,7 +388,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns a boolean of whether or not there are children.
|
||||
* Checks whether or not the element has any children, and returns the result as a boolean.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Checks whether or not an element has any children
|
||||
@@ -398,8 +400,9 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Put the names of all children into an array. Same as looping through
|
||||
* each child and calling getName() on each XMLElement.
|
||||
* Get the names of all of the element's children, and returns the names as an
|
||||
* array of Strings. This is the same as looping through and calling getName()
|
||||
* on each child element individually.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Returns the names of all children as an array
|
||||
@@ -424,7 +427,10 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all the child elements.
|
||||
* Returns all of the element's children as an array of XML objects. When
|
||||
* the <b>name</b> parameter is specified, then it will return all children
|
||||
* that match that name or path. The path is a series of elements and
|
||||
* sub-elements, separated by slashes.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Returns an array containing all child elements
|
||||
@@ -444,7 +450,9 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Quick accessor for an element at a particular index.
|
||||
* Returns the first of the element's children that matches the <b>name</b>
|
||||
* parameter. The name or path is a series of elements and sub-elements,
|
||||
* separated by slashes.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Returns the child element with the specified index value or path
|
||||
@@ -562,12 +570,16 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Appends a new child to the element
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Appends a new child to the element
|
||||
*/
|
||||
/**
|
||||
* Appends a new child to the element. The child can be specified with either a
|
||||
* String, which will be used as the new tag's name, or as a reference to an
|
||||
* existing XML object.<br />
|
||||
* <br />
|
||||
* A reference to the newly created child is returned as an XML object.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Appends a new child to the element
|
||||
*/
|
||||
public XML addChild(String tag) {
|
||||
Document document = node.getOwnerDocument();
|
||||
Node newChild = document.createElement(tag);
|
||||
@@ -593,12 +605,14 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified child
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Removes the specified child
|
||||
*/
|
||||
/**
|
||||
* Removes the specified element. First use <b>getChild()</b> to get a reference
|
||||
* to the desired element. Then pass that reference to <b>removeChild()</b> to
|
||||
* delete it.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Removes the specified child
|
||||
*/
|
||||
public void removeChild(XML kid) {
|
||||
node.removeChild(kid.node);
|
||||
children = null; // TODO not efficient
|
||||
@@ -681,7 +695,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of attributes.
|
||||
* Counts the specified element's number of attributes, returned as an int.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Counts the specified element's number of attributes
|
||||
@@ -692,7 +706,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of the names for all of the attributes for this node.
|
||||
* Gets all of the specified element's attributes, and returns them as an array of Strings.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Returns a list of names of all attributes as an array
|
||||
@@ -707,7 +721,8 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an attribute exists.
|
||||
* Checks whether or not an element has the specified attribute. The attribute
|
||||
* must be specified as a String, and a boolean is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Checks whether or not an element has the specified attribute
|
||||
@@ -742,7 +757,10 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content of an attribute as a String
|
||||
* Returns an attribute value of the element as a String. If the <b>defaultValue</b>
|
||||
* parameter is specified and the attribute doesn't exist, then <b>defaultValue</b>
|
||||
* is returned. If no <b>defaultValue</b> is specified and the attribute doesn't
|
||||
* exist, null is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an attribute as a String
|
||||
@@ -765,7 +783,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the content of an attribute as a String
|
||||
* Sets the content of an element's attribute as a String. The first String
|
||||
* specifies the attribute name, while the second specifies the new content.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Sets the content of an attribute as a String
|
||||
@@ -776,7 +795,10 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content of an attribute as an int
|
||||
* Returns an attribute value of the element as an int. If the <b>defaultValue</b>
|
||||
* parameter is specified and the attribute doesn't exist, then <b>defaultValue</b>
|
||||
* is returned. If no <b>defaultValue</b> is specified and the attribute doesn't
|
||||
* exist, the value 0 is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an attribute as an int
|
||||
@@ -787,7 +809,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the content of an attribute as an int
|
||||
* Sets the content of an element's attribute as an int. A String specifies
|
||||
* the attribute name, while the int specifies the new content.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Sets the content of an attribute as an int
|
||||
@@ -834,12 +857,15 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of an attribute, or zero if not present.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an attribute as a float
|
||||
*/
|
||||
/**
|
||||
* Returns an attribute value of the element as a float. If the
|
||||
* <b>defaultValue</b> parameter is specified and the attribute doesn't exist,
|
||||
* then <b>defaultValue</b> is returned. If no <b>defaultValue</b> is specified
|
||||
* and the attribute doesn't exist, the value 0.0 is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an attribute as a float
|
||||
*/
|
||||
public float getFloat(String name) {
|
||||
return getFloat(name, 0);
|
||||
}
|
||||
@@ -859,7 +885,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the content of an attribute as a float
|
||||
* Sets the content of an element's attribute as a float. A String specifies
|
||||
* the attribute name, while the float specifies the new content.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Sets the content of an attribute as a float
|
||||
@@ -893,10 +920,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Return the #PCDATA content of the element. If the element has a
|
||||
* combination of #PCDATA content and child elements, the #PCDATA
|
||||
* sections can be retrieved as unnamed child objects. In this case,
|
||||
* this method returns null.
|
||||
* Returns the content of an element. If there is no such content,
|
||||
* <b>null</b> is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an element
|
||||
@@ -916,7 +941,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content of an element as an int
|
||||
* Returns the content of an element as an int. If there is no such content,
|
||||
* either <b>null</b> or the provided default value is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an element as an int
|
||||
@@ -938,7 +964,8 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content of an element as a float
|
||||
* Returns the content of an element as a float. If there is no such content,
|
||||
* either <b>null</b> or the provided default value is returned.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets the content of an element as a float
|
||||
@@ -992,7 +1019,7 @@ public class XML implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the content of an element
|
||||
* Sets the element's content, which is specified as a String.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Sets the content of an element
|
||||
@@ -1022,15 +1049,25 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format this XML data as a String.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Formats XML data as a String
|
||||
* @param indent -1 for a single line (and no declaration), >= 0 for indents and newlines
|
||||
* @return the content
|
||||
* @see XML#toString()
|
||||
*/
|
||||
/**
|
||||
* Takes an XML object and converts it to a String, formatting its content as
|
||||
* specified with the <b>indent</b> parameter.<br />
|
||||
* <br />
|
||||
* If indent is set to -1, then the String is returned with no line breaks, no
|
||||
* indentation, and no XML declaration.<br />
|
||||
* <br />
|
||||
* If indent is set to 0 or greater, then the String is returned with line
|
||||
* breaks, and the specified number of spaces as indent values. Meaning, there
|
||||
* will be no indentation if 0 is specified, or each indent will be replaced
|
||||
* with the corresponding number of spaces: 1, 2, 3, and so on.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Formats XML data as a String
|
||||
* @param indent -1 for a single line (and no declaration), >= 0 for indents and
|
||||
* newlines
|
||||
* @return the content
|
||||
* @see XML#toString()
|
||||
*/
|
||||
public String format(int indent) {
|
||||
try {
|
||||
// entities = doctype.getEntities()
|
||||
@@ -1166,16 +1203,17 @@ public class XML implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the XML document formatted with two spaces for indents.
|
||||
* Chosen to do this since it's the most common case (e.g. with println()).
|
||||
* Same as format(2). Use the format() function for more options.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets XML data as a String using default formatting
|
||||
* @return the content
|
||||
* @see XML#format(int)
|
||||
*/
|
||||
/**
|
||||
* Takes an XML object and converts it to a String, using default formatting
|
||||
* rules (includes an XML declaration, line breaks, and two spaces for indents).
|
||||
* These are the same formatting rules used by <b>println()</b> when printing an
|
||||
* XML object. This method produces the same results as using <b>format(2)</b>.
|
||||
*
|
||||
* @webref xml:method
|
||||
* @webBrief Gets XML data as a String using default formatting
|
||||
* @return the content
|
||||
* @see XML#format(int)
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
//return format(2);
|
||||
|
||||
@@ -30,7 +30,31 @@ import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* @webref
|
||||
* Opens an I2C interface as master.<br/>
|
||||
* <br/>
|
||||
* I2C is a serial bus, commonly used to attach peripheral ICs (Integrated
|
||||
* Circuits) to processors and microcontrollers. It uses two pins, SDA (for
|
||||
* data) and SDL (for the clock signal). Multiple "slave" devices can be
|
||||
* connected to the same bus, as long as they are responding to different
|
||||
* addresses (see below).<br/>
|
||||
* <br/>
|
||||
* The I2C "master" device initiates a transmission, which includes sending the
|
||||
* address of the desired "slave" device. I2C addresses consist of 7 bits plus
|
||||
* one bit that indicates whether the device is being read from or written to.
|
||||
* Some datasheets list the address in an 8 bit form (7 address bits + R/W bit),
|
||||
* while others provide the address in a 7 bit form, with the address in the
|
||||
* lower 7 bits.<br/>
|
||||
* <br/>
|
||||
* This library expects addresses in their 7 bit form, similar to Arduino's Wire
|
||||
* library, and what is being output by the i2cdetect utility on Linux. If the
|
||||
* address provided in a datasheet is greater than 127 (hex 0x7f) or there are
|
||||
* separate addresses for read and write operations listed, which vary exactly
|
||||
* by one, then you want to shift the this number by one bit to the right before
|
||||
* passing it as an argument to
|
||||
* <a href="I2C_beginTransmission_.html">beginTransmission()</a>.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Opens an I2C interface as master
|
||||
*/
|
||||
public class I2C {
|
||||
|
||||
@@ -62,13 +86,22 @@ public class I2C {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Begins a transmission to an attached device
|
||||
* @see write
|
||||
* @see read
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Begins a transmission to an attached device.<br/>
|
||||
* <br/>
|
||||
* This function expects the address in the lower 7 bits, the same way as in
|
||||
* Arduino's Wire library, and as shown in the output of the i2cdetect tool. If
|
||||
* the address provided in a datasheet is greater than 127 (hex 0x7f) or there
|
||||
* are separate addresses for read and write operations listed, which vary
|
||||
* exactly by one, then you want to shift the this number by one bit to the
|
||||
* right before passing it as an argument to this function.
|
||||
*
|
||||
* @see write
|
||||
* @see read
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
* @webBrief Begins a transmission to an attached device
|
||||
*/
|
||||
public void beginTransmission(int slave) {
|
||||
// addresses 120 (0x78) to 127 are additionally reserved
|
||||
if (0x78 <= slave) {
|
||||
@@ -81,10 +114,18 @@ public class I2C {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes the I2C device
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Closes the I2C device<br/>
|
||||
* </br>
|
||||
* It is normally not necessary to explicitly close I2C interfaces, as they are
|
||||
* closed automatically by the operating system when the sketch exits.</br>
|
||||
* </br>
|
||||
* Note: It is possible to have two or more object using the same interface at a
|
||||
* time.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Closes the I2C device.
|
||||
*/
|
||||
public void close() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return;
|
||||
@@ -104,12 +145,18 @@ public class I2C {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ends the current transmissions
|
||||
* @see beginTransmission
|
||||
* @see write
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Ends the current transmissions<br/>
|
||||
* <br/>
|
||||
* This executes any queued writes. <a href="I2C_read_.html">Read()</a>
|
||||
* implicitly ends the current transmission as well, hence calling
|
||||
* endTransmission() afterwards is not necessary.
|
||||
*
|
||||
* @see beginTransmission
|
||||
* @see write
|
||||
* @webref
|
||||
* @webBrief Ends the current transmissions.
|
||||
*/
|
||||
public void endTransmission() {
|
||||
if (!transmitting) {
|
||||
// silently ignore this case
|
||||
@@ -137,6 +184,7 @@ public class I2C {
|
||||
* Lists all available I2C interfaces
|
||||
* @return String array
|
||||
* @webref
|
||||
* @webBrief Lists all available I2C interfaces
|
||||
*/
|
||||
public static String[] list() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
@@ -161,15 +209,22 @@ public class I2C {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads bytes from the attached device
|
||||
* @param len number of bytes to read
|
||||
* @return bytes read from device
|
||||
* @see beginTransmission
|
||||
* @see write
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Read bytes from the attached device<br/>
|
||||
* <br/>
|
||||
* You must call beginTransmission() before calling this function. This function
|
||||
* also ends the current transmission and sends any data that was queued using
|
||||
* write() before. It is not necessary to call
|
||||
* <a href="I2C_endTransmission_.html">endTransmission()</a> after read().
|
||||
*
|
||||
* @param len number of bytes to read
|
||||
* @return bytes read from device
|
||||
* @see beginTransmission
|
||||
* @see write
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
* @webBrief Read bytes from the attached device.
|
||||
*/
|
||||
public byte[] read(int len) {
|
||||
if (!transmitting) {
|
||||
throw new RuntimeException("beginTransmisson has not been called");
|
||||
@@ -195,14 +250,19 @@ public class I2C {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds bytes to be written to the device
|
||||
* @param out bytes to be written
|
||||
* @see beginTransmission
|
||||
* @see read
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Add bytes to be written to the device<br/>
|
||||
* <br/>
|
||||
* You must call beginTransmission() before calling this function. The actual
|
||||
* writing takes part when read() or endTransmission() is being called.
|
||||
*
|
||||
* @param out bytes to be written
|
||||
* @see beginTransmission
|
||||
* @see read
|
||||
* @see endTransmission
|
||||
* @webref
|
||||
* @webBrief Add bytes to be written to the device.
|
||||
*/
|
||||
public void write(byte[] out) {
|
||||
if (!transmitting) {
|
||||
throw new RuntimeException("beginTransmisson has not been called");
|
||||
|
||||
@@ -33,7 +33,19 @@ import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* @webref
|
||||
* Opens a LED device.<br/>
|
||||
* <br/>
|
||||
* This class can control your computer's build-in LEDs, such as the ones
|
||||
* commonly used to indicate the power status and disk activity.</br>
|
||||
* <br/>
|
||||
* Your operating system might not be set up to allow regular users to do this
|
||||
* kind of modification. If this is the case you should install a so-called
|
||||
* <i>udev rule</i> that relaxes the permissions for the files in
|
||||
* /sys/class/leds. You can also try running Processing as root user using
|
||||
* "sudo", but this is generally not recommended.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Opens a LED device
|
||||
*/
|
||||
public class LED {
|
||||
|
||||
@@ -47,7 +59,7 @@ public class LED {
|
||||
* Opens a LED device
|
||||
* @param dev device name
|
||||
* @see list
|
||||
* @webref
|
||||
* @webref Opens a LED device
|
||||
*/
|
||||
public LED(String dev) {
|
||||
NativeInterface.loadLibrary();
|
||||
@@ -107,6 +119,7 @@ public class LED {
|
||||
* Sets the brightness
|
||||
* @param bright 0.0 (off) to 1.0 (maximum)
|
||||
* @webref
|
||||
* @webBrief Sets the brightness
|
||||
*/
|
||||
public void brightness(float bright) {
|
||||
if (bright < 0.0 || 1.0 < bright) {
|
||||
@@ -126,10 +139,15 @@ public class LED {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restores the previous state
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Restores the previous state<br/>
|
||||
* <br/>
|
||||
* Without calling this function the LED will remain in the current state even
|
||||
* after the sketch has been closed.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Restores the previous state
|
||||
*/
|
||||
public void close() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return;
|
||||
@@ -154,6 +172,7 @@ public class LED {
|
||||
* Lists all available LED devices
|
||||
* @return String array
|
||||
* @webref
|
||||
* @webBrief Lists all available LED devices
|
||||
*/
|
||||
public static String[] list() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
|
||||
@@ -33,7 +33,10 @@ import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* Opens a PWM channel
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Opens a PWM channel
|
||||
*/
|
||||
public class PWM {
|
||||
|
||||
@@ -45,7 +48,7 @@ public class PWM {
|
||||
* Opens a PWM channel
|
||||
* @param channel PWM channel
|
||||
* @see list
|
||||
* @webref
|
||||
* @webref Opens a PWM channel
|
||||
*/
|
||||
public PWM(String channel) {
|
||||
NativeInterface.loadLibrary();
|
||||
@@ -90,7 +93,9 @@ public class PWM {
|
||||
|
||||
/**
|
||||
* Disables the PWM output
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Disables the PWM output
|
||||
*/
|
||||
public void clear() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
@@ -105,10 +110,15 @@ public class PWM {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives ownership of a channel back to the operating system
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Gives ownership of a channel back to the operating system<br/>
|
||||
* <br/>
|
||||
* Without calling this function the channel will remain in the current state
|
||||
* even after the sketch has been closed.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Gives ownership of a channel back to the operating system
|
||||
*/
|
||||
public void close() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return;
|
||||
@@ -134,6 +144,7 @@ public class PWM {
|
||||
* Lists all available PWM channels
|
||||
* @return String array
|
||||
* @webref
|
||||
* @webBrief Lists all available PWM channels
|
||||
*/
|
||||
public static String[] list() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
@@ -164,12 +175,16 @@ public class PWM {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables the PWM output
|
||||
* @param period cycle period in Hz
|
||||
* @param duty duty cycle, 0.0 (always off) to 1.0 (always on)
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Enables the PWM output<br/>
|
||||
* <br/>
|
||||
* When no period is specified, a default 1 kHz (1000 Hz) is used.
|
||||
*
|
||||
* @param period cycle period in Hz
|
||||
* @param duty duty cycle, 0.0 (always off) to 1.0 (always on)
|
||||
* @webref
|
||||
* @webBrief Enables the PWM output
|
||||
*/
|
||||
public void set(int period, float duty) {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return;
|
||||
@@ -206,7 +221,7 @@ public class PWM {
|
||||
|
||||
/**
|
||||
* Enables the PWM output with a preset period of 1 kHz
|
||||
* @webref
|
||||
* @nowebref
|
||||
*/
|
||||
public void set(float duty) {
|
||||
set(1000, duty);
|
||||
|
||||
@@ -32,7 +32,29 @@ import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @webref
|
||||
* Opens an SPI interface as master<br/>
|
||||
* </br>
|
||||
* Serial Peripheral Interface (SPI) is a serial bus, commonly used to
|
||||
* communicate with sensors and memory devices. It uses four pins: MOSI (Master
|
||||
* Out Slave In), MISO (Master In Slave Out), and SCLK (clock signal) - those
|
||||
* three are shared among all devices on the bus - as well as one or more SS
|
||||
* (Slave Select) pins, that are used for the master to signal to the slave
|
||||
* device that it is the desired respondent for the transmission.<br/>
|
||||
* <br/>
|
||||
* The "master" device initiates a transfer by pulling the SS pin of the "slave"
|
||||
* low, and begins outputting a clock signal. In SPI, both the "master" as well
|
||||
* as the "slave" device output data at the same time. It is hence not possible
|
||||
* to read data without writing some (even if it means outputting zeros or other
|
||||
* dummy data).</br>
|
||||
* </br>
|
||||
* There are multiple possible configuration settings for SPI, see
|
||||
* <a href="SPI_settings_.html">settings()</a> for details.</br>
|
||||
* <br/>
|
||||
* This library supports multiple SPI objects making use of the same SPI
|
||||
* interface.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Opens an SPI interface as master
|
||||
*/
|
||||
public class SPI {
|
||||
|
||||
@@ -74,6 +96,7 @@ public class SPI {
|
||||
* @param dev device name
|
||||
* @see list
|
||||
* @webref
|
||||
* @webBrief Opens an SPI interface as master
|
||||
*/
|
||||
public SPI(String dev) {
|
||||
NativeInterface.loadLibrary();
|
||||
@@ -90,10 +113,18 @@ public class SPI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes the SPI interface
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Closes the SPI interface</br>
|
||||
* </br>
|
||||
* It is normally not necessary to explicitly close SPI interfaces, as they are
|
||||
* closed automatically by the operating system when the sketch exits.</br>
|
||||
* </br>
|
||||
* Note: It is possible to have two or more objects using the same interface at
|
||||
* a time.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Closes the SPI interface
|
||||
*/
|
||||
public void close() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return;
|
||||
@@ -117,6 +148,7 @@ public class SPI {
|
||||
* Lists all available SPI interfaces
|
||||
* @return String array
|
||||
* @webref
|
||||
* @webBrief Lists all available SPI interfaces
|
||||
*/
|
||||
public static String[] list() {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
@@ -141,13 +173,22 @@ public class SPI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures the SPI interface
|
||||
* @param maxSpeed maximum transmission rate in Hz, 500000 (500 kHz) is a resonable default
|
||||
* @param dataOrder whether data is send with the first- or least-significant bit first (SPI.MSBFIRST or SPI.LSBFIRST, the former is more common)
|
||||
* @param mode <a href="https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase">SPI.MODE0 to SPI.MODE3</a>
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Configures the SPI interface<br/>
|
||||
* <br/>
|
||||
* The default setting is: 500000, SPI.MSBFIRST, SPI.MODE0
|
||||
*
|
||||
* @param maxSpeed maximum transmission rate in Hz, 500000 (500 kHz) is a
|
||||
* resonable default
|
||||
* @param dataOrder whether data is send with the first- or least-significant
|
||||
* bit first (SPI.MSBFIRST or SPI.LSBFIRST, the former is more
|
||||
* common)
|
||||
* @param mode <a href=
|
||||
* "https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase">SPI.MODE0
|
||||
* to SPI.MODE3</a>
|
||||
* @webref
|
||||
* @webBrief Configures the SPI interface
|
||||
*/
|
||||
public void settings(int maxSpeed, int dataOrder, int mode) {
|
||||
this.maxSpeed = maxSpeed;
|
||||
this.dataOrder = dataOrder;
|
||||
@@ -155,12 +196,17 @@ public class SPI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transfers data over the SPI bus
|
||||
* @param out bytes to send
|
||||
* @return bytes read in (array is the same length as out)
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Transfers data over the SPI bus<br/>
|
||||
* <br/>
|
||||
* With SPI, data is simultaneously being exchanged between the master device
|
||||
* and the slave device. For every byte that is being sent out, there's also one
|
||||
* byte being read in.
|
||||
*
|
||||
* @param out bytes to send
|
||||
* @return bytes read in (array is the same length as out)
|
||||
* @webref Transfers data over the SPI bus
|
||||
*/
|
||||
public byte[] transfer(byte[] out) {
|
||||
if (NativeInterface.isSimulated()) {
|
||||
return new byte[out.length];
|
||||
|
||||
@@ -26,7 +26,17 @@ import processing.core.*;
|
||||
|
||||
|
||||
/**
|
||||
* @webref
|
||||
* Opens an RC servo motor connected to a GPIO pin<br/>
|
||||
* </br>
|
||||
* This library uses timers to control RC servo motors by means of pulse width
|
||||
* modulation (PWM). While not as accurate as dedicated PWM hardware, it has
|
||||
* shown to be sufficient for many applications.<br/>
|
||||
* <br/>
|
||||
* Connect the signal wire (typically colored yellow) to any available GPIO pin
|
||||
* and control the servo's angle as shown in the example sketch.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Opens an RC servo motor connected to a GPIO pin
|
||||
*/
|
||||
public class SoftwareServo {
|
||||
|
||||
@@ -45,6 +55,7 @@ public class SoftwareServo {
|
||||
* Opens a servo motor
|
||||
* @param parent typically use "this"
|
||||
* @webref
|
||||
* @webBrief Opens a servo motor
|
||||
*/
|
||||
public SoftwareServo(PApplet parent) {
|
||||
NativeInterface.loadLibrary();
|
||||
@@ -54,6 +65,7 @@ public class SoftwareServo {
|
||||
/**
|
||||
* Closes a servo motor
|
||||
* @webref
|
||||
* @webBrief Closes a servo motor
|
||||
*/
|
||||
public void close() {
|
||||
detach();
|
||||
@@ -69,11 +81,20 @@ public class SoftwareServo {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attaches a servo motor to a GPIO pin
|
||||
* @param pin GPIO pin
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Attaches a servo motor to a GPIO pin<br/>
|
||||
* <br/>
|
||||
* You must call this function before calling write(). Note that the servo motor
|
||||
* will only be instructed to move after the first time write() is called.<br/>
|
||||
* <br/>
|
||||
* The optional parameters minPulse and maxPulse control the minimum and maximum
|
||||
* pulse width durations. The default values, identical to those of Arduino's
|
||||
* Servo class, should be compatible with most servo motors.
|
||||
*
|
||||
* @param pin GPIO pin
|
||||
* @webref
|
||||
* @webBrief Attaches a servo motor to a GPIO pin
|
||||
*/
|
||||
public void attach(int pin) {
|
||||
detach();
|
||||
this.pin = pin;
|
||||
@@ -96,11 +117,19 @@ public class SoftwareServo {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Moves a servo motor to a given orientation
|
||||
* @param angle angle in degrees (controls speed and direction on continuous-rotation servos)
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Moves a servo motor to a given orientation<br/>
|
||||
* <br/>
|
||||
* If you are using this class in combination with a continuous rotation servo,
|
||||
* different angles will result in the servo rotating forward or backward at
|
||||
* different speeds. For regular servo motors, this will instruct the servo to
|
||||
* rotate to and hold a specific angle.
|
||||
*
|
||||
* @param angle angle in degrees (controls speed and direction on
|
||||
* continuous-rotation servos)
|
||||
* @webref
|
||||
* @webBrief Moves a servo motor to a given orientation
|
||||
*/
|
||||
public void write(float angle) {
|
||||
if (attached() == false) {
|
||||
System.err.println("You need to call attach(pin) before write(angle).");
|
||||
@@ -137,16 +166,22 @@ public class SoftwareServo {
|
||||
* Returns whether a servo motor is attached to a pin
|
||||
* @return true if attached, false is not
|
||||
* @webref
|
||||
* @webBrief Returns whether a servo motor is attached to a pin
|
||||
*/
|
||||
public boolean attached() {
|
||||
return (pin != -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detatches a servo motor from a GPIO pin
|
||||
* @webref
|
||||
*/
|
||||
/**
|
||||
* Detatches a servo motor from a GPIO pin<br/>
|
||||
* <br/>
|
||||
* Calling this method will stop the servo from moving or trying to hold the
|
||||
* current orientation.
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Detatches a servo motor from a GPIO pin
|
||||
*/
|
||||
public void detach() {
|
||||
if (0 <= handle) {
|
||||
// stop thread
|
||||
|
||||
@@ -303,11 +303,11 @@ public class Client implements Runnable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns true if this client is still active and hasn't run
|
||||
* Returns <b>true</b> if this client is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
* @webref client:client
|
||||
* @webBrief Returns true if this client is still active
|
||||
* @webBrief Returns <b>true</b> if this client is still active
|
||||
* @usage application
|
||||
*/
|
||||
public boolean active() {
|
||||
@@ -389,8 +389,8 @@ public class Client implements Runnable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns -1 or 0xffff if
|
||||
* nothing is there.
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or
|
||||
* <b>0xffff</b> if nothing is there.
|
||||
*
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
@@ -422,7 +422,7 @@ public class Client implements Runnable {
|
||||
*
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @webBrief Reads everything in the buffer
|
||||
* @webBrief Reads a group of bytes from the buffer.
|
||||
*/
|
||||
public byte[] readBytes() {
|
||||
synchronized (bufferLock) {
|
||||
@@ -638,11 +638,13 @@ public class Client implements Runnable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Writes data to a server specified when constructing the client.
|
||||
* Writes data to a server specified when constructing the client, or writes
|
||||
* data to the specific client obtained from the Server <b>available()</b>
|
||||
* method.
|
||||
*
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @webBrief Writes bytes, chars, ints, bytes[], Strings
|
||||
* @webBrief Writes bytes, chars, ints, bytes[], Strings
|
||||
* @param data data to write
|
||||
*/
|
||||
public void write(int data) { // will also cover char
|
||||
|
||||
@@ -184,7 +184,7 @@ public class Server implements Runnable {
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns true if this server is still active and hasn't run
|
||||
* Returns <b>true</b> if this server is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
* @webref server:server
|
||||
|
||||
@@ -724,7 +724,6 @@ public class Serial implements SerialPortEventListener {
|
||||
/**
|
||||
* Writes bytes, chars, ints, bytes[], Strings to the serial port
|
||||
*
|
||||
* @generate Serial_write.xml
|
||||
* <h3>Advanced</h3>
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
|
||||
Reference in New Issue
Block a user