diff --git a/CVSROOT/checkoutlist b/CVSROOT/checkoutlist deleted file mode 100644 index b04b3501f..000000000 --- a/CVSROOT/checkoutlist +++ /dev/null @@ -1,13 +0,0 @@ -# The "checkoutlist" file is used to support additional version controlled -# administrative files in $CVSROOT/CVSROOT, such as template files. -# -# The first entry on a line is a filename which will be checked out from -# the corresponding RCS file in the $CVSROOT/CVSROOT directory. -# The remainder of the line is an error message to use if the file cannot -# be checked out. -# -# File format: -# -# [] -# -# comment lines begin with '#' diff --git a/CVSROOT/commitinfo b/CVSROOT/commitinfo deleted file mode 100644 index b19e7b7a6..000000000 --- a/CVSROOT/commitinfo +++ /dev/null @@ -1,15 +0,0 @@ -# The "commitinfo" file is used to control pre-commit checks. -# The filter on the right is invoked with the repository and a list -# of files to check. A non-zero exit of the filter program will -# cause the commit to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/config b/CVSROOT/config deleted file mode 100644 index ff43ec005..000000000 --- a/CVSROOT/config +++ /dev/null @@ -1,14 +0,0 @@ -# Set this to "no" if pserver shouldn't check system users/passwords -#SystemAuth=no - -# Put CVS lock files in this directory rather than directly in the repository. -#LockDir=/var/lock/cvs - -# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top -# level of the new working directory when using the `cvs checkout' -# command. -#TopLevelAdmin=no - -# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the -# history file, or a subset as needed (ie `TMAR' logs all write operations) -#LogHistory=TOFEWGCMAR diff --git a/CVSROOT/cvswrappers b/CVSROOT/cvswrappers deleted file mode 100644 index 0accaf1b1..000000000 --- a/CVSROOT/cvswrappers +++ /dev/null @@ -1,23 +0,0 @@ -# This file affects handling of files based on their names. -# -# The -t/-f options allow one to treat directories of files -# as a single file, or to transform a file in other ways on -# its way in and out of CVS. -# -# The -m option specifies whether CVS attempts to merge files. -# -# The -k option specifies keyword expansion (e.g. -kb for binary). -# -# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) -# -# wildcard [option value][option value]... -# -# where option is one of -# -f from cvs filter value: path to filter -# -t to cvs filter value: path to filter -# -m update methodology value: MERGE or COPY -# -k expansion mode value: b, o, kkv, &c -# -# and value is a single-quote delimited value. -# For example: -#*.gif -k 'b' diff --git a/CVSROOT/editinfo b/CVSROOT/editinfo deleted file mode 100644 index d78886c15..000000000 --- a/CVSROOT/editinfo +++ /dev/null @@ -1,21 +0,0 @@ -# The "editinfo" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/CVSROOT/modules b/CVSROOT/modules deleted file mode 100644 index cb9e9efc9..000000000 --- a/CVSROOT/modules +++ /dev/null @@ -1,26 +0,0 @@ -# Three different line formats are valid: -# key -a aliases... -# key [options] directory -# key [options] directory files... -# -# Where "options" are composed of: -# -i prog Run "prog" on "cvs commit" from top-level of module. -# -o prog Run "prog" on "cvs checkout" of module. -# -e prog Run "prog" on "cvs export" of module. -# -t prog Run "prog" on "cvs rtag" of module. -# -u prog Run "prog" on "cvs update" of module. -# -d dir Place module in directory "dir" instead of module name. -# -l Top-level directory only -- do not recurse. -# -# NOTE: If you change any of the "Run" options above, you'll have to -# release and re-checkout any working directories of these modules. -# -# And "directory" is a path to a directory relative to $CVSROOT. -# -# The "-a" option specifies an alias. An alias is interpreted as if -# everything on the right of the "-a" had been typed on the command line. -# -# You can encode a module within a module by using the special '&' -# character to interpose another module into the current module. This -# can be useful for creating a module that consists of many directories -# spread out over the entire source repository. diff --git a/CVSROOT/notify b/CVSROOT/notify deleted file mode 100644 index 34f0bc288..000000000 --- a/CVSROOT/notify +++ /dev/null @@ -1,12 +0,0 @@ -# The "notify" file controls where notifications from watches set by -# "cvs watch add" or "cvs edit" are sent. The first entry on a line is -# a regular expression which is tested against the directory that the -# change is being made to, relative to the $CVSROOT. If it matches, -# then the remainder of the line is a filter program that should contain -# one occurrence of %s for the user to notify, and information on its -# standard input. -# -# "ALL" or "DEFAULT" can be used in place of the regular expression. -# -# For example: -#ALL mail %s -s "CVS notification" diff --git a/CVSROOT/rcsinfo b/CVSROOT/rcsinfo deleted file mode 100644 index 49e59f4d0..000000000 --- a/CVSROOT/rcsinfo +++ /dev/null @@ -1,13 +0,0 @@ -# The "rcsinfo" file is used to control templates with which the editor -# is invoked on commit and import. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being made to, relative to the -# $CVSROOT. For the first match that is found, then the remainder of the -# line is the name of the file that contains the template. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/taginfo b/CVSROOT/taginfo deleted file mode 100644 index 274a46dd5..000000000 --- a/CVSROOT/taginfo +++ /dev/null @@ -1,20 +0,0 @@ -# The "taginfo" file is used to control pre-tag checks. -# The filter on the right is invoked with the following arguments: -# -# $1 -- tagname -# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d -# $3 -- repository -# $4-> file revision [file revision ...] -# -# A non-zero exit of the filter program will cause the tag to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/verifymsg b/CVSROOT/verifymsg deleted file mode 100644 index 86f747ce2..000000000 --- a/CVSROOT/verifymsg +++ /dev/null @@ -1,21 +0,0 @@ -# The "verifymsg" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/mobile/app/PdeCompiler.java b/mobile/app/PdeCompiler.java deleted file mode 100755 index b03ae431d..000000000 --- a/mobile/app/PdeCompiler.java +++ /dev/null @@ -1,560 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdeCompiler - default compiler class that connects to jikes - Part of the Processing project - http://processing.org - - Copyright (c) 2001-03 - Ben Fry, Massachusetts Institute of Technology and - Casey Reas, Interaction Design Institute Ivrea - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import processing.core.*; - -import java.io.*; -import java.util.*; -import java.util.zip.*; -import javax.swing.*; - -public class PdeCompiler implements PdeMessageConsumer { - static final String BUGS_URL = - "http://processing.org/bugs/"; - static final String SUPER_BADNESS = - "Compiler error, please submit this code to " + BUGS_URL; - - PdeSketch sketch; - String buildPath; - - //String buildPath; - //String className; - //File includeFolder; - PdeException exception; - //PdeEditor editor; - - /* - public PdeCompiler(String buildPath, String className, - File includeFolder, PdeEditor editor) { - this.buildPath = buildPath; - this.includeFolder = includeFolder; - this.className = className; - this.editor = editor; - } - - - public boolean compile(PrintStream leechErr) { - */ - - public PdeCompiler() { } // consider this a warning, you werkin soon. - - - public boolean compile(PdeSketch sketch, String buildPath, String bootClassPath) - throws PdeException { - - this.sketch = sketch; - this.buildPath = buildPath; - - // the pms object isn't used for anything but storage - PdeMessageStream pms = new PdeMessageStream(this); - - String baseCommand[] = new String[] { - // user.dir is folder containing P5 (and therefore jikes) - // macosx needs the extra path info. linux doesn't like it, though - // windows doesn't seem to care. write once, headache anywhere. - ((PdeBase.platform != PdeBase.MACOSX) ? "jikes" : - System.getProperty("user.dir") + File.separator + "jikes"), - - // this doesn't help much.. also java 1.4 seems to not support - // -source 1.1 for javac, and jikes seems to also have dropped it. - // for versions of jikes that don't complain, "final int" inside - // a function doesn't throw an error, so it could just be a - // ms jvm error that this sort of thing doesn't work. blech. - //"-source", - //"1.1", - - // necessary to make output classes compatible with 1.1 - // i.e. so that exported applets can work with ms jvm on the web - "-target", - PdePreferences.get("preproc.jdk_version"), //"1.1", - // let the incompatability headache begin - - // used when run without a vm ("expert" mode) - "-bootclasspath", - bootClassPath, - - // needed for macosx so that the classpath is set properly - // also for windows because qtjava will most likely be here - // and for linux, it just doesn't hurt - "-classpath", - sketch.classPath, //calcClassPath(includeFolder), - - "-nowarn", // we're not currently interested in warnings - "+E", // output errors in machine-parsable format - "-d", buildPath // output the classes in the buildPath - //buildPath + File.separator + className + ".java" // file to compile - }; - - // make list of code files that need to be compiled - // (some files are skipped if they contain no class) - String preprocNames[] = new String[sketch.codeCount]; - int preprocCount = 0; - for (int i = 0; i < sketch.codeCount; i++) { - if (sketch.code[i].preprocName != null) { - preprocNames[preprocCount++] = sketch.code[i].preprocName; - } - } - String command[] = new String[baseCommand.length + preprocCount]; - System.arraycopy(baseCommand, 0, command, 0, baseCommand.length); - // append each of the files to the command string - for (int i = 0; i < preprocCount; i++) { - command[baseCommand.length + i] = - buildPath + File.separator + preprocNames[i]; - } - - /* - String command[] = new String[baseCommand.length + sketch.codeCount]; - System.arraycopy(baseCommand, 0, command, 0, baseCommand.length); - // append each of the files to the command string - for (int i = 0; i < sketch.codeCount; i++) { - command[baseCommand.length + i] = - buildPath + File.separator + sketch.code[i].preprocName; - } - */ - - //for (int i = 0; i < command.length; i++) { - //System.out.println("cmd " + i + ": " + command[i]); - //} - - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - - int result = 0; // pre-initialized to quiet a bogus warning from jikes - try { - // execute the compiler, and create threads to deal - // with the input and error streams - // - Process process = Runtime.getRuntime().exec(command); - - PdeMessageSiphon errSiphon = new PdeMessageSiphon(process.getErrorStream(), this); - PdeMessageSiphon inSiphon = new PdeMessageSiphon(process.getInputStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean compiling = true; - while (compiling) { - try { - result = process.waitFor(); - //System.out.println("result is " + result); - compiling = false; - } catch (InterruptedException ignored) { - } - } - - } catch (Exception e) { - String msg = e.getMessage(); - if ((msg != null) && (msg.indexOf("jikes: not found") != -1)) { - //System.err.println("jikes is missing"); - PdeBase.showWarning("Compiler error", - "Could not find the compiler.\n" + - "jikes is missing from your PATH,\n" + - "see readme.txt for help.", null); - return false; - - } else { - e.printStackTrace(); - result = -1; - } - } - - // an error was queued up by message(), barf this back to build() - // which will barf it back to PdeEditor. if you're having trouble - // discerning the imagery, consider how cows regurgitate their food - // to digest it, and the fact that they have five stomaches. - // - //System.out.println("throwing up " + exception); - if (exception != null) throw exception; - - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (result != 0 && result != 1 ) { - //exception = new PdeException(SUPER_BADNESS); - //editor.error(exception); // this will instead be thrown - PdeBase.openURL(BUGS_URL); - throw new PdeException(SUPER_BADNESS); - } - - // success would mean that 'result' is set to zero - return (result == 0); // ? true : false; - } - - - boolean firstErrorFound; - boolean secondErrorFound; - - /** - * Part of the PdeMessageConsumer interface, this is called - * whenever a piece (usually a line) of error message is spewed - * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to PdeEditor. - */ - public void message(String s) { - // This receives messages as full lines, so a newline needs - // to be added as they're printed to the console. - System.err.println(s); - - // ignore cautions - if (s.indexOf("Caution") != -1) return; - - // jikes always uses a forward slash character as its separator, - // so replace any platform-specific separator characters before - // attemping to compare - // - String buildPathSubst = buildPath.replace(File.separatorChar, '/') + "/"; - - String partialTempPath = null; - int partialStartIndex = -1; //s.indexOf(partialTempPath); - int fileIndex = -1; // use this to build a better exception - - // iterate through the project files to see who's causing the trouble - for (int i = 0; i < sketch.codeCount; i++) { - if (sketch.code[i].preprocName == null) continue; - - partialTempPath = buildPathSubst + sketch.code[i].preprocName; - partialStartIndex = s.indexOf(partialTempPath); - if (partialStartIndex != -1) { - fileIndex = i; - //System.out.println("fileIndex is " + fileIndex); - break; - } - } - //+ className + ".java"; - - // if the partial temp path appears in the error message... - // - //int partialStartIndex = s.indexOf(partialTempPath); - if (partialStartIndex != -1) { - - // skip past the path and parse the int after the first colon - // - String s1 = s.substring(partialStartIndex + - partialTempPath.length() + 1); - int colon = s1.indexOf(':'); - int lineNumber = Integer.parseInt(s1.substring(0, colon)); - //System.out.println("pde / line number: " + lineNumber); - - if (fileIndex == 0) { // main class, figure out which tab - for (int i = 1; i < sketch.codeCount; i++) { - if (sketch.code[i].flavor == PdeSketch.PDE) { - if (sketch.code[i].lineOffset < lineNumber) { - fileIndex = i; - //System.out.println("i'm thinkin file " + i); - } - } - } - if (fileIndex != 0) { // if found another culprit - lineNumber -= sketch.code[fileIndex].lineOffset; - //System.out.println("i'm sayin line " + lineNumber); - } - } - - //String s2 = s1.substring(colon + 2); - int err = s1.indexOf("Error:"); - if (err != -1) { - - // if the first error has already been found, then this must be - // (at least) the second error found - if (firstErrorFound) { - secondErrorFound = true; - return; - } - - // if executing at this point, this is *at least* the first error - firstErrorFound = true; - - //err += "error:".length(); - String description = s1.substring(err + "Error:".length()); - description = description.trim(); - - String hasLoop = "The method \"void loop();\" with default access"; - if (description.indexOf(hasLoop) != -1) { - description = - "Rename loop() to draw() in Processing 0070 and higher"; - } - - String constructorProblem = - "No applicable overload was found for a constructor of type"; - if (description.indexOf(constructorProblem) != -1) { - //"simong.particles.ParticleSystem". Perhaps you wanted the overloaded version "ParticleSystem();" instead? - int nextSentence = description.indexOf("\".") + 3; - description = description.substring(nextSentence); - } - - String overloadProblem = "No applicable overload"; - if (description.indexOf(overloadProblem) != -1) { - int nextSentence = description.indexOf("\".") + 3; - description = description.substring(nextSentence); - } - - // c:/fry/processing/build/windows/work/lib/build/Temporary_6858_2476.java:1:34:1:41: Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs setup. Package "poo/shoe" could not be found in: - String classpathProblem = "You need to modify your classpath"; - if (description.indexOf(classpathProblem) != -1) { - if (description.indexOf("quicktime/std") != -1) { - // special case for the quicktime libraries - description = - "To run sketches that use the Processing video library, " + - "you must first install QuickTime for Java."; - - } else { - int nextSentence = description.indexOf(". Package") + 2; - description = - description.substring(nextSentence, description.indexOf(':')) + - " the code folder or in any libraries."; - } - } - - if (description.indexOf("Type java.io.Serializable was not found.") != -1) { - return; - } - if (description.indexOf("Type java.lang.Cloneable was not found.") != -1) { - return; - } - - //System.out.println("description = " + description); - //System.out.println("creating exception " + exception); - exception = new PdeException(description, fileIndex, lineNumber-1, -1); - - // NOTE!! major change here, this exception will be queued - // here to be thrown by the compile() function - //editor.error(exception); - - } else { - System.err.println("i suck: " + s); - } - - } else { - // this isn't the start of an error line, so don't attempt to parse - // a line number out of it. - - // if the second error hasn't been discovered yet, these lines - // are probably associated with the first error message, - // which is already in the status bar, and are likely to be - // of interest to the user, so spit them to the console. - // - if (!secondErrorFound) { - System.err.println(s); - } - } - } - - - static String bootClassPath; - - static public String calcBootClassPath() { - if (bootClassPath == null) { - String additional = ""; - if (PdeBase.platform == PdeBase.MACOSX) { - additional = - contentsToClassPath(new File("/System/Library/Java/Extensions/")); - } - bootClassPath = System.getProperty("sun.boot.class.path") + additional; - } - return bootClassPath; - } - - - /// - - - /** - * Return the path for a folder, with appended paths to - * any .jar or .zip files inside that folder. - * This will prepend a colon (or whatever the path separator is) - * so that it can be directly appended to another path string. - * - * This will always add the root folder as well, and doesn't bother - * checking to see if there are any .class files in the folder or - * within a subfolder. - */ - static public String contentsToClassPath(File folder) { - if (folder == null) return ""; - - StringBuffer abuffer = new StringBuffer(); - String sep = System.getProperty("path.separator"); - - try { - // add the folder itself in case any unzipped files - String path = folder.getCanonicalPath(); - abuffer.append(sep); - abuffer.append(path); - - if (!path.endsWith(File.separator)) { - path += File.separator; - } - //System.out.println("path is " + path); - - String list[] = folder.list(); - for (int i = 0; i < list.length; i++) { - if (list[i].toLowerCase().endsWith(".jar") || - list[i].toLowerCase().endsWith(".zip")) { - abuffer.append(sep); - abuffer.append(path); - abuffer.append(list[i]); - } - } - } catch (IOException e) { - e.printStackTrace(); // this would be odd - } - //System.out.println("included path is " + abuffer.toString()); - //packageListFromClassPath(abuffer.toString()); // WHY? - return abuffer.toString(); - } - - - /** - * A classpath, separated by the path separator, will contain - * a series of .jar/.zip files or directories containing .class - * files, or containing subdirectories that have .class files. - * - * @param path the input classpath - * @return array of possible package names - */ - static public String[] packageListFromClassPath(String path) { - Hashtable table = new Hashtable(); - String pieces[] = - PApplet.split(path, File.pathSeparatorChar); - - for (int i = 0; i < pieces.length; i++) { - //System.out.println("checking piece '" + pieces[i] + "'"); - if (pieces[i].length() == 0) continue; - - if (pieces[i].toLowerCase().endsWith(".jar") || - pieces[i].toLowerCase().endsWith(".zip")) { - packageListFromZip(pieces[i], table); - - } else { // it's another type of file or directory - File dir = new File(pieces[i]); - if (dir.exists() && dir.isDirectory()) { - packageListFromFolder(dir, null, table); - //importCount = magicImportsRecursive(dir, null, - // table); - //imports, importCount); - } - } - } - int tableCount = table.size(); - String output[] = new String[tableCount]; - int index = 0; - Enumeration e = table.keys(); - while (e.hasMoreElements()) { - output[index++] = ((String) e.nextElement()).replace('/', '.'); - } - //System.arraycopy(imports, 0, output, 0, importCount); - return output; - } - - - static private void packageListFromZip(String filename, Hashtable table) { - try { - ZipFile file = new ZipFile(filename); - Enumeration entries = file.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = (ZipEntry) entries.nextElement(); - - if (!entry.isDirectory()) { - String name = entry.getName(); - - if (name.endsWith(".class")) { - int slash = name.lastIndexOf('/'); - if (slash == -1) continue; - - String pname = name.substring(0, slash); - if (table.get(pname) == null) { - table.put(pname, new Object()); - } - } - } - } - } catch (IOException e) { - System.err.println("Ignoring " + filename + " (" + e.getMessage() + ")"); - //e.printStackTrace(); - } - } - - - /** - * Make list of package names by traversing a directory hierarchy. - * Each time a class is found in a folder, add its containing set - * of folders to the package list. If another folder is found, - * walk down into that folder and continue. - */ - static private void packageListFromFolder(File dir, String sofar, - Hashtable table) { - //String imports[], - //int importCount) { - //System.err.println("checking dir '" + dir + "'"); - boolean foundClass = false; - String files[] = dir.list(); - - for (int i = 0; i < files.length; i++) { - if (files[i].equals(".") || files[i].equals("..")) continue; - - File sub = new File(dir, files[i]); - if (sub.isDirectory()) { - String nowfar = - (sofar == null) ? files[i] : (sofar + "." + files[i]); - packageListFromFolder(sub, nowfar, table); - //System.out.println(nowfar); - //imports[importCount++] = nowfar; - //importCount = magicImportsRecursive(sub, nowfar, - // imports, importCount); - } else if (!foundClass) { // if no classes found in this folder yet - if (files[i].endsWith(".class")) { - //System.out.println("unique class: " + files[i] + " for " + sofar); - table.put(sofar, new Object()); - foundClass = true; - } - } - } - //return importCount; - } - - /* - static public int magicImportsRecursive(File dir, String sofar, - Hashtable table) { - //String imports[], - //int importCount) { - System.err.println("checking dir '" + dir + "'"); - String files[] = dir.list(); - for (int i = 0; i < files.length; i++) { - if (files[i].equals(".") || files[i].equals("..")) continue; - - File sub = new File(dir, files[i]); - if (sub.isDirectory()) { - String nowfar = (sofar == null) ? - files[i] : (sofar + "." + files[i]); - //System.out.println(nowfar); - imports[importCount++] = nowfar; - - importCount = magicImportsRecursive(sub, nowfar, - imports, importCount); - } - } - return importCount; - } - */ -} diff --git a/mobile/app/PdeEditor.java b/mobile/app/PdeEditor.java deleted file mode 100755 index 1ffbab006..000000000 --- a/mobile/app/PdeEditor.java +++ /dev/null @@ -1,1862 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdeEditor - main editor panel for the processing development environment - Part of the Processing project - http://processing.org - - Except where noted, code is written by Ben Fry and - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; -import java.util.zip.*; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.undo.*; - -import com.oroinc.text.regex.*; - -import com.apple.mrj.*; - - -public class PdeEditor extends JFrame -implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler -{ - // yeah - static final String WINDOW_TITLE = "Processing Mobile"; - - // p5 icon for the window - Image icon; - - // otherwise, if the window is resized with the message label - // set to blank, it's preferredSize() will be fukered - static final String EMPTY = - " " + - " " + - " "; - - static final int HANDLE_NEW = 1; - static final int HANDLE_OPEN = 2; - static final int HANDLE_QUIT = 3; - int checkModifiedMode; - String handleOpenPath; - boolean handleNewShift; - boolean handleNewLibrary; - //String handleSaveAsPath; - //String openingName; - - PdeEditorButtons buttons; - PdeEditorHeader header; - PdeEditorStatus status; - PdeEditorConsole console; - - JSplitPane splitPane; - JPanel consolePanel; - - // currently opened program - public PdeSketch sketch; - - public JEditTextArea textarea; - PdeEditorListener listener; - - // runtime information and window placement - Point appletLocation; - Point presentLocation; - Window presentationWindow; - RunButtonWatcher watcher; - PdeRuntime runtime; - - //boolean externalRuntime; - //String externalPaths; - //File externalCode; - - JMenuItem exportAppItem; - JMenuItem saveMenuItem; - JMenuItem saveAsMenuItem; - //JMenuItem beautifyMenuItem; - - // - - boolean running; - boolean presenting; - - // undo fellers - JMenuItem undoItem, redoItem; - protected UndoAction undoAction; - protected RedoAction redoAction; - static public UndoManager undo = new UndoManager(); // editor needs this guy - - // - - //PdeHistory history; // TODO re-enable history - PdeSketchbook sketchbook; - PdePreferences preferences; - PdeEditorFind find; - - //static Properties keywords; // keyword -> reference html lookup - - - public PdeEditor() { - super(WINDOW_TITLE + " - " + PdeBase.VERSION); - // this is needed by just about everything else - preferences = new PdePreferences(); - - // #@$*(@#$ apple.. always gotta think different - MRJApplicationUtils.registerAboutHandler(this); - MRJApplicationUtils.registerPrefsHandler(this); - MRJApplicationUtils.registerQuitHandler(this); - - // set the window icon - try { - icon = PdeBase.getImage("icon.gif", this); - setIconImage(icon); - } catch (Exception e) { } // fail silently, no big whup - - - // add listener to handle window close box hit event - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - handleQuit(); - } - }); - - PdeKeywords keywords = new PdeKeywords(); - // TODO re-enable history - //history = new PdeHistory(this); - sketchbook = new PdeSketchbook(this); - - JMenuBar menubar = new JMenuBar(); - menubar.add(buildFileMenu()); - menubar.add(buildEditMenu()); - menubar.add(buildSketchMenu()); - menubar.add(buildToolsMenu()); - // what platform has their help menu way on the right? - //if ((PdeBase.platform == PdeBase.WINDOWS) || - //menubar.add(Box.createHorizontalGlue()); - menubar.add(buildHelpMenu()); - - setJMenuBar(menubar); - - // doesn't matter when this is created, just make it happen at some point - find = new PdeEditorFind(PdeEditor.this); - - Container pain = getContentPane(); - pain.setLayout(new BorderLayout()); - - buttons = new PdeEditorButtons(this); - pain.add("West", buttons); - - JPanel rightPanel = new JPanel(); - rightPanel.setLayout(new BorderLayout()); - - header = new PdeEditorHeader(this); - rightPanel.add(header, BorderLayout.NORTH); - - textarea = new JEditTextArea(new PdeTextAreaDefaults()); - textarea.setRightClickPopup(new TextAreaPopup()); - textarea.setTokenMarker(new PdeKeywords()); - - textarea.setHorizontalOffset(5); - //textarea.setBorder(new EmptyBorder(0, 20, 0, 0)); - //textarea.setBackground(Color.white); - - // assemble console panel, consisting of status area and the console itself - consolePanel = new JPanel(); - //System.out.println(consolePanel.getInsets()); - consolePanel.setLayout(new BorderLayout()); - - status = new PdeEditorStatus(this); - consolePanel.add(status, BorderLayout.NORTH); - - console = new PdeEditorConsole(this); - consolePanel.add(console, BorderLayout.CENTER); - - splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, - textarea, consolePanel); - - splitPane.setOneTouchExpandable(true); - // repaint child panes while resizing - splitPane.setContinuousLayout(true); - // if window increases in size, give all of increase to textarea (top pane) - splitPane.setResizeWeight(1D); - - // to fix ugliness.. normally macosx java 1.3 puts an - // ugly white border around this object, so turn it off. - if (PdeBase.platform == PdeBase.MACOSX) { - splitPane.setBorder(null); - } - - // the default size on windows is too small and kinda ugly - int dividerSize = PdePreferences.getInteger("editor.divider.size"); - if (dividerSize != 0) { - splitPane.setDividerSize(dividerSize); - } - - rightPanel.add(splitPane, BorderLayout.CENTER); - - pain.add("Center", rightPanel); - - // hopefully these are no longer needed w/ swing - // (har har har.. that was wishful thinking) - listener = new PdeEditorListener(this, textarea); - textarea.pdeEditorListener = listener; - - // set the undo stuff for this feller - Document document = textarea.getDocument(); - document.addUndoableEditListener(new PdeUndoableEditListener()); - - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - if ((PdeBase.platform == PdeBase.MACOSX) || - (PdeBase.platform == PdeBase.MACOS9)) { - presentationWindow = new Frame(); - - // mrj is still (with version 2.2.x) a piece of shit, - // and doesn't return valid insets for frames - //presentationWindow.pack(); // make a peer so insets are valid - //Insets insets = presentationWindow.getInsets(); - // the extra +20 is because the resize boxes intrude - Insets insets = new Insets(21, 5, 5 + 20, 5); - - presentationWindow.setBounds(-insets.left, -insets.top, - screen.width + insets.left + insets.right, - screen.height + insets.top + insets.bottom); - } else { - presentationWindow = new Frame(); - //((Frame)presentationWindow).setUndecorated(true); - try { - Method undecoratedMethod = - Frame.class.getMethod("setUndecorated", - new Class[] { Boolean.TYPE }); - undecoratedMethod.invoke(presentationWindow, - new Object[] { Boolean.TRUE }); - } catch (Exception e) { } - //} catch (NoSuchMethodException e) { } - //} catch (NoSuchMethodError e) { } - - presentationWindow.setBounds(0, 0, screen.width, screen.height); - } - - Label label = new Label("stop"); - label.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - setVisible(true); - doClose(); - }}); - - Dimension labelSize = new Dimension(60, 20); - presentationWindow.setLayout(null); - presentationWindow.add(label); - label.setBounds(5, screen.height - 5 - labelSize.height, - labelSize.width, labelSize.height); - - Color presentationBgColor = - PdePreferences.getColor("run.present.bgcolor"); - presentationWindow.setBackground(presentationBgColor); - - textarea.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - if (presenting == true) { - try { - presentationWindow.toFront(); - runtime.applet.requestFocus(); - } catch (Exception ex) { } - } - } - }); - - this.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - if (presenting == true) { - try { - presentationWindow.toFront(); - runtime.applet.requestFocus(); - } catch (Exception ex) { } - } - } - }); - - // moved from the PdeRuntime window to the main presentation window - // [toxi 030903] - presentationWindow.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - //System.out.println("window got " + e); - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - runtime.stop(); - doClose(); - } else { - // pass on the event to the applet [toxi 030903] - runtime.applet.keyPressed(e); - } - } - }); - } - - - /** - * Hack for #@#)$(* Mac OS X. - */ - public Dimension getMinimumSize() { - return new Dimension(500, 500); - } - - - // ................................................................... - - - /** - * Post-constructor setup for the editor area. Loads the last - * sketch that was used (if any), and restores other Editor settings. - * The complement to "storePreferences", this is called when the - * application is first launched. - */ - public void restorePreferences() { - // figure out window placement - - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - boolean windowPositionInvalid = false; - - if (PdePreferences.get("last.screen.height") != null) { - // if screen size has changed, the window coordinates no longer - // make sense, so don't use them unless they're identical - int screenW = PdePreferences.getInteger("last.screen.width"); - int screenH = PdePreferences.getInteger("last.screen.height"); - - if ((screen.width != screenW) || (screen.height != screenH)) { - windowPositionInvalid = true; - } - } else { - windowPositionInvalid = true; - } - - if (windowPositionInvalid) { - //System.out.println("using default size"); - int windowH = PdePreferences.getInteger("default.window.height"); - int windowW = PdePreferences.getInteger("default.window.width"); - setBounds((screen.width - windowW) / 2, - (screen.height - windowH) / 2, - windowW, windowH); - // this will be invalid as well, so grab the new value - PdePreferences.setInteger("last.divider.location", - splitPane.getDividerLocation()); - } else { - setBounds(PdePreferences.getInteger("last.window.x"), - PdePreferences.getInteger("last.window.y"), - PdePreferences.getInteger("last.window.width"), - PdePreferences.getInteger("last.window.height")); - } - - - // last sketch that was in use - - //String sketchName = PdePreferences.get("last.sketch.name"); - String sketchPath = PdePreferences.get("last.sketch.path"); - //PdeSketch sketchTemp = new PdeSketch(sketchPath); - - if ((sketchPath != null) && (new File(sketchPath)).exists()) { - // don't check modified because nothing is open yet - handleOpen2(sketchPath); - - } else { - handleNew2(true); - } - - - // location for the console/editor area divider - - int location = PdePreferences.getInteger("last.divider.location"); - splitPane.setDividerLocation(location); - - - // read the preferences that are settable in the preferences window - - applyPreferences(); - } - - - /** - * Read and apply new values from the preferences, either because - * the app is just starting up, or the user just finished messing - * with things in the Preferences window. - */ - public void applyPreferences() { - - // apply the setting for 'use external editor' - boolean external = PdePreferences.getBoolean("editor.external"); - - textarea.setEditable(!external); - saveMenuItem.setEnabled(!external); - saveAsMenuItem.setEnabled(!external); - //beautifyMenuItem.setEnabled(!external); - - TextAreaPainter painter = textarea.getPainter(); - if (external) { - // disable line highlight and turn off the caret when disabling - Color color = PdePreferences.getColor("editor.external.bgcolor"); - painter.setBackground(color); - painter.lineHighlight = false; - textarea.setCaretVisible(false); - - } else { - Color color = PdePreferences.getColor("editor.bgcolor"); - painter.setBackground(color); - painter.lineHighlight = - PdePreferences.getBoolean("editor.linehighlight"); - textarea.setCaretVisible(true); - } - - // in case tab expansion stuff has changed - listener.applyPreferences(); - - // in case moved to a new location - sketchbook.rebuildMenus(); - } - - - /** - * Store preferences about the editor's current state. - * Called when the application is quitting. - */ - public void storePreferences() { - //System.out.println("storing preferences"); - - // window location information - Rectangle bounds = getBounds(); - PdePreferences.setInteger("last.window.x", bounds.x); - PdePreferences.setInteger("last.window.y", bounds.y); - PdePreferences.setInteger("last.window.width", bounds.width); - PdePreferences.setInteger("last.window.height", bounds.height); - - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - PdePreferences.setInteger("last.screen.width", screen.width); - PdePreferences.setInteger("last.screen.height", screen.height); - - // last sketch that was in use - //PdePreferences.set("last.sketch.name", sketchName); - //PdePreferences.set("last.sketch.name", sketch.name); - PdePreferences.set("last.sketch.path", sketch.getMainFilePath()); - - // location for the console/editor area divider - int location = splitPane.getDividerLocation(); - PdePreferences.setInteger("last.divider.location", location); - } - - - // ................................................................... - - - protected JMenu buildFileMenu() { - JMenuItem item; - JMenu menu = new JMenu("File"); - - if (!PdePreferences.getBoolean("export.library")) { - item = newJMenuItem("New", 'N'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleNew(false); - } - }); - menu.add(item); - - } else { - item = newJMenuItem("New Sketch", 'N'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleNew(false); - } - }); - menu.add(item); - - item = new JMenuItem("New Library"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleNewLibrary(); - } - }); - menu.add(item); - } - - /* - item = newJMenuItem("New code", 'N', true); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleNewCode(); - } - }); - menu.add(item); - */ - - /* - item = newJMenuItem("Open", 'O'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleOpen(null); - } - }); - menu.add(item); - menu.add(sketchbook.rebuildMenu()); - menu.add(sketchbook.getExamplesMenu()); - */ - menu.add(sketchbook.getOpenMenu()); - - saveMenuItem = newJMenuItem("Save", 'S'); - saveMenuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleSave(); - } - }); - menu.add(saveMenuItem); - - saveAsMenuItem = newJMenuItem("Save As...", 'S', true); - saveAsMenuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleSaveAs(); - } - }); - menu.add(saveAsMenuItem); - -//// mobile: removing standard export/export-app features for now. may -//// bring them back later so that MIDlets can be demoed on web pages. -/* - item = newJMenuItem("Export", 'E'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleExport(); - } - }); - menu.add(item); - - exportAppItem = newJMenuItem("Export Application", 'E', true); - exportAppItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleExportApp(); - } - }); - menu.add(exportAppItem); - */ -//// mobile: export MIDlet menu option - item = newJMenuItem("Export MIDlet", 'E', true); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleExportMIDlet(); - } - }); - menu.add(item); - - menu.addSeparator(); - - item = newJMenuItem("Page Setup", 'P', true); - item.setEnabled(false); - menu.add(item); - - item = newJMenuItem("Print", 'P'); - item.setEnabled(false); - menu.add(item); - - // macosx already has its own preferences and quit menu - if (PdeBase.platform != PdeBase.MACOSX) { - menu.addSeparator(); - - item = new JMenuItem("Preferences"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handlePrefs(); - } - }); - menu.add(item); - - menu.addSeparator(); - - item = newJMenuItem("Quit", 'Q'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleQuit(); - } - }); - menu.add(item); - } - return menu; - } - - - protected JMenu buildSketchMenu() { - JMenuItem item; - JMenu menu = new JMenu("Sketch"); - -//// mobile: removing standard run/present menus -/* - item = newJMenuItem("Run", 'R'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleRun(false); - } - }); - menu.add(item); - - item = newJMenuItem("Present", 'R', true); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleRun(true); - } - }); - menu.add(item); -*/ -//// mobile: run MIDlet in emulator - item = newJMenuItem("Run in Emulator", 'R'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleRunEmulator(); - } - }); - menu.add(item); - - //menu.add(newJMenuItem("Stop", 'T')); - menu.add(new JMenuItem("Stop")); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleStop(); - } - }); - menu.addSeparator(); - - // - - item = new JMenuItem("Add File..."); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - sketch.addFile(); - } - }); - menu.add(item); - - menu.add(sketchbook.getImportMenu()); - - if ((PdeBase.platform == PdeBase.WINDOWS) || - (PdeBase.platform == PdeBase.MACOSX)) { - // no way to do an 'open in file browser' on other platforms - // since there isn't any sort of standard - item = new JMenuItem("Show Sketch Folder"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - //PdeBase.openFolder(sketchDir); - PdeBase.openFolder(sketch.folder); - } - }); - menu.add(item); - } - - // TODO re-enable history - //history.attachMenu(menu); - return menu; - } - - - protected JMenu buildToolsMenu() { - JMenuItem item; - JMenu menu = new JMenu("Tools"); - - item = new JMenuItem("Auto Format"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleBeautify(); - } - }); - menu.add(item); - - item = new JMenuItem("Create Font..."); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - new PdeFontBuilder().show(sketch.dataFolder); - } - }); - menu.add(item); - - item = new JMenuItem("Archive Sketch"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - //new PdeFontBuilder().show(sketch.dataFolder); - Archiver archiver = new Archiver(); - archiver.setup(PdeEditor.this); - archiver.show(); - } - }); - menu.add(item); - - return menu; - } - - - protected JMenu buildHelpMenu() { - JMenu menu = new JMenu("Help"); - JMenuItem item; - - item = new JMenuItem("Environment"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - PdeBase.openURL(System.getProperty("user.dir") + File.separator + - "reference" + File.separator + "environment" + - File.separator + "index.html"); - } - }); - menu.add(item); - - item = new JMenuItem("Reference"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - PdeBase.openURL(System.getProperty("user.dir") + File.separator + - "reference" + File.separator + "index.html"); - } - }); - menu.add(item); - - item = newJMenuItem("Find in Reference", 'F', true); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (textarea.isSelectionActive()) { - String text = textarea.getSelectedText(); - if (text.length() == 0) { - message("First select a word to find in the reference."); - - } else { - String referenceFile = PdeKeywords.getReference(text); - if (referenceFile == null) { - message("No reference available for \"" + text + "\""); - } else { - PdeBase.showReference(referenceFile); - } - } - } - } - }); - menu.add(item); - - item = newJMenuItem("Visit Processing.org", '5'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - PdeBase.openURL("http://processing.org/"); - } - }); - menu.add(item); - - // macosx already has its own about menu - if (PdeBase.platform != PdeBase.MACOSX) { - menu.addSeparator(); - item = new JMenuItem("About Processing"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleAbout(); - } - }); - menu.add(item); - } - - return menu; - } - - - public JMenu buildEditMenu() { - JMenu menu = new JMenu("Edit"); - JMenuItem item; - - undoItem = newJMenuItem("Undo", 'Z'); - undoItem.addActionListener(undoAction = new UndoAction()); - menu.add(undoItem); - - redoItem = newJMenuItem("Redo", 'Y'); - redoItem.addActionListener(redoAction = new RedoAction()); - menu.add(redoItem); - - menu.addSeparator(); - - // TODO "cut" and "copy" should really only be enabled - // if some text is currently selected - item = newJMenuItem("Cut", 'X'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.cut(); - sketch.setModified(); - } - }); - menu.add(item); - - item = newJMenuItem("Copy", 'C'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.copy(); - } - }); - menu.add(item); - - item = newJMenuItem("Paste", 'V'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.paste(); - sketch.setModified(); - } - }); - menu.add(item); - - item = newJMenuItem("Select All", 'A'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.selectAll(); - } - }); - menu.add(item); - - menu.addSeparator(); - - item = newJMenuItem("Find...", 'F'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - find.show(); - } - }); - menu.add(item); - - item = newJMenuItem("Find Next", 'G'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - // TODO find next should only be enabled after a - // search has actually taken place - find.find(true); - } - }); - menu.add(item); - - return menu; - } - - - /** - * Convenience method for the antidote to overthought - * swing api mess for setting accelerators. - */ - static public JMenuItem newJMenuItem(String title, int what) { - return newJMenuItem(title, what, false); - } - - - /** - * A software engineer, somewhere, needs to have his abstraction - * taken away. I hear they jail people in third world countries for - * writing the sort of crappy api that would require a four line - * helpher function to *set the command key* for a menu item. - */ - static public JMenuItem newJMenuItem(String title, - int what, boolean shift) { - JMenuItem menuItem = new JMenuItem(title); - int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - if (shift) modifiers |= ActionEvent.SHIFT_MASK; - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); - return menuItem; - } - - - // ................................................................... - - - // This one listens for edits that can be undone. - protected class PdeUndoableEditListener implements UndoableEditListener { - public void undoableEditHappened(UndoableEditEvent e) { - // Remember the edit and update the menus. - undo.addEdit(e.getEdit()); - undoAction.updateUndoState(); - redoAction.updateRedoState(); - } - } - - - class UndoAction extends AbstractAction { - public UndoAction() { - super("Undo"); - this.setEnabled(false); - } - - public void actionPerformed(ActionEvent e) { - try { - undo.undo(); - } catch (CannotUndoException ex) { - //System.out.println("Unable to undo: " + ex); - //ex.printStackTrace(); - } - updateUndoState(); - redoAction.updateRedoState(); - } - - protected void updateUndoState() { - if (undo.canUndo()) { - this.setEnabled(true); - undoItem.setEnabled(true); - putValue(Action.NAME, undo.getUndoPresentationName()); - } else { - this.setEnabled(false); - undoItem.setEnabled(false); - putValue(Action.NAME, "Undo"); - } - } - } - - - class RedoAction extends AbstractAction { - public RedoAction() { - super("Redo"); - this.setEnabled(false); - } - - public void actionPerformed(ActionEvent e) { - try { - undo.redo(); - } catch (CannotRedoException ex) { - //System.out.println("Unable to redo: " + ex); - //ex.printStackTrace(); - } - updateRedoState(); - undoAction.updateUndoState(); - } - - protected void updateRedoState() { - if (undo.canRedo()) { - this.setEnabled(true); - redoItem.setEnabled(true); - putValue(Action.NAME, undo.getRedoPresentationName()); - } else { - this.setEnabled(false); - redoItem.setEnabled(false); - putValue(Action.NAME, "Redo"); - } - } - } - - - // ................................................................... - - - // interfaces for MRJ Handlers, but naming is fine - // so used internally for everything else - - public void handleAbout() { - //System.out.println("the about box will now be shown"); - final Image image = PdeBase.getImage("about.jpg", this); - int w = image.getWidth(this); - int h = image.getHeight(this); - final Window window = new Window(this) { - public void paint(Graphics g) { - g.drawImage(image, 0, 0, null); - - /* - // does nothing.. - Graphics2D g2 = (Graphics2D) g; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_OFF); - */ - - g.setFont(new Font("SansSerif", Font.PLAIN, 11)); - g.setColor(Color.white); - g.drawString(PdeBase.VERSION, 50, 30); - } - }; - window.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - window.dispose(); - } - }); - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - window.setBounds((screen.width-w)/2, (screen.height-h)/2, w, h); - window.show(); - } - - - /** - * Show the (already created on app init) preferences window. - */ - public void handlePrefs() { - // since this can't actually block, it'll hide - // the editor window while the prefs are open - preferences.showFrame(this); - // and then call applyPreferences if 'ok' is hit - // and then unhide - - // may need to rebuild sketch and other menus - //applyPreferences(); - - // next have editor do its thing - //editor.appyPreferences(); - } - - - // ................................................................... - - - /** - * Get the contents of the current buffer. Used by the PdeSketch class. - */ - public String getText() { - return textarea.getText(); - } - - - /** - * Called by PdeEditorHeader when the tab is changed - * (or a new set of files are opened). - * @param discardUndo true if undo info to this point should be ignored - */ - public void setText(String what, boolean discardUndo) { - textarea.setText(what); - - if (discardUndo) undo.discardAllEdits(); - - textarea.select(0, 0); // move to the beginning of the document - textarea.requestFocus(); // get the caret blinking - } - - - public void handleRun(boolean present) { - doClose(); - running = true; - buttons.run(); - - // do this for the terminal window / dos prompt / etc - for (int i = 0; i < 10; i++) System.out.println(); - - // clear the console on each run, unless the user doesn't want to - //if (PdeBase.getBoolean("console.auto_clear", true)) { - //if (PdePreferences.getBoolean("console.auto_clear", true)) { - if (PdePreferences.getBoolean("console.auto_clear")) { - console.clear(); - } - - presenting = present; - if (presenting) { - // wipe everything out with a bulbous screen-covering window - presentationWindow.show(); - presentationWindow.toFront(); - } - - try { - if (!sketch.handleRun()) return; - - runtime = new PdeRuntime(sketch, this); - runtime.start(presenting ? presentLocation : appletLocation); - watcher = new RunButtonWatcher(); - - } catch (PdeException e) { - error(e); - - } catch (Exception e) { - e.printStackTrace(); - } - //sketch.cleanup(); // where does this go? - } - - class RunButtonWatcher implements Runnable { - Thread thread; - - public RunButtonWatcher() { - thread = new Thread(this, "run button watcher"); - thread.setPriority(Thread.MIN_PRIORITY); - thread.start(); - } - - public void run() { - while (Thread.currentThread() == thread) { - if (runtime == null) { - stop(); - - } else { - if (runtime.applet != null) { - if (runtime.applet.finished) { - stop(); - } - //buttons.running(!runtime.applet.finished); - - } else if (runtime.process != null) { - //buttons.running(true); // ?? - try { - runtime.process.waitFor(); - stop(); - } catch (InterruptedException ie) { - - } - } else { - stop(); - } - } - try { - Thread.sleep(250); - } catch (InterruptedException e) { } - //System.out.println("still inside runner thread"); - } - } - - public void stop() { - buttons.running(false); - thread = null; - } - } - - - public void handleStop() { // called by menu or buttons - if (presenting) { - doClose(); - } else { - doStop(); - } - } - - - /** - * Stop the applet but don't kill its window. - */ - public void doStop() { - if (runtime != null) runtime.stop(); - if (watcher != null) watcher.stop(); - message(EMPTY); - - // the buttons are sometimes still null during the constructor - // is this still true? are people still hitting this error? - /*if (buttons != null)*/ buttons.clear(); - - running = false; - } - - - /** - * Stop the applet and kill its window. When running in presentation - * mode, this will always be called instead of doStop(). - */ - public void doClose() { - if (presenting) { - presentationWindow.hide(); - - } else { - try { - // the window will also be null the process was running - // externally. so don't even try setting if window is null - // since PdeRuntime will set the appletLocation when an - // external process is in use. - if (runtime.window != null) { - appletLocation = runtime.window.getLocation(); - } - } catch (NullPointerException e) { } - } - - //if (running) doStop(); - doStop(); // need to stop if runtime error - - try { - if (runtime != null) { - runtime.close(); // kills the window - runtime = null; // will this help? - } - } catch (Exception e) { } - //buttons.clear(); // done by doStop - - sketch.cleanup(); - - // [toxi 030903] - // focus the PDE again after quitting presentation mode - toFront(); - } - - - /** - * Check to see if there have been changes. If so, prompt user - * whether or not to save first. If the user cancels, just ignore. - * Otherwise, one of the other methods will handle calling - * checkModified2() which will get on with business. - */ - protected void checkModified(int checkModifiedMode) { - this.checkModifiedMode = checkModifiedMode; - - if (!sketch.modified) { - checkModified2(); - return; - } - - String prompt = "Save changes to " + sketch.name + "? "; - - if (checkModifiedMode != HANDLE_QUIT) { - // if the user is not quitting, then use the nicer - // dialog that's actually inside the p5 window. - status.prompt(prompt); - - } else { - // if the user selected quit, then this has to be done with - // a JOptionPane instead of internally in the editor. - // TODO this is actually just a bug to be fixed. - - // macosx java kills the app even though cancel might get hit - // so the cancel button is (temporarily) left off - // this may be treated differently in macosx java 1.4, - // but 1.4 isn't currently stable enough to use. - - // turns out windows has the same problem (sometimes) - // disable cancel for now until a fix can be found. - - Object[] options = { "Yes", "No" }; - int result = JOptionPane.showOptionDialog(this, - prompt, - "Quit", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[0]); - - if (result == JOptionPane.YES_OPTION) { - handleSave(); - checkModified2(); - - } else if (result == JOptionPane.NO_OPTION) { - checkModified2(); // though this may just quit - - } else if (result == JOptionPane.CANCEL_OPTION) { - // ignored - } - } - } - - - /** - * Called by PdeEditorStatus to complete the job. - */ - public void checkModified2() { - switch (checkModifiedMode) { - case HANDLE_NEW: handleNew2(false); break; - case HANDLE_OPEN: handleOpen2(handleOpenPath); break; - case HANDLE_QUIT: handleQuit2(); break; - } - checkModifiedMode = 0; - } - - - /** - * New was called (by buttons or by menu), first check modified - * and if things work out ok, handleNew2() will be called. - * - * If shift is pressed when clicking the toolbar button, then - * force the opposite behavior from sketchbook.prompt's setting - */ - public void handleNew(boolean shift) { - doStop(); - handleNewShift = shift; - handleNewLibrary = false; - checkModified(HANDLE_NEW); - } - - - /** - * User selected "New Library", this will act just like handleNew - * but internally set a flag that the new guy is a library, - * meaning that a "library" subfolder will be added. - */ - public void handleNewLibrary() { - doStop(); - handleNewShift = false; - handleNewLibrary = true; - checkModified(HANDLE_NEW); - } - - - /** - * Does all the plumbing to create a new project - * then calls handleOpen to load it up. - * @param startup true if the app is starting (auto-create a sketch) - */ - protected void handleNew2(boolean startup) { - try { - String pdePath = - sketchbook.handleNew(startup, handleNewShift, handleNewLibrary); - if (pdePath != null) handleOpen2(pdePath); - - } catch (IOException e) { - // not sure why this would happen, but since there's no way to - // recover (outside of creating another new setkch, which might - // just cause more trouble), then they've gotta quit. - PdeBase.showError("Problem creating a new sketch", - "An error occurred while creating\n" + - "a new sketch. Processing must now quit.", e); - } - } - - - /** - * Open a sketch given the full path to the .pde file. - * Pass in 'null' to prompt the user for the name of the sketch. - */ - public void handleOpen(String path) { - if (path == null) { // "open..." selected from the menu - path = sketchbook.handleOpen(); - if (path == null) return; - } - doStop(); - handleOpenPath = path; - checkModified(HANDLE_OPEN); - } - - - /** - * Second stage of open, occurs after having checked to - * see if the modifications (if any) to the previous sketch - * need to be saved. - */ - protected void handleOpen2(String path) { - try { - // check to make sure that this .pde file is - // in a folder of the same name - File file = new File(path); - File parentFile = new File(file.getParent()); - String parentName = parentFile.getName(); - String pdeName = parentName + ".pde"; - File altFile = new File(file.getParent(), pdeName); - - //System.out.println("path = " + file.getParent()); - //System.out.println("name = " + file.getName()); - //System.out.println("pname = " + parentName); - - if (pdeName.equals(file.getName())) { - // no beef with this guy - - } else if (altFile.exists()) { - // user selected a .java from the same sketch, - // but open the .pde instead - path = altFile.getAbsolutePath(); - //System.out.println("found alt file in same folder"); - - } else if (!path.endsWith(".pde")) { - PdeBase.showWarning("Bad file selected", - "Processing can only open its own sketches\n" + - "and other files ending in .pde", null); - return; - - } else { - String properParent = - file.getName().substring(0, file.getName().length() - 4); - - Object[] options = { "OK", "Cancel" }; - String prompt = - "The file \"" + file.getName() + "\" needs to be inside\n" + - "a sketch folder named \"" + properParent + "\".\n" + - "Create this folder, move the file, and continue?"; - - int result = JOptionPane.showOptionDialog(this, - prompt, - "Moving", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[0]); - - if (result == JOptionPane.YES_OPTION) { - // create properly named folder - File properFolder = new File(file.getParent(), properParent); - if (properFolder.exists()) { - PdeBase.showWarning("Error", - "A folder named \"" + properParent + "\" " + - "already exists. Can't open sketch.", null); - return; - } - if (!properFolder.mkdirs()) { - throw new IOException("Couldn't create sketch folder"); - } - // copy the sketch inside - File properPdeFile = new File(properFolder, file.getName()); - File origPdeFile = new File(path); - PdeBase.copyFile(origPdeFile, properPdeFile); - - // remove the original file, so user doesn't get confused - origPdeFile.delete(); - - // update with the new path - path = properPdeFile.getAbsolutePath(); - - } else if (result == JOptionPane.NO_OPTION) { - return; - } - } - - sketch = new PdeSketch(this, path); - // TODO re-enable this once export application works -//// mobile: exportAppItem removed from mobile - //exportAppItem.setEnabled(false && !sketch.isLibrary()); - buttons.disableRun(sketch.isLibrary()); - header.rebuild(); - if (PdePreferences.getBoolean("console.auto_clear")) { - console.clear(); - } - - } catch (Exception e) { - error(e); - } - } - - - // there is no handleSave1 since there's never a need to prompt - public void handleSave() { - message("Saving..."); - try { - if (sketch.save()) { - message("Done Saving."); - } else { - message(EMPTY); - } - // rebuild sketch menu in case a save-as was forced - sketchbook.rebuildMenus(); - - } catch (Exception e) { - // show the error as a message in the window - error(e); - - // zero out the current action, - // so that checkModified2 will just do nothing - checkModifiedMode = 0; - // this is used when another operation calls a save - } - buttons.clear(); - } - - - public void handleSaveAs() { - doStop(); - - message("Saving..."); - try { - if (sketch.saveAs()) { - message("Done Saving."); - sketchbook.rebuildMenus(); - } else { - message("Save Cancelled."); - } - - } catch (Exception e) { - // show the error as a message in the window - error(e); - } - buttons.clear(); - } - - - /** - * Handles calling the export() function on sketch, and - * queues all the gui status stuff that comes along with it. - * - * Made synchronized to (hopefully) avoid problems of people - * hitting export twice, quickly, and horking things up. - */ - synchronized public void handleExport() { - String what = sketch.isLibrary() ? "Applet" : "Library"; - message("Exporting " + what + "..."); - try { - boolean success = sketch.isLibrary() ? - sketch.exportLibrary() : sketch.exportApplet(); - if (success) { - message("Done exporting."); - } else { - // error message will already be visible - } - } catch (Exception e) { - message("Error during export."); - e.printStackTrace(); - } - buttons.clear(); - } - - - synchronized public void handleExportApp() { - message("Exporting application..."); - try { - if (sketch.exportApplication()) { - message("Done exporting."); - } else { - // error message will already be visible - } - } catch (Exception e) { - message("Error during export."); - e.printStackTrace(); - } - buttons.clear(); - } - - - /** - * Quit, but first ask user if it's ok. Also store preferences - * to disk just in case they want to quit. Final exit() happens - * in PdeEditor since it has the callback from PdeEditorStatus. - */ - public void handleQuit() { - // stop isn't sufficient with external vm & quit - // instead use doClose() which will kill the external vm - //doStop(); - doClose(); - - //if (!checkModified()) return; - checkModified(HANDLE_QUIT); - //System.out.println("exiting doquit"); - } - - - /** - * Actually do the quit action. - */ - protected void handleQuit2() { - storePreferences(); - preferences.save(); - - sketchbook.clean(); - - //System.out.println("exiting here"); - System.exit(0); - } - - - // an improved algorithm that would still avoid a full state machine - // 1. build an array of strings for the lines - // 2. first remove everything between /* and */ (relentless) - // 3. next remove anything inside two sets of " " - // but not if escaped with a \ - // these can't extend beyond a line, so that works well - // (this will save from "http://blahblah" showing up as a comment) - // 4. remove from // to the end of a line everywhere - // 5. run through remaining text to do indents - // using hokey brace-counting algorithm - // 6. also add indents for switch statements - // case blah: { } (colons at end of line isn't a good way) - // maybe /case \w+\:/ - public void handleBeautify() { - String prog = textarea.getText(); - - // TODO re-enable history - //history.record(prog, PdeHistory.BEAUTIFY); - - int tabSize = PdePreferences.getInteger("editor.tabs.size"); - - char program[] = prog.toCharArray(); - StringBuffer buffer = new StringBuffer(); - boolean gotBlankLine = false; - int index = 0; - int level = 0; - - while (index != program.length) { - int begin = index; - while ((program[index] != '\n') && - (program[index] != '\r')) { - index++; - if (program.length == index) - break; - } - int end = index; - if (index != program.length) { - if ((index+1 != program.length) && - // treat \r\n from windows as one line - (program[index] == '\r') && - (program[index+1] == '\n')) { - index += 2; - } else { - index++; - } - } // otherwise don't increment - - String line = new String(program, begin, end-begin); - line = line.trim(); - - if (line.length() == 0) { - if (!gotBlankLine) { - // let first blank line through - buffer.append('\n'); - gotBlankLine = true; - } - } else { - //System.out.println(level); - int idx = -1; - String myline = line.substring(0); - while (myline.lastIndexOf('}') != idx) { - idx = myline.indexOf('}'); - myline = myline.substring(idx+1); - level--; - } - //for (int i = 0; i < level*2; i++) { - // TODO i've since forgotten how i made this work (maybe it's even - // a bug) but for now, level is incrementing/decrementing in - // steps of two. in the interest of getting a release out, - // i'm just gonna roll with that since this function will prolly - // be replaced entirely and there are other things to worry about. - for (int i = 0; i < tabSize * level / 2; i++) { - buffer.append(' '); - } - buffer.append(line); - buffer.append('\n'); - //if (line.charAt(0) == '{') { - //level++; - //} - idx = -1; - myline = line.substring(0); - while (myline.lastIndexOf('{') != idx) { - idx = myline.indexOf('{'); - myline = myline.substring(idx+1); - level++; - } - gotBlankLine = false; - } - } - - // save current (rough) selection point - int selectionEnd = textarea.getSelectionEnd(); - - // replace with new bootiful text - setText(buffer.toString(), false); - - // make sure the caret would be past the end of the text - if (buffer.length() < selectionEnd - 1) { - selectionEnd = buffer.length() - 1; - } - - // at least in the neighborhood - textarea.select(selectionEnd, selectionEnd); - - //setSketchModified(true); - //sketch.setCurrentModified(true); - sketch.setModified(); - buttons.clear(); - } - - - // TODO iron out bugs with this code under - // different platforms, especially macintosh - public void highlightLine(int lnum) { - if (lnum < 0) { - textarea.select(0, 0); - return; - } - //System.out.println(lnum); - String s = textarea.getText(); - int len = s.length(); - int st = -1; - int ii = 0; - int end = -1; - int lc = 0; - if (lnum == 0) st = 0; - for (int i = 0; i < len; i++) { - ii++; - //if ((s.charAt(i) == '\n') || (s.charAt(i) == '\r')) { - boolean newline = false; - if (s.charAt(i) == '\r') { - if ((i != len-1) && (s.charAt(i+1) == '\n')) { - i++; //ii--; - } - lc++; - newline = true; - } else if (s.charAt(i) == '\n') { - lc++; - newline = true; - } - if (newline) { - if (lc == lnum) - //st = i+1; - st = ii; - else if (lc == lnum+1) { - //end = i; - end = ii; - break; - } - } - } - if (end == -1) end = len; - - // sometimes KJC claims that the line it found an error in is - // the last line in the file + 1. Just highlight the last line - // in this case. [dmose] - if (st == -1) st = len; - - textarea.select(st, end); - } - - - // ................................................................... - - - public void error(Exception e) { - status.error(e.getMessage()); - e.printStackTrace(); - } - - - public void error(PdeException e) { - if (e.file >= 0) sketch.setCurrent(e.file); - if (e.line >= 0) highlightLine(e.line); - - status.error(e.getMessage()); - buttons.clearRun(); - } - - - /* - public void finished() { - running = false; - buttons.clearRun(); - message("Done."); - } - */ - - - public void message(String msg) { - status.notice(msg); - } - - - /* - public void messageClear(String msg) { - status.unnotice(msg); - } - */ - - - // ................................................................... - - - /** - * Returns the edit popup menu. - */ - class TextAreaPopup extends JPopupMenu { - //protected ReferenceKeys referenceItems = new ReferenceKeys(); - String currentDir = System.getProperty("user.dir"); - String referenceFile = null; - - JMenuItem cutItem, copyItem; - JMenuItem referenceItem; - - - public TextAreaPopup() { - JMenuItem item; - - cutItem = new JMenuItem("Cut"); - cutItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.cut(); - } - }); - this.add(cutItem); - - copyItem = new JMenuItem("Copy"); - copyItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.copy(); - } - }); - this.add(copyItem); - - item = new JMenuItem("Paste"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.paste(); - } - }); - this.add(item); - - item = new JMenuItem("Select All"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textarea.selectAll(); - } - }); - this.add(item); - - this.addSeparator(); - - referenceItem = new JMenuItem("Find in Reference"); - referenceItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - PdeBase.showReference(referenceFile); - } - }); - this.add(referenceItem); - } - - // if no text is selected, disable copy and cut menu items - public void show(Component component, int x, int y) { - if (textarea.isSelectionActive()) { - cutItem.setEnabled(true); - copyItem.setEnabled(true); - - referenceFile = PdeKeywords.getReference(textarea.getSelectedText()); - if (referenceFile != null) { - referenceItem.setEnabled(true); - } - } else { - cutItem.setEnabled(false); - copyItem.setEnabled(false); - referenceItem.setEnabled(false); - } - super.show(component, x, y); - } - } - -//// mobile: exports MIDlet and executes emulator - public void handleRunEmulator() { - doClose(); - running = true; - buttons.run(); - - // do this for the terminal window / dos prompt / etc - for (int i = 0; i < 10; i++) System.out.println(); - - // clear the console on each run, unless the user doesn't want to - //if (PdeBase.getBoolean("console.auto_clear", true)) { - //if (PdePreferences.getBoolean("console.auto_clear", true)) { - if (PdePreferences.getBoolean("console.auto_clear")) { - console.clear(); - } - - try { - if (!sketch.exportMIDlet()) return; - - runtime = new PdeEmulator(sketch, this); - runtime.start(null); - watcher = new RunButtonWatcher(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -//// mobile: exports MIDlet - synchronized public void handleExportMIDlet() { - message("Exporting MIDlet..."); - try { - if (sketch.exportMIDlet()) { - message("Done exporting."); - File midletDir = new File(sketch.folder, "midlet"); - PdeBase.openFolder(midletDir); - } else { - // error message will already be visible - } - } catch (Exception e) { - message("Error during export."); - e.printStackTrace(); - } - buttons.clear(); - } -} - diff --git a/mobile/app/PdeEditorButtons.java b/mobile/app/PdeEditorButtons.java deleted file mode 100755 index 7b38adbe7..000000000 --- a/mobile/app/PdeEditorButtons.java +++ /dev/null @@ -1,417 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdeEditorButtons - run/stop/etc buttons for the ide - Part of the Processing project - http://processing.org - - Copyright (c) 2004 Ben Fry and the Processing project. - - The original rendition of this code was written by Ben Fry and - Copyright (c) 2001-03 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import java.awt.*; -import java.awt.event.*; -import java.awt.font.*; -import java.awt.geom.*; -import javax.swing.*; -import javax.swing.event.*; - - -public class PdeEditorButtons extends JComponent implements MouseInputListener { - - static final String title[] = { - "", "run", "stop", "new", "open", "save", "export" - }; - - static final int BUTTON_COUNT = title.length; - static final int BUTTON_WIDTH = PdePreferences.GRID_SIZE; - static final int BUTTON_HEIGHT = PdePreferences.GRID_SIZE; - - static final int NOTHING = 0; - static final int RUN = 1; - static final int STOP = 2; - - static final int NEW = 3; - static final int OPEN = 4; - static final int SAVE = 5; - static final int EXPORT = 6; - - static final int INACTIVE = 0; - static final int ROLLOVER = 1; - static final int ACTIVE = 2; - - PdeEditor editor; - boolean disableRun; - //Label status; - - Image offscreen; - int width, height; - - Color bgcolor; - - Image buttons; - Image inactive[]; - Image rollover[]; - Image active[]; - int currentRollover; - int currentSelection; - - JPopupMenu popup; - - int buttonCount; - int state[] = new int[BUTTON_COUNT]; - Image stateImage[]; - int which[]; // mapping indices to implementation - - int x1, x2; - int y1[], y2[]; - - String status; - Font statusFont; - Color statusColor; - int statusY; - - - public PdeEditorButtons(PdeEditor editor) { - this.editor = editor; - buttons = PdeBase.getImage("buttons.gif", this); - - buttonCount = 0; - which = new int[BUTTON_COUNT]; - - which[buttonCount++] = NOTHING; - which[buttonCount++] = RUN; - which[buttonCount++] = STOP; - which[buttonCount++] = NEW; - which[buttonCount++] = OPEN; - which[buttonCount++] = SAVE; - which[buttonCount++] = EXPORT; - - currentRollover = -1; - - bgcolor = PdePreferences.getColor("buttons.bgcolor"); - - status = ""; - - //setLayout(null); - //status = new JLabel(); - statusFont = PdePreferences.getFont("buttons.status.font"); - statusColor = PdePreferences.getColor("buttons.status.color"); - //add(status); - - //status.setBounds(-5, BUTTON_COUNT * BUTTON_HEIGHT, - // BUTTON_WIDTH + 15, BUTTON_HEIGHT); - //status.setAlignment(Label.CENTER); - statusY = (BUTTON_COUNT + 1) * BUTTON_HEIGHT; - - addMouseListener(this); - addMouseMotionListener(this); - } - - - /* - public void update() { - paint(this.getGraphics()); - } - - public void update(Graphics g) { - paint(g); - } - */ - - //public void paintComponent(Graphics g) { - //super.paintComponent(g); - //} - - - public void paintComponent(Graphics screen) { - if (inactive == null) { - inactive = new Image[BUTTON_COUNT]; - rollover = new Image[BUTTON_COUNT]; - active = new Image[BUTTON_COUNT]; - - //state = new int[BUTTON_COUNT]; - - for (int i = 0; i < BUTTON_COUNT; i++) { - inactive[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT); - Graphics g = inactive[i].getGraphics(); - g.drawImage(buttons, -(i*BUTTON_WIDTH), -2*BUTTON_HEIGHT, null); - - rollover[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT); - g = rollover[i].getGraphics(); - g.drawImage(buttons, -(i*BUTTON_WIDTH), -1*BUTTON_HEIGHT, null); - - active[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT); - g = active[i].getGraphics(); - g.drawImage(buttons, -(i*BUTTON_WIDTH), -0*BUTTON_HEIGHT, null); - } - - state = new int[buttonCount]; - stateImage = new Image[buttonCount]; - for (int i = 0; i < buttonCount; i++) { - setState(i, INACTIVE, false); - } - } - Dimension size = size(); - if ((offscreen == null) || - (size.width != width) || (size.height != height)) { - offscreen = createImage(size.width, size.height); - width = size.width; - height = size.height; - - x1 = 0; - x2 = BUTTON_WIDTH; - - y1 = new int[buttonCount]; - y2 = new int[buttonCount]; - - int offsetY = 0; - for (int i = 0; i < buttonCount; i++) { - y1[i] = offsetY; - y2[i] = offsetY + BUTTON_HEIGHT; - offsetY = y2[i]; - } - } - Graphics g = offscreen.getGraphics(); - g.setColor(bgcolor); //getBackground()); - g.fillRect(0, 0, width, height); - - for (int i = 0; i < buttonCount; i++) { - //g.drawImage(stateImage[i], x1[i], y1, null); - g.drawImage(stateImage[i], x1, y1[i], null); - } - - g.setColor(statusColor); - g.setFont(statusFont); - - // if i ever find the guy who wrote the java2d api, - // i will hurt him. or just laugh in his face. or pity him. - Graphics2D g2 = (Graphics2D) g; - FontRenderContext frc = g2.getFontRenderContext(); - float statusW = (float) statusFont.getStringBounds(status, frc).getWidth(); - float statusX = (getSize().width - statusW) / 2; - - //int statusWidth = g.getFontMetrics().stringWidth(status); - //int statusX = (getSize().width - statusWidth) / 2; - - g2.drawString(status, statusX, statusY); - screen.drawImage(offscreen, 0, 0, null); - } - - - public void mouseMoved(MouseEvent e) { - // mouse events before paint(); - if (state == null) return; - - if (state[OPEN] != INACTIVE) { - // avoid flicker, since there will probably be an update event - setState(OPEN, INACTIVE, false); - } - //System.out.println(e); - //mouseMove(e); - handleMouse(e.getX(), e.getY()); - } - - - public void mouseDragged(MouseEvent e) { } - - - public void handleMouse(int x, int y) { - if (currentRollover != -1) { - if ((y > y1[currentRollover]) && (x > x1) && - (y < y2[currentRollover]) && (x < x2)) { - return; - - } else { - setState(currentRollover, INACTIVE, true); - messageClear(title[currentRollover]); - currentRollover = -1; - } - } - int sel = findSelection(x, y); - if (sel == -1) return; - - if (state[sel] != ACTIVE) { - if (!(disableRun && ((sel == RUN) || (sel == STOP)))) { - setState(sel, ROLLOVER, true); - currentRollover = sel; - } - } - } - - - private int findSelection(int x, int y) { - // if app loads slowly and cursor is near the buttons - // when it comes up, the app may not have time to load - if ((y1 == null) || (y2 == null)) return -1; - - for (int i = 0; i < buttonCount; i++) { - if ((x > x1) && (y > y1[i]) && - (x < x2) && (y < y2[i])) { - //if ((x > x1[i]) && (y > y1) && - //(x < x2[i]) && (y < y2)) { - return i; - } - } - return -1; - } - - - private void setState(int slot, int newState, boolean updateAfter) { - //if (inactive == null) return; - state[slot] = newState; - switch (newState) { - case INACTIVE: - stateImage[slot] = inactive[which[slot]]; - break; - case ACTIVE: - stateImage[slot] = active[which[slot]]; - break; - case ROLLOVER: - stateImage[slot] = rollover[which[slot]]; - message(title[which[slot]]); - break; - } - if (updateAfter) repaint(); // changed for swing from update(); - } - - - public void mouseEntered(MouseEvent e) { - //mouseMove(e); - handleMouse(e.getX(), e.getY()); - } - - - public void mouseExited(MouseEvent e) { - if (state[OPEN] != INACTIVE) { - setState(OPEN, INACTIVE, true); - } - - // kludge - //for (int i = 0; i < BUTTON_COUNT; i++) { - //messageClear(title[i]); - //} - status = ""; - //mouseMove(e); - handleMouse(e.getX(), e.getY()); - } - - int wasDown = -1; - - - public void mousePressed(MouseEvent e) { - int x = e.getX(); - int y = e.getY(); - - int sel = findSelection(x, y); - ///if (sel == -1) return false; - if (sel == -1) return; - currentRollover = -1; - currentSelection = sel; - if (!(disableRun && ((sel == RUN) || (sel == STOP)))) { - setState(sel, ACTIVE, true); - } - - if (currentSelection == OPEN) { - if (popup == null) { - //popup = new JPopupMenu(); - popup = editor.sketchbook.getPopupMenu(); - add(popup); - } - //editor.sketchbook.rebuildPopup(popup); - popup.show(this, x, y); - } - } - - - public void mouseClicked(MouseEvent e) { } - - - public void mouseReleased(MouseEvent e) { - switch (currentSelection) { - case RUN: - if (!disableRun) { - editor.handleRunEmulator();//(e.isShiftDown()); - } - break; - - case STOP: - if (!disableRun) { - setState(RUN, INACTIVE, true); - editor.handleStop(); - } - break; - - case OPEN: setState(OPEN, INACTIVE, true); break; - case NEW: editor.handleNew(e.isShiftDown()); break; - case SAVE: editor.handleSave(); break; - case EXPORT: editor.handleExportMIDlet(); break; - } - currentSelection = -1; - } - - - public void disableRun(boolean what) { - disableRun = what; - } - - - public void clear() { // (int button) { - if (inactive == null) return; - - // skip the run button, do the others - for (int i = 1; i < buttonCount; i++) { - setState(i, INACTIVE, false); - } - repaint(); // changed for swing from update(); - } - - - public void run() { - if (inactive == null) return; - clear(); - setState(RUN, ACTIVE, true); - } - - - public void running(boolean yesno) { - setState(RUN, yesno ? ACTIVE : INACTIVE, true); - } - - - public void clearRun() { - if (inactive == null) return; - setState(RUN, INACTIVE, true); - } - - - public void message(String msg) { - //status.setText(msg + " "); // don't mind the hack - status = msg; - } - - public void messageClear(String msg) { - //if (status.getText().equals(msg + " ")) status.setText(PdeEditor.EMPTY); - if (status.equals(msg)) status = ""; - } - - - public Dimension getPreferredSize() { - return new Dimension(BUTTON_WIDTH, (BUTTON_COUNT + 1)*BUTTON_HEIGHT); - } -} diff --git a/mobile/app/PdeEmulator.java b/mobile/app/PdeEmulator.java deleted file mode 100755 index 23819b35f..000000000 --- a/mobile/app/PdeEmulator.java +++ /dev/null @@ -1,48 +0,0 @@ -import java.awt.Point; -import java.io.*; - -/** - * - * @author Francis Li - */ -public class PdeEmulator extends PdeRuntime { - - /** Creates a new instance of PdeEmulator */ - public PdeEmulator(PdeSketch sketch, PdeEditor editor) { - super(sketch, editor); - } - - public void start(Point windowLocation) throws PdeException { - try{ - String wtkBinPath = PdePreferences.get("wtk.path") + File.separator + "bin"; - - StringBuffer command = new StringBuffer(); - command.append(wtkBinPath); - command.append(File.separator); - command.append("emulator.exe -Xdescriptor:\""); - command.append(sketch.folder.getPath()); - command.append(File.separator); - command.append("midlet"); - command.append(File.separator); - command.append(sketch.name); - command.append(".jad\""); - - process = Runtime.getRuntime().exec(command.toString(), null, new File(wtkBinPath)); - processInput = new SystemOutSiphon(process.getInputStream()); - processError = new PdeMessageSiphon(process.getErrorStream(), this); - processOutput = process.getOutputStream(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void stop() { - } - - public void close() { - } - - public void message(String s) { - System.err.println(s); - } -} diff --git a/mobile/app/PdePreprocessor.java b/mobile/app/PdePreprocessor.java deleted file mode 100755 index 6ba7a11df..000000000 --- a/mobile/app/PdePreprocessor.java +++ /dev/null @@ -1,419 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdePreprocessor - wrapper for default ANTLR-generated parser - Part of the Processing project - http://processing.org - - Except where noted, code is written by Ben Fry and - Copyright (c) 2001-03 Massachusetts Institute of Technology - - ANTLR-generated parser and several supporting classes written - by Dan Mosedale via funding from the Interaction Institute IVREA. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import processing.core.*; - -import java.io.*; - -import antlr.*; -import antlr.collections.*; -import antlr.collections.impl.*; - -import com.oroinc.text.regex.*; - - -public class PdePreprocessor { - - static final int JDK11 = 0; - static final int JDK13 = 1; - static final int JDK14 = 2; - - static String defaultImports[][] = new String[3][]; - - // these ones have the .* at the end, since a class name - // might be at the end instead of .* whcih would make trouble - // other classes using this can lop of the . and anything after - // it to produce a package name consistently. - String extraImports[]; - - // imports just from the code folder, treated differently - // than the others, since the imports are auto-generated. - String codeFolderImports[]; - - static final int STATIC = 0; // formerly BEGINNER - static final int ACTIVE = 1; // formerly INTERMEDIATE - static final int JAVA = 2; // formerly ADVANCED - // static to make it easier for the antlr preproc to get at it - static int programType = -1; - - Reader programReader; - String buildPath; - - // used for calling the ASTFactory to get the root node - private static final int ROOT_ID = 0; - - private String baseClass; - private String[] baseImports; - - public void setBaseClass(String baseClass) { - this.baseClass = baseClass; - } - - public void setBaseImports(String[] baseImports) { - this.baseImports = baseImports; - } - - - /** - * These may change in-between (if the prefs panel adds this option) - * so grab them here on construction. - */ - public PdePreprocessor() { - defaultImports[JDK11] = - PApplet.split(PdePreferences.get("preproc.imports.jdk11"), ','); - defaultImports[JDK13] = - PApplet.split(PdePreferences.get("preproc.imports.jdk13"), ','); - defaultImports[JDK14] = - PApplet.split(PdePreferences.get("preproc.imports.jdk14"), ','); - } - - - /** - * Used by PdeEmitter.dumpHiddenTokens() - */ - public static TokenStreamCopyingHiddenTokenFilter filter; - - - /** - * preprocesses a pde file and write out a java file - * @return the classname of the exported Java - */ - //public String write(String program, String buildPath, String name, - // String extraImports[]) throws java.lang.Exception { - public String write(String program, String buildPath, String name, String codeFolderPackages[]) - throws java.lang.Exception { - // if the program ends with no CR or LF an OutOfMemoryError will happen. - // not gonna track down the bug now, so here's a hack for it: - if ((program.length() > 0) && - program.charAt(program.length()-1) != '\n') { - program += "\n"; - } - - if (PdePreferences.getBoolean("preproc.substitute_unicode")) { - // check for non-ascii chars (these will be/must be in unicode format) - char p[] = program.toCharArray(); - int unicodeCount = 0; - for (int i = 0; i < p.length; i++) { - if (p[i] > 127) unicodeCount++; - } - // if non-ascii chars are in there, convert to unicode escapes - if (unicodeCount != 0) { - // add unicodeCount * 5.. replacing each unicode char - // with six digit uXXXX sequence (xxxx is in hex) - // (except for nbsp chars which will be a replaced with a space) - int index = 0; - char p2[] = new char[p.length + unicodeCount*5]; - for (int i = 0; i < p.length; i++) { - if (p[i] < 128) { - p2[index++] = p[i]; - - } else if (p[i] == 160) { // unicode for non-breaking space - p2[index++] = ' '; - - } else { - int c = p[i]; - p2[index++] = '\\'; - p2[index++] = 'u'; - char str[] = Integer.toHexString(c).toCharArray(); - // add leading zeros, so that the length is 4 - //for (int i = 0; i < 4 - str.length; i++) p2[index++] = '0'; - for (int m = 0; m < 4 - str.length; m++) p2[index++] = '0'; - System.arraycopy(str, 0, p2, index, str.length); - index += str.length; - } - } - program = new String(p2, 0, index); - } - } - - // if this guy has his own imports, need to remove them - // just in case it's not an advanced mode sketch - PatternMatcher matcher = new Perl5Matcher(); - PatternCompiler compiler = new Perl5Compiler(); - //String mess = "^\\s*(import\\s+\\S+\\s*;)"; - String mess = "^\\s*(import\\s+)(\\S+)(\\s*;)"; - java.util.Vector imports = new java.util.Vector(); - - Pattern pattern = null; - try { - pattern = compiler.compile(mess); - } catch (MalformedPatternException e) { - e.printStackTrace(); - return null; - } - - do { - PatternMatcherInput input = new PatternMatcherInput(program); - if (!matcher.contains(input, pattern)) break; - - MatchResult result = matcher.getMatch(); - String piece1 = result.group(1).toString(); - String piece2 = result.group(2).toString(); // the package name - String piece3 = result.group(3).toString(); - String piece = piece1 + piece2 + piece3; - int len = piece.length(); - - //imports.add(piece); - imports.add(piece2); - int idx = program.indexOf(piece); - // just remove altogether? - program = program.substring(0, idx) + program.substring(idx + len); - - //System.out.println("removing " + piece); - - } while (true); - - int importsCount = imports.size(); - extraImports = new String[importsCount]; - imports.copyInto(extraImports); - - - /* - if (codeFolderPackages != null) { - extraImports = new String[importsCount + codeFolderPackages.length]; - imports.copyInto(extraImports); - for (int i = 0; i < codeFolderPackages.length; i++) { - extraImports[importsCount + i] = codeFolderPackages[i] + ".*"; - } - codeFolderImports = null; - } - */ - - if (codeFolderPackages != null) { - codeFolderImports = new String[codeFolderPackages.length]; - for (int i = 0; i < codeFolderPackages.length; i++) { - codeFolderImports[i] = codeFolderPackages[i] + ".*"; - } - } else { - codeFolderImports = null; - } - - // - - // do this after the program gets re-combobulated - this.programReader = new StringReader(program); - this.buildPath = buildPath; - - // create a lexer with the stream reader, and tell it to handle - // hidden tokens (eg whitespace, comments) since we want to pass these - // through so that the line numbers when the compiler reports errors - // match those that will be highlighted in the PDE IDE - // - PdeLexer lexer = new PdeLexer(programReader); - lexer.setTokenObjectClass("antlr.CommonHiddenStreamToken"); - - // create the filter for hidden tokens and specify which tokens to - // hide and which to copy to the hidden text - // - filter = new TokenStreamCopyingHiddenTokenFilter(lexer); - filter.hide(PdeRecognizer.SL_COMMENT); - filter.hide(PdeRecognizer.ML_COMMENT); - filter.hide(PdeRecognizer.WS); - filter.copy(PdeRecognizer.SEMI); - filter.copy(PdeRecognizer.LPAREN); - filter.copy(PdeRecognizer.RPAREN); - filter.copy(PdeRecognizer.LCURLY); - filter.copy(PdeRecognizer.RCURLY); - filter.copy(PdeRecognizer.COMMA); - filter.copy(PdeRecognizer.RBRACK); - filter.copy(PdeRecognizer.LBRACK); - filter.copy(PdeRecognizer.COLON); - - // create a parser and set what sort of AST should be generated - // - PdeRecognizer parser = new PdeRecognizer(filter); - - // use our extended AST class - // - parser.setASTNodeClass("antlr.ExtendedCommonASTWithHiddenTokens"); - - // start parsing at the compilationUnit non-terminal - // - parser.pdeProgram(); - - // set up the AST for traversal by PdeEmitter - // - ASTFactory factory = new ASTFactory(); - AST parserAST = parser.getAST(); - AST rootNode = factory.create(ROOT_ID, "AST ROOT"); - rootNode.setFirstChild(parserAST); - - // unclear if this actually works, but it's worth a shot - // - ((CommonAST)parserAST).setVerboseStringConversion( - true, parser.getTokenNames()); - - // if this is an advanced program, the classname is already defined. - // - if (programType == JAVA) { - name = getFirstClassName(parserAST); - } - - // if 'null' was passed in for the name, but this isn't - // a 'java' mode class, then there's a problem, so punt. - // - if (name == null) return null; - - // output the code - // - PdeEmitter emitter = new PdeEmitter(); - File streamFile = new File(buildPath, name + ".java"); - PrintStream stream = new PrintStream(new FileOutputStream(streamFile)); - - //writeHeader(stream, extraImports, name); - writeHeader(stream, name); - - emitter.setOut(stream); - emitter.print(rootNode); - - writeFooter(stream); - stream.close(); - - // if desired, serialize the parse tree to an XML file. can - // be viewed usefully with Mozilla or IE - - if (PdePreferences.getBoolean("preproc.output_parse_tree")) { - - stream = new PrintStream(new FileOutputStream("parseTree.xml")); - stream.println(""); - stream.println(""); - OutputStreamWriter writer = new OutputStreamWriter(stream); - if (parserAST != null) { - ((CommonAST)parserAST).xmlSerialize(writer); - } - writer.flush(); - stream.println(""); - writer.close(); - } - - return name; - } - - - /** - * Write any required header material (eg imports, class decl stuff) - * - * @param out PrintStream to write it to. - * @param exporting Is this being exported from PDE? - * @param name Name of the class being created. - */ - void writeHeader(PrintStream out, String className) { - - // must include processing.core - out.print("import processing.core.*; "); - - // emit emports that are needed for classes from the code folder - if (extraImports != null) { - for (int i = 0; i < extraImports.length; i++) { - out.print("import " + extraImports[i] + "; "); - } - } - - if (codeFolderImports != null) { - for (int i = 0; i < codeFolderImports.length; i++) { - out.print("import " + codeFolderImports[i] + "; "); - } - } - - // emit standard imports (read from pde.properties) - // for each language level that's being used. - String jdkVersionStr = PdePreferences.get("preproc.jdk_version"); - - int jdkVersion = JDK11; // default - if (jdkVersionStr.equals("1.3")) { jdkVersion = JDK13; }; - if (jdkVersionStr.equals("1.4")) { jdkVersion = JDK14; }; - - if (baseImports != null) { - int length = baseImports.length; - for (int i = 0; i < length; i++) { - out.print("import " + baseImports[i] + ";"); - } - } else { - for (int i = 0; i <= jdkVersion; i++) { - for (int j = 0; j < defaultImports[i].length; j++) { - out.print("import " + defaultImports[i][j] + ".*; "); - } - } - } - - if (programType < JAVA) { - // open the class definition - if (baseClass != null) { - out.print("public class " + className + " extends " + baseClass + "{"); - } else { - out.print("public class " + className + " extends PApplet {"); - } - - if (programType == STATIC) { - // now that size() and background() can go inside of draw() - // actually, use setup(), because when running externally - // the applet size needs to be set before the window is drawn, - // meaning that after setup() things need to be ducky. - //out.print("public void draw() {"); - out.print("public void setup() {"); - } - } - } - - /** - * Write any necessary closing text. - * - * @param out PrintStream to write it to. - */ - void writeFooter(PrintStream out) { - - if (programType == STATIC) { - // close off draw() definition - out.print("noLoop(); "); - out.print("}"); - } - - if (programType < JAVA) { - // close off the class definition - out.print("}"); - } - } - - - static String advClassName = ""; - - /** - * Find the first CLASS_DEF node in the tree, and return the name of the - * class in question. - * - * XXXdmose right now, we're using a little hack to the grammar to get - * this info. In fact, we should be descending the AST passed in. - */ - String getFirstClassName(AST ast) { - - String t = advClassName; - advClassName = ""; - - return t; - } - -} diff --git a/mobile/app/PdePreverifier.java b/mobile/app/PdePreverifier.java deleted file mode 100755 index 36f678fae..000000000 --- a/mobile/app/PdePreverifier.java +++ /dev/null @@ -1,55 +0,0 @@ -import java.io.*; - -public class PdePreverifier implements PdeMessageConsumer { - - public PdePreverifier() { - } - - public boolean preverify(File source, File output) { - String wtkPath = PdePreferences.get("wtk.path"); - String wtkBinPath = wtkPath + File.separator + "bin" + File.separator; - String wtkLibPath = wtkPath + File.separator + "lib" + File.separator; - - StringBuffer command = new StringBuffer(); - command.append(wtkBinPath); - command.append("preverify.exe -target CLDC1.0 -classpath "); - command.append(wtkLibPath); - command.append("cldcapi10.jar;"); - command.append(wtkLibPath); - command.append("midpapi10.jar;lib"); - command.append(File.separator); - command.append("mobile.jar"); - command.append(" -d \""); - command.append(output.getPath()); - command.append("\" \""); - command.append(source.getPath()); - command.append("\""); - //System.out.println(command.toString()); - try { - Process p = Runtime.getRuntime().exec(command.toString()); - boolean running = true; - int result = -1; - while (running) { - try { - result = p.waitFor(); - new PdeMessageSiphon(p.getInputStream(), this); - new PdeMessageSiphon(p.getErrorStream(), this); - - running = false; - } catch (InterruptedException ie) { - ie.printStackTrace (); - } - } - //System.out.println("Preverify complete!"); - return (result == 0); - } catch (Exception e) { - e.printStackTrace (); - } - - return false; - } - - public void message(String s) { - System.err.println(s); - } -} diff --git a/mobile/app/PdeSketch.java b/mobile/app/PdeSketch.java deleted file mode 100755 index 90920867e..000000000 --- a/mobile/app/PdeSketch.java +++ /dev/null @@ -1,2034 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdeSketch - stores information about files in the current sketch - Part of the Processing project - http://processing.org - - Except where noted, code is written by Ben Fry - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import processing.core.*; - -import java.awt.FileDialog; -import java.io.*; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; - -import javax.swing.JOptionPane; - -import com.oroinc.text.regex.*; - - -public class PdeSketch { - static String TEMP_BUILD_PATH = "lib" + File.separator + "build"; - static File tempBuildFolder; - - PdeEditor editor; - - // name of sketch, which is the name of main file - // (without .pde or .java extension) - String name; - - // name of 'main' file, used by load(), such as sketch_04040.pde - String mainFilename; - //String path; // path to 'main' file for this sketch - - // true if any of the files have been modified - boolean modified; - - boolean library; // true if it's a library - - public File folder; //sketchFolder; - File dataFolder; - File codeFolder; - - static final int PDE = 0; - static final int JAVA = 1; - - PdeCode current; - int codeCount; - PdeCode code[]; - - int hiddenCount; - PdeCode hidden[]; - - // all these set each time build() is called - String mainClassName; - String classPath; - String libraryPath; - boolean externalRuntime; - Vector importedLibraries; // vec of File objects - - /** - * path is location of the main .pde file, because this is also - * simplest to use when opening the file from the finder/explorer. - */ - public PdeSketch(PdeEditor editor, String path) throws IOException { - this.editor = editor; - - File mainFile = new File(path); - //System.out.println("main file is " + mainFile); - - mainFilename = mainFile.getName(); - //System.out.println("main file is " + mainFilename); - - // get the name of the sketch by chopping .pde or .java - // off of the main file name - if (mainFilename.endsWith(".pde")) { - name = mainFilename.substring(0, mainFilename.length() - 4); - } else if (mainFilename.endsWith(".java")) { - name = mainFilename.substring(0, mainFilename.length() - 5); - } - - // lib/build must exist when the application is started - // it is added to the CLASSPATH by default, but if it doesn't - // exist when the application is started, then java will remove - // the entry from the CLASSPATH, causing PdeRuntime to fail. - // - tempBuildFolder = new File(TEMP_BUILD_PATH); - if (!tempBuildFolder.exists()) { - tempBuildFolder.mkdirs(); - PdeBase.showError("Required folder missing", - "A required folder was missing from \n" + - "from your installation of Processing.\n" + - "It has now been replaced, please restart \n" + - "the application to complete the repair.", null); - } - - folder = new File(new File(path).getParent()); - //System.out.println("sketch dir is " + folder); - - codeFolder = new File(folder, "code"); - dataFolder = new File(folder, "data"); - - File libraryFolder = new File(folder, "library"); - if (libraryFolder.exists()) { - library = true; - } - - load(); - } - - - /** - * Build the list of files. - * - * Generally this is only done once, rather than - * each time a change is made, because otherwise it gets to be - * a nightmare to keep track of what files went where, because - * not all the data will be saved to disk. - * - * The exception is when an external editor is in use, - * in which case the load happens each time "run" is hit. - */ - public void load() { - // get list of files in the sketch folder - String list[] = folder.list(); - - for (int i = 0; i < list.length; i++) { - if (list[i].endsWith(".pde")) codeCount++; - else if (list[i].endsWith(".java")) codeCount++; - else if (list[i].endsWith(".pde.x")) hiddenCount++; - else if (list[i].endsWith(".java.x")) hiddenCount++; - } - - code = new PdeCode[codeCount]; - hidden = new PdeCode[hiddenCount]; - - int codeCounter = 0; - int hiddenCounter = 0; - - for (int i = 0; i < list.length; i++) { - if (list[i].endsWith(".pde")) { - code[codeCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 4), - new File(folder, list[i]), - PDE); - - } else if (list[i].endsWith(".java")) { - code[codeCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 5), - new File(folder, list[i]), - JAVA); - - } else if (list[i].endsWith(".pde.x")) { - hidden[hiddenCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 6), - new File(folder, list[i]), - PDE); - - } else if (list[i].endsWith(".java.x")) { - hidden[hiddenCounter++] = - new PdeCode(list[i].substring(0, list[i].length() - 7), - new File(folder, list[i]), - JAVA); - } - } - //System.out.println("code count 2 is " + codeCount); - - // remove any entries that didn't load properly - int index = 0; - while (index < codeCount) { - if (code[index].program == null) { - //hide(index); // although will this file be hidable? - for (int i = index+1; i < codeCount; i++) { - code[i-1] = code[i]; - } - codeCount--; - - } else { - index++; - } - } - //System.out.println("code count 3 is " + codeCount); - - // move the main class to the first tab - // start at 1, if it's at zero, don't bother - //System.out.println("looking for " + mainFilename); - for (int i = 1; i < codeCount; i++) { - if (code[i].file.getName().equals(mainFilename)) { - //System.out.println("found main code at slot " + i); - PdeCode temp = code[0]; - code[0] = code[i]; - code[i] = temp; - break; - } - } - - // sort the entries at the top - sortCode(); - - // set the main file to be the current tab - //current = code[0]; - setCurrent(0); - } - - - protected void insertCode(PdeCode newCode) { - // add file to the code/codeCount list, resort the list - if (codeCount == code.length) { - PdeCode temp[] = new PdeCode[codeCount+1]; - System.arraycopy(code, 0, temp, 0, codeCount); - code = temp; - } - code[codeCount++] = newCode; - } - - - protected void sortCode() { - // cheap-ass sort of the rest of the files - // it's a dumb, slow sort, but there shouldn't be more than ~5 files - for (int i = 1; i < codeCount; i++) { - int who = i; - for (int j = i + 1; j < codeCount; j++) { - if (code[j].name.compareTo(code[who].name) < 0) { - who = j; // this guy is earlier in the alphabet - } - } - if (who != i) { // swap with someone if changes made - PdeCode temp = code[who]; - code[who] = code[i]; - code[i] = temp; - } - } - } - - boolean renamingCode; - - - public void newCode() { - //System.out.println("new code"); - // ask for name of new file - // maybe just popup a text area? - renamingCode = false; - editor.status.edit("Name for new file:", ""); - } - - - public void renameCode() { - // don't allow rename of the main code - if (current == code[0]) return; - // TODO maybe gray out the menu on setCurrent(0) - - // ask for new name of file (internal to window) - // TODO maybe just popup a text area? - renamingCode = true; - editor.status.edit("New name for file:", current.name); - } - - - /** - * This is called upon return from entering a new file name. - * (that is, from either newCode or renameCode after the prompt) - * This code is almost identical for both the newCode and renameCode - * cases, so they're kept merged except for right in the middle - * where they diverge. - */ - public void nameCode(String newName) { - // if renaming to the same thing as before, just ignore. - // also ignoring case here, because i don't want to write - // a bunch of special stuff for each platform - // (osx is case insensitive but preserving, windows insensitive, - // *nix is sensitive and preserving.. argh) - if (renamingCode && newName.equalsIgnoreCase(current.name)) { - // exit quietly for the 'rename' case. - // if it's a 'new' then an error will occur down below - return; - } - - String newFilename = null; - int newFlavor = 0; - - // add .pde to file if it has no extension - if (newName.endsWith(".pde")) { - newFilename = newName; - newName = newName.substring(0, newName.length() - 4); - newFlavor = PDE; - - } else if (newName.endsWith(".java")) { - newFilename = newName; - newName = newName.substring(0, newName.length() - 5); - newFlavor = JAVA; - - } else { - newFilename = newName + ".pde"; - newFlavor = PDE; - } - - // dots are allowed for the .pde and .java, but not in general - // so make sure the user didn't name things poo.time.pde - // or something like that (nothing against poo time) - if (newName.indexOf('.') != -1) { - newName = PdeSketchbook.sanitizedName(newName); - newFilename = newName + ((newFlavor == PDE) ? ".pde" : ".java"); - } - - // create the new file, new PdeCode object and load it - File newFile = new File(folder, newFilename); - if (newFile.exists()) { // yay! users will try anything - PdeBase.showMessage("Nope", - "A file named \"" + newFile + "\" already exists\n" + - "in \"" + folder.getAbsolutePath() + "\""); - return; - } - - if (renamingCode) { - if (!current.file.renameTo(newFile)) { - PdeBase.showWarning("Error", - "Could not rename \"" + current.file.getName() + - "\" to \"" + newFile.getName() + "\"", null); - return; - } - current.file = newFile; - current.name = newName; - current.flavor = newFlavor; - - } else { // creating a new file - try { - newFile.createNewFile(); // TODO returns a boolean - } catch (IOException e) { - PdeBase.showWarning("Error", - "Could not create the file \"" + newFile + "\"\n" + - "in \"" + folder.getAbsolutePath() + "\"", e); - return; - } - PdeCode newCode = new PdeCode(newName, newFile, newFlavor); - insertCode(newCode); - } - - // sort the entries - sortCode(); - - // set the new guy as current - setCurrent(newName); - - // update the tabs - editor.header.repaint(); - } - - - /** - * Remove a piece of code from the sketch and from the disk. - */ - public void deleteCode() { - // don't allow delete of the main code - // TODO maybe gray out the menu on setCurrent(0) - if (current == code[0]) { - PdeBase.showMessage("Can't do that", - "You cannot delete the main " + - ".pde file from a sketch\n"); - return; - } - - // confirm deletion with user, yes/no - Object[] options = { "OK", "Cancel" }; - String prompt = - "Are you sure you want to delete \"" + current.name + "\"?"; - int result = JOptionPane.showOptionDialog(editor, - prompt, - "Delete", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[0]); - if (result == JOptionPane.YES_OPTION) { - // delete the file - if (!current.file.delete()) { - PdeBase.showMessage("Couldn't do it", - "Could not delete \"" + current.name + "\"."); - return; - } - - // remove code from the list - removeCode(current); - - // just set current tab to the main tab - setCurrent(0); - - // update the tabs - editor.header.repaint(); - } - } - - - protected void removeCode(PdeCode which) { - // remove it from the internal list of files - // resort internal list of files - for (int i = 0; i < codeCount; i++) { - if (code[i] == which) { - for (int j = i; j < codeCount-1; j++) { - code[j] = code[j+1]; - } - codeCount--; - return; - } - } - System.err.println("removeCode: internal error.. could not find code"); - } - - - public void hideCode() { - // don't allow hide of the main code - // TODO maybe gray out the menu on setCurrent(0) - if (current == code[0]) { - PdeBase.showMessage("Can't do that", - "You cannot hide the main " + - ".pde file from a sketch\n"); - return; - } - - // rename the file - File newFile = new File(current.file.getAbsolutePath() + ".x"); - if (!current.file.renameTo(newFile)) { - PdeBase.showWarning("Error", - "Could not hide " + - "\"" + current.file.getName() + "\".", null); - return; - } - current.file = newFile; - - // move it to the hidden list - if (hiddenCount == hidden.length) { - PdeCode temp[] = new PdeCode[hiddenCount+1]; - System.arraycopy(hidden, 0, temp, 0, hiddenCount); - hidden = temp; - } - hidden[hiddenCount++] = current; - - // remove it from the main list - removeCode(current); - - // update the tabs - setCurrent(0); - editor.header.repaint(); - } - - - public void unhideCode(String what) { - //System.out.println("unhide " + e); - int unhideIndex = -1; - for (int i = 0; i < hiddenCount; i++) { - if (hidden[i].name.equals(what)) { - unhideIndex = i; - - // remove from the 'hidden' list - for (int j = i; j < hiddenCount-1; j++) { - hidden[j] = hidden[j+1]; - } - hiddenCount--; - break; - } - } - if (unhideIndex == -1) { - System.err.println("internal error: could find " + what + " to unhide."); - return; - } - PdeCode unhideCode = hidden[unhideIndex]; - if (!unhideCode.file.exists()) { - PdeBase.showMessage("Can't unhide", - "The file \"" + what + "\" no longer exists."); - //System.out.println(unhideCode.file); - return; - } - String unhidePath = unhideCode.file.getAbsolutePath(); - File unhideFile = - new File(unhidePath.substring(0, unhidePath.length() - 2)); - - if (!unhideCode.file.renameTo(unhideFile)) { - PdeBase.showMessage("Can't unhide", - "The file \"" + what + "\" could not be" + - "renamed and unhidden."); - return; - } - unhideCode.file = unhideFile; - insertCode(unhideCode); - sortCode(); - setCurrent(unhideCode.name); - editor.header.repaint(); - } - - - /** - * Return true if this sketch is a library. - */ - public boolean isLibrary() { - return library; - } - - - /** - * Sets the modified value for the code in the frontmost tab. - */ - public void setModified() { - current.modified = true; - calcModified(); - } - - - public void calcModified() { - modified = false; - for (int i = 0; i < codeCount; i++) { - if (code[i].modified) { - modified = true; - break; - } - } - editor.header.repaint(); - } - - - /** - * Save all code in the current sketch. - */ - public boolean save() throws IOException { - // first get the contents of the editor text area - if (current.modified) { - current.program = editor.getText(); - } - - // see if actually modified - if (!modified) return false; - - // check if the files are read-only. - // if so, need to first do a "save as". - if (isReadOnly()) { - PdeBase.showMessage("Sketch is read-only", - "Some files are marked \"read-only\", so you'll\n" + - "need to re-save this sketch to another location."); - // if the user cancels, give up on the save() - if (!saveAs()) return false; - } - - for (int i = 0; i < codeCount; i++) { - if (code[i].modified) code[i].save(); - } - calcModified(); - return true; - } - - - public void saveCurrent() throws IOException { - current.save(); - calcModified(); - } - - - /** - * handles 'save as' for a sketch.. essentially duplicates - * the current sketch folder to a new location, and then calls - * 'save'. (needs to take the current state of the open files - * and save them to the new folder.. but not save over the old - * versions for the old sketch..) - * - * also removes the previously-generated .class and .jar files, - * because they can cause trouble. - */ - public boolean saveAs() throws IOException { - // get new name for folder - FileDialog fd = new FileDialog(editor, //new Frame(), - "Save sketch folder as...", - FileDialog.SAVE); - // always default to the sketchbook folder.. - //fd.setDirectory(PdePreferences.get("sketchbook.path")); - fd.setDirectory(folder.getParent()); - fd.setFile(folder.getName()); - //System.out.println("setting to " + folder.getParent()); - - // TODO or maybe this should default to the - // parent dir of the old folder? - - fd.show(); - String newParentDir = fd.getDirectory(); - String newName = fd.getFile(); - - // user cancelled selection - if (newName == null) return false; - newName = PdeSketchbook.sanitizeName(newName); - - // new sketch folder - File newFolder = new File(newParentDir, newName); - - // make sure the paths aren't the same - if (newFolder.equals(folder)) { - PdeBase.showWarning("You can't fool me", - "The new sketch name and location are the same\n" + - "as the old. I ain't not doin nuthin'.", null); - return false; - } - - // check to see if the user is trying to save this sketch - // inside the same sketch - try { - String newPath = newFolder.getCanonicalPath() + File.separator; - String oldPath = folder.getCanonicalPath() + File.separator; - //System.out.println(newPath); - //System.out.println(oldPath); - - if (newPath.indexOf(oldPath) == 0) { - PdeBase.showWarning("How very Borges of you", - "You cannot save the sketch into a folder\n" + - "inside itself. This would go on forever.", null); - return false; - } - } catch (IOException e) { } - - // copy the entire contents of the sketch folder - PdeBase.copyDir(folder, newFolder); - - // change the references to the dir location in PdeCode files - for (int i = 0; i < codeCount; i++) { - code[i].file = new File(newFolder, code[i].file.getName()); - } - for (int i = 0; i < hiddenCount; i++) { - hidden[i].file = new File(newFolder, hidden[i].file.getName()); - } - - // remove the old sketch file from the new dir - code[0].file.delete(); - // name for the new main .pde file - code[0].file = new File(newFolder, newName + ".pde"); - code[0].name = newName; - // write the contents to the renamed file - // (this may be resaved if the code is modified) - code[0].save(); - - // change the other paths - String oldName = name; - name = newName; - File oldFolder = folder; - folder = newFolder; - dataFolder = new File(folder, "data"); - codeFolder = new File(folder, "code"); - - // remove the 'applet', 'application', 'library' folders - // from the copied version. - // otherwise their .class and .jar files can cause conflicts. - PdeBase.removeDir(new File(folder, "applet")); - PdeBase.removeDir(new File(folder, "application")); - PdeBase.removeDir(new File(folder, "library")); - - // do a "save" - // this will take care of the unsaved changes in each of the tabs - save(); - - // get the changes into the sketchbook menu - //sketchbook.rebuildMenu(); - // done inside PdeEditor instead - - // update the tabs for the name change - editor.header.repaint(); - - // let PdeEditor know that the save was successful - return true; - } - - - /** - * Prompt the user for a new file to the sketch. - * This could be .class or .jar files for the code folder, - * .pde or .java files for the project, - * or .dll, .jnilib, or .so files for the code folder - */ - public void addFile() { - // get a dialog, select a file to add to the sketch - String prompt = - "Select an image or other data file to copy to your sketch"; - //FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD); - FileDialog fd = new FileDialog(editor, prompt, FileDialog.LOAD); - fd.show(); - - String directory = fd.getDirectory(); - String filename = fd.getFile(); - if (filename == null) return; - - // copy the file into the folder. if people would rather - // it move instead of copy, they can do it by hand - File sourceFile = new File(directory, filename); - - File destFile = null; - boolean addingCode = false; - - // if the file appears to be code related, drop it - // into the code folder, instead of the data folder - if (filename.toLowerCase().endsWith(".class") || - filename.toLowerCase().endsWith(".jar") || - filename.toLowerCase().endsWith(".dll") || - filename.toLowerCase().endsWith(".jnilib") || - filename.toLowerCase().endsWith(".so")) { - //File codeFolder = new File(this.folder, "code"); - if (!codeFolder.exists()) codeFolder.mkdirs(); - destFile = new File(codeFolder, filename); - - } else if (filename.toLowerCase().endsWith(".pde") || - filename.toLowerCase().endsWith(".java")) { - destFile = new File(this.folder, filename); - addingCode = true; - - } else { - //File dataFolder = new File(this.folder, "data"); - if (!dataFolder.exists()) dataFolder.mkdirs(); - destFile = new File(dataFolder, filename); - } - - // make sure they aren't the same file - if (!addingCode && sourceFile.equals(destFile)) { - PdeBase.showWarning("You can't fool me", - "This file has already been copied to the\n" + - "location where you're trying to add it.\n" + - "I ain't not doin nuthin'.", null); - return; - } - - // in case the user is "adding" the code in an attempt - // to update the sketch's tabs - if (!sourceFile.equals(destFile)) { - try { - PdeBase.copyFile(sourceFile, destFile); - } catch (IOException e) { - PdeBase.showWarning("Error adding file", - "Could not add '" + filename + - "' to the sketch.", e); - } - } - - // make the tabs update after this guy is added - if (addingCode) { - String newName = destFile.getName(); - int newFlavor = -1; - if (newName.toLowerCase().endsWith(".pde")) { - newName = newName.substring(0, newName.length() - 4); - newFlavor = PDE; - } else { - newName = newName.substring(0, newName.length() - 5); - newFlavor = JAVA; - } - - // see also "nameCode" for identical situation - PdeCode newCode = new PdeCode(newName, destFile, newFlavor); - insertCode(newCode); - sortCode(); - setCurrent(newName); - editor.header.repaint(); - } - } - - - public void addLibrary(String jarPath) { - String list[] = PdeCompiler.packageListFromClassPath(jarPath); - - // import statements into the main sketch file (code[0]) - // if the current code is a .java file, insert into current - if (current.flavor == PDE) { - setCurrent(0); - } - // could also scan the text in the file to see if each import - // statement is already in there, but if the user has the import - // commented out, then this will be a problem. - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < list.length; i++) { - buffer.append("import "); - buffer.append(list[i]); - buffer.append(".*;\n"); - } - buffer.append('\n'); - buffer.append(editor.getText()); - editor.setText(buffer.toString(), false); - setModified(); - } - - - /** - * Change what file is currently being edited. - * 1. store the String for the text of the current file. - * 2. retrieve the String for the text of the new file. - * 3. change the text that's visible in the text area - */ - public void setCurrent(int which) { - // get the text currently being edited - //program[current] = editor.getText(); - if (current != null) { - current.program = editor.getText(); - } - - current = code[which]; - - // set to the text for this file - // 'true' means to wipe out the undo buffer - // (so they don't undo back to the other file.. whups!) - editor.setText(current.program, true); - - // and i'll personally make a note of the change - //current = which; - - editor.header.rebuild(); - } - - - /** - * Internal helper function to set the current tab - * based on a name (used by codeNew and codeRename). - */ - protected void setCurrent(String findName) { - for (int i = 0; i < codeCount; i++) { - if (findName.equals(code[i].name)) { - setCurrent(i); - return; - } - } - } - - - /** - * Cleanup temporary files used during a build/run. - */ - protected void cleanup() { - // if the java runtime is holding onto any files in the build dir, we - // won't be able to delete them, so we need to force a gc here - // - System.gc(); - - // note that we can't remove the builddir itself, otherwise - // the next time we start up, internal runs using PdeRuntime won't - // work because the build dir won't exist at startup, so the classloader - // will ignore the fact that that dir is in the CLASSPATH in run.sh - // - //File dirObject = new File(TEMP_BUILD_PATH); - //PdeBase.removeDescendants(dirObject); - PdeBase.removeDescendants(tempBuildFolder); - } - - - /** - * Preprocess, Compile, and Run the current code. - * This is not Runnable.run(), but a handler for the run() command. - * - * There are three main parts to this process: - * - * (0. if not java, then use another 'engine'.. i.e. python) - * - * 1. do the p5 language preprocessing - * this creates a working .java file in a specific location - * better yet, just takes a chunk of java code and returns a - * new/better string editor can take care of saving this to a - * file location - * - * 2. compile the code from that location - * catching errors along the way - * placing it in a ready classpath, or .. ? - * - * 3. run the code - * needs to communicate location for window - * and maybe setup presentation space as well - * run externally if a code folder exists, - * or if more than one file is in the project - * - * X. afterwards, some of these steps need a cleanup function - */ - //public void run() throws PdeException { - public boolean handleRun() throws PdeException { - current.program = editor.getText(); - - // TODO record history here - //current.history.record(program, PdeHistory.RUN); - - // if an external editor is being used, need to grab the - // latest version of the code from the file. - if (PdePreferences.getBoolean("editor.external")) { - // history gets screwed by the open.. - //String historySaved = history.lastRecorded; - //handleOpen(sketch); - //history.lastRecorded = historySaved; - - // nuke previous files and settings, just get things loaded - load(); - } - - // in case there were any boogers left behind - // do this here instead of after exiting, since the exit - // can happen so many different ways.. and this will be - // better connected to the dataFolder stuff below. - cleanup(); - - // make up a temporary class name to suggest. - // name will only be used if the code is not in ADVANCED mode. - String suggestedClassName = - ("Temporary_" + String.valueOf((int) (Math.random() * 10000)) + - "_" + String.valueOf((int) (Math.random() * 10000))); - - // handle preprocessing the main file's code - mainClassName = build(TEMP_BUILD_PATH, suggestedClassName); - // externalPaths is magically set by build() - - if (!externalRuntime) { // only if not running externally already - // copy contents of data dir into lib/build - if (dataFolder.exists()) { - // just drop the files in the build folder (pre-68) - //PdeBase.copyDir(dataDir, buildDir); - // drop the files into a 'data' subfolder of the build dir - try { - PdeBase.copyDir(dataFolder, new File(tempBuildFolder, "data")); - } catch (IOException e) { - e.printStackTrace(); - throw new PdeException("Problem copying files from data folder"); - } - } - } - - // if the compilation worked, run the applet -// if (mainClassName != null) { - - /* - if (externalPaths == null) { - externalPaths = - PdeCompiler.calcClassPath(null) + File.pathSeparator + - tempBuildPath; - } else { - externalPaths = - tempBuildPath + File.pathSeparator + - PdeCompiler.calcClassPath(null) + File.pathSeparator + - externalPaths; - } - */ - - // get a useful folder name for the 'code' folder - // so that it can be included in the java.library.path - /* - String libraryPath = ""; - if (externalCode != null) { - libraryPath = externalCode.getCanonicalPath(); - } - */ - - // create a runtime object -// runtime = new PdeRuntime(this, editor); - - // if programType is ADVANCED - // or the code/ folder is not empty -> or just exists (simpler) - // then set boolean for external to true - // include path to build in front, then path for code folder - // when passing the classpath through - // actually, build will already be in there, just prepend code - - // use the runtime object to consume the errors now - // no need to bother recycling the old guy - //PdeMessageStream messageStream = new PdeMessageStream(runtime); - - // start the applet -// runtime.start(presenting ? presentLocation : appletLocation); //, - //new PrintStream(messageStream)); - - // spawn a thread to update PDE GUI state -// watcher = new RunButtonWatcher(); - -// } else { - // [dmose] throw an exception here? - // [fry] iirc the exception will have already been thrown -// cleanup(); -// } - return (mainClassName != null); - } - - - /** - * Have the contents of the currently visible tab been modified? - */ - /* - public boolean isCurrentModified() { - return modified[current]; - } - */ - - - /** - * Build all the code for this sketch. - * - * In an advanced program, the returned classname could be different, - * which is why the className is set based on the return value. - * A compilation error will burp up a PdeException. - * - * @return null if compilation failed, main class name if not - */ - protected String build(String buildPath, String suggestedClassName) - throws PdeException { - //String importPackageList[] = null; - String javaClassPath = System.getProperty("java.class.path"); - // remove quotes if any.. this is an annoying thing on windows - if (javaClassPath.startsWith("\"") && javaClassPath.endsWith("\"")) { - javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1); - } - javaClassPath = PdeSketchbook.librariesClassPath + File.pathSeparator + - javaClassPath; - - return build(buildPath, suggestedClassName, null, null, - PdeCompiler.calcBootClassPath(), javaClassPath); - } - - protected String build(String buildPath, String suggestedClassName, - String baseClass, String[] baseImports, - String bootClassPath, String additionalClassPath) - throws PdeException { - - String codeFolderPackages[] = null; - - classPath = buildPath; - if (additionalClassPath != null) { - classPath += File.pathSeparator + additionalClassPath; - } - - // figure out the contents of the code folder to see if there - // are files that need to be added to the imports - //File codeFolder = new File(folder, "code"); - if (codeFolder.exists()) { - externalRuntime = true; - classPath += File.pathSeparator + - PdeCompiler.contentsToClassPath(codeFolder); - //importPackageList = PdeCompiler.packageListFromClassPath(classPath); - libraryPath = codeFolder.getAbsolutePath(); - - // get a list of .jar files in the "code" folder - // (class files in subfolders should also be picked up) - String codeFolderClassPath = - PdeCompiler.contentsToClassPath(codeFolder); - // get list of packages found in those jars - codeFolderPackages = - PdeCompiler.packageListFromClassPath(codeFolderClassPath); - //PApplet.println(libraryPath); - //PApplet.println("packages:"); - //PApplet.printarr(codeFolderPackages); - } else { - // check to see if multiple files that include a .java file - externalRuntime = false; - for (int i = 0; i < codeCount; i++) { - if (code[i].flavor == JAVA) externalRuntime = true; - } - //externalRuntime = (codeCount > 1); // may still be set true later - //importPackageList = null; - libraryPath = ""; - } - - // if 'data' folder is large, set to external runtime - if (dataFolder.exists() && - PdeBase.calcFolderSize(dataFolder) > 768 * 1024) { // if > 768k - externalRuntime = true; - } - - - // 1. concatenate all .pde files to the 'main' pde - // store line number for starting point of each code bit - - StringBuffer bigCode = new StringBuffer(code[0].program); - int bigCount = countLines(code[0].program); - - for (int i = 1; i < codeCount; i++) { - if (code[i].flavor == PDE) { - code[i].lineOffset = ++bigCount; - bigCode.append('\n'); - bigCode.append(code[i].program); - bigCount += countLines(code[i].program); - code[i].preprocName = null; // don't compile me - } - } - - - // 2. run preproc on that code using the sugg class name - // to create a single .java file and write to buildpath - - String primaryClassName = null; - - PdePreprocessor preprocessor = new PdePreprocessor(); - try { - // if (i != 0) preproc will fail if a pde file is not - // java mode, since that's required - preprocessor.setBaseClass(baseClass); - preprocessor.setBaseImports(baseImports); - - String className = - preprocessor.write(bigCode.toString(), buildPath, - suggestedClassName, codeFolderPackages); - //preprocessor.write(bigCode.toString(), buildPath, - // suggestedClassName, importPackageList); - if (className == null) { - throw new PdeException("Could not find main class"); - // this situation might be perfectly fine, - // (i.e. if the file is empty) - //System.out.println("No class found in " + code[i].name); - //System.out.println("(any code in that file will be ignored)"); - //System.out.println(); - - } else { - code[0].preprocName = className + ".java"; - } - - // store this for the compiler and the runtime - primaryClassName = className; - //System.out.println("primary class " + primaryClassName); - - // check if the 'main' file is in java mode - if ((PdePreprocessor.programType == PdePreprocessor.JAVA) || - (preprocessor.extraImports.length != 0)) { - externalRuntime = true; // we in advanced mode now, boy - } - - } catch (antlr.RecognitionException re) { - // this even returns a column - int errorFile = 0; - int errorLine = re.getLine() - 1; - for (int i = 1; i < codeCount; i++) { - if ((code[i].flavor == PDE) && - (code[i].lineOffset < errorLine)) { - errorFile = i; - } - } - errorLine -= code[errorFile].lineOffset; - - throw new PdeException(re.getMessage(), errorFile, - errorLine, re.getColumn()); - - } catch (antlr.TokenStreamRecognitionException tsre) { - // while this seems to store line and column internally, - // there doesn't seem to be a method to grab it.. - // so instead it's done using a regexp - PatternMatcher matcher = new Perl5Matcher(); - PatternCompiler compiler = new Perl5Compiler(); - // line 3:1: unexpected char: 0xA0 - String mess = "^line (\\d+):(\\d+):\\s"; - - Pattern pattern = null; - try { - pattern = compiler.compile(mess); - } catch (MalformedPatternException e) { - PdeBase.showWarning("Internal Problem", - "An internal error occurred while trying\n" + - "to compile the sketch. Please report\n" + - "this online at http://processing.org/bugs", e); - } - - PatternMatcherInput input = - new PatternMatcherInput(tsre.toString()); - if (matcher.contains(input, pattern)) { - MatchResult result = matcher.getMatch(); - - int errorLine = Integer.parseInt(result.group(1).toString()) - 1; - int errorColumn = Integer.parseInt(result.group(2).toString()); - int errorFile = 0; - for (int i = 1; i < codeCount; i++) { - if ((code[i].flavor == PDE) && - (code[i].lineOffset < errorLine)) { - errorFile = i; - } - } - errorLine -= code[errorFile].lineOffset; - - throw new PdeException(tsre.getMessage(), - errorFile, errorLine, errorColumn); - - } else { - // this is bad, defaults to the main class.. hrm. - throw new PdeException(tsre.toString(), 0, -1, -1); - } - - } catch (PdeException pe) { - // PdeExceptions are caught here and re-thrown, so that they don't - // get lost in the more general "Exception" handler below. - throw pe; - - } catch (Exception ex) { - // TODO better method for handling this? - System.err.println("Uncaught exception type:" + ex.getClass()); - ex.printStackTrace(); - throw new PdeException(ex.toString()); - } - - // grab the imports from the code just preproc'd - - importedLibraries = new Vector(); - String imports[] = preprocessor.extraImports; - for (int i = 0; i < imports.length; i++) { - // remove things up to the last dot - String entry = imports[i].substring(0, imports[i].lastIndexOf('.')); - //System.out.println("found package " + entry); - File libFolder = (File) PdeSketchbook.importToLibraryTable.get(entry); - if (libFolder == null) { - //throw new PdeException("Could not find library for " + entry); - continue; - } - //System.out.println(" found lib folder " + libFolder); - importedLibraries.add(libFolder); - - libraryPath += File.pathSeparator + libFolder.getAbsolutePath(); - } - - - // 3. then loop over the code[] and save each .java file - - for (int i = 0; i < codeCount; i++) { - if (code[i].flavor == JAVA) { - // no pre-processing services necessary for java files - // just write the the contents of 'program' to a .java file - // into the build directory. uses byte stream and reader/writer - // shtuff so that unicode bunk is properly handled - String filename = code[i].name + ".java"; - try { - PdeBase.saveFile(code[i].program, new File(buildPath, filename)); - } catch (IOException e) { - e.printStackTrace(); - throw new PdeException("Problem moving " + filename + - " to the build folder"); - } - code[i].preprocName = filename; - } - } - - // compile the program. errors will happen as a PdeException - // that will bubble up to whomever called build(). - // - PdeCompiler compiler = new PdeCompiler(); - boolean success = compiler.compile(this, buildPath, bootClassPath); - //System.out.println("success = " + success + " ... " + primaryClassName); - return success ? primaryClassName : null; - } - - - protected int countLines(String what) { - char c[] = what.toCharArray(); - int count = 0; - for (int i = 0; i < c.length; i++) { - if (c[i] == '\n') count++; - } - return count; - } - - - /** - * Called by PdeEditor to handle someone having selected 'export'. - * Pops up a dialog box for export options, and then calls the - * necessary function with the parameters from the window. - * - * +-------------------------------------------------------+ - * + + - * + Export to: [ Applet (for the web) + ] [ OK ] + - * + + - * + > Advanced + - * + + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Version: [ Java 1.1 + ] + - * + + - * + Recommended version of Java when exporting applets. + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Version: [ Java 1.3 + ] + - * + + - * + Java 1.3 is not recommended for applets, + - * + unless you are using features that require it. + - * + Using a version of Java other than 1.1 will require + - * + your Windows users to install the Java Plug-In, + - * + and your Macintosh users to be running OS X. + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Version: [ Java 1.4 + ] + - * + + - * + identical message as 1.3 above... + - * + + - * +-------------------------------------------------------+ - * - * +-------------------------------------------------------+ - * + + - * + Export to: [ Application + ] [ OK ] + - * + + - * + > Advanced + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Version: [ Java 1.1 + ] + - * + + - * + Not much point to using Java 1.1 for applications. + - * + To run applications, all users will have to + - * + install Java, in which case they'll most likely + - * + have version 1.3 or later. + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Version: [ Java 1.3 + ] + - * + + - * + Java 1.3 is the recommended setting for exporting + - * + applications. Applications will run on any Windows + - * + or Unix machine with Java installed. Mac OS X has + - * + Java installed with the operation system, so there + - * + is no additional installation will be required. + - * + + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + + - * + Platform: [ Mac OS X + ] <-- defaults to current platform - * + + - * + Exports the application as a double-clickable + - * + .app package, compatible with Mac OS X. + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Platform: [ Windows + ] + - * + + - * + Exports the application as a double-clickable + - * + .exe and a handful of supporting files. + - * + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - * + Platform: [ jar file + ] + - * + + - * + A jar file can be used on any platform that has + - * + Java installed. Simply doube-click the jar (or type + - * + "java -jar sketch.jar" at a command prompt) to run + - * + the application. It is the least fancy method for + - * + exporting. + - * + + - * +-------------------------------------------------------+ - * - - * +-------------------------------------------------------+ - * + + - * + Export to: [ Library + ] [ OK ] + - * + + - * +-------------------------------------------------------+ - */ - //public boolean export() throws Exception { - //return exportApplet(true); - //} - - - public boolean exportApplet(/*boolean replaceHtml*/) throws Exception { - boolean replaceHtml = true; - //File appletDir, String exportSketchName, File dataDir) { - //String program = textarea.getText(); - - // create the project directory - // pass null for datapath because the files shouldn't be - // copied to the build dir.. that's only for the temp stuff - File appletDir = new File(folder, "applet"); - - boolean writeHtml = true; - if (appletDir.exists()) { - File htmlFile = new File(appletDir, "index.html"); - if (htmlFile.exists() && !replaceHtml) { - writeHtml = false; - } - } else { - appletDir.mkdirs(); - } - - // build the sketch - String foundName = build(appletDir.getPath(), name); - - // (already reported) error during export, exit this function - if (foundName == null) return false; - - // if name != exportSketchName, then that's weirdness - // BUG unfortunately, that can also be a bug in the preproc :( - if (!name.equals(foundName)) { - PdeBase.showWarning("Error during export", - "Sketch name is " + name + " but the sketch\n" + - "name in the code was " + foundName, null); - return false; - } - - if (writeHtml) { - int wide = PApplet.DEFAULT_WIDTH; - int high = PApplet.DEFAULT_HEIGHT; - - //try { - PatternMatcher matcher = new Perl5Matcher(); - PatternCompiler compiler = new Perl5Compiler(); - - // this matches against any uses of the size() function, - // whether they contain numbers of variables or whatever. - // this way, no warning is shown if size() isn't actually - // used in the applet, which is the case especially for - // beginners that are cutting/pasting from the reference. - String sizing = - "[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\S+)\\s*\\);"; - Pattern pattern = compiler.compile(sizing); - - // adds a space at the beginning, in case size() is the very - // first thing in the program (very common), since the regexp - // needs to check for things in front of it. - PatternMatcherInput input = - new PatternMatcherInput(" " + code[0].program); - if (matcher.contains(input, pattern)) { - MatchResult result = matcher.getMatch(); - try { - wide = Integer.parseInt(result.group(1).toString()); - high = Integer.parseInt(result.group(2).toString()); - - } catch (NumberFormatException e) { - // found a reference to size, but it didn't - // seem to contain numbers - final String message = - "The size of this applet could not automatically be\n" + - "determined from your code. You'll have to edit the\n" + - "HTML file to set the size of the applet."; - - PdeBase.showWarning("Could not find applet size", message, null); - } - } // else no size() command found - - // handle this in editor instead, rare or nonexistant - //} catch (MalformedPatternException e) { - //PdeBase.showWarning("Internal Problem", - // "An internal error occurred while trying\n" + - // "to export the sketch. Please report this.", e); - //return false; - //} - - StringBuffer sources = new StringBuffer(); - for (int i = 0; i < codeCount; i++) { - sources.append("" + - code[i].name + " "); - } - - File htmlOutputFile = new File(appletDir, "index.html"); - FileOutputStream fos = new FileOutputStream(htmlOutputFile); - PrintStream ps = new PrintStream(fos); - - // @@sketch@@, @@width@@, @@height@@, @@archive@@, @@source@@ - - InputStream is = null; - // if there is an applet.html file in the sketch folder, use that - File customHtml = new File(folder, "applet.html"); - if (customHtml.exists()) { - is = new FileInputStream(customHtml); - } - if (is == null) { - is = PdeBase.getStream("applet.html"); - } - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - - String line = null; - while ((line = reader.readLine()) != null) { - if (line.indexOf("@@") != -1) { - StringBuffer sb = new StringBuffer(line); - int index = 0; - while ((index = sb.indexOf("@@sketch@@")) != -1) { - sb.replace(index, index + "@@sketch@@".length(), - name); - } - while ((index = sb.indexOf("@@source@@")) != -1) { - sb.replace(index, index + "@@source@@".length(), - sources.toString()); - } - while ((index = sb.indexOf("@@archive@@")) != -1) { - sb.replace(index, index + "@@archive@@".length(), - name + ".jar"); - } - while ((index = sb.indexOf("@@width@@")) != -1) { - sb.replace(index, index + "@@width@@".length(), - String.valueOf(wide)); - } - while ((index = sb.indexOf("@@height@@")) != -1) { - sb.replace(index, index + "@@height@@".length(), - String.valueOf(high)); - } - line = sb.toString(); - } - ps.println(line); - } - - reader.close(); - ps.flush(); - ps.close(); - } - - // copy the source files to the target, since we like - // to encourage people to share their code - for (int i = 0; i < codeCount; i++) { - try { - PdeBase.copyFile(code[i].file, - new File(appletDir, code[i].file.getName())); - } catch (IOException e) { - - } - } - - // create new .jar file - FileOutputStream zipOutputFile = - new FileOutputStream(new File(appletDir, name + ".jar")); - ZipOutputStream zos = new ZipOutputStream(zipOutputFile); - ZipEntry entry; - - // add the contents of the code folder to the jar - // unpacks all jar files - //File codeFolder = new File(folder, "code"); - if (codeFolder.exists()) { - String includes = PdeCompiler.contentsToClassPath(codeFolder); - packClassPathIntoZipFile(includes, zos); - } - - // add contents of 'library' folders to the jar file - // if a file called 'export.txt' is in there, it contains - // a list of the files that should be exported. - // otherwise, all files are exported. - Enumeration enum = importedLibraries.elements(); - while (enum.hasMoreElements()) { - // in the list is a File object that points the - // library sketch's "library" folder - File libraryFolder = (File)enum.nextElement(); - //System.out.println("exporting files from " + libFolder); - File exportSettings = new File(libraryFolder, "export.txt"); - String exportList[] = null; - if (exportSettings.exists()) { - //exportList = PApplet.loadStrings(exportSettings); - String info[] = PApplet.loadStrings(exportSettings); - for (int i = 0; i < info.length; i++) { - if (info[i].startsWith("applet")) { - int idx = info[i].indexOf('='); // get applet= or applet = - String commas = info[i].substring(idx+1).trim(); - exportList = PApplet.split(commas, ", "); - } - } - } else { - exportList = libraryFolder.list(); - } - for (int i = 0; i < exportList.length; i++) { - if (exportList[i].equals(".") || - exportList[i].equals("..")) continue; - - exportList[i] = PApplet.trim(exportList[i]); - if (exportList[i].equals("")) continue; - - File exportFile = new File(libraryFolder, exportList[i]); - if (!exportFile.exists()) { - System.err.println("File " + exportList[i] + " does not exist"); - - } else if (exportFile.isDirectory()) { - System.err.println("Ignoring sub-folder \"" + exportList[i] + "\""); - - } else if (exportFile.getName().toLowerCase().endsWith(".zip") || - exportFile.getName().toLowerCase().endsWith(".jar")) { - packClassPathIntoZipFile(exportFile.getAbsolutePath(), zos); - - } else { // just copy the file over.. prolly a .dll or something - PdeBase.copyFile(exportFile, - new File(appletDir, exportFile.getName())); - } - } - } - - // add the appropriate bagel to the classpath - /* - String jdkVersion = PdePreferences.get("compiler.jdk_version"); - String bagelJar = "lib/export11.jar"; // default - if (jdkVersion.equals("1.3") || jdkVersion.equals("1.4")) { - bagelJar = "lib/export13.jar"; - } - */ - String bagelJar = "lib/core.jar"; - - //if (jdkVersionStr.equals("1.3")) { bagelJar = "export13.jar" }; - //if (jdkVersionStr.equals("1.4")) { bagelJar = "export14.jar" }; - packClassPathIntoZipFile(bagelJar, zos); - - /* - // add the contents of lib/export to the jar file - // these are the jdk11-only bagel classes - String exportDir = ("lib" + File.separator + - "export" + File.separator); - String bagelClasses[] = new File(exportDir).list(); - - for (int i = 0; i < bagelClasses.length; i++) { - if (!bagelClasses[i].endsWith(".class")) continue; - entry = new ZipEntry(bagelClasses[i]); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(exportDir + bagelClasses[i]))); - zos.closeEntry(); - } - */ - - // TODO these two loops are insufficient. - // should instead recursively add entire contents of build folder - // the data folder will already be a subdirectory - // and the classes may be buried in subfolders if a package name was used - - // files to include from data directory - //if ((dataDir != null) && (dataDir.exists())) { - if (dataFolder.exists()) { - String dataFiles[] = dataFolder.list(); - for (int i = 0; i < dataFiles.length; i++) { - // don't export hidden files - // skipping dot prefix removes all: . .. .DS_Store - if (dataFiles[i].charAt(0) == '.') continue; - - entry = new ZipEntry(dataFiles[i]); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(dataFolder, dataFiles[i]))); - zos.closeEntry(); - } - } - - // add the project's .class files to the jar - // just grabs everything from the build directory - // since there may be some inner classes - // (add any .class files from the applet dir, then delete them) - String classfiles[] = appletDir.list(); - for (int i = 0; i < classfiles.length; i++) { - if (classfiles[i].endsWith(".class")) { - entry = new ZipEntry(classfiles[i]); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(appletDir, classfiles[i]))); - zos.closeEntry(); - } - } - - // remove the .class files from the applet folder. if they're not - // removed, the msjvm will complain about an illegal access error, - // since the classes are outside the jar file. - for (int i = 0; i < classfiles.length; i++) { - if (classfiles[i].endsWith(".class")) { - File deadguy = new File(appletDir, classfiles[i]); - if (!deadguy.delete()) { - PdeBase.showWarning("Could not delete", - classfiles[i] + " could not \n" + - "be deleted from the applet folder. \n" + - "You'll need to remove it by hand.", null); - } - } - } - - // close up the jar file - zos.flush(); - zos.close(); - - PdeBase.openFolder(appletDir); - - //} catch (Exception e) { - //e.printStackTrace(); - //} - return true; - } - - - public boolean exportApplication() { - return true; - } - - - public boolean exportLibrary() { - return true; - } - - - /** - * Slurps up .class files from a colon (or semicolon on windows) - * separated list of paths and adds them to a ZipOutputStream. - */ - static public void packClassPathIntoZipFile(String path, - ZipOutputStream zos) - throws IOException { - String pieces[] = PApplet.split(path, File.pathSeparatorChar); - - for (int i = 0; i < pieces.length; i++) { - if (pieces[i].length() == 0) continue; - //System.out.println("checking piece " + pieces[i]); - - // is it a jar file or directory? - if (pieces[i].toLowerCase().endsWith(".jar") || - pieces[i].toLowerCase().endsWith(".zip")) { - try { - ZipFile file = new ZipFile(pieces[i]); - Enumeration entries = file.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = (ZipEntry) entries.nextElement(); - if (entry.isDirectory()) { - // actually 'continue's for all dir entries - - } else { - String name = entry.getName(); - // ignore contents of the META-INF folders - if (name.indexOf("META-INF") == 0) continue; - ZipEntry entree = new ZipEntry(name); - - zos.putNextEntry(entree); - byte buffer[] = new byte[(int) entry.getSize()]; - InputStream is = file.getInputStream(entry); - - int offset = 0; - int remaining = buffer.length; - while (remaining > 0) { - int count = is.read(buffer, offset, remaining); - offset += count; - remaining -= count; - } - - zos.write(buffer); - zos.flush(); - zos.closeEntry(); - } - } - } catch (IOException e) { - System.err.println("Error in file " + pieces[i]); - e.printStackTrace(); - } - } else { // not a .jar or .zip, prolly a directory - File dir = new File(pieces[i]); - // but must be a dir, since it's one of several paths - // just need to check if it exists - if (dir.exists()) { - packClassPathIntoZipFileRecursive(dir, null, zos); - } - } - } - } - - - /** - * Continue the process of magical exporting. This function - * can be called recursively to walk through folders looking - * for more goodies that will be added to the ZipOutputStream. - */ - static public void packClassPathIntoZipFileRecursive(File dir, - String sofar, - ZipOutputStream zos) - throws IOException { - String files[] = dir.list(); - for (int i = 0; i < files.length; i++) { - //if (files[i].equals(".") || files[i].equals("..")) continue; - // ignore . .. and .DS_Store - if (files[i].charAt(0) == '.') continue; - - File sub = new File(dir, files[i]); - String nowfar = (sofar == null) ? - files[i] : (sofar + "/" + files[i]); - - if (sub.isDirectory()) { - packClassPathIntoZipFileRecursive(sub, nowfar, zos); - - } else { - // don't add .jar and .zip files, since they only work - // inside the root, and they're unpacked - if (!files[i].toLowerCase().endsWith(".jar") && - !files[i].toLowerCase().endsWith(".zip") && - files[i].charAt(0) != '.') { - ZipEntry entry = new ZipEntry(nowfar); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(sub)); - zos.closeEntry(); - } - } - } - } - - - /** - * Returns true if this is a read-only sketch. Used for the - * examples directory, or when sketches are loaded from read-only - * volumes or folders without appropraite permissions. - */ - public boolean isReadOnly() { - String apath = folder.getAbsolutePath(); - if (apath.startsWith(PdeSketchbook.examplesPath) || - apath.startsWith(PdeSketchbook.librariesPath)) { - return true; - - // this doesn't work on directories - //} else if (!folder.canWrite()) { - } else { - // check to see if each modified code file can be written to - for (int i = 0; i < codeCount; i++) { - if (code[i].modified && !code[i].file.canWrite()) { - //System.err.println("found a read-only file " + code[i].file); - return true; - } - } - //return true; - } - return false; - } - - - /** - * Returns path to the main .pde file for this sketch. - */ - public String getMainFilePath() { - return code[0].file.getAbsolutePath(); - } - - /** Packages up sketch into an executable midlet with JAD descriptor. - */ - public boolean exportMIDlet() throws Exception { - boolean replaceJad = true; - - // create the project directory - File midletDir = new File(folder, "midlet"); - - boolean writeJad = true; - if (midletDir.exists()) { - File jadFile = new File(midletDir, name + ".jad"); - if (jadFile.exists() && !replaceJad) { - writeJad = false; - } - //// delete any existing jar file - File jarFile = new File(midletDir, name + ".jar"); - if (jarFile.exists()) { - jarFile.delete(); - } - } else { - midletDir.mkdirs(); - } - - // build the sketch - String wtkPath = PdePreferences.get("wtk.path"); - if (wtkPath == null) { - PdeBase.showWarning("Sun Wireless Toolkit (WTK) not found", - "Please specify the location of the WTK in your preferences.txt file. Example:\n\n" + - "wtk.path=C:\\WTK22", null); - } - String wtkLibPath = wtkPath + File.separator + "lib" + File.separator; - String baseClass = "PMIDlet"; - String[] baseImports = {}; - String bootClassPath = wtkLibPath + "cldcapi10.jar" + File.pathSeparator + - wtkLibPath + "midpapi10.jar"; - //// this is just to satisfy Jikes which wants java.io.Serializable and java.lang.Cloneable to be reachable... - //System.out.println(System.getProperty ("java.home")); - bootClassPath += File.pathSeparator + System.getProperty("java.home") + File.separator + "lib" + File.separator + "rt.jar"; - String additionalClassPath = "lib" + File.separator + "mobile.jar"; - String foundName = build(midletDir.getPath(), name, baseClass, baseImports, - bootClassPath, additionalClassPath); - - // (already reported) error during export, exit this function - if (foundName == null) return false; - - // if name != exportSketchName, then that's weirdness - // BUG unfortunately, that can also be a bug in the preproc :( - if (!name.equals(foundName)) { - PdeBase.showWarning("Error during export", - "Sketch name is " + name + " but the sketch\n" + - "name in the code was " + foundName, null); - return false; - } - - //// preverify class files into temporary directory - PdePreverifier preverifier = new PdePreverifier(); - File tmpDir = new File(folder, "tmp"); - if (preverifier.preverify(midletDir, tmpDir) != true) { - return false; - } - - //// generate manifest file and JAD file - File mfOutputFile = new File(tmpDir, "MANIFEST.MF"); - FileOutputStream fos = new FileOutputStream(mfOutputFile); - PrintStream ps = new PrintStream(fos); - - File jadFile = new File(midletDir, name + ".jad"); - PrintStream jadPs = new PrintStream(new FileOutputStream(jadFile)); - - InputStream is = null; - // if there is a mobile.mf file in the sketch folder, use that - File customMf = new File(folder, "mobile.mf"); - if (customMf.exists()) { - is = new FileInputStream(customMf); - } - if (is == null) { - is = PdeBase.getStream("mobile.mf"); - } - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - - String line = null; - while ((line = reader.readLine()) != null) { - if (line.indexOf("@@") != -1) { - StringBuffer sb = new StringBuffer(line); - int index = 0; - while ((index = sb.indexOf("@@sketch@@")) != -1) { - sb.replace(index, index + "@@sketch@@".length(), - name); - } - line = sb.toString(); - } - ps.println(line); - jadPs.println(line); - } - reader.close(); - ps.flush(); - ps.close(); - - // create new .jar file - File jarFile = new File(midletDir, name + ".jar"); - FileOutputStream zipOutputFile = - new FileOutputStream(jarFile); - ZipOutputStream zos = new ZipOutputStream(zipOutputFile); - ZipEntry entry; - - // add the contents of the code folder to the jar - // unpacks all jar files - //File codeFolder = new File(folder, "code"); - if (codeFolder.exists()) { - String includes = PdeCompiler.contentsToClassPath(codeFolder); - packClassPathIntoZipFile(includes, zos); - } - - // add contents of 'library' folders to the jar file - // if a file called 'export.txt' is in there, it contains - // a list of the files that should be exported. - // otherwise, all files are exported. - Enumeration enum = importedLibraries.elements(); - while (enum.hasMoreElements()) { - // in the list is a File object that points the - // library sketch's "library" folder - File libraryFolder = (File)enum.nextElement(); - //System.out.println("exporting files from " + libFolder); - File exportSettings = new File(libraryFolder, "export.txt"); - String exportList[] = null; - if (exportSettings.exists()) { - //exportList = PApplet.loadStrings(exportSettings); - String info[] = PApplet.loadStrings(exportSettings); - for (int i = 0; i < info.length; i++) { - if (info[i].startsWith("applet")) { - int idx = info[i].indexOf('='); // get applet= or applet = - String commas = info[i].substring(idx+1).trim(); - exportList = PApplet.split(commas, ", "); - } - } - } else { - exportList = libraryFolder.list(); - } - for (int i = 0; i < exportList.length; i++) { - if (exportList[i].equals(".") || - exportList[i].equals("..")) continue; - - exportList[i] = PApplet.trim(exportList[i]); - if (exportList[i].equals("")) continue; - - File exportFile = new File(libraryFolder, exportList[i]); - if (!exportFile.exists()) { - System.err.println("File " + exportList[i] + " does not exist"); - - } else if (exportFile.isDirectory()) { - System.err.println("Ignoring sub-folder \"" + exportList[i] + "\""); - - } else if (exportFile.getName().toLowerCase().endsWith(".zip") || - exportFile.getName().toLowerCase().endsWith(".jar")) { - packClassPathIntoZipFile(exportFile.getAbsolutePath(), zos); - - } else { // just copy the file over.. prolly a .dll or something - PdeBase.copyFile(exportFile, - new File(midletDir, exportFile.getName())); - } - } - } - - //// add the mobile core - packClassPathIntoZipFile(additionalClassPath, zos); - - // files to include from data directory - //if ((dataDir != null) && (dataDir.exists())) { - if (dataFolder.exists()) { - String dataFiles[] = dataFolder.list(); - for (int i = 0; i < dataFiles.length; i++) { - // don't export hidden files - // skipping dot prefix removes all: . .. .DS_Store - if (dataFiles[i].charAt(0) == '.') continue; - - entry = new ZipEntry(dataFiles[i]); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(dataFolder, dataFiles[i]))); - zos.closeEntry(); - } - } - - //// add the preverified .class files to the jar - String classfiles[] = tmpDir.list(); - for (int i = 0; i < classfiles.length; i++) { - if (classfiles[i].endsWith(".class")) { - entry = new ZipEntry(classfiles[i]); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(tmpDir, classfiles[i]))); - zos.closeEntry(); - } else if (classfiles[i].endsWith(".MF")) { - entry = new ZipEntry("META-INF/MANIFEST.MF"); - zos.putNextEntry(entry); - zos.write(PdeBase.grabFile(new File(tmpDir, classfiles[i]))); - zos.closeEntry(); - } - } - - // remove the .class files from the midlet folder - classfiles = midletDir.list(); - for (int i = 0; i < classfiles.length; i++) { - if (classfiles[i].endsWith(".class")) { - File deadguy = new File(midletDir, classfiles[i]); - if (!deadguy.delete()) { - PdeBase.showWarning("Could not delete", - classfiles[i] + " could not \n" + - "be deleted from the applet folder. \n" + - "You'll need to remove it by hand.", null); - } - } - } - - // close up the jar file - zos.flush(); - zos.close(); - - //// now we can get the size of the jar file to generate the JAD file from manifest file - jadPs.println("MIDlet-Jar-URL: " + name + ".jar"); - jadPs.println("MIDlet-Jar-Size: " + jarFile.length()); - jadPs.close(); - - //// delete temporary directory - classfiles = tmpDir.list(); - for (int i = 0; i < classfiles.length; i++) { - File deadguy = new File(tmpDir, classfiles[i]); - if (!deadguy.delete()) { - PdeBase.showWarning("Could not delete", - classfiles[i] + " could not \n" + - "be deleted from the temporary folder. \n" + - "You'll need to remove it by hand.", null); - } - } - tmpDir.delete(); - - return true; - } -} diff --git a/mobile/build/shared/lib/mobile.mf b/mobile/build/shared/lib/mobile.mf deleted file mode 100755 index 881681036..000000000 --- a/mobile/build/shared/lib/mobile.mf +++ /dev/null @@ -1,6 +0,0 @@ -MIDlet-1: @@sketch@@, ,@@sketch@@ -MIDlet-Name: @@sketch@@ -MIDlet-Version: 1.0.0 -MIDlet-Vendor: Processing Mobile 74alpha -MicroEdition-Profile: MIDP-1.0 -MicroEdition-Configuration: CLDC-1.0 \ No newline at end of file diff --git a/mobile/build/windows/build.xml b/mobile/build/windows/build.xml deleted file mode 100755 index 982f77492..000000000 --- a/mobile/build/windows/build.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mobile/core/processing/core/PCanvas.java b/mobile/core/processing/core/PCanvas.java deleted file mode 100755 index 1b33e6b50..000000000 --- a/mobile/core/processing/core/PCanvas.java +++ /dev/null @@ -1,628 +0,0 @@ -package processing.core; - -import javax.microedition.lcdui.*; - -import java.util.*; - -/** - * - * @author Francis Li - */ -public class PCanvas extends Canvas { - private PMIDlet midlet; - - private Image buffer; - private Graphics bufferg; - - private int width; - private int height; - - private boolean stroke; - private int strokeWidth; - private int strokeColor; - - private boolean fill; - private int fillColor; - - private int rectMode; - private int ellipseMode; - - private int shapeMode; - private int[] vertex; - private int vertexIndex; - private int[] curveVertex; - private int curveVertexIndex; - - private int textMode; - - /** Creates a new instance of PCanvas */ - public PCanvas(PMIDlet midlet) { - this.midlet = midlet; - - width = getWidth(); - height = getHeight(); - - buffer = Image.createImage(width, height); - bufferg = buffer.getGraphics(); - - stroke = true; - strokeColor = 0; - strokeWidth = 1; - - fill = true; - fillColor = 0xFFFFFF; - - rectMode = PMIDlet.CORNER; - ellipseMode = PMIDlet.CORNER; - - shapeMode = -1; - vertex = new int[16]; - vertexIndex = 0; - - curveVertex = new int[8]; - curveVertexIndex = 0; - - textMode = Graphics.TOP | Graphics.LEFT; - - background(200); - } - - protected void paint(Graphics g) { - g.drawImage(buffer, 0, 0, Graphics.LEFT | Graphics.TOP); - } - - protected void keyPressed(int keyCode) { - midlet.keyPressed = true; - - int action = getGameAction(keyCode); - switch (action) { - case Canvas.UP: - midlet.key = PMIDlet.UP; - break; - case Canvas.DOWN: - midlet.key = PMIDlet.DOWN; - break; - case Canvas.LEFT: - midlet.key = PMIDlet.LEFT; - break; - case Canvas.RIGHT: - midlet.key = PMIDlet.RIGHT; - break; - case Canvas.FIRE: - midlet.key = PMIDlet.FIRE; - break; - default: - //// MIDP 1.0 says the KEY_ values map to ASCII values, but I've seen it - //// different on some foreign (i.e. Korean) handsets - if ((keyCode >= Canvas.KEY_NUM0) && (keyCode <= Canvas.KEY_NUM9)) { - midlet.key = (char) ('0' + (keyCode - Canvas.KEY_NUM0)); - } else { - switch (keyCode) { - case Canvas.KEY_POUND: - midlet.key = '#'; - break; - case Canvas.KEY_STAR: - midlet.key = '*'; - break; - } - } - } - midlet.keyPressed(); - } - - protected void keyReleased(int keyCode) { - midlet.keyPressed = false; - midlet.keyReleased(); - } - - public void point(int x1, int y1) { - if (stroke) { - bufferg.setColor(strokeColor); - bufferg.drawLine(x1, y1, x1, y1); - } - } - - public void line(int x1, int y1, int x2, int y2) { - if (stroke) { - bufferg.setColor(strokeColor); - bufferg.drawLine(x1, y1, x2, y2); - if (strokeWidth > 1) { - //// to do - } - } - } - - public void triangle(int x1, int y1, int x2, int y2, int x3, int y3) { - shapeMode = PMIDlet.POLYGON; - vertex[0] = x1; - vertex[1] = y1; - vertex[2] = x2; - vertex[3] = y2; - vertex[4] = x3; - vertex[5] = y3; - vertexIndex = 6; - endShape(); - } - - public void quad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - shapeMode = PMIDlet.POLYGON; - vertex[0] = x1; - vertex[1] = y1; - vertex[2] = x2; - vertex[3] = y2; - vertex[4] = x3; - vertex[5] = y3; - vertex[6] = x4; - vertex[7] = y4; - vertexIndex = 8; - endShape(); - } - - public void rect(int x, int y, int width, int height) { - int temp; - switch (rectMode) { - case PMIDlet.CORNERS: - temp = x; - x = Math.min(x, width); - width = Math.abs(x - temp); - temp = y; - y = Math.min(y, height); - height = Math.abs(y - temp); - break; - case PMIDlet.CENTER_DIAMETER: - x -= width / 2; - y -= height / 2; - break; - } - if (fill) { - bufferg.setColor(fillColor); - bufferg.fillRect(x, y, width, height); - } - if (stroke) { - bufferg.setColor(strokeColor); - bufferg.drawRect(x, y, width, height); - } - } - - public void rectMode(int MODE) { - if ((MODE >= PMIDlet.CORNER) && (MODE <= PMIDlet.CENTER_DIAMETER)) { - rectMode = MODE; - } - } - - public void ellipse(int x, int y, int width, int height) { - int temp; - switch (ellipseMode) { - case PMIDlet.CORNERS: - temp = x; - x = Math.min(x, width); - width = Math.abs(x - temp); - temp = y; - y = Math.min(y, height); - height = Math.abs(y - temp); - break; - case PMIDlet.CENTER_DIAMETER: - x -= width / 2; - y -= height / 2; - break; - case PMIDlet.CENTER_RADIUS: - x -= width; - y -= height; - width *= 2; - height *= 2; - break; - } - if (fill) { - bufferg.setColor(fillColor); - bufferg.fillArc(x, y, width, height, 0, 360); - } - if (stroke) { - bufferg.setColor(strokeColor); - bufferg.drawArc(x, y, width, height, 0, 360); - } - } - - public void ellipseMode(int MODE) { - if ((MODE >= PMIDlet.CORNER) && (MODE <= PMIDlet.CENTER_RADIUS)) { - ellipseMode = MODE; - } - } - - public void curve(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - beginShape(PMIDlet.LINE_STRIP); - curveVertex(x1, y1); - curveVertex(x1, y1); - curveVertex(x2, y2); - curveVertex(x3, y3); - curveVertex(x4, y4); - curveVertex(x4, y4); - endShape(); - } - - public void bezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - beginShape(PMIDlet.LINE_STRIP); - bezierVertex(x1, y1); - bezierVertex(x2, y2); - bezierVertex(x3, y3); - bezierVertex(x4, y4); - endShape(); - } - - public void strokeWeight(int width) { - strokeWidth = width; - } - - public void beginShape(int MODE) { - if ((MODE >= PMIDlet.POINTS) && (MODE <= PMIDlet.POLYGON)) { - shapeMode = MODE; - } else { - shapeMode = PMIDlet.POINTS; - } - vertexIndex = 0; - curveVertexIndex = 0; - } - - public void endShape() { - int i; - int step; - switch (shapeMode) { - case PMIDlet.POINTS: - i = 0; - step = 2; - break; - case PMIDlet.LINES: - i = 2; - step = 4; - break; - case PMIDlet.LINE_STRIP: - case PMIDlet.LINE_LOOP: - i = 2; - step = 2; - break; - case PMIDlet.TRIANGLES: - i = 4; - step = 6; - break; - case PMIDlet.TRIANGLE_STRIP: - i = 4; - step = 2; - break; - case PMIDlet.QUADS: - i = 6; - step = 8; - break; - case PMIDlet.QUAD_STRIP: - i = 6; - step = 4; - break; - case PMIDlet.POLYGON: - polygon(0, vertexIndex - 2); - return; - default: - return; - } - - for (; i < vertexIndex; i += step) { - switch (shapeMode) { - case PMIDlet.POINTS: - point(vertex[i], vertex[i + 1]); - break; - case PMIDlet.LINES: - case PMIDlet.LINE_STRIP: - case PMIDlet.LINE_LOOP: - line(vertex[i - 2], vertex[i - 1], vertex[i], vertex[i + 1]); - break; - case PMIDlet.TRIANGLES: - case PMIDlet.TRIANGLE_STRIP: - polygon(i - 4, i); - break; - case PMIDlet.QUADS: - case PMIDlet.QUAD_STRIP: - polygon(i - 6, i); - break; - } - } - //// handle loop closing - if (shapeMode == PMIDlet.LINE_LOOP) { - if (vertexIndex >= 2) { - line(vertex[vertexIndex - 2], vertex[vertexIndex - 1], vertex[0], vertex[1]); - } - } - - vertexIndex = 0; - } - - private void polygon(int startIndex, int endIndex) { - //// make sure at least 2 vertices - if (endIndex >= (startIndex + 2)) { - //// make sure at least 3 vertices for fill - if (endIndex >= (startIndex + 4)) { - if (fill) { - bufferg.setColor(fillColor); - - //// insertion sort of edges from top-left to bottom right - Vector edges = new Vector(); - int edgeCount = 0; - Edge e1, e2; - int i, j; - int yMin = Integer.MAX_VALUE; - int yMax = Integer.MIN_VALUE; - for (i = startIndex; i <= endIndex; i += 2) { - e1 = new Edge(); - if (i == startIndex) { - //// handle connecting line between start and endpoints - if (vertex[startIndex + 1] < vertex[endIndex + 1]) { - e1.x1 = vertex[startIndex]; - e1.y1 = vertex[startIndex + 1]; - e1.x2 = vertex[endIndex]; - e1.y2 = vertex[endIndex + 1]; - } else { - e1.x1 = vertex[endIndex]; - e1.y1 = vertex[endIndex + 1]; - e1.x2 = vertex[startIndex]; - e1.y2 = vertex[startIndex + 1]; - } - } else if (vertex[i - 1] < vertex[i + 1]) { - e1.x1 = vertex[i - 2]; - e1.y1 = vertex[i - 1]; - e1.x2 = vertex[i]; - e1.y2 = vertex[i + 1]; - } else { - e1.x1 = vertex[i]; - e1.y1 = vertex[i + 1]; - e1.x2 = vertex[i - 2]; - e1.y2 = vertex[i - 1]; - } - e1.x = e1.x1; - e1.dx = e1.x2 - e1.x1; - e1.dy = e1.y2 - e1.y1; - - yMin = Math.min(e1.y1, yMin); - yMax = Math.max(e1.y2, yMax); - - for (j = 0; j < edgeCount; j++) { - e2 = (Edge) edges.elementAt(j); - if (e1.y1 < e2.y1) { - edges.insertElementAt(e1, j); - e1 = null; - break; - } else if (e1.y1 == e2.y1) { - if (e1.x1 < e2.x1) { - edges.insertElementAt(e1, j); - e1 = null; - break; - } - } - } - if (e1 != null) { - edges.addElement(e1); - } - edgeCount += 1; - } - - //// draw scanlines - Vector active = new Vector(); - int activeCount = 0; - for (int y = yMin; y <= yMax; y++) { - //// update currently active edges - for (i = activeCount - 1; i >= 0; i--) { - e1 = (Edge) active.elementAt(i); - if (e1.y2 <= y) { - //// remove edges not intersecting current scan line - active.removeElementAt(i); - activeCount--; - } else { - //// update x coordinate - e1.x = (y - e1.y1) * e1.dx / e1.dy + e1.x1; - } - } - - //// re-sort active edge list - Vector newActive = new Vector(); - for (i = 0; i < activeCount; i++) { - e1 = (Edge) active.elementAt(i); - - for (j = 0; j < i; j++) { - e2 = (Edge) newActive.elementAt(j); - if (e1.x < e2.x) { - newActive.insertElementAt(e1, j); - e1 = null; - break; - } - } - if (e1 != null) { - newActive.addElement(e1); - } - } - active = newActive; - - //// insertion sort any new intersecting edges into active list - for (i = 0; i < edgeCount; i++) { - e1 = (Edge) edges.elementAt(i); - if (e1.y1 == y) { - for (j = 0; j < activeCount; j++) { - e2 = (Edge) active.elementAt(j); - if (e1.x < e2.x) { - active.insertElementAt(e1, j); - e1 = null; - break; - } - } - if (e1 != null) { - active.addElement(e1); - } - activeCount++; - - //// remove from edges list - edges.removeElementAt(i); - edgeCount--; - //// indices are shifted down one - i--; - } else { - break; - } - } - //// draw line segments between pairs of edges - for (i = 1; i < activeCount; i += 2) { - e1 = (Edge) active.elementAt(i - 1); - e2 = (Edge) active.elementAt(i); - - bufferg.drawLine(e1.x, y, e2.x, y); - } - } - } - } - if (stroke) { - for (int i = startIndex + 2; i <= endIndex; i += 2) { - line(vertex[i - 2], vertex[i - 1], vertex[i], vertex[i + 1]); - } - line(vertex[endIndex], vertex[endIndex + 1], vertex[startIndex], vertex[startIndex + 1]); - } - } - } - - public void vertex(int x, int y) { - vertex[vertexIndex] = x; - vertexIndex++; - vertex[vertexIndex] = y; - vertexIndex++; - - int length = vertex.length; - if (vertexIndex == length) { - int[] old = vertex; - vertex = new int[length * 2]; - System.arraycopy(old, 0, vertex, 0, length); - } - } - - public void curveVertex(int x, int y) { - //// use fixed point, 8-bit precision - curveVertex[curveVertexIndex] = x << 8; - curveVertexIndex++; - curveVertex[curveVertexIndex] = y << 8; - curveVertexIndex++; - - if (curveVertexIndex == 8) { - int tension = 128 /* 0.5f */; - - int dx0 = ((curveVertex[4] - curveVertex[0]) * tension) >> 8; - int dx1 = ((curveVertex[6] - curveVertex[2]) * tension) >> 8; - int dy0 = ((curveVertex[5] - curveVertex[1]) * tension) >> 8; - int dy1 = ((curveVertex[7] - curveVertex[3]) * tension) >> 8; - - plotCurveVertices(curveVertex[2], curveVertex[3], - curveVertex[4], curveVertex[5], - dx0, dx1, dy0, dy1); - - for (int i = 0; i < 6; i++) { - curveVertex[i] = curveVertex[i + 2]; - } - curveVertexIndex = 6; - } - } - - public void bezierVertex(int x, int y) { - //// use fixed point, 8-bit precision - curveVertex[curveVertexIndex] = x << 8; - curveVertexIndex++; - curveVertex[curveVertexIndex] = y << 8; - curveVertexIndex++; - - if (curveVertexIndex == 8) { - //// use fixed point, 8-bit precision - int tension = 768 /* 3.0f */; - - int dx0 = ((curveVertex[2] - curveVertex[0]) * tension) >> 8; - int dx1 = ((curveVertex[6] - curveVertex[4]) * tension) >> 8; - int dy0 = ((curveVertex[3] - curveVertex[1]) * tension) >> 8; - int dy1 = ((curveVertex[7] - curveVertex[5]) * tension) >> 8; - - plotCurveVertices(curveVertex[0], curveVertex[1], - curveVertex[6], curveVertex[7], - dx0, dx1, dy0, dy1); - - curveVertexIndex = 0; - } - } - - private void plotCurveVertices(int x0, int y0, int x1, int y1, int dx0, int dx1, int dy0, int dy1) { - int x, y, t, t2, t3, h0, h1, h2, h3; - vertex(x0 >> 8, y0 >> 8); - for (t = 0; t < 256 /* 1.0f */; t += 26 /* 0.1f */) { - t2 = (t * t) >> 8; - t3 = (t * t2) >> 8; - - h0 = ((512 /* 2.0f */ * t3) >> 8) - ((768 /* 3.0f */ * t2) >> 8) + 256 /* 1.0f */; - h1 = ((-512 /* -2.0f */ * t3) >> 8) + ((768 /* 3.0f */ * t2) >> 8); - h2 = t3 - ((512 /* 2.0f */ * t2) >> 8) + t; - h3 = t3 - t2; - - x = ((h0 * x0) >> 8) + ((h1 * x1) >> 8) + ((h2 * dx0) >> 8) + ((h3 * dx1) >> 8); - y = ((h0 * y0) >> 8) + ((h1 * y1) >> 8) + ((h2 * dy0) >> 8) + ((h3 * dy1) >> 8); - vertex(x >> 8, y >> 8); - } - vertex(x1 >> 8, y1 >> 8); - } - - public void translate(int x, int y) { - bufferg.translate(x, y); - } - - public void background(int gray) { - background(gray, gray, gray); - } - - public void background(int value1, int value2, int value3) { - bufferg.setColor(value1, value2, value3); - bufferg.fillRect(0, 0, width, height); - } - - public void stroke(int gray) { - stroke(gray, gray, gray); - } - - public void stroke(int value1, int value2, int value3) { - stroke = true; - strokeColor = ((value1 & 0xFF) << 16) | ((value2 & 0xFF) << 8) | (value3 & 0xFF); - } - - public void noStroke() { - stroke = false; - } - - public void fill(int gray) { - fill(gray, gray, gray); - } - - public void fill(int value1, int value2, int value3) { - fill = true; - fillColor = ((value1 & 0xFF) << 16) | ((value2 & 0xFF) << 8) | (value3 & 0xFF); - } - - public void noFill() { - fill = false; - } - - public void text(String data, int x, int y) { - bufferg.drawString(data, x, y, textMode); - } - - public void textMode(int MODE) { - switch (MODE) { - case PMIDlet.ALIGN_LEFT: - textMode = Graphics.TOP | Graphics.LEFT; - break; - case PMIDlet.ALIGN_RIGHT: - textMode = Graphics.TOP | Graphics.RIGHT; - break; - case PMIDlet.ALIGN_CENTER: - textMode = Graphics.TOP | Graphics.HCENTER; - break; - } - } - - private static class Edge { - public int x1, y1, x2, y2; - public int x, dx, dy; - } -} \ No newline at end of file diff --git a/mobile/core/processing/core/PMIDlet.java b/mobile/core/processing/core/PMIDlet.java deleted file mode 100755 index 16222ca79..000000000 --- a/mobile/core/processing/core/PMIDlet.java +++ /dev/null @@ -1,378 +0,0 @@ -package processing.core; - -import java.io.*; -import java.util.*; -import javax.microedition.lcdui.*; -import javax.microedition.midlet.*; - -/** - * - * @author Francis Li - */ -public abstract class PMIDlet extends MIDlet implements Runnable { - private Display display; - private PCanvas canvas; - - private boolean running; - private long startTime; - - private Calendar calendar; - private Random random; - - /** Creates a new instance of PMIDlet */ - public PMIDlet() { - display = Display.getDisplay(this); - } - - protected final void destroyApp(boolean unconditional) throws MIDletStateChangeException { - running = false; - } - - protected final void pauseApp() { - running = false; - } - - protected final void startApp() throws MIDletStateChangeException { - running = true; - if (canvas == null) { - canvas = new PCanvas(this); - width = canvas.getWidth(); - height = canvas.getHeight(); - - startTime = System.currentTimeMillis(); - - setup(); - } - display.setCurrent(canvas); - display.callSerially(this); - } - - public final void run() { - draw(); - canvas.repaint(); - - if (running) { - display.callSerially(this); - } - } - - public static final int CORNER = 0; - public static final int CORNERS = 1; - public static final int CENTER_DIAMETER = 2; - public static final int CENTER_RADIUS = 3; - - public static final int POINTS = 0; - public static final int LINES = 1; - public static final int LINE_STRIP = 2; - public static final int LINE_LOOP = 3; - public static final int TRIANGLES = 4; - public static final int TRIANGLE_STRIP = 5; - public static final int QUADS = 6; - public static final int QUAD_STRIP = 7; - public static final int POLYGON = 8; - - public static final int UP = 0; - public static final int DOWN = 1; - public static final int LEFT = 2; - public static final int RIGHT = 3; - public static final int FIRE = 4; - - public static final int ALIGN_LEFT = 0; - public static final int ALIGN_RIGHT = 1; - public static final int ALIGN_CENTER = 2; - - protected int width; - protected int height; - - protected char key; - protected boolean keyPressed; - - public void setup() { - } - - public void draw() { - } - - public void keyPressed() { - - } - - public void keyReleased() { - - } - - public final void redraw() { - draw(); - canvas.repaint(); - } - - public final void loop() { - running = true; - display.callSerially(this); - } - - public final void noLoop() { - running = false; - } - - public final void size(int width, int height) { - } - - public final void framerate(int fps) { - } - - public final void point(int x1, int y1) { - canvas.point(x1, y1); - } - - public final void line(int x1, int y1, int x2, int y2) { - canvas.line(x1, y1, x2, y2); - } - - public final void triangle(int x1, int y1, int x2, int y2, int x3, int y3) { - canvas.triangle(x1, y1, x2, y2, x3, y3); - } - - public final void quad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - canvas.quad(x1, y1, x2, y2, x3, y3, x4, y4); - } - - public final void rect(int x, int y, int width, int height) { - canvas.rect(x, y, width, height); - } - - public final void rectMode(int MODE) { - canvas.rectMode(MODE); - } - - public final void ellipse(int x, int y, int width, int height) { - canvas.ellipse(x, y, width, height); - } - - public final void ellipseMode(int MODE) { - canvas.ellipseMode(MODE); - } - - public final void curve(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - canvas.curve(x1, y1, x2, y2, x3, y3, x4, y4); - } - - public final void bezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { - canvas.bezier(x1, y1, x2, y2, x3, y3, x4, y4); - } - - public final void strokeWeight(int width) { - canvas.strokeWeight(width); - } - - public final void beginShape(int MODE) { - canvas.beginShape(MODE); - } - - public final void endShape() { - canvas.endShape(); - } - - public final void vertex(int x, int y) { - canvas.vertex(x, y); - } - - public final void curveVertex(int x, int y) { - canvas.curveVertex(x, y); - } - - public final void bezierVertex(int x, int y) { - canvas.bezierVertex(x, y); - } - - public final void translate(int x, int y) { - canvas.translate(x, y); - } - - public final void background(int gray) { - canvas.background(gray); - } - - public final void background(int value1, int value2, int value3) { - canvas.background(value1, value2, value3); - } - - public final void stroke(int gray) { - canvas.stroke(gray); - } - - public final void stroke(int value1, int value2, int value3) { - canvas.stroke(value1, value2, value3); - } - - public final void noStroke() { - canvas.noStroke(); - } - - public final void fill(int gray) { - canvas.fill(gray); - } - - public final void fill(int value1, int value2, int value3) { - canvas.fill(value1, value2, value3); - } - - public final void noFill() { - canvas.noFill(); - } - - public final void text(String data, int x, int y) { - canvas.text(data, x, y); - } - - public final void textMode(int MODE) { - canvas.textMode(MODE); - } - - public final int millis() { - return (int) (System.currentTimeMillis() - startTime); - } - - private void checkCalendar() { - if (calendar == null) { - calendar = Calendar.getInstance(); - } - calendar.setTime(new Date()); - } - - public final int second() { - checkCalendar(); - return calendar.get(Calendar.SECOND); - } - - public final int minute() { - checkCalendar(); - return calendar.get(Calendar.MINUTE); - } - - public final int hour() { - checkCalendar(); - return calendar.get(Calendar.HOUR_OF_DAY); - } - - public final int day() { - checkCalendar(); - return calendar.get(Calendar.DAY_OF_MONTH); - } - - public final int month() { - checkCalendar(); - return calendar.get(Calendar.MONTH); - } - - public final int year() { - checkCalendar(); - return calendar.get(Calendar.YEAR); - } - - public final int abs(int value) { - return Math.abs(value); - } - - public final int max(int value1, int value2) { - return Math.max(value1, value2); - } - - public final int min(int value1, int value2) { - return Math.min(value1, value2); - } - - public final int sq(int value) { - return value * value; - } - - public final int pow(int base, int exponent) { - int value = 1; - for (int i = 0; i < exponent; i++) { - value *= base; - } - - return value; - } - - public final int constrain(int value, int min, int max) { - return Math.min(Math.max(value, min), max); - } - - public final int random(int value1) { - return random(0, value1); - } - - public final int random(int value1, int value2) { - if (random == null) { - random = new Random(); - } - int min = Math.min(value1, value2); - int range = Math.abs(value2 - value1); - - return min + Math.abs((random.nextInt() % range)); - } - - public final String[] loadStrings(String filename) { - String[] strings = null; - InputStream is = null; - try { - is = getClass().getResourceAsStream(filename); - Reader r = new InputStreamReader(is); - - strings = new String[8]; - int numStrings = 0; - - StringBuffer buffer = new StringBuffer(); - int input = r.read(); - while (true) { - if ((input < 0) || (input == '\n')) { - String s = buffer.toString().trim(); - if (s.length() > 0) { - numStrings++; - - int length = strings.length; - if (numStrings > length) { - String[] old = strings; - strings = new String[length * 2]; - System.arraycopy(old, 0, strings, 0, length); - } - strings[numStrings - 1] = s; - } - buffer.delete(0, Integer.MAX_VALUE); - - if (input < 0) { - break; - } - } else { - buffer.append((char) input); - } - - input = r.read(); - } - //// shrink array - if (numStrings < strings.length) { - String[] old = strings; - strings = new String[numStrings]; - if (numStrings > 0) { - System.arraycopy(old, 0, strings, 0, numStrings); - } - } - } catch (Exception e) { - - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ioe) { - - } - } - if (strings == null) { - strings = new String[0]; - } - } - - return strings; - } -} diff --git a/mobile/core/test/BeginShapeTest1.java b/mobile/core/test/BeginShapeTest1.java deleted file mode 100755 index eb1b18fa2..000000000 --- a/mobile/core/test/BeginShapeTest1.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest1 extends PMIDlet { - - void setup() { - beginShape(POINTS); - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest2.java b/mobile/core/test/BeginShapeTest2.java deleted file mode 100755 index ffc764808..000000000 --- a/mobile/core/test/BeginShapeTest2.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest2 extends PMIDlet { - - void setup() { - beginShape(LINES); - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest3.java b/mobile/core/test/BeginShapeTest3.java deleted file mode 100755 index 84c56560c..000000000 --- a/mobile/core/test/BeginShapeTest3.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest3 extends PMIDlet { - - void setup() { - beginShape(LINE_STRIP); - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest4.java b/mobile/core/test/BeginShapeTest4.java deleted file mode 100755 index 385397f95..000000000 --- a/mobile/core/test/BeginShapeTest4.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest4 extends PMIDlet { - - void setup() { - beginShape(LINE_LOOP); - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest5.java b/mobile/core/test/BeginShapeTest5.java deleted file mode 100755 index 272e39bfc..000000000 --- a/mobile/core/test/BeginShapeTest5.java +++ /dev/null @@ -1,22 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest5 extends PMIDlet { - - void setup() { - beginShape(TRIANGLES); - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - vertex(90, 75); - endShape(); - } - -} diff --git a/mobile/core/test/BeginShapeTest6.java b/mobile/core/test/BeginShapeTest6.java deleted file mode 100755 index e0c36de04..000000000 --- a/mobile/core/test/BeginShapeTest6.java +++ /dev/null @@ -1,22 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest6 extends PMIDlet { - - void setup() { - beginShape(TRIANGLE_STRIP); - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - vertex(90, 75); - endShape(); - } - -} diff --git a/mobile/core/test/BeginShapeTest7.java b/mobile/core/test/BeginShapeTest7.java deleted file mode 100755 index e4a0db339..000000000 --- a/mobile/core/test/BeginShapeTest7.java +++ /dev/null @@ -1,22 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest7 extends PMIDlet { - - void setup() { - beginShape(QUADS); - vertex(30, 20); - vertex(30, 75); - vertex(50, 75); - vertex(50, 20); - vertex(65, 20); - vertex(65, 75); - vertex(85, 75); - vertex(85, 20); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest8.java b/mobile/core/test/BeginShapeTest8.java deleted file mode 100755 index 1176884dc..000000000 --- a/mobile/core/test/BeginShapeTest8.java +++ /dev/null @@ -1,22 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest8 extends PMIDlet { - - void setup() { - beginShape(QUAD_STRIP); - vertex(30, 20); - vertex(30, 75); - vertex(50, 75); - vertex(50, 20); - vertex(65, 20); - vertex(65, 75); - vertex(85, 75); - vertex(85, 20); - endShape(); - } -} diff --git a/mobile/core/test/BeginShapeTest9.java b/mobile/core/test/BeginShapeTest9.java deleted file mode 100755 index 5c2ae55e5..000000000 --- a/mobile/core/test/BeginShapeTest9.java +++ /dev/null @@ -1,20 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BeginShapeTest9 extends PMIDlet { - - void setup() { - beginShape(POLYGON); - vertex(20, 20); - vertex(40, 20); - vertex(40, 40); - vertex(60, 40); - vertex(60, 60); - vertex(20, 60); - endShape(); - } -} diff --git a/mobile/core/test/BezierTest1.java b/mobile/core/test/BezierTest1.java deleted file mode 100755 index a0957da39..000000000 --- a/mobile/core/test/BezierTest1.java +++ /dev/null @@ -1,17 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BezierTest1 extends PMIDlet { - - void setup() { - stroke(255, 102, 0); - line(85, 20, 10, 10); - line(90, 90, 15, 80); - stroke(0, 0, 0); - bezier(85, 20, 10, 10, 90, 90, 15, 80); - } -} diff --git a/mobile/core/test/BezierTest2.java b/mobile/core/test/BezierTest2.java deleted file mode 100755 index 5be845d82..000000000 --- a/mobile/core/test/BezierTest2.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BezierTest2 extends PMIDlet { - - void setup() { - stroke(255, 102, 0); - line(30, 20, 80, 5); - line(80, 75, 30, 75); - stroke(0, 0, 0); - bezier(30, 20, 80, 5, 80, 75, 30, 75); - } - -} diff --git a/mobile/core/test/BezierVertexTest.java b/mobile/core/test/BezierVertexTest.java deleted file mode 100755 index 0077fcb9c..000000000 --- a/mobile/core/test/BezierVertexTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class BezierVertexTest extends PMIDlet { - - void setup() { - beginShape(LINE_STRIP); - bezierVertex(30, 20); - bezierVertex(80, 0); - bezierVertex(80, 75); - bezierVertex(30, 75); - endShape(); - } -} diff --git a/mobile/core/test/CurveTest.java b/mobile/core/test/CurveTest.java deleted file mode 100755 index 3f446a3ac..000000000 --- a/mobile/core/test/CurveTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class CurveTest extends PMIDlet { - - void setup() { - curve(10, 26, 83, 24, 83, 61, 25, 65); - } - -} diff --git a/mobile/core/test/CurveVertexTest.java b/mobile/core/test/CurveVertexTest.java deleted file mode 100755 index f3cd60782..000000000 --- a/mobile/core/test/CurveVertexTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class CurveVertexTest extends PMIDlet { - - void setup() { - beginShape(LINE_STRIP); - curveVertex(84, 91); - curveVertex(84, 91); - curveVertex(68, 19); - curveVertex(21, 17); - curveVertex(32, 100); - curveVertex(32, 100); - endShape(); - } -} diff --git a/mobile/core/test/EllipseModeTest.java b/mobile/core/test/EllipseModeTest.java deleted file mode 100755 index 23d441c44..000000000 --- a/mobile/core/test/EllipseModeTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class EllipseModeTest extends PMIDlet { - void setup() { - ellipseMode(CENTER_DIAMETER); - ellipse(35, 35, 50, 50); - ellipseMode(CORNER); - fill(102); - ellipse(35, 35, 50, 50); - } -} diff --git a/mobile/core/test/EllipseTest.java b/mobile/core/test/EllipseTest.java deleted file mode 100755 index 065f083b7..000000000 --- a/mobile/core/test/EllipseTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class EllipseTest extends PMIDlet { - void setup() { - ellipse(30, 20, 55, 55); - } -} diff --git a/mobile/core/test/LineTest1.java b/mobile/core/test/LineTest1.java deleted file mode 100755 index 8e23c9a43..000000000 --- a/mobile/core/test/LineTest1.java +++ /dev/null @@ -1,12 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class LineTest1 extends PMIDlet { - void setup() { - line(30, 20, 85, 75); - } -} diff --git a/mobile/core/test/LineTest2.java b/mobile/core/test/LineTest2.java deleted file mode 100755 index ea287e845..000000000 --- a/mobile/core/test/LineTest2.java +++ /dev/null @@ -1,16 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class LineTest2 extends PMIDlet { - void setup() { - line(30, 20, 85, 20); - stroke(126); - line(85, 20, 85, 75); - stroke(255); - line(85, 75, 30, 75); - } -} diff --git a/mobile/core/test/Linear.java b/mobile/core/test/Linear.java deleted file mode 100755 index 434580aaa..000000000 --- a/mobile/core/test/Linear.java +++ /dev/null @@ -1,30 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class Linear extends PMIDlet { - // Linear - // by REAS - - int a = 100; - - public void setup() - { - size(200, 200); - stroke(255); - framerate(30); - } - - public void draw() - { - background(51); - a = a - 1; - if (a < 0) { - a = height; - } - line(0, a, width, a); - } -} diff --git a/mobile/core/test/PointTest.java b/mobile/core/test/PointTest.java deleted file mode 100755 index 063007a93..000000000 --- a/mobile/core/test/PointTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class PointTest extends PMIDlet { - void setup() { - point(30, 20); - point(85, 20); - point(85, 75); - point(30, 75); - } -} diff --git a/mobile/core/test/Points_Lines.java b/mobile/core/test/Points_Lines.java deleted file mode 100755 index 7af67d9a8..000000000 --- a/mobile/core/test/Points_Lines.java +++ /dev/null @@ -1,38 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class Points_Lines extends PMIDlet { - void setup() { - // Points and Lines - // by REAS - - int d = 40; - int p1 = d; - int p2 = p1+d; - int p3 = p2+d; - int p4 = p3+d; - - size(200, 200); - background(0); - - // Draw gray box - stroke(153); - line(p3, p3, p2, p3); - line(p2, p3, p2, p2); - line(p2, p2, p3, p2); - line(p3, p2, p3, p3); - - // Draw white points - stroke(255); - point(p1, p1); - point(p1, p3); - point(p2, p4); - point(p3, p1); - point(p4, p2); - point(p4, p4); - } -} diff --git a/mobile/core/test/QuadTest.java b/mobile/core/test/QuadTest.java deleted file mode 100755 index 1c8978fcd..000000000 --- a/mobile/core/test/QuadTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class QuadTest extends PMIDlet { - - void setup() { - quad(38, 31, 86, 20, 69, 63, 30, 76); - } -} diff --git a/mobile/core/test/RandomTest1.java b/mobile/core/test/RandomTest1.java deleted file mode 100755 index d8f61ef46..000000000 --- a/mobile/core/test/RandomTest1.java +++ /dev/null @@ -1,17 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class RandomTest1 extends PMIDlet { - - void setup() { - for(int i=0; i<100; i++) { - int r = random(50); - stroke(r*5); - line(50, i, 50+r, i); - } - } -} diff --git a/mobile/core/test/RandomTest2.java b/mobile/core/test/RandomTest2.java deleted file mode 100755 index f1d418838..000000000 --- a/mobile/core/test/RandomTest2.java +++ /dev/null @@ -1,17 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class RandomTest2 extends PMIDlet { - - void setup() { - for(int i=0; i<100; i++) { - int r = random(-50, 50); - stroke(abs(r*5)); - line(50, i, 50+r, i); - } - } -} diff --git a/mobile/core/test/RectModeTest.java b/mobile/core/test/RectModeTest.java deleted file mode 100755 index 1226a99ee..000000000 --- a/mobile/core/test/RectModeTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class RectModeTest extends PMIDlet { - - void setup() { - rectMode(CENTER_DIAMETER); - rect(35, 35, 50, 50); - rectMode(CORNER); - fill(102); - rect(35, 35, 50, 50); - } -} diff --git a/mobile/core/test/RectTest.java b/mobile/core/test/RectTest.java deleted file mode 100755 index a8c04c4e3..000000000 --- a/mobile/core/test/RectTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class RectTest extends PMIDlet { - - void setup() { - rect(30, 20, 55, 55); - } -} diff --git a/mobile/core/test/SecondTest.java b/mobile/core/test/SecondTest.java deleted file mode 100755 index 4b92c48e2..000000000 --- a/mobile/core/test/SecondTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class SecondTest extends PMIDlet { - - public void draw() { - background(204); - int s = second(); // Values from 0 - 59 - int m = minute(); // Values from 0 - 59 - int h = hour(); // Values from 0 - 23 - line(s, 0, s, 33); - line(m, 33, m, 66); - line(h, 66, h, 100); - } -} diff --git a/mobile/core/test/Shape_Primitives.java b/mobile/core/test/Shape_Primitives.java deleted file mode 100755 index f3c561788..000000000 --- a/mobile/core/test/Shape_Primitives.java +++ /dev/null @@ -1,23 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class Shape_Primitives extends PMIDlet { - void setup() { - // Shape Primitives - // by REAS - - size(200, 200); - background(0); - noStroke(); - fill(226); - triangle(10, 10, 10, 200, 45, 200); - rect(45, 45, 35, 35); - quad(105, 10, 120, 10, 120, 200, 80, 200); - ellipse(120, 60, 40, 40); - triangle(160, 10, 195, 200, 160, 200); - } -} diff --git a/mobile/core/test/StrokeWeightTest.java b/mobile/core/test/StrokeWeightTest.java deleted file mode 100755 index 4fdd49003..000000000 --- a/mobile/core/test/StrokeWeightTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class StrokeWeightTest extends PMIDlet { - void setup() { - strokeWeight(1); // Default - line(20, 20, 80, 20); - - strokeWeight(4); // Thicker - line(20, 40, 80, 40); - - strokeWeight(10); // Beastly - line(20, 70, 80, 70); - } -} diff --git a/mobile/core/test/TriangleTest.java b/mobile/core/test/TriangleTest.java deleted file mode 100755 index 6f116f321..000000000 --- a/mobile/core/test/TriangleTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class TriangleTest extends PMIDlet { - - void setup() { - triangle(30, 75, 58, 20, 86, 75); - } -} diff --git a/mobile/core/test/Vertices.java b/mobile/core/test/Vertices.java deleted file mode 100755 index ba11e984e..000000000 --- a/mobile/core/test/Vertices.java +++ /dev/null @@ -1,51 +0,0 @@ -package test; -import processing.core.*; - -/** - * - * @author Francis Li - */ -public class Vertices extends PMIDlet { - - void setup() { - // Vertices - // by REAS - - size(200, 200); - background(0); - - stroke(102); - beginShape(LINE_STRIP); - curveVertex(168, 182); - curveVertex(168, 182); - curveVertex(136, 38); - curveVertex(42, 34); - curveVertex(64, 200); - curveVertex(64, 200); - endShape(); - - stroke(51); - beginShape(LINES); - vertex(60, 40); - vertex(160, 10); - vertex(170, 150); - vertex(60, 150); - endShape(); - - stroke(126); - beginShape(LINE_STRIP); - bezierVertex(60, 40); - bezierVertex(160, 10); - bezierVertex(170, 150); - bezierVertex(60, 150); - endShape(); - - stroke(255); - beginShape(POINTS); - vertex(60, 40); - vertex(160, 10); - vertex(170, 150); - vertex(60, 150); - endShape(); - } -} diff --git a/mobile/web/css/mobile.css b/mobile/web/css/mobile.css deleted file mode 100644 index 366d6c3bb..000000000 --- a/mobile/web/css/mobile.css +++ /dev/null @@ -1,178 +0,0 @@ -body { - background: #fff; - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - font-weight: normal; - color: #553; - text-decoration: none; - margin-top: 0; - margin-left: 0; - margin-right: 0; - margin-bottom: 0; -} - -h3 { - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 19px; - font-weight: normal; - font-decoration: none; - color: #996; - padding: 0px; - margin: 0px; -} - -h4 { - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - text-decoration: none; - color: #998; - padding: 0px; - margin: 0px; -} - -td { - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - color: #663 -} - -select { - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - background-color : #fff; - height: 15px; - width: 200px; - color: #663; - border: 1px #06c solid -} - -pre { - margin-top: 0px; -} - -a:link { - color: #d60; - font-size: 11px; - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - text-decoration: underlined; - background-color : transparent; -} - -a:visited { - color: #d60; - font-size: 11px; - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - text-decoration: underlined; - background-color : transparent; -} - -a:hover { - color: #bb3; - font-size: 11px; - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - text-decoration: underlined; - background-color : #000; -} - -a:active { - color: #d60; - font-size: 11px; - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - text-decoration: none; - background-color : transparent; -} - -.inputnav { - font-family: Geneva, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - font-weight: normal; - color: #333333; -} - -.pad { - padding-right: 10px; -} - -.unlinked { - font-size: 11px; - color: #999966; - font-family: Geneva, Arial, Helvetica, sans-serif; -} - -.subtitle { - font-size: 11px; - font-style: italic; - color: #666633; -} - -.backslash { - color: #996600; -} - -.column { - float: left; - width: 250px; - margin: 0px; - padding: 0px; -} - -.column2x { - float: left; - width: 500px; - margin: 0px; - padding: 0px; -} - -.reffieldheader { - vertical-align: top; - width: 100px; - padding-right: 20px; - padding-bottom: 40px; -} - -.reffield { - vertical-align: top; - width: 560px; - padding-bottom: 40px; -} - -#head { - position: relative; - left: 0px; - width: 750px; - margin: 5px 50px 0px 50px; - padding: 0px 0px 0px 0px; -} - -#navigation { - position: relative; - left: 0px; - width: 750px; - margin: 0px 50px 0px 50px; - padding: 0px 0px 0px 0px; -} - -#backnavigation { - position: relative; - left: 0px; - width: 800px; - margin: 40px 50px 0px 0px; - padding: 0px 0px 0px 0px; -} - -#content { - position: relative; - left: 0px; - width: 750px; - margin: 40px 50px 0px 50px; - padding: 0px 0px 0px 0px; -} - -#footer { - position: relative; - clear: both; - left: 0px; - width: 750px; - margin: 0px 50px 20px 50px; - padding: 100px 0px 0px 0px; -} diff --git a/mobile/web/download/index.php b/mobile/web/download/index.php deleted file mode 100644 index a6e1496ea..000000000 --- a/mobile/web/download/index.php +++ /dev/null @@ -1,19 +0,0 @@ -> Download"; - -require '../header.inc.php'; -?> -

Processing Mobile pre-Alpha

-
    -
  1. Download and install the Wireless Toolkit (WTK) from Sun. The latest version is 2.1.

    -http://java.sun.com/products/j2mewtoolkit/
     
  2. -
  3. Download and install Processing Mobile.

    -0071 pre-ALPHA  |  17 10 2004  Windows Expert
     
  4. -
  5. Modify preferences.txt to include the following line, based on the installation location of the WTK:
    -
    -wtk.path=C:\WTK21
     
  6. -
- - \ No newline at end of file diff --git a/mobile/web/footer.inc.php b/mobile/web/footer.inc.php deleted file mode 100644 index 660b746b8..000000000 --- a/mobile/web/footer.inc.php +++ /dev/null @@ -1,8 +0,0 @@ - - - - diff --git a/mobile/web/header.inc.php b/mobile/web/header.inc.php deleted file mode 100644 index 6736094fe..000000000 --- a/mobile/web/header.inc.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - - -<?php echo $PAGE_TITLE ?> - - - - - - - - -
- - - - - -
- - - - - - Index - -
-
- -
diff --git a/mobile/web/index.php b/mobile/web/index.php deleted file mode 100644 index bc5edb774..000000000 --- a/mobile/web/index.php +++ /dev/null @@ -1,17 +0,0 @@ - - -
-  -
-
-
- Processing Mobile allows software written using the Processing programming - language and development environment to run on Java Powered mobile devices. -
- \ No newline at end of file diff --git a/mobile/web/info.php b/mobile/web/info.php deleted file mode 100644 index cf6086080..000000000 --- a/mobile/web/info.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/mobile/web/reference/API/Array.xml b/mobile/web/reference/API/Array.xml deleted file mode 100644 index 04f4a61b0..000000000 --- a/mobile/web/reference/API/Array.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - -Array - -Data - -Composite - -Web & Application - - - - -int[] numbers = new int[3]; -numbers[0] = 90; -numbers[1] = 150; -numbers[2] = 30; -int a = numbers[0] + numbers[1]; // Sets variable a to 240 -int b = numbers[1] + numbers[2]; // Sets variable b to 180 - - - - - - -int[] numbers = { 90, 150, 30 }; -int a = numbers[0] + numbers[1]; // Sets variable a to 240 -int b = numbers[1] + numbers[2]; // Sets variable b to 180 - - - - - - -int degrees = 360; -float[] cos_vals = new float[degrees]; -for(int i=0; i < degrees; i++) { - cos_vals[i] = cos(TWO_PI/degrees * i); -} - - - - -An array is a list of data. It is possible to have an array of any type of data. Each piece of data in an array is identified by an index number representing its position in the array. The first element in the array is [0], the second element is [1], and so on. Arrays are similar to objects, so they must be created with the keyword new. Every array has a variable length which is an integer value for the total number of elements in the array. - - - -datatype[] var -var[element] = value -var.length - - - - -any primitive or compound datatype, including user defined classes - - - - -any valid variable name - - - - -int: must not exceed the length of the array - 1 - - - - -data to assign to the array element, must be the same datatype as the array - - - - - - -1.0 - -Object - -PDE - - - - - - - - - - - diff --git a/mobile/web/reference/API/Object.xml b/mobile/web/reference/API/Object.xml deleted file mode 100644 index 012b7ae6a..000000000 --- a/mobile/web/reference/API/Object.xml +++ /dev/null @@ -1,84 +0,0 @@ - - -Object - -Data - -Composite - -Web & Application - - - - -// Declare and contruct two objects (h1, h2) from the class HLine -HLine h1 = new HLine(20, 2.0); -HLine h2 = new HLine(50, 2.5); - -void setup() -{ - size(200, 200); - framerate(30); -} - -void loop() { - background(204); - h1.update(); - h2.update(); -} - -class HLine { - float ypos, speed; - HLine (float y, float s) { - ypos = y; - speed = s; - } - void update() { - ypos += speed; - if (ypos > width) { - ypos = 0; - } - line(0, ypos, width, ypos); - } -} - - - - -Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants). - - - -class instance - - - - -the class to created the object from - - - - -any variable name - - - - - -class - - -1.0 - -Object - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/String.xml b/mobile/web/reference/API/String.xml deleted file mode 100644 index 79187d305..000000000 --- a/mobile/web/reference/API/String.xml +++ /dev/null @@ -1,108 +0,0 @@ - - -String - -Data - -Composite - -Web & Application - - - - -String str1 = "CCCP"; -char data[] = {'C', 'C', 'C', 'P'}; -String str2 = new String(data); -println(str1); // Prints "CCCP" to the console -println(str2); // Prints "CCCP" to the console - - - - -A string is a sequence of characters. The class String includes methods for examining individual characters, comparing strings, searching strings, extracting parts of strings, and for converting an entire string uppercase and lowercase. Strings are always defined inside double quotes ("Abc") and characters are always defined inside single quotes('A').

There are more string methods than those linked from this page. Additional String documentation is located at http://java.sun.com/j2se/1.4.2/docs/api/ -
- - - - - - - - - - - - - - -charAt() -Returns the character at the specified index - - -equals() -Compares a string to a specified object - - -indexOf() -Returns the index value of the first occurance of a character within the input string - - -length() -Returns the number of characters in the input string - - -substring() -Returns a new string that is part of the input string - - -toLowerCase() -Converts all the characters to lower case - - -toUpperCase() -Converts all the characters to upper case - - - -String(data) -String(data, offset, length) - - - -data -byte[] or char[]: array of bytes to be decoded into characters or array of characters to be combined into a string - - - -offset -int: index of the first character - - - -length -int: number of characters - - - - - - -char -text() - - -1.0 - -Object - -PDE - - - - - - - - -
diff --git a/mobile/web/reference/API/String_charAt.xml b/mobile/web/reference/API/String_charAt.xml deleted file mode 100644 index 18356c58b..000000000 --- a/mobile/web/reference/API/String_charAt.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - -charAt() - -String - -Method - -Web & Application - - - - -String str = "CCCP"; -char c1 = str.charAt(0); -char c2 = str.charAt(1); -char c3 = str.charAt(str.length()-1); -println(c1 + ":" + c2 + ":" + c3); // Prints 'C:C:P' - - - - -Returns the character at the specified index. An index ranges from 0 to the length of the string minus 1. The first character of the sequence is at index 0, the next at index 1, etc. - - - -charAt(index) - - - - -int: the index of the character - - -char - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/String_equals.xml b/mobile/web/reference/API/String_equals.xml deleted file mode 100644 index a23abc970..000000000 --- a/mobile/web/reference/API/String_equals.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - -equals() - -String - -Method - -Web & Application - - - - -String str1 = "CCCP"; -String str2 = "CCCP"; -// Tests to see if str1 is equal to str2 -if(str1.equals(str2) == true) { - println("Equal"); // They are equal so this line will print -} else { - println("Not equal"); -} - - - - -Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the same and false if they are not. - - - -equals(str) - - - - -String: any valid String - - -Boolean - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/String_indexOf.xml b/mobile/web/reference/API/String_indexOf.xml deleted file mode 100644 index 2b58a69c5..000000000 --- a/mobile/web/reference/API/String_indexOf.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - -indexOf() - -String - -Method - -Web & Application - - - - -String str = "CCCP"; -int p1 = str.indexOf("C"); -int p2 = str.indexOf("P"); -int p3 = str.indexOf("CP"); -println(p1 + ":" + p2 + ":" + p3); // Prints '0:3:2' - - - - -Tests to see if a substring is embedded in a string and returns the index position of the first occurance of the substring defined in the str parameter. If the str parameter is not found in the string, -1 is returned. - - - -indexOf(str) -indexOf(str, fromIndex) - - - - -String: the substring to search - - - - -int: the index from which to start the search - - -int - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/String_length.xml b/mobile/web/reference/API/String_length.xml deleted file mode 100644 index a3470db76..000000000 --- a/mobile/web/reference/API/String_length.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - -length() - -String - -Method - -Web & Application - - - - -String str1 = "CCCP"; -String str2 = "Rabbit"; -int l1 = str1.length(); -int l2 = str2.length(); -println(l1 + ":" + l2); // Prints '4:6' - - - - -Returns the total number of characters included in the string as an integer number.
Note: You find the size of an array with the length field which works a little differently from String's length() method. -
- - -charAt() - - - - - - - -int - - - - -1.0 - -Method - -Core - - -
diff --git a/mobile/web/reference/API/String_substring.xml b/mobile/web/reference/API/String_substring.xml deleted file mode 100644 index ab9b6b3d8..000000000 --- a/mobile/web/reference/API/String_substring.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - -substring() - -String - -Method - -Web & Application - - - - -String str1 = "CCCP"; -String str2 = "Rabbit"; -String ss1 = str1.substring(2); // Returns "CP" -String ss2 = str2.substring(3); // Returns "bit" -String ss3 = str1.substring(0, 2); // Returns "CC" -println(ss1 + ":" + ss2 + ":" + ss3); // Prints 'CP:bit:CC' - - - - -Returns a new string that is a part of the original string. When using the endIndex parameter, the string between beginIndex and endIndex-1 is returned. - - - -substring(beginIndex) -substring(beginIndex, endIndex) - - - - -int: position from which to begin (inclusive) - - - - -int: position from which to end (exclusive) - - -None - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/String_toLowerCase.xml b/mobile/web/reference/API/String_toLowerCase.xml deleted file mode 100644 index 1f15f36a7..000000000 --- a/mobile/web/reference/API/String_toLowerCase.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - -toLowerCase() - -String - -Method - -Web & Application - - - - -String str1 = "CCCP"; -String str2 = "Rabbit"; -str1 = str1.toLowerCase(); -str2 = str2.toLowerCase(); -println(str1 + ":" + str2); // Prints cccp:rabbit - - - - -Converts all of the characters in the string to lowercase. For example, "ABC" will convert to "abc". - - - -toLowerCase() - - - - - - - -String - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/String_toUpperCase.xml b/mobile/web/reference/API/String_toUpperCase.xml deleted file mode 100644 index b242b6773..000000000 --- a/mobile/web/reference/API/String_toUpperCase.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - -toUpperCase() - -String - -Method - -Web & Application - - - - -String str1 = "Cccp"; -String str2 = "Rabbit"; -str1 = str1.toUpperCase(); -str2 = str2.toUpperCase(); -println(str1 + ":" + str2); // Prints CCCP:RABBIT - - - - -Converts all of the characters in the string to uppercase. For example, "abc" will convert to "ABC". - - - -charAt() - - - - -int: X coordinate of the pixel in source image - - -String - - - - -1.0 - -Method - -Core - - - diff --git a/mobile/web/reference/API/abs.xml b/mobile/web/reference/API/abs.xml deleted file mode 100644 index 5dc8fdf9a..000000000 --- a/mobile/web/reference/API/abs.xml +++ /dev/null @@ -1,51 +0,0 @@ - - -abs() - -Math - -Calcuation - -Web & Application - - - - -int a = abs(153); // Sets a to 153 -int b = abs(-15); // Sets b to 15 -float c = abs(12.234); // Sets c to 12.234 -float d = abs(-9.23); // Sets d to 9.23 - - - - -Calculates the absolute value (magnitude) of a number. The absolute value of a number is always positive. - - - -abs(value) - - - - -float or int - - -float or int (depending on the input values) - - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/addassign.xml b/mobile/web/reference/API/addassign.xml deleted file mode 100644 index f2ddf6ded..000000000 --- a/mobile/web/reference/API/addassign.xml +++ /dev/null @@ -1,59 +0,0 @@ - - -+= (add assign) - -Math - -Operators - -Web & Application - - - - -int a = 50; -int b = 23; -a += b; // sets "a" to 73 - - - - -Combines addition with assignment. The expression a += b is equivalent to a = a + b. - - - -value1 += value2 - - - - -int or float - - - - -any numberical value the same datatype as value1 - - - - - -= (assign) -+ (add) --= (subtract assign) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/addition.xml b/mobile/web/reference/API/addition.xml deleted file mode 100644 index efad64445..000000000 --- a/mobile/web/reference/API/addition.xml +++ /dev/null @@ -1,80 +0,0 @@ - - -+ (addition) - -Math - -Operators - -Web & Application - - - - -int a = 50 + 5; // Sets a to 55 -int b = a + 5; // Sets b to 60 - - - - - - -String s1 = "Chernenko"; -String s2 = "Brezhnev"; -String sc1 = s1 + s2; -String sc2 = s1 + ", Andropov, " + s2; -println(sc1); // Prints ChernenkoBrezhnev -println(sc2); // Prints Chernenko, Andropov, Brezhnev - - - - - - -String s1 = "Gorbachev"; -int i = 1987; -String sc1 = s1 + i; -println(sc1); // Prints Gorbachev1987 - - - - -Adds two values or concatenates string values. As a mathematical operator, it calculates the sum of two values. As a string operator, it combines two strings into one and converts from primitive datatypes into the String datatype if necessary. - - - -value1 + value2 - - - - -String, int, float, char, byte, boolean - - - - -String, int, float, char, byte, boolean - - - - - -++ (increment) -+= (add assign) -- (minus) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/append.xml b/mobile/web/reference/API/append.xml deleted file mode 100644 index 332be40f2..000000000 --- a/mobile/web/reference/API/append.xml +++ /dev/null @@ -1,53 +0,0 @@ - - -append() - -Data - -Array Functions - -Web & Application - - - - -String sa1[] = { "OH ", "NY ", "CA "}; -String sa2[] = append(sa1, "MA "); -print(sa2); // Prints "OH NY CA MA" - - - - -Expands an array by one element and adds data to the new position. The datatype of the element parameter must be the same as the datatype of the array. - - - -append(array, element) - - - - -boolean[], byte[], char[], int[], float[], or String[] - - - - -new data for the array - - -Array (the same datatype as the input) - - -shorten() -expand() - - -1.0 - -Function - -Core - -Extended - - diff --git a/mobile/web/reference/API/arrayaccess.xml b/mobile/web/reference/API/arrayaccess.xml deleted file mode 100644 index 97020e739..000000000 --- a/mobile/web/reference/API/arrayaccess.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -[] (array access) - -Structure - - - -Web & Application - - - - -int[] numbers = new int[3]; -numbers[0] = 90; -numbers[1] = 150; -numbers[2] = 30; -int a = numbers[0] + numbers[1]; // Sets variable a to 240 -int b = numbers[1] + numbers[2]; // Sets variable b to 180 - - - - -The array access operator is used to specify a location within an array. The data at this location can be defined with the syntax array[element] = value or read with the syntax value = array[element]. - - - -datatype[] -array[element] - - - - -any primitive or compound datatype, including user defined classes - - - - -any valid variable name - - - - -int: must not exceed the length of the array - 1 - - - - - -Array - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/assign.xml b/mobile/web/reference/API/assign.xml deleted file mode 100644 index c2115db79..000000000 --- a/mobile/web/reference/API/assign.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -= (assign) - -Structure - - - -Web & Application - - - - -int a; -a = 30; // Assigns for value 30 to the variable "a" -a = a + 40; // Assigns the value 70 to the variable "a" - - - - -Assigns a value to a variable. The "=" sign does not mean "equals", but is used to place data within a variable. The "=" operator is formally called the assignment operator. There are many different types of variables (int, floats, strings, etc.) and the assignment operator can only assign values which are the same type as the variable it is assigning. For example, if the variable is of type int, the value must also be an int. - - - -var = value - - - - -any valid variable name - - - - -any value of the same type as the variable. For example, if the variable is of type "int", the value must also be an int - - - - - -+= (add assign) --= (subtract assign) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/background.xml b/mobile/web/reference/API/background.xml deleted file mode 100644 index ce46505e9..000000000 --- a/mobile/web/reference/API/background.xml +++ /dev/null @@ -1,96 +0,0 @@ - - -background() - -Color - -Setting - -Web & Application - - -background_.gif - -background(51); - - - - -background_2.gif - -background(255, 204, 0); - - - - -background_4.jar - -void loop() { - background(255, 204, 0); - line(0, 0, mouseX, mouseY); - line(100, 0, mouseX, mouseY); - line(100, 100, mouseX, mouseY); - line(0, 100, mouseX, mouseY); -} - - - - -background_3.jpg - -PImage b; -b = loadImage("laDefense.jpg"); -background(b); - - - - -The background() function sets the color used for the background of the Processing window. The default background is light gray. In the loop() function, the background color is used to refresh the display window between frames. It is possible to load a JPG or GIF image as the background by loading an image which is the same size as the display window. The image must be in the data directory of the sketch for it to load properly. - - - -background(value1) -background(value1, value2, value3) -background(image) - - - - -int or float: red or hue value (depending on the current color mode) - - - - -int or float: green or saturation value (depending on the current color mode) - - - - -int or float: blue or brightness value (depending on the current color mode) - - - - -PImage: the name of a PImage the same size as the display window - - -None - - -colorMode() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/beginShape.xml b/mobile/web/reference/API/beginShape.xml deleted file mode 100644 index 2f5a0c57d..000000000 --- a/mobile/web/reference/API/beginShape.xml +++ /dev/null @@ -1,170 +0,0 @@ - - -beginShape() - -Shape - -Vertex - -Web & Application - - -beginShape_.gif - -beginShape(POINTS); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -beginShape_2.gif - -beginShape(LINES); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -beginShape_3.gif - -beginShape(LINE_STRIP); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -beginShape_4.gif - -beginShape(LINE_LOOP); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -beginShape_5.gif - -beginShape(TRIANGLES); -vertex(30, 75); -vertex(40, 20); -vertex(50, 75); -vertex(60, 20); -vertex(70, 75); -vertex(80, 20); -vertex(90, 75); -endShape(); - - - - -beginShape_6.gif - -beginShape(TRIANGLE_STRIP); -vertex(30, 75); -vertex(40, 20); -vertex(50, 75); -vertex(60, 20); -vertex(70, 75); -vertex(80, 20); -vertex(90, 75); -endShape(); - - - - -beginShape_7.gif - -beginShape(QUADS); -vertex(30, 20); -vertex(30, 75); -vertex(50, 75); -vertex(50, 20); -vertex(65, 20); -vertex(65, 75); -vertex(85, 75); -vertex(85, 20); -endShape(); - - - - -beginShape_8.gif - -beginShape(QUAD_STRIP); -vertex(30, 20); -vertex(30, 75); -vertex(50, 75); -vertex(50, 20); -vertex(65, 20); -vertex(65, 75); -vertex(85, 75); -vertex(85, 20); -endShape(); - - - - -beginShape_9.gif - -beginShape(POLYGON); -vertex(20, 20); -vertex(40, 20); -vertex(40, 40); -vertex(60, 40); -vertex(60, 60); -vertex(20, 60); -endShape(); - - - - -Using the beginShape() and endShape() functions allow creating more complex forms. beginShape() begins recording vertices for a shape and endShape() stops recording. The beginShape() function requires a parameter to tell it which type of shape to create from the provided vertices. The parameters available for beginShape() are LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, QUADS, QUAD_STRIP, and POLYGON. After calling the beginShape() function, a series of vertex() commands must follow. To stop drawing the shape, call endShape(). The vertex() function with two parameters specifies a position in 2D and the vertex() function with three parameters specifies a position in 3D. Each shape will be outlined with the current stroke color and filled with the fill color. Transformations such as translate(), rotate(), and scale() do not work within beginShape(). - - - -beginShape(MODE) - - - - -Either LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, QUADS, QUAD_STRIP, POLYGON - - -None - - -endShape() -vertex() -curveVertex() -bezierVertex() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/bezier.xml b/mobile/web/reference/API/bezier.xml deleted file mode 100644 index 5bec877b9..000000000 --- a/mobile/web/reference/API/bezier.xml +++ /dev/null @@ -1,101 +0,0 @@ - - -bezier() - -Shape - -Curves - -Web & Application - - -bezier_.gif - -stroke(255, 102, 0); -line(85, 20, 10, 10); -line(90, 90, 15, 80); -stroke(0, 0, 0); -bezier(85, 20, 10, 10, 90, 90, 15, 80); - - - - -bezier_2.gif - -stroke(255, 102, 0); -line(30, 20, 80, 5); -line(80, 75, 30, 75); -stroke(0, 0, 0); -bezier(30, 20, 80, 5, 80, 75, 30, 75); - - - - -Draws a Bezier curve on the screen. These curves are defined by a series of anchor and control points. The first two parameters specify the first anchor point and the last two parameters specify the other anchor point. The middle parameters specify the control points which define the shape of the curve. Bezier curves were developed by French engineer Pierre Bezier. - - - -bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - - - -int or float: x-coordinate of the first anchor point - - - - -int or float: y-coordinate of the first anchor point - - - - -int or float: x-coordinate of the first control point - - - - -int or float: y-coordinate of the first control point - - - - -int or float: x-coordinate of the second control point - - - - -int or float: y-coordinate of the second control point - - - - -int or float: x-coordinate of the second anchor point - - - - -int or float: y-coordinate of the second anchor point - - -None - - -bezierVertex() -curve() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/bezierVertex.xml b/mobile/web/reference/API/bezierVertex.xml deleted file mode 100644 index 35330682e..000000000 --- a/mobile/web/reference/API/bezierVertex.xml +++ /dev/null @@ -1,68 +0,0 @@ - - -bezierVertex() - -Shape - -Vertex - -Web & Application - - -bezierVertex_.gif - -beginShape(LINE_STRIP); -bezierVertex(30, 20); -bezierVertex(80, 0); -bezierVertex(80, 75); -bezierVertex(30, 75); -endShape(); - - - - -Specifies vertex coordinates for Bezier curves. This function must be used between beginShape() and endShape(). These curves are defined by a series of anchor and control points. Bezier curves were developed by French engineer Pierre Bezier. - - - -bezierVertex(x, y) -bezierVertex(x, y, z) - - - - -The x-coordinate of the vertex, either a float or int - - - - -The y-coordinate of the vertex, either a float or int - - - - -The z-coordinate of the vertex, either a float or int - - - - - -curveVertex() -vertex() -bezier() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/bitwiseAND.xml b/mobile/web/reference/API/bitwiseAND.xml deleted file mode 100644 index 995a7e3e1..000000000 --- a/mobile/web/reference/API/bitwiseAND.xml +++ /dev/null @@ -1,74 +0,0 @@ - - -& (bitwise AND) - -Math - -Bitwise Operators - -Web & Application - - - - - -int a = 207; // In binary: 11001111 -int b = 61; // In binary: 00111101 -int c = a & b; // In binary: 00001101 -println(c); // Prints "13", the decimal equivalent to 00001101 - - - - - - -color argb = color(204, 204, 51, 255); -// The sytax "& 0xFF" compares the binary -// representation of the two values and -// makes all but the last 8 bits into a 0. -// "0xFF" is 00000000000000000000000011111111 -int a = argb >> 24 & 0xFF; -int r = argb >> 16 & 0xFF; -int g = argb >> 8 & 0xFF; -int b = argb & 0xFF; -fill(r, g, b, a); -rect(30, 20, 55, 55); - - - - -Compares each corresponding bit in the binary representation of the values. For each comparison two 1's yeild 1, 1 and 0 yeild 0, and two 0's yeild 0. This is easy to see when we look at the binary representation of numbers

  11010110  // 214
& 01011100 // 92
--------
01010100 // 84

To see the binary representation of a number, use the binary() function with println(). -
- - -value & value2 - - - - -int, char, byte - - - - -int, char, byte - - - - - - -| (bitwise OR) -binary() - - -1.0 - -Operator - -PDE - -Extended - - -
diff --git a/mobile/web/reference/API/bitwiseOR.xml b/mobile/web/reference/API/bitwiseOR.xml deleted file mode 100644 index 0114a5bf4..000000000 --- a/mobile/web/reference/API/bitwiseOR.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -| (bitwise OR) - -Math - -Bitwise Operators - -Web & Application - - - - - -int a = 205; // In binary: 11001101 -int b = 45; // In binary: 00101101 -int c = a | b; // In binary: 11101101 -println(c); // Prints "237", the decimal equivalent to 11101101 - - - - - - -int a = 255 << 24; // Binary: 11111111000000000000000000000000 -int r = 204 << 16; // Binary: 00000000110011000000000000000000 -int g = 204 << 8; // Binary 00000000000000001100110000000000 -int b = 51; // Binary: 00000000000000000000000000110011 -// OR the values together: 11111111110011001100110000110011 -color argb = a | r | g | b; -fill(argb); -rect(30, 20, 55, 55); - - - - -Compares each corresponding bit in the binary representation of the values. For each comparison two 1's yeild 1, 1 and 0 yeild 1, and two 0's yeild 0. This is easy to see when we look at the binary representation of numbers

  11010110  // 214
& 01011100 // 92
--------
11011110 // 222

To see the binary representation of a number, use the binary() function with println(). -
- - -value | value2 - - - - -int, char, byte - - - - -int, char, byte - - - - - - -& (bitwise AND) -binary() - - -1.0 - -Operator - -PDE - -Extended - - -
diff --git a/mobile/web/reference/API/blue.xml b/mobile/web/reference/API/blue.xml deleted file mode 100644 index 0d5615910..000000000 --- a/mobile/web/reference/API/blue.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -blue() - -Color - -Creating & Reading - -Web & Application - - -blue_.gif - -noStroke(); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = blue(c); // Sets "value" to "255" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the blue element from a color. - - - -blue(color) - - - - -any value of the color datatype - - -float - - -red() -green() -hue() -saturation() -brightness() - - -1.0 - -Function - -Core - - - - - - diff --git a/mobile/web/reference/API/boolean.xml b/mobile/web/reference/API/boolean.xml deleted file mode 100644 index 485f3e705..000000000 --- a/mobile/web/reference/API/boolean.xml +++ /dev/null @@ -1,65 +0,0 @@ - - -boolean - -Data - -Primitive - -Web & Application - - -boolean.gif - -boolean a = false; -if (!a) { - rect(30, 20, 50, 50); -} -a = true; -if (a) { - line(20, 10, 90, 80); - line(20, 80, 90, 10); -} - - - - -Datatype for the Boolean values true and false. It is common to use booleanvalues with control statements to determine the flow of a program. The first time a variable is written, it must be declared with a statement expressing its datatype. - - - -boolean var -boolean var = booleanvalue - - - - -variable name referencing the value - - - - -true or false - - - - - -true -false - - -1.0 - -Datatype - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/booleanconvert.xml b/mobile/web/reference/API/booleanconvert.xml deleted file mode 100644 index 06fa751f7..000000000 --- a/mobile/web/reference/API/booleanconvert.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -boolean() - -Data - -Conversion - -Web & Application - - - - -float f = 0.0; -boolean b = boolean(f); -println(f + " : " + b); // Prints "0.0 : false" - -int i = 1; -b = boolean(i); -println(i + " : " + b); // Prints "1 : true" - -i = 3445; -b = boolean(i); -println(i + " : " + b); // Prints "3445 : true" - - - - -Converts a primitive datatype, string, or array to its boolean representation. The number 0 evaluates to false and all other numbers evaluate to true. - - - -boolean(val) - - - - -int, float, char, byte, String, int[], float[], char[], byte[], String[] - - -byte - - -boolean - - -1.0 - -Function - -IDE - - - - - - - - - diff --git a/mobile/web/reference/API/break.xml b/mobile/web/reference/API/break.xml deleted file mode 100644 index 7fa402af8..000000000 --- a/mobile/web/reference/API/break.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -break - -Control - -Conditionals - -Web & Application - - - - -char letter = 'B'; - -switch(letter) { - case 'A': - println("Alpha"); // Does not execute - break; - case 'B': - println("Bravo"); // Prints "Bravo" - break; - default: - println("Zulu"); // Does not execute - break; -} - - - - -Ends the execution of a structure such as switch(), for(), or while() and jumps to the next statement after. - - - -break - - - - - - - - - - -switch() -for() -while() - - -1.0 - -Keyword - -Java - -extended - - - diff --git a/mobile/web/reference/API/brightness.xml b/mobile/web/reference/API/brightness.xml deleted file mode 100644 index e22301472..000000000 --- a/mobile/web/reference/API/brightness.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -brightness() - -Color - -Creating & Reading - -Web & Application - - -brightness_.gif - -noStroke(); -colorMode(HSB, 255); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = brightness(c); // Sets "value" to "255" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the brightness value from a color. - - - -brightness(color) - - - - -any value of the color datatype - - -float - - -red() -green() -blue() -hue() -saturation() - - -1.0 - -Function - -Core - -Extended - - - - diff --git a/mobile/web/reference/API/byte.xml b/mobile/web/reference/API/byte.xml deleted file mode 100644 index 4cc7953e7..000000000 --- a/mobile/web/reference/API/byte.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -byte - -Data - -Primitive - -Web & Application - - - - -byte a; // Declare variable "a" of type byte -a = 23; // Assign "a" the value 23 -byte b = -128; // Declare variable "b" and assign it the value -128 -byte c = a + b; // Declare variable "c" and assign it the sum of "a" and "b" - - - - -Datatype for bytes, 8 bits of information storing numerical values from 127 to -128. Bytes are a convenient datatype for sending information to and from the serial port and for representing letters in a simpler format than the char datatype. The first time a variable is written, it must be declared with a statement expressing its datatype. Subsequent uses of this variable must not reference the datatype because Processing will think the variable is being declared again. - - - -byte var -byte var = value - - - - -variable name referencing the value - - - - -a number between 127 to -128 - - - - - -int -float -boolean - - -1.0 - -Datatype - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/byteconvert.xml b/mobile/web/reference/API/byteconvert.xml deleted file mode 100644 index 37550166e..000000000 --- a/mobile/web/reference/API/byteconvert.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -byte() - -Data - -Conversion - -Web & Application - - - - -float f = 65.0; -byte b = byte(f); -println(f + " : " + b); // Prints "65.0 : 65" - -char c = 'E'; -b = byte(c); -println(c + " : " + b); // Prints "E : 69" - -f = 130.0; -b = byte(f); -println(f + " : " + b); // Prints "130.0 : -126" - - - - -Converts a primitive datatype, string, or array to its byte representation. A byte can only be a whole number between -128 and 127, therefore when a number outside this range is converted, its value wraps to the corresponding byte representation. - - - -byte(val) - - - - -int, float, char, boolean, String, int[], float[], char[], boolean[], String[] - - -byte - - -byte -int() - - -1.0 - -Function - -IDE - - - - - - - - - diff --git a/mobile/web/reference/API/case.xml b/mobile/web/reference/API/case.xml deleted file mode 100644 index 6709f47e0..000000000 --- a/mobile/web/reference/API/case.xml +++ /dev/null @@ -1,69 +0,0 @@ - - -case - -Control - -Conditionals - -Web & Application - - - - -char letter = 'B'; - -switch(letter) { - case 'A': - println("Alpha"); // Does not execute - break; - case 'B': - println("Bravo"); // Prints "Bravo" - break; - default: - println("Zulu"); // Does not execute - break; -} - - - - -Denotes the different labels to be evaluated with the parameter in the switch() structure. - - - -case label: statements - - - - -byte, char, or int - - - - -one or more valid statements - - - - - -switch() -default -break - - -1.0 - -Keyword - -Java - - -extended - - - - - - diff --git a/mobile/web/reference/API/ceil.xml b/mobile/web/reference/API/ceil.xml deleted file mode 100644 index b8f21fb72..000000000 --- a/mobile/web/reference/API/ceil.xml +++ /dev/null @@ -1,51 +0,0 @@ - - -ceil() - -Math - -Calculation - -Web & Application - - - - -float x = 8.22; -float a = ceil(x); // Set "a" to 9.0 - - - - -Calculates the closest value that is greater than or equal to the value of the parameter. For example, ceil(9.03) returns the value 10.0. - - - -ceil(value) - - - - -float - - -float - - -floor() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/char.xml b/mobile/web/reference/API/char.xml deleted file mode 100644 index 0bf819c1a..000000000 --- a/mobile/web/reference/API/char.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -char - -Data - -Primitive - -Web & Application - - - - -char m; // Declare variable "m" of type char -m = 'A'; // Assign "m" the value "A" -int n = '&'; // Declare variable "n" and assign it the value "&" - - - - -Datatype for characters, typographic symbols such as A, d, and $. A char stores letters and symbols in the Unicode format, a coding system developed to support a variety of world languages. Each char is two bytes (16 bits) in length and is distinguished by surrounding it with single quotes. Character escapes may also stored as a char. For example, the representation for the "delete" key is '\377'. The first time a variable is written, it must be declared with a statement expressing its datatype. Subsequent uses of this variable must not reference the datatype because Processing will think the variable is being declared again. - - - -char var -char var = value - - - - -variable name referencing the value - - - - -any character - - - - - -String - - -1.0 - -Datatype - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/charconvert.xml b/mobile/web/reference/API/charconvert.xml deleted file mode 100644 index 42c56a879..000000000 --- a/mobile/web/reference/API/charconvert.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -char() - -Data - -Conversion - -Web & Application - - - - -int i = 65; -char c = char(i); -println(i + " : " + c); // Prints "65 : A" - -float f = 72.4; -c = char(f); -println(f + " : " + c); // Prints "72.4 : H" - -boolean b = true; -c = char(b); -println(b + " : " + c); // Prints "true : t" - - - - -Converts a primitive datatype, string, or array to a numeric character representation. - - - -char(val) - - - - -int, float, byte, boolean, String, int[], float[], byte[], boolean[], String[] - - -char - - -char -int() -float() -byte() - - -1.0 - -Function - -IDE - - - - - - - - - diff --git a/mobile/web/reference/API/class.xml b/mobile/web/reference/API/class.xml deleted file mode 100644 index e26bb8a06..000000000 --- a/mobile/web/reference/API/class.xml +++ /dev/null @@ -1,80 +0,0 @@ - - -class - -Structure - - - -Web & Application - - - - -// Declare and contruct two objects (h1, h2) from the class HLine -HLine h1 = new HLine(20, 2.0); -HLine h2 = new HLine(50, 2.5); - -void setup() -{ - size(200, 200); - framerate(30); -} - -void loop() { - background(204); - h1.update(); - h2.update(); -} - -class HLine { - float ypos, speed; - HLine (float y, float s) { - ypos = y; - speed = s; - } - void update() { - ypos += speed; - if (ypos > width) { - ypos = 0; - } - line(0, ypos, width, ypos); - } -} - - - - -Keyword used to indicate the declaration of a class. A class is a composite of data and methods (functions) which may be instantiated as objects. The first letter of a class name is usually uppercase to separate it from other kinds of variables. A related tutorial on Object-Oriented Programming is hosted from the Sun website. - - - -class ClassName { - statements -} - - - - -Any valid variable name - - - - -any valid statements - - - - - -Object - - -1.0 - -Keyword - -PDE - - - diff --git a/mobile/web/reference/API/color.xml b/mobile/web/reference/API/color.xml deleted file mode 100644 index 19fa9419d..000000000 --- a/mobile/web/reference/API/color.xml +++ /dev/null @@ -1,78 +0,0 @@ - - -color() - -Color - -Creating & Reading - -Web & Application - - -color_.gif - -color c1 = color(102, 102, 0); -fill(c1); -noStroke(); -rect(30, 20, 55, 55); - - - - -Creates colors which may be stored in variables of the color datatype. The parameters are interpreted as RGB or HSB values depending on the current colorMode(). The default mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) will return a bright yellow color. The color() function packs the information input through its parameters into a 32 bit number in the following order AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB where R is the red/hue value, G is green/saturation, and B is blue/brightness. - - - -color(gray) -color(gray, alpha) -color(value1, value2, value3) -color(value1, value2, value3, alpha) - - - - -int or float: number specifying value between white and black - - - - -int or float: relative to current color range - - - - -int or float: red or hue values relative to the current color range - - - - -int or float: green or saturation values relative to the current color range - - - - -int or float: blue or brightness values relative to the current color range - - - -color - - -color -colorMode() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/colorMode.xml b/mobile/web/reference/API/colorMode.xml deleted file mode 100644 index 646a8fe03..000000000 --- a/mobile/web/reference/API/colorMode.xml +++ /dev/null @@ -1,91 +0,0 @@ - - -colorMode() - -Color - -Setting - -Web & Application - - -colorMode_.jpg - -noStroke(); -colorMode(RGB, 100); -for(int i=0; i<100; i++) { - for(int j=0; j<100; j++) { - stroke(i, j, 0); - point(i, j); - } -} - - - - -colorMode_2.jpg - -noStroke(); -colorMode(HSB, 100); -for(int i=0; i<100; i++) { - for(int j=0; j<100; j++) { - stroke(i, j, 100); - point(i, j); - } -} - - - - -Changes the way Processing interprets color data. By default, fill(), stroke(), and background() colors are set by values between 0 and 255 using the RGB color model. It is possible to change the numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the parameters range1, range2, and range 3. - - - -colorMode(mode); -colorMode(mode, range); -colorMode(mode, range1, range2, range3); - - - - -Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - - - - -int or float: range for all color elements - - - - -int or float: range for the red or hue depending on the current color mode - - - - -int or float: range for the green or saturation depending on the current color mode - - - - -int or float: range for the blue or brightness depending on the current color mode - - -None - - -background() -fill() -stroke() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/color_datatype.xml b/mobile/web/reference/API/color_datatype.xml deleted file mode 100644 index 8c5c61262..000000000 --- a/mobile/web/reference/API/color_datatype.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -color - -Data - -Primitive - -Web & Application - - -color.gif - -color c1 = color(204, 153, 0); -color c2 = #FFCC00; -noStroke(); -fill(c1); -rect(0, 0, 25, 100); -fill(c2); -rect(25, 0, 25, 100); -color c3 = get(10, 50); -fill(c3); -rect(50, 0, 50, 100); - - - - -Datatype for storing color values. Colors may be assigned with get() and color() or they may be specified directly using hexadecimal notation such as #FFCC00. Colors are 32 bits of information ordered as AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB where the A's contain the alpha value, the R's are the red/hue value, G's are green/saturation, and B's are blue/brightness. Color is a datatype unique to Processing. - - - -color var -color var = colorvalue - - - - -variable name referencing the value - - - - -any color value - - - - - -colorMode() -color() - - -1.0 - -Datatype - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/comma.xml b/mobile/web/reference/API/comma.xml deleted file mode 100644 index 3bf873339..000000000 --- a/mobile/web/reference/API/comma.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -, (comma) - -Structure - - - -Web & Application - - - - - -// Comma used to separate a list of variable declarations -int a=20, b=30, c=80; - -// Comma used to separate a list of values assigned to an array -int[] d = { 20, 60, 80 }; - -// Comma used to separate a list of parameters passed to a function -line(a, b, c, b); -line(d[0], d[1], d[2], d[1]); - - - - -Separates parameters in function calls and elements during assignment. - - - -value1, ..., valueN - - - - -any int, float, byte, boolean, color, char, String - - - - - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/comment.xml b/mobile/web/reference/API/comment.xml deleted file mode 100644 index b04b0bee0..000000000 --- a/mobile/web/reference/API/comment.xml +++ /dev/null @@ -1,53 +0,0 @@ - - -// (comment) - -Structure - - - -Web & Application - - - - -// Draws two lines which divides the window -// into four quadrants -line(0, 50, 100, 50); // Draw the horizontal line -line(50, 0, 50, 100); // Draw the vertical line - - - - -Explanatory notes embedded within the code. Comments are used to remind yourself and to inform others about the function of your program. Single-line comments are signified with the // characters. Comments are ignored by the compiler. - - - -// comment - - - - -any sequence of characters - - - - - -/* */ (multiline comment) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/concat.xml b/mobile/web/reference/API/concat.xml deleted file mode 100644 index e27f47114..000000000 --- a/mobile/web/reference/API/concat.xml +++ /dev/null @@ -1,51 +0,0 @@ - - -concat() - -Data - -Array Functions - -Web & Application - - - - -String sa1[] = { "OH ", "NY ", "CA "}; -String sa2[] = { "KY ", "IN ", "MA "}; -String sa3[] = concat(sa1, sa2); -print(sa3); // Prints "OH NY CA KY IN MA " - - - - -Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the same datatype. - - - -concat(array1, array2) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[] - - -Array (the same datatype as the input) - - -splice() - - -1.0 - -Function - -Core - - -Extended - - - - diff --git a/mobile/web/reference/API/conditional.xml b/mobile/web/reference/API/conditional.xml deleted file mode 100644 index d4295df4a..000000000 --- a/mobile/web/reference/API/conditional.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -?: (conditional) - -Control - -Conditionals - -Web & Application - - - - -int s = 0; -for(int i=5; i<100; i+=5) { - s = (i < 50) ? 0 : 255; - stroke(s); - line(30, i, 80, i); -} - - - - -A shortcut for writing an if() and else structure. If the condition evaluates to true, expression1 is evaluated and returned. If the condition evaluates to false, expression2 is evaluated and returned.

The following conditional:
condition : expression1 ? expression2

is equivalent to this structure:
if(condition) {
expression1
} else {
expression2
}
-
- - -condition ? expression1 : expression2 - - - - -any valid expression which evaluates to true or false - - - - -any valid expression - - - - -any valid expression - - -Variable, dependent on the datatype of the expressions - - -if() -else - - -1.0 - -Structure - -PDE - - -Extended - - - - - -
diff --git a/mobile/web/reference/API/constrain.xml b/mobile/web/reference/API/constrain.xml deleted file mode 100644 index 517e35de2..000000000 --- a/mobile/web/reference/API/constrain.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -constrain() - -Math - -Calculation - -Web & Application - - -constrain_.jar - -void loop() -{ - background(204); - float mx = constrain(mouseX, 30, 70); - rect(mx-10, 40, 20, 20); -} - - - - -Constrains a value to not exceed a maximum and minimum value. - - - -constrain(value, min, max) - - - - -int or float: the value to constrain - - - - -int or float: minimum limit - - - - -int or float: maximum limit - - -float or int (depending on the input values) - - -max() -min() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/contract.xml b/mobile/web/reference/API/contract.xml deleted file mode 100644 index 5de189dbd..000000000 --- a/mobile/web/reference/API/contract.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - -contract() - -Data - -Array Functions - -Web & Application - - - - -int[] ia = {0, 1, 2, 3, 4, 5, 6, 7}; -println(ia.length); // Prints "8" -ia = contract(ia, 5); -println(ia.length); // Prints "5" - - - - -Decreases the size of an array. The required newSize parameter provides precise control over the decrease in size. - - - -contract(array, newSize) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[] - - - - -positive int: new size for the array - - -Array (the same datatype as the input) - - -expand() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/curlybraces.xml b/mobile/web/reference/API/curlybraces.xml deleted file mode 100644 index d90e7b36f..000000000 --- a/mobile/web/reference/API/curlybraces.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -{} (curly braces) - -Structure - - - -Web & Application - - - - -int[] a = { 5, 20, 25, 45, 70 }; - -void setup() { - size(100, 100); -} - -void loop() { - for(int i=0; i<a.length; i++) { - line(0, a[i], 50, a[i]); - } -} - - - - -Define the beginning and end of functions blocks and statement blocks such as the for() and if() structures. Curly braces are also used for defining inital values in array declarations. - - - -{ statements } -{ ele0, ..., eleN } - - - - -any sequence of valid statements - - - - -list of elements separated by commas - - - - - -() (parentheses) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/curve.xml b/mobile/web/reference/API/curve.xml deleted file mode 100644 index c08ec1daf..000000000 --- a/mobile/web/reference/API/curve.xml +++ /dev/null @@ -1,91 +0,0 @@ - - -curve() - -Shape - -Curves - -Web & Application - - -curve_.gif - -stroke(255, 102, 0); -curve(5, 26, 5, 26, 73, 24, 73, 61); -stroke(0); -curve(5, 26, 73, 24, 73, 61, 15, 65); -stroke(255, 102, 0); -curve(73, 24, 73, 61, 15, 65, 15, 65); - - - - -Draws a curved line on the screen. The first and second parameters specify the first anchor point and the last two parameters specify the second anchor. The middle parameters specify the points for defining the shape of the curve. Longer curves can be created by putting a series of curve() functions together. An additional function called curveTightness() provides control for the visual quality of the curve. The curve() function is an implementation of Catmull-Rom splines. - - - -curve(x1, y1, x2, y2, x3, y3, x4, y4); - - - - -int or float: x-coordinate of the first anchor - - - - -int or float: y-coordinate of the first anchor - - - - -int or float: x-coordinate of the first point - - - - -int or float: y-coordinate of the first point - - - - -int or float: x-coordinate of the second point - - - - -int or float: y-coordinate of the second point - - - - -int or float: x-coordinate of the second anchor - - - - -int or float: y-coordinate of the second anchor - - -None - - -curveVertex() -bezier() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/curveVertex.xml b/mobile/web/reference/API/curveVertex.xml deleted file mode 100644 index b8fead772..000000000 --- a/mobile/web/reference/API/curveVertex.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -curveVertex() - -Shape - -Vertex - -Application & Web - - -curveVertex_.gif - -beginShape(LINE_STRIP); -curveVertex(84, 91); -curveVertex(84, 91); -curveVertex(68, 19); -curveVertex(21, 17); -curveVertex(32, 100); -curveVertex(32, 100); -endShape(); - - - - -Specifies vertex coordinates for curves. This function may only be called between beginShape() and endShape(). The curveVertex() function is an implementation of Catmull-Rom splines. - - - -curveVertex(x, y) -curveVertex(x, y, z) - - - - -The x-coordinate of the vertex, either a float or int - - - - -The y-coordinate of the vertex, either a float or int - - - - -The z-coordinate of the vertex, either a float or int - - -None - - -beginShape() -endShape() -vertex() -bezierVertex() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/day.xml b/mobile/web/reference/API/day.xml deleted file mode 100644 index 7ee229eef..000000000 --- a/mobile/web/reference/API/day.xml +++ /dev/null @@ -1,73 +0,0 @@ - - -day() - -Input/Output - -Time & Date - -Web & Application - - -day_.jar - -void setup() { - PFont metaBold; - metaBold = loadFont("fonts/Meta-Bold.vlw.gz"); - setFont(metaBold, 44); - hint(SMOOTH_IMAGES); -} - -void loop() { - int d = day(); // Values from 1 - 31 - int m = month(); // Values from 1 - 12 - int y = year(); // 2003, 2004, 2005, etc. - String s = String.valueOf(d); - text(s, 10, 28); - s = String.valueOf(m); - text(s, 10, 56); - s = String.valueOf(y); - text(s, 10, 84); -} - - - - -Processing communicates with the clock on your computer. The day() function returns the current day as a value from 1 - 31. - - - -day() - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/decrement.xml b/mobile/web/reference/API/decrement.xml deleted file mode 100644 index f194c1931..000000000 --- a/mobile/web/reference/API/decrement.xml +++ /dev/null @@ -1,54 +0,0 @@ - - --- (decrement) - -Math - -Operators - -Web & Application - - - - -int a = 5; // Sets "a" to 5 -int b = a--; // Sets "b" to 5, then decrements "a" to 4 -int c = a; // Sets "c" to 4 - - - - -Substracts the value of an integer variable by 1. Equivalent to the operation i = i - 1. If the value of the variable i is five, then the expression i-- decreases the value of i to 4. - - - -var-- - - - - -int - - - - - -- (minus) --= (subtract assign) -++ (increment) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/default.xml b/mobile/web/reference/API/default.xml deleted file mode 100644 index b46ee8bcf..000000000 --- a/mobile/web/reference/API/default.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -default - -Control - -Conditionals - -Web & Application - - - - -char letter = 'F'; - -switch(letter) { - case 'A': - println("Alpha"); // Does not execute - break; - case 'B': - println("Bravo"); // Does not execute - break; - default: - println("Zulu"); // Prints "Zulu" - break; -} - - - - -Keyword for defining the default condition of a switch(). If none of the case labels match the switch() parameter, the statement(s) after the default syntax are executed. Switch structures don't require a default. - - - -default: statements - - - - -one or more valid statements to be executed - - - - - -switch() -break -case - - -1.0 - -Keyword - -Java - - -Extended - - - - - - diff --git a/mobile/web/reference/API/delay.xml b/mobile/web/reference/API/delay.xml deleted file mode 100644 index 89a610c93..000000000 --- a/mobile/web/reference/API/delay.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -delay() - -Environment - - - -Web & Application - - -delay_.jar - -int pos = 0; -void loop() { - background(204); - pos++; - line(pos, 20, pos, 80); - if(pos > width) { - pos = 0; - } - delay(250); // Stops the program for 250 milliseconds -} - - - - -Forces the program to stop running for a specified time. Delay times are specified in thousandths of a second. The function call delay(3000) will stop the program for three seconds. This function causes the program to stop as soon as it is called, except if the program is running the loop() for the first time, it will complete the loop before stopping. - - - -delay(milliseconds) - - - - -int: specified as milliseconds (there are 1000 milliseconds in 1 second) - - -None - - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/dist.xml b/mobile/web/reference/API/dist.xml deleted file mode 100644 index 9ab1ed301..000000000 --- a/mobile/web/reference/API/dist.xml +++ /dev/null @@ -1,80 +0,0 @@ - - -dist() - -Math - -Calculation - -Web & Application - - -dist_.jar - -// Sets the background gray value based on -// the distance of the mouse from the center -void loop() { - float d = dist(50, 50, mouseX, mouseY); - fill(d*4); - rect(0, 0, 99, 99); -} - - - - -Calculates the distance between two points. - - - -dist(x1, y1, x2, y2); -dist(x1, y1, z1, x2, y2, z2); - - - - -int or float: x-coordinate of the first point - - - - -int or float: y-coordinate of the first point - - - - -int or float: z-coordinate of the first point - - - - -int or float: x-coordinate of the second point - - - - -int or float: y-coordinate of the second point - - - - -int or float: z-coordinate of the second point - - -float - - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/divide.xml b/mobile/web/reference/API/divide.xml deleted file mode 100644 index 5829b89c8..000000000 --- a/mobile/web/reference/API/divide.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -/ (divide) - -Math - -Operators - -Web & Application - - - - -int g = 50 / 5; // Sets g 10 -int h = g / 5; // Sets h 2 - - - - -Divides the value of the second parameter by the value of the first parameter. The answer to the equation 20 / 4 is 5. The number 20 is the sum of 4 of the number 5. As an equation we see that 4 + 4 + 4 + 4 + 4 = 20. - - - -value1 / value2 - - - - -int or float - - - - -int or float, but not zero (it is not possible divide by zero) - - - - - -* (multiply) -% (modulo) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/dot.xml b/mobile/web/reference/API/dot.xml deleted file mode 100644 index 310ad6d52..000000000 --- a/mobile/web/reference/API/dot.xml +++ /dev/null @@ -1,90 +0,0 @@ - - -. (dot) - -Structure - - - -Web & Application - - - - -// Declare and contruct two objects (h1, h2) from the class HLine -HLine h1 = new HLine(20, 1.0); -HLine h2 = new HLine(50, 5.0); - -void setup() { - size(200, 200); -} - -void loop() { - if(h2.speed > 1.0) { - h2.speed -= 0.01; - } - h1.update(); - h2.update(); -} - -class HLine { - float ypos, speed; - HLine (float y, float s) { - ypos = y; - speed = s; - } - void update() { - ypos += speed; - if (ypos > width) { - ypos = 0; - } - line(0, ypos, width, ypos); - } -} - - - - -Provides access to an object's methods and data. An object is an instance of a class and contains is a grouping of methods (object functions) and data (object variables and constants). The dot operator directs the program to the information encapsulated within an object. - - - -object.method() -object.data - - - - -the object you want to access - - - - -method encapsulated in the object - - - - -variable or constant encapsulated in the object - - - - - -Object - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/draw.xml b/mobile/web/reference/API/draw.xml deleted file mode 100644 index a2875f590..000000000 --- a/mobile/web/reference/API/draw.xml +++ /dev/null @@ -1,69 +0,0 @@ - - -draw() - -Structure - - - -Web & Application - - - - - -void setup() { - size(200, 200); - noStroke(); -} - -int a = 0; - -void draw() { - fill(a); - a = a + 1; - if (a > width) { - a = 0; - } - rect(a, 0, 2, 200); -} - - - - -Continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. Calling redraw() will cause the code inside draw() to execute once and calling loop() will cause the code inside draw() to execute continuously. The draw() function is used in conjunction with setup(). The number of times draw() executes in each second may be controlled with the delay() and framerate() functions. - - - -draw() { - statements -} - - - - -A sequence of statements to be executed over and over again - - -None - - -setup() -loop() -noLoop() - - -1.0 - -Processing Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/ellipse.xml b/mobile/web/reference/API/ellipse.xml deleted file mode 100644 index a0f97d965..000000000 --- a/mobile/web/reference/API/ellipse.xml +++ /dev/null @@ -1,65 +0,0 @@ - - -ellipse() - -Shape - -2D Primitives - -Web & Application - - -ellipse_.gif - -ellipse(56, 46, 55, 55); - - - - -Draws an ellipse (oval) in the display window. An ellipse with an equal width and height is a circle. The first two parameters set the location, the third sets the width, and the fourth sets the height. The origin may be changed with the ellipseMode() function. - - - -ellipse(x, y, width, height) - - - - -int or float: x-coordinate of the ellipse - - - - -int or float: y-coordinate of the ellipse - - - - -int or float: width of the ellipse - - - - -int or float: height of the ellipse - - -None - - -ellipseMode() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/ellipseMode.xml b/mobile/web/reference/API/ellipseMode.xml deleted file mode 100644 index a9173d649..000000000 --- a/mobile/web/reference/API/ellipseMode.xml +++ /dev/null @@ -1,47 +0,0 @@ - - -ellipseMode() - -Shape - -2D Primitives - -Web & Application - - -ellipseMode_.gif - -ellipseMode(CENTER); -ellipse(35, 35, 50, 50); -ellipseMode(CORNER); -fill(102); -ellipse(35, 35, 50, 50); - - - - -The origin of the ellipse is modified by the ellipseMode() function. The default configuration is ellipseMode(CENTER), which specifies the location of the ellipse as the center of the shape. The CENTER_RADIUS mode is the same, but the width and height parameters to ellipse() specify the radius of the ellipse, rather than the diameter. The CORNER mode draws the shape from the upper-left corner of its bounding box. The CORNERS mode uses the four parameters to ellipse() to set two opposing corners of the ellipse's bounding box. The parameter must be written in "ALL CAPS" because Processing is a case sensitive language. - - - -ellipseMode(MODE) - - - - -Either CENTER, CENTER_RADIUS, CORNER, CORNERS. - - -None - - -ellipse() - - -1.0 - -Function - -Core - - diff --git a/mobile/web/reference/API/else.xml b/mobile/web/reference/API/else.xml deleted file mode 100644 index a8f2b083a..000000000 --- a/mobile/web/reference/API/else.xml +++ /dev/null @@ -1,88 +0,0 @@ - - -else - -Control - -Conditionals - -Web & Application - - -else.gif - -for(int i = 5; i < 95; i += 5) { - if(i < 35) { - line( 30, i, 80, i ); - } else { - line( 20, i, 90, i ); - } -} - - - - -else2.gif - -for(int i = 5; i < 95; i += 5) { - if(i < 35) { - line( 30, i, 80, i ); - } else if (i < 65) { - line( 20, i, 90, i ); - } else { - line( 0, i, 100, i ); - } -} - - - - -Extends the if() structure allowing the program to choose between two or more block of code. It specifies a block of code to execute when the expression in if() is false. - - - -if(expression) { - statements -} else { - statements -} - -if(expression) { - statements -} else if(expression) { - statements -} else { - statements -} - - - - -any valid expression that evaluates to true or false - - - - -one or more statements to be executed - - - - - -if() - - -1.0 - -Keyword - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/endShape.xml b/mobile/web/reference/API/endShape.xml deleted file mode 100644 index f5df676db..000000000 --- a/mobile/web/reference/API/endShape.xml +++ /dev/null @@ -1,55 +0,0 @@ - - -endShape() - -Shape - -Vertex - -Web & Application - - -endShape_.gif - -beginShape(LINE_STRIP); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -The endShape() function is the companion to beginShape() and may only be called after the later. When endshape() is called, all of image data defined since the previous call to beginShape() is written into the image buffer. - - - -beginShape() - - - - - - - -None - - -beginShape() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/equality.xml b/mobile/web/reference/API/equality.xml deleted file mode 100644 index 1b03adc10..000000000 --- a/mobile/web/reference/API/equality.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -== (equality) - -Control - -Relational Operators - -Web & Application - - - - -int a = 23; -int b = 23; -if(a == b) { - println("variables a and b are equal"); -} - - - - -Determines if two values are equivalent. The equality operator is different from the assignment operator. - - - -value1 == value2 - - - - -int, float, char, byte, boolean, String - - - - -int, float, char, byte, boolean, String - - - - - -> (greater than) -< (less than) ->= (greater than or equal to) -<= (less than or equal to) -!= (inequality) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/expand.xml b/mobile/web/reference/API/expand.xml deleted file mode 100644 index 436c4f792..000000000 --- a/mobile/web/reference/API/expand.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -expand() - -Data - -Array Functions - -Web & Application - - - - -int[] ia = {0, 1, 3, 4}; -println(ia.length); // Prints "4" -ia = expand(ia); -println(ia.length); // Prints "8" -ia = expand(ia, 512); -println(ia.length); // Prints "512" - - - - -Increases the size of an array. By default, this function doubles the size of the array, but the optional newSize parameter provides precise control over the increase in size. - - - -expand(array) -expand(array, newSize) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[] - - - - -positive int: new size for the array - - -Array (the same datatype as the input) - - -contract() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/false.xml b/mobile/web/reference/API/false.xml deleted file mode 100644 index 64105e356..000000000 --- a/mobile/web/reference/API/false.xml +++ /dev/null @@ -1,56 +0,0 @@ - - -false - -Structure - - - -Web & Application - - - - -rect(30, 20, 50, 50); -boolean b = false; -if(b == false) { - line(20, 10, 90, 80); // This line draws -} else { - line(20, 80, 90, 10); -} - - - - -Reserved word representing the logical value "false". Only variables of type boolean may be assigned the value false - - - -false - - - - - - - - - -any valid statements - - - - - -true -boolean - - -1.0 - -Keyword - -PDE - - - diff --git a/mobile/web/reference/API/fill.xml b/mobile/web/reference/API/fill.xml deleted file mode 100644 index a8ce8bd7e..000000000 --- a/mobile/web/reference/API/fill.xml +++ /dev/null @@ -1,90 +0,0 @@ - - -fill() - -Color - -Setting - -Web & Application - - -fill_.gif - -fill(153); -rect(30, 20, 55, 55); - - - - -fill_2.gif - -fill(204, 102, 0); -rect(30, 20, 55, 55); - - - - -Sets the color used to fill shapes. For example, if you call fill(204, 102, 0) and draw a rectangle it will be filled with orange. This color is either specified in terms of the RGB or HSB color depending on the current colorMode(). The default color space is RGB, with each value in the range from 0 to 255. The version of fill() with one parameter specifies a gray value, the version with three parameters specifies a color, and the version with four parameters specifies a color with an alpha value. Note: the value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default value is 255. - - - -fill(gray) -fill(gray, alpha) -fill(value1, value2, value3) -fill(color) -fill(color, alpha) -fill(value1, value2, value3, alpha) - - - - -int or float: number specifying value between white and black - - - - -int or float: red or hue value - - - - -int or float: green or saturation value - - - - -int or float: blue or brightness value - - - - -int or float: opacity of the fill - - - - -color: any value of the color datatype - - -None - - -noFill() -colorMode() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/floor.xml b/mobile/web/reference/API/floor.xml deleted file mode 100644 index 9a4586fd2..000000000 --- a/mobile/web/reference/API/floor.xml +++ /dev/null @@ -1,51 +0,0 @@ - - -floor() - -Math - -Calculation - -Web & Application - - - - -float x = 2.88; -float a = floor(x); // Set "a" to 2.0 - - - - -Calculates the closest value that is less than or equal to the value of the parameter. - - - -floor(value) - - - - -float - - -float - - -ceil() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/for.xml b/mobile/web/reference/API/for.xml deleted file mode 100644 index 54e82ae15..000000000 --- a/mobile/web/reference/API/for.xml +++ /dev/null @@ -1,102 +0,0 @@ - - -for() - -Control - -Iteration - -Web & Application - - -for_.gif - - -for(int i=0; i<40; i=i+1) { - line(30, i, 80, i); -} - - - - -for_2.gif - - -for(int i=0; i<80; i=i+5) { - line(30, i, 80, i); -} - - - - -for_3.gif - - -for(int i=40; i<80; i=i+5) { - line(30, i, 80, i); -} - - - - -for_4.gif - - -for(int i=30; i<80; i=i+5) { - for(int j=0; j<80; j=j+5) { - point(i, j); - } -} - - - - -Controls a sequence of repetitions. A for() structure has three parts: init, test, and update. Each part must be separated by a semi-colon ";". The loop continues until the test evaluates to false. When a for() structure is executed, the following sequence of events occurs:
1. The init statement is executed
2. The test is evaluated to be true or false
3. If the test is true, jump to step 4. If the test is False, jump to step 6
4. Execute the statements within the block
5. Execute the update statement and jump to step 2
6. Exit the loop. -
- - -for(init; test; update) { - statements -} - - - - -statement executed once when beginning loop - - - - -if the test evaluates to true, the statements execute - - - - -executes at the end of each iteration - - - - -collection of statements executed each time through the loop - - - - - -while() - - -1.0 - -Structure - -PDE - - - - - - - - -
diff --git a/mobile/web/reference/API/greaterthan.xml b/mobile/web/reference/API/greaterthan.xml deleted file mode 100644 index 30b8167cd..000000000 --- a/mobile/web/reference/API/greaterthan.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -> (greater than) - -Control - -Relational Operators - -Web & Application - - - - -int a = 5; -int b = 13; -if(b > a) { - println("variable b is larger the variable a"); -} - - - - -Tests if the value on the left is larger than the value on the right. - - - -value1 > value2 - - - - -int or float - - - - -int or float - - - - - -< (less than) ->= (greater than or equal to) -<= (less than or equal to) -== (equality) -!= (inequality) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/greaterthanorequalto.xml b/mobile/web/reference/API/greaterthanorequalto.xml deleted file mode 100644 index 3fdc1fb09..000000000 --- a/mobile/web/reference/API/greaterthanorequalto.xml +++ /dev/null @@ -1,63 +0,0 @@ - - ->= (greater than or equal to) - -Control - -Relational Operators - -Web & Application - - - - -int a = 23; -int b = 23; -if(a >= b) { - println("variable a is greater or equal to variable b ") -} - - - - -Tests if the value on the left is larger than the value on the right or if the values are equivalent. - - - -value1 >= value2 - - - - -int or float - - - - -int or float - - - - - -> (greater than) -< (less than) -<= (less than or equal to) -== (equality) -!= (inequality) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/green.xml b/mobile/web/reference/API/green.xml deleted file mode 100644 index b2a6821c1..000000000 --- a/mobile/web/reference/API/green.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -green() - -Color - -Creating & Reading - -Web & Application - - -green_.gif - -noStroke(); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = green(c); // Sets "value" to "126" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the green value from a color. - - - -green(color) - - - - -any value of the color datatype - - -float - - -red() -blue() -hue() -saturation() -brightness() - - -1.0 - -Function - -Core - - - - - - diff --git a/mobile/web/reference/API/height.xml b/mobile/web/reference/API/height.xml deleted file mode 100644 index db383aec9..000000000 --- a/mobile/web/reference/API/height.xml +++ /dev/null @@ -1,53 +0,0 @@ - - -height - -Environment - - - -Web & Application - - -height.gif - -noStroke(); -background(0); -rect(40, 0, 20, height); -rect(60, 0, 20, height/2); - - - - -System variable which stores the height of the display window. This value is set by the second parameter of the size() function. For example, the function call size(320, 240) sets the height variable to the value 240. The value of height is zero until size() is called. - - - -height - - - - - - - - - - -width - - -1.0 - -System variable - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/hour.xml b/mobile/web/reference/API/hour.xml deleted file mode 100644 index 8cb7bd643..000000000 --- a/mobile/web/reference/API/hour.xml +++ /dev/null @@ -1,62 +0,0 @@ - - -hour() - -Input/Output - -Time & Date - -Web & Application - - -hour_.jar - -void loop() { - background(204); - int s = second(); // Values from 0 - 59 - int m = minute(); // Values from 0 - 59 - int h = hour(); // Values from 0 - 23 - line(s, 0, s, 33); - line(m, 33, m, 66); - line(h, 66, h, 100); -} - - - - -Processing communicates with the clock on your computer. The hour() function returns the current hour as a value from 0 - 23. - - - -hour() - - - - - - - -int - - -millis() -second() -minute() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - diff --git a/mobile/web/reference/API/hue.xml b/mobile/web/reference/API/hue.xml deleted file mode 100644 index 1c8a0985a..000000000 --- a/mobile/web/reference/API/hue.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -hue() - -Color - -Creating & Reading - -Web & Application - - -hue_.gif - -noStroke(); -colorMode(HSB, 255); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = hue(c); // Sets "value" to "0" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the hue value from a color. - - - -hue(color) - - - - -any value of the color datatype - - -float - - -red() -green() -blue() -saturation() -brightness() - - -1.0 - -Function - -Core - -Extended - - - - - - - diff --git a/mobile/web/reference/API/if.xml b/mobile/web/reference/API/if.xml deleted file mode 100644 index baf7cd092..000000000 --- a/mobile/web/reference/API/if.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -if() - -Control - -Conditionals - -Web & Application - - -if_.gif - -for(int i=5; i<height; i+=5) { - stroke(255); //Set the color to white - if(i < 35) { //When "i" is less than "35"... - stroke(0); //...set the color to black - } - line(30, i, 80, i); -} - - - - -Allows the program to make a decision about which code to execute. If the expression evaluates to true, the statements enclosed within the block are executed and if the expression evaluates to false the statements are not executed. - - - -if(expression) { - statements -} - - - - -any valid expression that evaluates to true or false - - - - -one or more statements to be executed - - - - - -else - - -1.0 - -Structure - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/increment.xml b/mobile/web/reference/API/increment.xml deleted file mode 100644 index 58ecb5a62..000000000 --- a/mobile/web/reference/API/increment.xml +++ /dev/null @@ -1,54 +0,0 @@ - - -++ (increment) - -Math - -Operators - -Web & Application - - - - -int a = 1; // Sets "a" to 1 -int b = a++; // Sets "b" to 1, then increments "a" to 2 -int c = a; // Sets "c" to 2 - - - - -Increases the value of an integer variable by 1. Equivalent to the operation i = i + 1. If the value of the variable i is five, then the expression i++ increases the value of i to 6. - - - -value++ - - - - -int - - - - - -+ (add) -+= (add assign) --- (decrement) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/inequality.xml b/mobile/web/reference/API/inequality.xml deleted file mode 100644 index 7a798beea..000000000 --- a/mobile/web/reference/API/inequality.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -!= (inequality) - -Control - -Relational Operators - -Web & Application - - - - -int a = 22; -int b = 23; -if(a != b) { - println("variable a is not equal to variable b"); -} - - - - -Determines if one expression is not equivalent to another. - - - -value1 != value2 - - - - -int, float, char, byte, boolean, String - - - - -int, float, char, byte, boolean, String - - - - - -> (greater than) -< (less than) ->= (greater than or equal to) -<= (less than or equal to) -== (equality) - - -1.0 - -Operator - -PDE - - - - - - - - - - diff --git a/mobile/web/reference/API/int.xml b/mobile/web/reference/API/int.xml deleted file mode 100644 index e4e9c4e56..000000000 --- a/mobile/web/reference/API/int.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -int - -Data - -Primitive - -Web & Application - - - - -int a; // Declare variable "a" of type int -a = 23; // Assign "a" the value 23 -int b = -256; // Declare variable "b" and assign it the value -256 -int c = a + b; // Declare variable "c" and assign it the sum of "a" and "b" - - - - -Datatype for integers, numbers without a decimal point. Integers can be as large as 2,147,483,647 and as low as -2,147,483,648. They are stored as 32 bits of information. The first time a variable is written, it must be declared with a statement expressing its datatype. Subsequent uses of this variable must not reference the datatype because Processing will think the variable is being declared again. - - - -int var -int var = value - - - - -variable name referencing the value - - - - -any integer value - - - - - -splitInts() -float - - -1.0 - -Datatype - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/intconvert.xml b/mobile/web/reference/API/intconvert.xml deleted file mode 100644 index 86ccca86c..000000000 --- a/mobile/web/reference/API/intconvert.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -int() - -Data - -Conversion - -Web & Application - - - - -float f = 65.0; -int i = int(f); -println(f + " : " + i); // Prints "65.0 : 65" - -char c = 'E'; -i = int(c); -println(c + " : " + i); // Prints "E : 69" - - - - -Converts a primitive datatype, string, or array to its integer representation. - - - -int(value) - - - - -float, char, byte, boolean, String, float[], char[], byte[], boolean[], String[] - - -int - - -int -float() - - -1.0 - -Function - -IDE - - - - - - - - - diff --git a/mobile/web/reference/API/join.xml b/mobile/web/reference/API/join.xml deleted file mode 100644 index 482fbbf44..000000000 --- a/mobile/web/reference/API/join.xml +++ /dev/null @@ -1,110 +0,0 @@ - - -join() - -Data - -String Functions - -Web & Application - - - - -// works identically with float[] and String[] -int list[] = new list[3]; -list[0] = 8; -list[1] = 67; -list[2] = 5; -String formatted = join(list, ", "); -// formatted now contains "8, 67, 5" - -// to format the number of digits used -// the '3' means to pad with zeroes up to 3 digits -String withzeroes = join(list, " ", 3); -// withzeros now contains "008 067 005" - -// for floats, formatting is more complicated because -// there are also digits after the decimal point. -float f[] = new float[3]; -f[0] = 1.3; -f[1] = 92.8; -f[2] = 0.7; -// 3 digits on the left of the decimal point -// 2 digits to the right of the decimal point -String zerofloats = join(f, " ", 3, 2); -// zerofloats now contains "001.30 092.80 007.70" - -// or if you don't want to pad the left-hand side -// a zero will say to ignore and don't pad -String lesspadding = join(f, " ", 0, 2); -// lesspadding now contains "1.30 92.80 7.70" - - - - - -Combines an array of elements into one String. - - - -join(anyArray, separator) -join(intArray, separator, digits) -join(floatArray, separator, left, right) - - - - -array of strings, ints, or floats - - - - -array of ints - - - - -array of floats - - - - -String: a string to be placed between each item - - - - -int: number of digits to pad with zeroes - - - - -int: number of digits to the left of the decimal point - - - - -int: number of digits to the right of the decimal point - - -String - - -split() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/key.xml b/mobile/web/reference/API/key.xml deleted file mode 100644 index 286ef0ee2..000000000 --- a/mobile/web/reference/API/key.xml +++ /dev/null @@ -1,86 +0,0 @@ - - -key - -Input/Output - -Keyboard - -Web & Application - - -key.jar - -// Click on the window to give it focus -// and press the 'B' key - -void loop() { - if(keyPressed) { - if (key == 'b' || key == 'B') { - fill(0); - } - } else { - fill(255); - } - rect(25, 25, 50, 50); -} - - - - -key2.jar - -// Click on the window to give it focus -// and press the up and down arrow keys - -void loop() { - if(keyPressed) { - if (key == UP) { - fill(255); - } else if (key == DOWN) { - fill(0); - } - } else { - fill(126); - } - rect(25, 25, 50, 50); -} - - - - -The system variable key always contains the value of the most recently pressed key on the keyboard. For detecting the arrow keys, the key variable is set to either UP, DOWN, LEFT, or RIGHT. Other special key constants are ALT, CONTROL, and SHIFT. - - - -key - - - - - - - - - - -keyPressed -keyCode -keyPressed() -keyReleased() - - -1.0 - -System variable - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/keyPressed.xml b/mobile/web/reference/API/keyPressed.xml deleted file mode 100644 index a877002b7..000000000 --- a/mobile/web/reference/API/keyPressed.xml +++ /dev/null @@ -1,72 +0,0 @@ - - -keyPressed() - -Input/Output - -Keyboard - -Web & Application - - -keyPressed_.jar - -// Click on the image to give it focus, -// and then press any key - -int value = 0; - -void loop() { - fill(value); - rect(25, 25, 50, 50); -} - -void keyPressed() -{ - if(value == 0) { - value = 255; - } else { - value = 0; - } -} - - - - -The keyPressed() function is called once every time a key is pressed. As a general rule, nothing should be draw within the keyPressed() block. - - - -void keyPressed() { - statements -} - - - - - - - -None - - -keyPressed -key -keyCode -keyReleased() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/keyPressed_var.xml b/mobile/web/reference/API/keyPressed_var.xml deleted file mode 100644 index 58872d18c..000000000 --- a/mobile/web/reference/API/keyPressed_var.xml +++ /dev/null @@ -1,68 +0,0 @@ - - -keyPressed - -Input/Output - -Keyboard - -Web & Application - - -keyPressed.jar - -// Click on the image to give it focus -// and press any key - -// Note: the rectangle in this example may -// flicker as the operating system may -// register a long key press as a repetition -// of key presses - -void loop() { - if (keyPressed == true) { - fill(0); - } else { - fill(255); - } - rect(25, 25, 50, 50); -} - - - - -The boolean system variable keyPressed is true if any key is pressed and false if no keys are pressed. - - - -keyPressed - - - - - - - - - - -key -keyCode -keyPressed() -keyReleased() - - -1.0 - -System variable - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/keyReleased.xml b/mobile/web/reference/API/keyReleased.xml deleted file mode 100644 index 056aaa9bc..000000000 --- a/mobile/web/reference/API/keyReleased.xml +++ /dev/null @@ -1,72 +0,0 @@ - - -keyReleased() - -Input/Output - -Keyboard - -Web & Application - - -keyReleased_.jar - -// Click on the image to give it focus, -// and then press any key - -int value = 0; - -void loop() { - fill(value); - rect(25, 25, 50, 50); -} - -void keyReleased() -{ - if(value == 0) { - value = 255; - } else { - value = 0; - } -} - - - - -The keyReleased() function is called once every time a key is released. As a general rule, nothing should be draw within the keyReleased() block. - - - -void keyReleased() { - statements -} - - - - - - - -None - - -keyPressed -key -keyCode -keyPressed() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/leftshift.xml b/mobile/web/reference/API/leftshift.xml deleted file mode 100644 index 6e128ef8e..000000000 --- a/mobile/web/reference/API/leftshift.xml +++ /dev/null @@ -1,77 +0,0 @@ - - -<< (left shift) - -Math - -Bitwise Operators - -Web & Application - - - - -int m = 1 << 3; // In binary: 1 to 1000 -println(m); // Prints "8" -int n = 1 << 8; // In binary: 1 to 100000000 -println(n); // Prints "256" -int o = 2 << 3; // In binary: 10 to 10000 -println(o); // Prints "16" -int p = 13 << 1; // In binary: 1101 to 11010 -println(p); // Prints "26" - - - - - - -// Packs four 8 bit numbers into one 32 bit number -int a = 255; // Binary: 00000000000000000000000011111111 -int r = 204; // Binary: 00000000000000000000000011001100 -int g = 204; // Binary: 00000000000000000000000011001100 -int b = 51; // Binary: 00000000000000000000000000110011 -a = a << 24; // Binary: 11111111000000000000000000000000 -r = r << 16; // Binary: 00000000110011000000000000000000 -g = g << 8; // Binary: 00000000000000001100110000000000 - -// Equivalent to "color argb = color(r, g, b, a)" but faster -color argb = a | r | g | b; -fill(argb); -rect(30, 20, 55, 55); - - - - -Shifts bits to the left. The number to the left of the operator is shifted the number of places specified by the number to the right. Each shift to the left doubles the number, therefore each left shift multiplies the original number by 2. Use the left shift for fast multiplication or to pack a group of numbers together into one larger number. Left shifting only works with integers or numbers which automatically convert to an integer such at byte and char. - - - -value << n - - - - -int: the value to shift - - - - -int: the number of places to shift left - - - - - ->> (right shift) - - -1.0 - -Operator - -PDE - -Extended - - - diff --git a/mobile/web/reference/API/lerp.xml b/mobile/web/reference/API/lerp.xml deleted file mode 100644 index 767f86d50..000000000 --- a/mobile/web/reference/API/lerp.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - -lerp() - -Math - -Calculation - -Web & Application - - -lerp_.gif - -float a = 20; -float b = 80; -float c = lerp(a, b, .2); -float d = lerp(a, b, .5); -float e = lerp(a, b, .8); -beginShape(POINTS); -vertex(a, 50); -vertex(b, 50); -vertex(c, 50); -vertex(d, 50); -vertex(e, 50); -endShape(); - - - - -lerp_2.gif - -int x1 = 15; -int y1 = 10; -int x2 = 80; -int y2 = 90; -line(x1, y1, x2, y2); -for(int i=0; i<=10; i++) { - float x = lerp(x1, x2, i/10.0) + 10; - float y = lerp(y1, y2, i/10.0); - point(x, y); -} - - - - -Calculates a number between two numbers at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. The lerp function is convenient for creating motion along a strait path and for drawing dotted lines. - - - -lerp(value1, value2, amt) - - - - -float or int: first value - - - - -float or int: second value - - - - -float: between 0.0 and 1.0 - - -float - - -curvePoint() -bezierPoint() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/lessthan.xml b/mobile/web/reference/API/lessthan.xml deleted file mode 100644 index 642139da3..000000000 --- a/mobile/web/reference/API/lessthan.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -< (less than) - -Control - -Relational Operators - -Web & Application - - - - -int a = 22; -int b = 23; -if(a < b) { - println("variable a is less then variable b "); -} - - - - -Tests if the value on the left is smaller than the value on the right. - - - -value1 < value2 - - - - -int or float - - - - -int or float - - - - - -> (greater than) ->= (greater than or equal to) -<= (less than or equal to) -== (equality) -!= (inequality) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/lessthanorequalto.xml b/mobile/web/reference/API/lessthanorequalto.xml deleted file mode 100644 index 9af840331..000000000 --- a/mobile/web/reference/API/lessthanorequalto.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -<= (less than or equal to) - -Control - -Relational Operators - - - - - - -int a = 22; -int b = 23; -if(a <= b) { - println("variable a is less or equal to variable b "); -} - - - - -Tests if the value on the left is less than the value on the right or if the values are equivalent. - - - -value1 <= value2 - - - - -int or float - - - - -int or float - - - - - -> (greater than) -< (less than) ->= (greater than or equal to) -== (equality) -!= (inequality) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/line.xml b/mobile/web/reference/API/line.xml deleted file mode 100644 index 178ad6357..000000000 --- a/mobile/web/reference/API/line.xml +++ /dev/null @@ -1,87 +0,0 @@ - - -line() - -Shape - -2D Primitives - -Web & Application - - -line_.gif - -line(30, 20, 85, 75); - - - - -line_2.gif - -line(30, 20, 85, 20); -stroke(126); -line(85, 20, 85, 75); -stroke(255); -line(85, 75, 30, 75); - - - - -A line is a direct path between two points. The version of line() with four parameters draws the line in the XY plane at Z=0. The version with six parameters allows the line to be placed anywhere within XYZ space. To color a line, use the stroke() function. A line cannot be filled, therefore the fill() method will not affect the color of a line. Lines are drawn with a width of one pixel. - - - -line(x1, y1, x2, y2); -line(x1, y1, z1, x2, y2, z2); - - - - -int or float: x-coordinate of the first point - - - - -int or float: y-coordinate of the first point - - - - -int or float: z-coordinate of the first point - - - - -int or float: x-coordinate of the second point - - - - -int or float: y-coordinate of the second point - - - - -int or float: z-coordinate of the second point - - -None - - -beginShape() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/loadBytes.xml b/mobile/web/reference/API/loadBytes.xml deleted file mode 100644 index 01cea5e9b..000000000 --- a/mobile/web/reference/API/loadBytes.xml +++ /dev/null @@ -1,68 +0,0 @@ - - -loadBytes() - -Input/Output - -Files - -Web & Application - - - - -// open a file and read its binary data -byte b[] = loadBytes("something.dat"); - -// print each value, from 0 to 255 -for (int i = 0; i < b.length; i++) { - // every tenth number, start a new line - if ((i % 10) == 0) { - println(); - } - - // bytes are from -128 to 127, this converts to 0 to 255 - int a = b[i] & 0xff; - print(a + " "); -} -// print a blank line at the end -println(); - - - - - -Reads the contents of a file or url and places it in a byte array. If a file is specified, it must be located in the sketch's "data" directory/folder. - - - -loadBytes(filename); - - - - -String: name of a file in the data folder or a url. - - -byte[] - - -loadStrings() -saveStrings() -saveBytes() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/loadStrings.xml b/mobile/web/reference/API/loadStrings.xml deleted file mode 100644 index 718554a4c..000000000 --- a/mobile/web/reference/API/loadStrings.xml +++ /dev/null @@ -1,56 +0,0 @@ - - -loadStrings() - -Input/Output - -Files - -Web & Application - - - - -String lines[] = loadStrings("list.txt"); -println("there are " + lines.length + " lines"); -for (int i=0; i < lines.length; i++) { - println(lines[i]); -} - - - - -Reads the contents of a file or url and creates a String array of its individual lines. If a file is specified, it must be located in the sketch's "data" directory/folder. - - - -loadStrings(filename) - - - - -String: name of the file or url to load - - -String[] - - -loadBytes() -saveStrings() -saveBytes() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/log.xml b/mobile/web/reference/API/log.xml deleted file mode 100644 index 81531be1a..000000000 --- a/mobile/web/reference/API/log.xml +++ /dev/null @@ -1,54 +0,0 @@ - - -log() - -Math - -Calculation - -Web & Application - - - - -void setup() { - int i = 12; - println(log(i)); - println(log10(i)); -} - -// Calculates the base-10 logarithm of a number -float log10 (int x) { - return (log(x) / log(10)); -} - - - - -Calculates the natural logarithm (the base-e logarithm) of a number. This function expects the values greater than 0.0. - - - -log(value) - - - - -int or float: number must be greater then 0.0 - - -float - - - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/logicalAND.xml b/mobile/web/reference/API/logicalAND.xml deleted file mode 100644 index 4949b83b0..000000000 --- a/mobile/web/reference/API/logicalAND.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -&& (logical AND) - -Control - -Logical Operators - -Web & Application - - -logicalAND.gif - -for(int i=5; i<=95; i+=5) { - if((i > 35) && (i < 60)) { - stroke(0); //Set color to black - } else { - stroke(255); //Set color to white - } - line(30, i, 80, i); -} - - - - -Compares two expressions and returns true only if both evaluate to true. Returns false if one or both evaluate to false. The following list shows all possible combinations:

true && false // Evaluates false because the second is false
false && true // Evaluates false because the first is false
true && true // Evaluates true because both are true
false && false // Evaluates false because both are false
-
- - -expression1 && expression2 - - - - -any valid expression - - - - -any valid expression - - - - - -|| (logical OR) -! (logical NOT) -if() - - -1.0 - -Operator - -PDE - - - - - - - - -
diff --git a/mobile/web/reference/API/logicalNOT.xml b/mobile/web/reference/API/logicalNOT.xml deleted file mode 100644 index cd96b7899..000000000 --- a/mobile/web/reference/API/logicalNOT.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -! (logical NOT) - -Control - -Logical Operators - -Web & Application - - -logicalNOT.gif - -boolean a = false; -if (!a) { - rect(30, 20, 50, 50); -} -a = true; -if (a) { - line(20, 10, 90, 80); - line(20, 80, 90, 10); -} - - - - -Inverts the Boolean value of an expression. Returns true if the expression is false and returns false if the expression is true. If the expression (a>b) evaluates to true, then !(a>b) evaluates to false. - - - -!expression - - - - -any valid expression - - - - - -|| (logical OR) -&& (logical AND) -if() - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/logicalOR.xml b/mobile/web/reference/API/logicalOR.xml deleted file mode 100644 index 9c1067e83..000000000 --- a/mobile/web/reference/API/logicalOR.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -|| (logical OR) - -Control - -Logical Operators - -Web & Application - - -logicalOR.gif - -for(int i=5 ; i<=95; i+=5) { - if((i < 35) || (i > 60)) { - line(30, i, 80, i); - } -} - - - - -Compares two expressions and returns true if one or both evaluate to true. Returns false only if both expressions are false. The following list shows all possible combinations:

true || false // Evaluates true because the first is true
false || true // Evaluates true because the second is true
true || true // Evaluates true because both are true
false || false // Evaluates false because both are false
-
- - -expression1 || expression2 - - - - -any valid expression - - - - -any valid expression - - - - - -&& (logical AND) -! (logical NOT) -if() - - -1.0 - -Operator - -PDE - - - - - - - - -
diff --git a/mobile/web/reference/API/loop.xml b/mobile/web/reference/API/loop.xml deleted file mode 100644 index e48ac9e48..000000000 --- a/mobile/web/reference/API/loop.xml +++ /dev/null @@ -1,73 +0,0 @@ - - -loop() - -Structure - - - -Web & Application - - - - - -void setup() { - size(200, 200); - noLoop(); -} - -float x = 0; - -void draw() { - background(204); - x = x + .1; - if (x > width) { - x = 0; - } - line(x, 0, x, height); -} - -void mousePressed() { - loop(); -} - -void mouseReleased() { - noLoop(); -} - - - - -Causes Processing to continuously execute the code within draw(). If noLoop() is called, the code in draw() stops executing. - - - -loop() - - - - - - - -None - - -noLoop() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/max.xml b/mobile/web/reference/API/max.xml deleted file mode 100644 index e078e36b8..000000000 --- a/mobile/web/reference/API/max.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -max() - -Math - -Calculation - -Web & Application - - - - -int a = max(5, 9); // Sets "a" to 9 -int b = max(-4, -12); // Sets "b" to -4 -float c = max(12.3, 230.24); // Sets "c" to 230.24 - - - - -Determines the largest value in a sequence of numbers. - - - -max(value1, value2) -max(value1, value2, value 3) - - - - -int or float - - - - -int or float - - - - -int or float - - -int or float (depending on the inputs) - - -min() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/millis.xml b/mobile/web/reference/API/millis.xml deleted file mode 100644 index 67190ca9a..000000000 --- a/mobile/web/reference/API/millis.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -millis() - -Input/Output - -Time & Date - -Web & Application - - -millis_.jar - -void loop() { - float m = millis(); - fill(m % 255); - rect(25, 25, 50, 50); -} - - - - -Returns the number of milliseconds (thousandths of a second) since starting an applet. This information is often used for timing animation sequences. - - - -millis() - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/min.xml b/mobile/web/reference/API/min.xml deleted file mode 100644 index f5a76766c..000000000 --- a/mobile/web/reference/API/min.xml +++ /dev/null @@ -1,63 +0,0 @@ - - -min() - -Math - -Calculation - -Web & Application - - - - -int d = min(5, 9); // Sets "d" to 5 -int e = min(-4, -12); // Sets "e" to -12 -float f = min(12.3, 230.24); // Sets "f" to 12.3 - - - - -Determines the smallest value in a sequence of numbers. - - - -min(value1, value2) -min(value1, value2, value 3) - - - - -int or float - - - - -int or float - - - - -int or float - - -int or float (depending on the inputs) - - -max() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/minus.xml b/mobile/web/reference/API/minus.xml deleted file mode 100644 index 9f551be7d..000000000 --- a/mobile/web/reference/API/minus.xml +++ /dev/null @@ -1,69 +0,0 @@ - - -- (minus) - -Math - -Operators - -Web & Application - - - - -int c = 50 - 5; // Sets c to 45 -int d = c - 5; // Sets d to 40 -int e = d - 60; // Sets e to -20 - - - - - - -int a = 5; // Sets "a" to 5 -int b = -a; // Sets "b" to -5 -int c = -(5 + 3); // Sets "c" to -8 - - - - -Subtracts one value from another and may also be used to negate a value. As a subtraction operator, the value of the second parameter is subtracted from the first. For example, 5 - 3 yields the number 2. As a negation operator, it is equivalent to multiplying a number by -1. For example, -5 is the same as 5 * -1. - - - --value1 -value1 - value2 - - - - -int or float - - - - -int or float - - - - - --- (decrement) --= (subtract assign) -+ (add) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/minute.xml b/mobile/web/reference/API/minute.xml deleted file mode 100644 index bf20f3ab5..000000000 --- a/mobile/web/reference/API/minute.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -minute() - -Input/Output - -Time & Date - -Web & Application - - -minute_.jar - -void loop() { - background(204); - int s = second(); // Values from 0 - 59 - int m = minute(); // Values from 0 - 59 - int h = hour(); // Values from 0 - 23 - line(s, 0, s, 33); - line(m, 33, m, 66); - line(h, 66, h, 100); -} - - - - -Processing communicates with the clock on your computer. The minute() function returns the current minute as a value from 0 - 59. - - - -minute() - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/modulo.xml b/mobile/web/reference/API/modulo.xml deleted file mode 100644 index 0325dd641..000000000 --- a/mobile/web/reference/API/modulo.xml +++ /dev/null @@ -1,70 +0,0 @@ - - -% (modulo) - -Math - -Operators - -Web & Application - - - - -int a = 20%100; // Sets a to 20 -int b = 20%100; // Sets b to 20 -int c = 75%100; // Sets c to 75 -int d = 275%100; // Sets d to 75 - - - - - - -float a = 0.0; -void loop() { - background(204); - a = (a + 0.5)%width; - line(a, 0, a, height); -} - - - - -Calculates the remainer when one number is divided by another. It is extremely useful for keeping numbers within a boundary such as keeping a shape on the screen. - - - -value1%value2 - - - - -int - - - - -int - - - - - -/ (divide) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/month.xml b/mobile/web/reference/API/month.xml deleted file mode 100644 index 86b72e988..000000000 --- a/mobile/web/reference/API/month.xml +++ /dev/null @@ -1,73 +0,0 @@ - - -month() - -Input/Output - -Time & Date - -Web & Application - - -month_.jar - -void setup() { - PFont metaBold; - metaBold = loadFont("fonts/Meta-Bold.vlw.gz"); - setFont(metaBold, 44); - hint(SMOOTH_IMAGES); -} - -void loop() { - int d = day(); // Values from 1 - 31 - int m = month(); // Values from 1 - 12 - int y = year(); // 2003, 2004, 2005, etc. - String s = String.valueOf(d); - text(s, 10, 28); - s = String.valueOf(m); - text(s, 10, 56); - s = String.valueOf(y); - text(s, 10, 84); -} - - - - -Processing communicates with the clock on your computer. The month() function returns the current month as a value from 1 - 12. - - - -month() - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/multilinecomment.xml b/mobile/web/reference/API/multilinecomment.xml deleted file mode 100644 index a650d1eb1..000000000 --- a/mobile/web/reference/API/multilinecomment.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -/* */ (multiline comment) - -Structure - - - -Web & Application - - - - -/* - Draws two lines which divides the window - into four quadrants. First draws a horizonal - line and then the vertical line -*/ -line(0, 50, 100, 50); -line(50, 0, 50, 100); - - - - -Explanatory notes embedded within the code. Comments are used to remind yourself and to inform others about the function of your program. Multiline comments are used for large text descriptions of code or to comment out chunks of code while debugging applications. Comments are ignored by the compiler - - - -/* - comment -*/ - - - - -any sequence of characters - - - - - -// (comment) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/multiply.xml b/mobile/web/reference/API/multiply.xml deleted file mode 100644 index 9d169690c..000000000 --- a/mobile/web/reference/API/multiply.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -* (multiply) - -Math - -Operators - -Web & Application - - - - -int e = 50 * 5; // Sets e to 250 -int f = e * 5; // Sets f to 1250 - - - - -Multiplies the values of the two parameters. Multiplication is equivalent to a sequence of addition. For example 5 * 4 is equivalent to 5 + 5 + 5 + 5. - - - -value1 * value2 - - - - -int, float, byte, or char - - - - -int, float, byte, or char - - - - - -+ (add) -/ (divide) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/new.xml b/mobile/web/reference/API/new.xml deleted file mode 100644 index 495d66e1c..000000000 --- a/mobile/web/reference/API/new.xml +++ /dev/null @@ -1,70 +0,0 @@ - - -new - -Structure - - - -Web & Application - - - - -HLine h1 = new HLine(); -float[] speeds = new float[3]; -float ypos; - -void setup() { - size(200, 200); - speeds[0] = 0.1; - speeds[1] = 2.0; - speeds[2] = 0.5; -} - -void loop() { - ypos += speeds[int(random(3))]; - if (ypos > width) { - ypos = 0; - } - h1.update(ypos); -} - -class HLine { - void update(float y) { - line(0, y, width, y); - } -} - - - - -Dynamically creates an object. - - - -new - - - - - - - - - - -1.0 - -keyword - -PDE - -Extended - - - - - - - diff --git a/mobile/web/reference/API/nf.xml b/mobile/web/reference/API/nf.xml deleted file mode 100644 index 4865bb1a4..000000000 --- a/mobile/web/reference/API/nf.xml +++ /dev/null @@ -1,86 +0,0 @@ - - -nf() - -Data - -String Functions - -Web & Application - - - - -int a=200, b=40, c=90; -String sa = nf(a, 10); -println(sa); // prints "0000000200" -String sb = nf(b, 5); -println(sb); // prints "00040" -String sc = nf(c, 3); -println(sc); // prints "090" - -float d = 200.94, e = 40.2, f = 9.012; -String sd = nf(d, 10, 4); -println(sd); // prints "0000000200.9400" -String se = nf(e, 5, 3); -println(se); // prints "00040.200" -String sf = nf(f, 3, 5); -println(sf); // prints "009.01200" - - - - -Utility function for formatting numbers into strings. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers. - - - -nf(intValue, digits) -nf(floatValue, left, right) - - - - -int: the number to format - - - - -int: number of digits to pad with zeroes - - - - -float: the number to format - - - - -int: number of digits to the left of the decimal point - - - - -int: number of digits to the right of the decimal point - - -String - - -nfs() -nfp() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/nfp.xml b/mobile/web/reference/API/nfp.xml deleted file mode 100644 index 2ff03e5c8..000000000 --- a/mobile/web/reference/API/nfp.xml +++ /dev/null @@ -1,82 +0,0 @@ - - -nfp() - -Data - -String Functions - -Web & Application - - - - -int a=200, b=-40, c=90; -String sa = nfp(a, 10); -println(sa); // prints "+0000000200" -String sb = nfp(b, 5); -println(sb); // prints "-00040" -String sc = nfp(c, 3); -println(sc); // prints "+090" - -float d = -200.94, e = 40.2, f = -9.012; -String sd = nfp(d, 10, 4); -println(sd); // prints "-0000000200.9400" -String se = nfp(e, 5, 3); -println(se); // prints "+00040.200" -String sf = nfp(f, 3, 5); -println(sf); // prints "-009.01200" - - - - -Utility function for formatting numbers into strings. Similar to nf() but puts a "+" in front of positive numbers and a "-" in front of negative numbers. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers. - - - -nfp(intValue, digits) -nfp(floatValue, left, right) - - - - -int: the number to format - - - - -int: number of digits to pad with zeroes - - - - -float: the number to format - - - - -int: number of digits to the left of the decimal point - - - - -int: number of digits to the right of the decimal point - - -String - - -nfs() -nf() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/nfs.xml b/mobile/web/reference/API/nfs.xml deleted file mode 100644 index dfc23af62..000000000 --- a/mobile/web/reference/API/nfs.xml +++ /dev/null @@ -1,87 +0,0 @@ - - -nfs() - -Data - -String Functions - -Web & Application - - - - -int a=200, b=-40, c=90; -String sa = nfs(a, 10); -println(sa); // prints " 0000000200" -String sb = nfs(b, 5); -println(sb); // prints "-00040" -String sc = nfs(c, 3); -println(sc); // prints " 090" - -float d = -200.94, e = 40.2, f = -9.012; -String sd = nfs(d, 10, 4); -println(sd); // prints "-0000000200.9400" -String se = nfs(e, 5, 3); -println(se); // prints " 00040.200" -String sf = nfs(f, 3, 5); -println(sf); // prints "-009.01200" - - - - -Utility function for formatting numbers into strings. Similar to nf() but leaves a blank space in front of positive numbers so they align with negative numbers in spite of the minus symbol. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers. - - - -nfs(intValue, digits) -nfs(floatValue, left, right) - - - - -int: the number to format - - - - -int: number of digits to pad with zeroes - - - - -float: the number to format - - - - -int: number of digits to the left of the decimal point - - - - -int: number of digits to the right of the decimal point - - - -String or String[] - - -nf() -nfp() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/noFill.xml b/mobile/web/reference/API/noFill.xml deleted file mode 100644 index 79aff0eae..000000000 --- a/mobile/web/reference/API/noFill.xml +++ /dev/null @@ -1,44 +0,0 @@ - - -noFill() - -Color - -Setting - -Web & Application - - -noFill_.gif - -rect(15, 10, 55, 55); -noFill(); -rect(30, 20, 55, 55); - - - - -Disables filling geometry. If both noStroke() and noFill() are called, nothing will be drawn to the screen. - - - -noFill() - - - - - - - -None - - -fill() - - -1.0 - -Function - -Core - diff --git a/mobile/web/reference/API/noLoop.xml b/mobile/web/reference/API/noLoop.xml deleted file mode 100644 index ccc5d560d..000000000 --- a/mobile/web/reference/API/noLoop.xml +++ /dev/null @@ -1,73 +0,0 @@ - - -noLoop() - -Structure - - - -Web & Application - - - - - -void setup() { - size(200, 200); - noLoop(); -} - -float x = 0; - -void draw() { - background(204); - x = x + .1; - if (x > width) { - x = 0; - } - line(x, 0, x, height); -} - -void mousePressed() { - loop(); -} - -void mouseReleased() { - noLoop(); -} - - - - -Stops Processing from continuously executing the code within draw(). If loop() is called, the code in draw() is executed continuously. - - - -noLoop() - - - - - - - -None - - -loop() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/noStroke.xml b/mobile/web/reference/API/noStroke.xml deleted file mode 100644 index b3c9cb277..000000000 --- a/mobile/web/reference/API/noStroke.xml +++ /dev/null @@ -1,51 +0,0 @@ - - -noStroke() - -Color - -Setting - -Web & Application - - -noStroke_.gif - -noStroke(); -rect(30, 20, 55, 55); - - - - -Disables drawing the stroke (outline). If both noStroke() and noFill() are called, nothing will be drawn to the screen. - - - -noStroke() - - - - - - - -None - - -stroke() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/parentheses.xml b/mobile/web/reference/API/parentheses.xml deleted file mode 100644 index b12f91304..000000000 --- a/mobile/web/reference/API/parentheses.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -() (parentheses) - -Structure - - - -Web & Application - - - - -int a; -a = (4 + 3) * 2; // Grouping expressions -if (a > 10) { // Containing expressions - line(a, 0, a, 100); // Containing a list of parameters -} - - - - -Grouping and containing expressions and parameters. Parentheses have multiple functions relating to functions and structures. They are used to contain a list of parameters passed to functions and control structures and they are used to group expressions to control the order of execution. Some functions have no parameters and in this case, the space between parentheses is blank. - - - -function() -function(p1, ..., pN) -structure(expression) - - - - -any function - - - - -list of parameters specific to the function - - - - -Control structure such as if(), for(), while() - - - - -any valid expression or group of expression - - - - - -, (comma) - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/point.xml b/mobile/web/reference/API/point.xml deleted file mode 100644 index 38dc96592..000000000 --- a/mobile/web/reference/API/point.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -point() - -Shape - -2D Primitives - -Web & Application - - -point_.gif - -point(30, 20); -point(85, 20); -point(85, 75); -point(30, 75); - - - - -A point is a coordinate in space. In Processing, points have a dimension of one pixel. The first parameter is the horizontal value for the point, the second value is the vertical value for the point, and the optional third value is the depth value. - - - -point(x1, y1); -point(x1, y1, z1); - - - - -int or float: x-coordinate of the point - - - - -int or float: y-coordinate of the point - - - - -int or float: z-coordinate of the point - - -None - - -beginShape() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/pow.xml b/mobile/web/reference/API/pow.xml deleted file mode 100644 index 03482b562..000000000 --- a/mobile/web/reference/API/pow.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -pow() - -Math - -Calculation - -Web & Application - - - - -float a = pow( 1, 3); // Sets "a" to 1*1*1 = 1 -float b = pow( 3, 5); // Sets "b" to 3*3*3*3*3 = 243 -float c = pow( 3,-5); // Sets "c" to 1 / 3*3*3*3*3 = 1 / 243 = .0041 -float d = pow(-3, 5); // Sets "d" to -3*-3*-3*-3*-3 = -243 - - - - -Facilitates exponential expressions. The pow() function is an efficient way of multiplying numbers by themselves (or their reciprocal) in large quantities. For example, pow(3, 5) is equivalent to the expression 3*3*3*3*3 and pow(3, -5) is equivalent to 1 / 3*3*3*3*3. - - - -pow(base, exponent) - - - - -int or float: base of the exponential expression - - - - -int or float: power of which to raise the base - - -float - - -sqrt() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/print.xml b/mobile/web/reference/API/print.xml deleted file mode 100644 index a1c5cd4f7..000000000 --- a/mobile/web/reference/API/print.xml +++ /dev/null @@ -1,70 +0,0 @@ - - -print() - -Input/Output - -Text Output - -IDE - - - - -print("begin- "); -float f = 0.3; -int i = 1024; -print("f is " + f + " and i is " + 1024); -String s = " -end"; -println(s); - -// The above code prints: -// begin- f is 0.3 and i is 1024 -end - - - - - - -float[] f = { 0.3, 0.4, 0.5 }; -print(f); - -// The above code prints: -// 0.30.40.5 - - - - - -Writes to the console area of the Processing environment. This is often helpful for looking at the data a program is producing. The companion function println() works like print(), but creates a new line of text for each call to the function. Individual elements can be separated with quotes ("") and joined with the addition operator (+) except when printing array data. - - - -print(data) - - - - -boolean, byte, char, color, int, float, String, boolean[], byte[], char[], color[], int[], float[], or String[] - - - - - -println() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/println.xml b/mobile/web/reference/API/println.xml deleted file mode 100644 index a4834f2c7..000000000 --- a/mobile/web/reference/API/println.xml +++ /dev/null @@ -1,72 +0,0 @@ - - -println() - -Input/Output - -Text Output - -IDE - - - - -println("begin"); -float f = 0.3; -println("f is equal to " + f + " and i is equal to " + 1024); -String s = "end"; -println(s); - -// The above code prints the following lines: -// begin -// f is equal to 0.3 and i is equal to 1024 -// end - - - - - - -float[] f = { 0.3, 0.4, 0.5 }; -println(f); - -// The above code prints: -// 0.3 -// 0.4 -// 0.5 - - - - -Writes to the text area of the Processing environment's console. This is often helpful for looking at the data a program is producing. Each call to this function creates a new line of output. Individual elements can be separated with quotes ("") and joined with the string concatenation operator (+) except when printing array data. - - - -println(data) - - - - -boolean, byte, char, color, int, float, String, boolean[], byte[], char[], color[], int[], float[], or String[] - - -None - - -print() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/quad.xml b/mobile/web/reference/API/quad.xml deleted file mode 100644 index b0b48f275..000000000 --- a/mobile/web/reference/API/quad.xml +++ /dev/null @@ -1,83 +0,0 @@ - - -quad() - -Shape - -2D Primitives - -Web & Application - - -quad_.gif - -quad(38, 31, 86, 20, 69, 63, 30, 76); - - - - -A quad is a quadrilateral, a four sided polygon. It is similar to a rectangle, but the angles between its edges are not constrained to ninety degrees. - - - -quad(x1, y1, x2, y2, x3, y3, x4, y4); - - - - -int or float: x-coordinate of the first corner - - - - -int or float: y-coordinate of the first corner - - - - -int or float: x-coordinate of the second corner - - - - -int or float: y-coordinate of the second corner - - - - -int or float: x-coordinate of the third corner - - - - -int or float: y-coordinate of the third corner - - - - -int or float: x-coordinate of the fourth corner - - - - -int or float: y-coordinate of the fourth corner - - -None - - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/random.xml b/mobile/web/reference/API/random.xml deleted file mode 100644 index 2e6e4387d..000000000 --- a/mobile/web/reference/API/random.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -random() - -Math - -Random - -Web & Application - - -random_.jar - -for(int i=0; i<100; i++) { - float r = random(50); - stroke(r*5); - line(50, i, 50+r, i); -} - - - - -random_2.jar - -for(int i=0; i<100; i++) { - float r = random(-50, 50); - stroke(abs(r*5)); - line(50, i, 50+r, i); -} - - - - -Generates random numbers. Each time the random() function is called, it returns an unexpected value within the specified range. If one parameter is passed to the function it will return a float between zero and the value of the parameter. The function call random(5) returns values between 0 and 5. If two parameters are passed, it will return a float with a value between the the parameters. The function call random(-5, 10.2) returns values between -5 and 10.2. To convert a floating-point random number to an integer, use the int() function. - - - -random(value1); -random(value1, value2); - - - - -int or float - - - - -int or float - - -float - - -noise() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/randomSeed.xml b/mobile/web/reference/API/randomSeed.xml deleted file mode 100644 index dc32a543e..000000000 --- a/mobile/web/reference/API/randomSeed.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -randomSeed() - -Math - -Random - -Web & Application - - - - -randomSeed(0); -for(int i=0; i<100; i++) { - float r = random(0, 255); - stroke(r); - line(i, 0, i, 100); -} - - - - - -Sets the seed value for random(). By default, random() produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run. - - - -random(value); - - - - -int - - -None - - -random() -noise() -noiseSeed() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/rect.xml b/mobile/web/reference/API/rect.xml deleted file mode 100644 index 062065860..000000000 --- a/mobile/web/reference/API/rect.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -rect() - -Shape - -2D Primitives - -Web & Application - - -rect_.gif - -rect(30, 20, 55, 55); - - - - -Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. The first two parameters set the location, the third sets the width, and the fourth sets the height. The origin is changed with the rectMode() function. - - - -rect(x, y, width, height); - - - - -int or float: x-coordinate of the rectangle - - - - -int or float: y-coordinate of the rectangle - - - - -int or float: width of the rectangle - - - - -int or float: height of the rectangle - - -None - - -rectMode() -quad() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/rectMode.xml b/mobile/web/reference/API/rectMode.xml deleted file mode 100644 index 1a027b16a..000000000 --- a/mobile/web/reference/API/rectMode.xml +++ /dev/null @@ -1,54 +0,0 @@ - - -rectMode() - -Shape - -2D Primitives - -Web & Application - - -rectMode_.gif - -rectMode(CENTER); -rect(35, 35, 50, 50); -rectMode(CORNER); -fill(102); -rect(35, 35, 50, 50); - - - - -Modifies the location from which rectangles draw. The default mode is rectMode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of rect() to specify the width and height. The syntax rectMode(CORNERS) uses the first and second parameters of rect() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax rectMode(CENTER) draws the image from its center point and uses the third and forth parameters to rect() to specify the image's width and height. The parameter must be written in "ALL CAPS" because Processing is a case sensitive language. - - - -rectMode(MODE) - - - - -Either CORNER, CORNERS, CENTER - - -None - - -rect() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/red.xml b/mobile/web/reference/API/red.xml deleted file mode 100644 index d84fb494f..000000000 --- a/mobile/web/reference/API/red.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -red() - -Color - -Creating & Reading - -Web & Application - - -red_.gif - -noStroke(); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = red(c); // Sets "value" to "0" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the red value from a color. - - - -red(color) - - - - -any value of the color datatype - - -float - - -green() -blue() -hue() -saturation() -brightness() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/redraw.xml b/mobile/web/reference/API/redraw.xml deleted file mode 100644 index 90f5c00fd..000000000 --- a/mobile/web/reference/API/redraw.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -redraw() - -Structure - - - -Web & Application - - - - - -float x = 0; - -void setup() { - size(200, 200); - noLoop(); -} - -void draw() { - background(204); - line(x, 0, x, height); -} - -void mousePressed() { - x += 1; - redraw(); -} - - - - -Causes Processing to execute the code within draw() one time. This gives control for updating the display window only when it's necessary. - - - -redraw() - - - - - - - -None - - -noLoop() -loop() - - -1.0 - -Function - -PDE - - - diff --git a/mobile/web/reference/API/return.xml b/mobile/web/reference/API/return.xml deleted file mode 100644 index 76f8f70d7..000000000 --- a/mobile/web/reference/API/return.xml +++ /dev/null @@ -1,90 +0,0 @@ - - -return - -Structure - - - -Web & Application - - - - -int val = 30; - -void draw() { - int t = timestwo(val); - println(t); -} - -int timestwo(int doubledVal) { - doubledVal = doubledVal * 2; - return doubledVal; -} - - - - - - -int[] vals = {10, 20, 30}; - -void draw() { - int[] t = timestwo(vals); - println(t); -} - -int[] timestwo(int[] doubledVals) { - for(int i=0; i<b.length; i++) { - b[i] = b[i] * 2; - } - return doubledVals; -} - - - - -Keyword used to indicate the value to return from a function. The value being returned must be the same datatype as defined in the function declaration. Functions declared with void can't return values and shouldn't include a return value. Functions can't include more than one return and the statement including return must be the last line in the function. - - - -type function { - statements - return value -} - - - - -boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], float[], String[] - - - - -any function that is being defined - - - - -any valid statements - - - - -must be the same datatype as the type parameter - - - - - - - -1.0 - -Keyword - -PDE - - - diff --git a/mobile/web/reference/API/reverse.xml b/mobile/web/reference/API/reverse.xml deleted file mode 100644 index 04c758a25..000000000 --- a/mobile/web/reference/API/reverse.xml +++ /dev/null @@ -1,50 +0,0 @@ - - -reverse() - -Data - -Array Functions - -Web & Application - - - - -String sa[] = { "OH ", "NY ", "MA ", "CA "}; -sa = reverse(sa); -print(sa); // Prints "CA MA NY OH " - - - - -Reverses the order of an array. - - - -reverse(array) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[] - - -Array (the same datatype as the input) - - -sort() - - -1.0 - -Function - -Core - - -Extended - - - - diff --git a/mobile/web/reference/API/rightshift.xml b/mobile/web/reference/API/rightshift.xml deleted file mode 100644 index bd47726f7..000000000 --- a/mobile/web/reference/API/rightshift.xml +++ /dev/null @@ -1,71 +0,0 @@ - - ->> (right shift) - -Math - -Bitwise Operators - -Web & Application - - - - -int m = 8 >> 3; // In binary: 1000 to 1 -println(m); // Prints "1" -int n = 256 >> 6; // In binary: 100000000 to 100 -println(n); // Prints "4" -int o = 16 >> 3; // In binary: 10000 to 10 -println(o); // Prints "2" -int p = 26 >> 1; // In binary: 11010 to 1101 -println(p); // Prints "13" - - - - - - -color argb = color(204, 204, 51, 255); -int a = argb >> 24 & 0xFF; -int r = argb >> 16 & 0xFF; // Faster way of getting red(argb) -int g = argb >> 8 & 0xFF; // Faster way of getting green(argb) -int b = argb & 0xFF; // Faster way of getting blue(argb) -fill(r, g, b, a); -rect(30, 20, 55, 55); - - - - -Shifts bits to the right. The number to the left of the operator is shifted the number of places specified by the number to the right. Each shift to the right halves the number, therefore each left shift divides the original number by 2. Use the right shift for fast divisions or to extract an individual number from a packed number. Right shifting only works with integers or numbers which automatically convert to an integer such at byte and char. - - - -value >> n - - - - -int: the value to shift - - - - -int: the number of places to shift right - - - - - -<< (left shift) - - -1.0 - -Operator - -PDE - -Extended - - - diff --git a/mobile/web/reference/API/saturation.xml b/mobile/web/reference/API/saturation.xml deleted file mode 100644 index fd9c96e6c..000000000 --- a/mobile/web/reference/API/saturation.xml +++ /dev/null @@ -1,58 +0,0 @@ - - -saturation() - -Color - -Creating & Reading - -Web & Application - - -saturation_.gif - -noStroke(); -colorMode(HSB, 255); -color c = color(0, 126, 255); -fill(c); -rect(15, 20, 35, 60); -float value = saturation(c); // Sets "value" to "126" -fill(value); -rect(50, 20, 35, 60); - - - - -Extracts the saturation value from a color. - - - -saturation(color) - - - - -any value of the color datatype - - -float - - -red() -green() -blue() -hue() -brightness() - - -1.0 - -Function - -Core - -Extended - - - - diff --git a/mobile/web/reference/API/saveBytes.xml b/mobile/web/reference/API/saveBytes.xml deleted file mode 100644 index 9bd438b54..000000000 --- a/mobile/web/reference/API/saveBytes.xml +++ /dev/null @@ -1,60 +0,0 @@ - - -saveBytes() - -Input/Output - -Files - -Application - - - - -byte[] nums = { 0, 34, 5, 127, 52}; - -// now write the bytes to a file -saveBytes("numbers.txt", nums); - - - - -Opposite of loadBytes(), will write an entire array of bytes to a file. This file is saved to the sketch's folder, which is opened by selecting "Show sketch folder" from the "Sketch" menu. - - - -saveBytes(filename, bytes) - - - - -name of file to write to - - - - -array of bytes to be written - - -None - - -loadStrings() -loadBytes() -saveStrings() - - -1.0 - -Function - -Core - -Extended - - - - - - - diff --git a/mobile/web/reference/API/saveStrings.xml b/mobile/web/reference/API/saveStrings.xml deleted file mode 100644 index 4e79e156f..000000000 --- a/mobile/web/reference/API/saveStrings.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -saveStrings() - -Input/Output - -Files - -Application - - - - -String words = "apple bear cat dog"; -String list[] = splitStrings(words); - -// now write the strings to a file, each on a separate line -saveStrings("nouns.txt", list); - - - - -Writes an array of strings to a file, one line per string. This file is saved to the sketch's folder, which is opened by selecting "Show sketch folder" from the "Sketch" menu. - - - -saveStrings(filename, strings) - - - - -filename for output - - - - -string array to be written - - - - - -loadStrings() -loadBytes() -saveBytes() - - -1.0 - -Function - -Core - - -Extended - - - - - - diff --git a/mobile/web/reference/API/second.xml b/mobile/web/reference/API/second.xml deleted file mode 100644 index 9831bce81..000000000 --- a/mobile/web/reference/API/second.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -second() - -Input/Output - -Time & Date - -Web & Application - - -second_.jar - -void loop() { - background(204); - int s = second(); // Values from 0 - 59 - int m = minute(); // Values from 0 - 59 - int h = hour(); // Values from 0 - 23 - line(s, 0, s, 33); - line(m, 33, m, 66); - line(h, 66, h, 100); -} - - - - -Processing communicates with the clock on your computer. The second() function returns the current second as a value from 0 - 59. - - - -second - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/semicolon.xml b/mobile/web/reference/API/semicolon.xml deleted file mode 100644 index 3ab159655..000000000 --- a/mobile/web/reference/API/semicolon.xml +++ /dev/null @@ -1,52 +0,0 @@ - - -; (semicolon) - -Structure - - - -Web & Application - - - - -int a; // Declaration statement -a = 30; // Assignment statement -println(i); // Function statement - - - - -A statement terminator which separates elements of the program. A statement is a complete instruction to the computer and the semicolon is used to separate instructions (this is similar to the period "." in written English). Semicolons are also used to separate the different elements of a for() structure. - - - -statement; - - - - -a single statement to execute - - - - - -for() - - -1.0 - -Operator - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/setup.xml b/mobile/web/reference/API/setup.xml deleted file mode 100644 index 10c6f9525..000000000 --- a/mobile/web/reference/API/setup.xml +++ /dev/null @@ -1,64 +0,0 @@ - - -setup() - -Structure - - - -Web & Application - - - - -void setup() { - size(200, 200); - background(0); - noStroke(); - fill(102); -} - -int a = 0; - -void draw() { - rect(a++%width, 10, 2, 80); -} - - - - -Function called once when the program begins running. Used to define initial enviroment properties such as screen size, background color, loading images, etc. before the draw() begins executing. Variables declared within setup() are not accessible within draw(). - - - -void setup() { - statements -} - - - - -any valid statements - - -None - - -loop() -size() - - -1.0 - -Processing Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/shorten.xml b/mobile/web/reference/API/shorten.xml deleted file mode 100644 index 190d273bc..000000000 --- a/mobile/web/reference/API/shorten.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - -shorten() - -Data - -Array Functions - -Web & Application - - - - -String sa1[] = { "OH ", "NY ", "CA "}; -String sa2[] = shorten(sa1); -print(sa1); // Prints "OH NY " -println(); -sa2 = shorten(sa2); -print(sa2); // Prints "OH " - - - - -Decreases an array by one element and returns the shortened array. - - - -append(array) - - - - -boolean[], byte[], char[], int[], float[], or String[] - - -Array (the same datatype as the input) - - -append() -expand() - - -1.0 - -Function - -Core - -Extended - - diff --git a/mobile/web/reference/API/slice.xml b/mobile/web/reference/API/slice.xml deleted file mode 100644 index 57cd50fca..000000000 --- a/mobile/web/reference/API/slice.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - -slice() - -Data - -Array Functions - -Web & Application - - - - -String sa1[] = { "OH ", "NY ", "CA ", "VA ", "CO ", "IL "}; -String sa2[] = slice(sa1, 1); -print(sa2); // Prints "NY CA VA CO IL " -println(); -String sa3[] = slice(sa1, 2, 3); -print(sa3); // Prints "CA VA CO " - - - - -Extracts an array of elements from an existing array. The array parameter defines the array from which the elements will be copied and the offset and length parameters determine which elements to extract. If no length is given, elements will be extracted from the offset to the end of the array. When specifying the offset remember the first array element is 0. This function does not change the source array. - - - -slice(array, offset) -slice(array, offset, length) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[]: base array - - - - -int: position to begin - - - - -int: number of values to extract - - -Array (the same datatype as the input) - - -splice() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/sort.xml b/mobile/web/reference/API/sort.xml deleted file mode 100644 index 784233c3b..000000000 --- a/mobile/web/reference/API/sort.xml +++ /dev/null @@ -1,66 +0,0 @@ - - -sort() - -Data - -Array Functions - -Web & Application - - - - -float a[] = { 3.4, 3.6, 2, 0, 7.1 }; -sort(a); -for (int i = 0; i < a.length; i++) { - println(a[i]); -} - - - - - - -String s[] = { "deer", "elephant", "bear", "apple", "car" }; -sort(s); -for (int i = 0; i < s.length; i++) { - println(s[i]); -} - - - - -Sorts an array of numbers from smallest to largest and puts an array of words in alphabetical order. - - - -sort(array) - - - - -String[], int[], or float[] - - - - - -reverse() - - -1.0 - -Function - -Core - - -Extended - - - - - - - diff --git a/mobile/web/reference/API/splice.xml b/mobile/web/reference/API/splice.xml deleted file mode 100644 index 1d3e87614..000000000 --- a/mobile/web/reference/API/splice.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - -splice() - -Data - -Array Functions - -Web & Application - - - - -String sa1[] = { "OH ", "NY ", "CA "}; -sa1 = splice(sa1, "KY ", 1); -print(sa1); // Prints "OH KY NY CA " -println(); -String sa2[] = { "VA ", "CO ", "IL " }; -sa1 = splice(sa1, sa2, 2); -print(sa1); // Prints "OH KY VA CO IL NY CA " - - - - -Inserts a value or array of values into an existing array. The first two parameters must be of the same datatype. The array parameter defines the array which will be modified and the second parameter defines the data which will be inserted. - - - -splice(array, value, index) -splice(array, array2, index) - - - - -booleans[], bytes[], chars[], ints[], floats[], or Strings[]: base array - - - - -booleans, bytes, chars, ints, floats, or Strings: value to be spliced in - - - - -booleans[], bytes[], chars[], ints[], floats[], Strings[]: array to be spliced in - - - - -int: position in the array from which to insert data - - -Array (the same datatype as the input) - - -contract() -slice() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/split.xml b/mobile/web/reference/API/split.xml deleted file mode 100644 index 29aa64e3d..000000000 --- a/mobile/web/reference/API/split.xml +++ /dev/null @@ -1,72 +0,0 @@ - - -split() - -Data - -String Functions - -Web & Application - - - - -String numbers = "Putin Yeltsin Gorbachev"; -String list[] = split(numbers); -// list[0] is now Putin, list[1] is now Yeltsin, ... - - - - - - -String numbers = "Chernenko,Andropov,Brezhnev"; -String list[] = splitInts(numbers, ','); -// list[0] is now Chernenko, list[1] is Andropov, ... - - - - - - -String numbers = "8 67 5 309"; -int list[] = int(splitInts(numbers)); -// list[0] is now 8, list[1] is now 67, ... - - - - -A utility function which separates a series of data embedded into a String into an array of Strings. The delim parameter specifies the character or characters which mark the boundaries between each data element. If no delim character is specified, a whitespace character is used as the split character. Whitespace characters include tab (\t), line feed (\n), carriage return (\r), and form feed (\f), and space. To convert a String to an array of integers or floats, use the datatype conversion functions int() and float() to convert the array of Strings (see example above). - - - -split(str) -split(str, delim) - - - - -the string to be split - - - - -the character or String used to separate the data - - -String[] - - -join() - - -1.0 - -Function - -Core - -Extended - - - diff --git a/mobile/web/reference/API/sq.xml b/mobile/web/reference/API/sq.xml deleted file mode 100644 index d585be5d5..000000000 --- a/mobile/web/reference/API/sq.xml +++ /dev/null @@ -1,56 +0,0 @@ - - -sq() - -Math - -Calculation - -Web & Application - - -sq_.gif - -noStroke(); -float a = sq(1); // Sets a to 1 -float b = sq(-5); // Sets b to 25 -float c = sq(9); // Sets c to 81 -rect(0, 25, a, 10); -rect(0, 45, b, 10); -rect(0, 65, c, 10); - - - - -Squares a number (multiplies a number by itself). The result is always a positive number, as multiplying two negative numbers always yields a positive result. For example, -1 * -1 = 1. - - - -sq(value) - - - - -int or float - - -float - - -sqrt() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/sqrt.xml b/mobile/web/reference/API/sqrt.xml deleted file mode 100644 index bfa434fd6..000000000 --- a/mobile/web/reference/API/sqrt.xml +++ /dev/null @@ -1,57 +0,0 @@ - - -sqrt() - -Math - -Calculation - -Web & Application - - -sqrt_.gif - -noStroke(); -float a = sqrt(6561); // Sets a to 81 -float b = sqrt(625); // Sets b to 25 -float c = sqrt(1); // Sets c to 1 -rect(0, 25, a, 10); -rect(0, 45, b, 10); -rect(0, 65, c, 10); - - - - -Calculates the square root of a number. The square root of a number is always positive, even though there may be a valid negative root. The square root s of number a is such that s*s = a. It is the opposite of squaring. - - - -sqrt(value) - - - - -int or float: non-negative number - - -float - - -pow() -sq() - - -1.0 - -Function - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/strconvert.xml b/mobile/web/reference/API/strconvert.xml deleted file mode 100644 index 382539989..000000000 --- a/mobile/web/reference/API/strconvert.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - -str() - -Data - -Conversion - -Web & Application - - - - -boolean b = false; -byte y = -28; -char c = 'R'; -float f = -32.6; -int i = 1024; - -String sb = str(b); -String sy = str(y); -String sc = str(c); -String sf = str(f); -String si = str(i); - -sb = sb + sy + sc + sf + si + sh; - -println(sb); // Prints 'false-28R-32.61024' - - - - -Returns the string representation of primitive datatypes and arrays. For example the integer 3 will return the string "3", the float -12.6 will return the string "-12.6", and a boolean value true will return the string "true". - - - -str(data) - - - - -boolean, byte, char, float, int, boolean[], byte[], char[], float[], int[] - - -String or String[] - - - - -1.0 - -Function - -Core - - - diff --git a/mobile/web/reference/API/stroke.xml b/mobile/web/reference/API/stroke.xml deleted file mode 100644 index 09f4678cf..000000000 --- a/mobile/web/reference/API/stroke.xml +++ /dev/null @@ -1,82 +0,0 @@ - - -stroke() - -Color - -Setting - -Web & Application - - -stroke_.gif - -stroke(153); -rect(30, 20, 55, 55); - - - - -stroke_2.gif - -stroke(204, 102, 0); -rect(30, 20, 55, 55); - - - - -Sets the stroke color which is the color used to draw lines and borders around shapes. This color is either specified in terms of the RGB or HSB color depending on the current colorMode(). The default color space is RGB, with each value in the range from 0 to 255. The version of stroke() with one parameter specifies a gray value, the version with three parameters specifies a color, and the version with four parameters specifies a color with an alpha value. Note: the value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default value is 255. - - - -stroke(gray) -stroke(value1, value2, value3); -stroke(color); - - - - -int or float: specifies a value between white and black - - - - -int or float: red or hue value (depending on the current color mode) - - - - -int or float: green or saturation value (depending on the current color mode) - - - - -int or float: blue or brightness value (depending on the current color mode) - - - - -color: any value of the color datatype - - -None - - -noStroke() -colorMode() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/subtractassign.xml b/mobile/web/reference/API/subtractassign.xml deleted file mode 100644 index 3454df63e..000000000 --- a/mobile/web/reference/API/subtractassign.xml +++ /dev/null @@ -1,52 +0,0 @@ - - --= (subtract assign) - -Math - -Operators - -Web & Application - - - - -int a = 50; -int b = 23; -a -= b; // sets "a" to 27 - - - - -Combines subtraction with assignment. The expression a -= b is equivalent to a = a - b. - - - -value1 -= value2 - - - - -int or float - - - - -int or float - - - - -+= (add assign) -- (minus) - - -1.0 - -Operator - -Core - - - - diff --git a/mobile/web/reference/API/switch.xml b/mobile/web/reference/API/switch.xml deleted file mode 100644 index e6ec70964..000000000 --- a/mobile/web/reference/API/switch.xml +++ /dev/null @@ -1,118 +0,0 @@ - - -switch() - -Control - -Conditionals - -Web & Application - - - - -int num = 1; - -switch(num) { - case 0: - println("Zero"); // Does not execute - break; - case 1: - println("One"); // Prints "One" - break; -} - - - - - - -char letter = 'N'; - -switch(letter) { - case 'A': - println("Alpha"); // Does not execute - break; - case 'B': - println("Bravo"); // Does not execute - break; - default: // Default executes if the case labels - println("None"); // don't match the switch parameter - break; -} - - - - - - -// Removing a "break" enables testing -// for more than one value at once - -char letter = 'b'; - -switch(letter) { - case 'a': - case 'A': - println("Alpha"); // Does not execute - break; - case 'b': - case 'B': - println("Bravo"); // Prints "Bravo" - break; -} - - - - - -Works like an if else structure, but switch() is more convenient when you need to select between three or more alternatives. Program controls jumps to the case with the same value as the expression. All remaining statements in the switch are executed unless redirectly by a break. Only primitive datatypes which can convert to an integer (byte, char, and int) may be used as the expression parameter. The default is optional. - - - -switch(expression) -{ - case label: - statements - case label: // Optional - statements // " - default: // " - statements // " -} - - - - -byte, char, or int - - - - -byte, char, or int - - - - -one or more statements to be executed - - - - - -case -default -break -if() -else - - -1.0 - -Function - -Java - -extended - - - diff --git a/mobile/web/reference/API/triangle.xml b/mobile/web/reference/API/triangle.xml deleted file mode 100644 index 2eaf663be..000000000 --- a/mobile/web/reference/API/triangle.xml +++ /dev/null @@ -1,75 +0,0 @@ - - -triangle() - -Shape - -2D Primitives - -Web & Application - - -triangle_.gif - -triangle(30, 75, 58, 20, 86, 75); - - - - -A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point. - - - -triangle(x1, y1, x2, y2, x3, y3); - - - - -int or float: x-coordinate of the first point - - - - -int or float: y-coordinate of the first point - - - - -int or float: x-coordinate of the second point - - - - -int or float: y-coordinate of the second point - - - - -int or float: x-coordinate of the third point - - - - -int or float: y-coordinate of the third point - - -None - - -beginShape() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/trim.xml b/mobile/web/reference/API/trim.xml deleted file mode 100644 index 78fa28281..000000000 --- a/mobile/web/reference/API/trim.xml +++ /dev/null @@ -1,47 +0,0 @@ - - -trim() - -Data - -String Functions - -Web & Application - - - - -String s = " Somerville MA "; -println(s); // Prints " Somerville MA " -String s2 = trim(s); -println(s2); // Prints "Somerville MA" - - - - -Removes whitespace characters from the beginning and end of a String. In addition to standard whitespace characters such as space, carriage return, and tab, this function also removes the Unicode "nbsp" character. - - - -trim(str) - - - - -any String - - -String - - - - -1.0 - -Function - -Core - -Extended - - diff --git a/mobile/web/reference/API/true.xml b/mobile/web/reference/API/true.xml deleted file mode 100644 index ad8425956..000000000 --- a/mobile/web/reference/API/true.xml +++ /dev/null @@ -1,56 +0,0 @@ - - -true - -Structure - - - -Web & Application - - - - -rect(30, 20, 50, 50); -boolean b = true; -if(b == true) { - line(20, 10, 90, 80); // This line draws -} else { - line(20, 80, 90, 10); -} - - - - -Reserved word representing the logical value "true". Only variables of type boolean may be assigned the value true - - - -false - - - - - - - - - -any valid statements - - - - - -false -boolean - - -1.0 - -Keyword - -PDE - - - diff --git a/mobile/web/reference/API/vertex.xml b/mobile/web/reference/API/vertex.xml deleted file mode 100644 index 3771e7338..000000000 --- a/mobile/web/reference/API/vertex.xml +++ /dev/null @@ -1,101 +0,0 @@ - - -vertex() - -Shape - -Vertex - -Application & Web - - -vertex_.gif - -beginShape(POINTS); -vertex(30, 20); -vertex(85, 20); -vertex(85, 75); -vertex(30, 75); -endShape(); - - - - -vertex_2.gif - -noStroke(); -BImage a = loadImage("arch.jpg"); -beginShape(); -texture(a); -// "arch.jpg" is 100x100 pixels in size so -// the values 0 and 100 are used for the -// parameters "u" and "v" to map it directly -// to the vertex points -vertex(10, 20, 0, 0); -vertex(80, 5, 100, 0); -vertex(95, 90, 100, 100); -vertex(40, 95, 0, 100); -endShape(); - - - - -All shapes are constructed by connecting a series of vertices. vertex() is used to specify the vertex coordinates for points, lines, triangles, quads, and polygons and is used exclusively within the beginShape() and endShape() function. This function is also used to map a texture onto the geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode(). - - - -vertex(x, y); -vertex(x, y, z); -vertex(x, y, u, v); -vertex(x, y, z, u, v); - - - - -int or float: x-coordinate of the vertex - - - - -int or float: y-coordinate of the vertex - - - - -int or float: z-coordinate of the vertex - - - - -int or float: horizontal coordinate for the texture mapping - - - - -int or float: vertical coordinate for the texture mapping - - -None - - -beginShape() -endShape() -bezierVertex() -curveVertex() -texture() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/void.xml b/mobile/web/reference/API/void.xml deleted file mode 100644 index ce60eeecc..000000000 --- a/mobile/web/reference/API/void.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -void - -Structure - - - -Web & Application - - - - -void setup() { - size(200, 200); -} - -void loop() { - line(10, 100, 190, 100); -} - - - - -Keyword used indicate a function returns no value. Each function must either return a value of a specific datatype or use the keyword void to specify the function returns nothing. - - - -void function { - statements -} - - - - -any function that is being defined or implemented - - - - -any valid statements - - - - - - -1.0 - -Keyword - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/while.xml b/mobile/web/reference/API/while.xml deleted file mode 100644 index b93434f27..000000000 --- a/mobile/web/reference/API/while.xml +++ /dev/null @@ -1,61 +0,0 @@ - - -while() - -Control - -Iteration - -Web & Application - - -while_.gif - -int i=0; -while(i<80) { - line(30, i, 80, i); - i = i + 5; -} - - - - -Controls a sequence of repetitions. The while structure executes a series of statements continuously while the expression is true. The expression must be updated during the repetitions or the program will never "break out" of while(). - - - -while(expression) { - statements -} - - - - -a valid expression - - - - -one or more statements - - - - - -for() - - -1.0 - -Structure - -PDE - - - - - - - - - diff --git a/mobile/web/reference/API/width.xml b/mobile/web/reference/API/width.xml deleted file mode 100644 index 6fe6e71ed..000000000 --- a/mobile/web/reference/API/width.xml +++ /dev/null @@ -1,54 +0,0 @@ - - -width - -Environment - - - -Web & Application - - -width.gif - -noStroke(); -background(0); -rect(0, 40, width, 20); -rect(0, 60, width/2, 20); - - - - -System variable which stores the width of the display window. This value is set by the first parameter of the size() function. For example, the function call size(320, 240) sets the width variable to the value 320. The value of width is zero until size() is called. - - - - -width - - - - - - - - - - -height - - -1.0 - -System variable - -Core - - - - - - - - - diff --git a/mobile/web/reference/API/year.xml b/mobile/web/reference/API/year.xml deleted file mode 100644 index 5fb6060d0..000000000 --- a/mobile/web/reference/API/year.xml +++ /dev/null @@ -1,74 +0,0 @@ - - -year() - -Input/Output - -Time & Date - -Web & Application - - -year_.jar - -void setup() { - PFont metaBold; - metaBold = loadFont("fonts/Meta-Bold.vlw.gz"); - setFont(metaBold, 44); - hint(SMOOTH_IMAGES); -} - -void loop() { - int d = day(); // Values from 1 - 31 - int m = month(); // Values from 1 - 12 - int y = year(); // 2003, 2004, 2005, etc. - String s = String.valueOf(d); - text(s, 10, 28); - s = String.valueOf(m); - text(s, 10, 56); - s = String.valueOf(y); - text(s, 10, 84); -} - - - - - -Processing communicates with the clock on your computer. The year() function returns the current year as an integer (2003, 2004, 2005, etc). - - - -year() - - - - - - - -int - - -millis() -second() -minute() -hour() -day() -month() -year() - - -1.0 - -Function - -Core - - - - - - - - - diff --git a/mobile/web/reference/index.php b/mobile/web/reference/index.php deleted file mode 100644 index 529d8af6b..000000000 --- a/mobile/web/reference/index.php +++ /dev/null @@ -1,113 +0,0 @@ - array(), - 'Environment' => array(), - 'Data' => array('Primitive' => array(), - 'Composite' => array(), - 'Conversion' => array(), - 'String Functions' => array(), - 'Array Functions' => array()), - 'Control' => array('Relational Operators' => array(), - 'Iteration' => array(), - 'Conditionals' => array(), - 'Logical Operators' => array()), - 'Shape' => array('2D Primitives' => array(), - 'Curves' => array(), - '3D Primitives' => array(), - 'Stroke attributes' => array(), - 'Vertex' => array()), - 'Input/Output' => array('Mouse' => array(), - 'Keyboard' => array(), - 'Time & Date' => array(), - 'Text Output' => array(), - 'Files' => array(), - 'Web' => array()), - 'Color' => array('Setting' => array(), - 'Creating & Reading' => array()), - /* - 'Image' => array('PImage' => array(), - 'Loading & Displaying' => array(), - 'Pixels' => array()), - 'Typography' => array('PFont' => array(), - 'Loading & Displaying' => array()), - */ - 'Math' => array('Operators' => array(), - 'Bitwise Operators' => array(), - 'Calculation' => array(), - 'Trigonometry' => array(), - 'Random' => array()), -); - -$PAGE_TITLE = "Processing Mobile Language"; -require '../header.inc.php'; - -$total = 0; - -$dir = opendir('API'); -$filename = readdir($dir); -while ($filename !== false) { - $filename = readdir($dir); - if (strstr($filename, '.xml') !== false) { - $dom = @domxml_open_file('API/' . $filename); - - $shortname = substr($filename, 0, strlen($filename) - 4); - - $name = $dom->get_elements_by_tagname('name'); - $name = trim($name[0]->get_content()); - - $cat = $dom->get_elements_by_tagname('category'); - $cat = trim($cat[0]->get_content()); - - $subcat = $dom->get_elements_by_tagname('subcategory'); - $subcat = trim($subcat[0]->get_content()); - - $categories[$cat][$subcat][] = $shortname."\n".$name; - - $total++; - } -} - -?> -
-  -
- - - - -
This reference is a work in progress. The descriptions have been copied from the Processing project and have not yet been updated to reflect the additional constraints of Processing Mobile.
-
-
- - $entry) { ?> -
-
- $e) { ?> - 0) { ?> - - -
- - - - "> - -
- -
- - -
-
- ($total / 4)) { ?> - -
-
- - -
- \ No newline at end of file diff --git a/mobile/web/reference/reference.php b/mobile/web/reference/reference.php deleted file mode 100644 index 3d3c3293f..000000000 --- a/mobile/web/reference/reference.php +++ /dev/null @@ -1,127 +0,0 @@ -> Language (API)"; -$PAGE_SHOWBACKINDEX = true; - -require '../header.inc.php'; - -$dom = @domxml_open_file("API/{$_GET['name']}.xml"); -$root = $dom->document_element(); -$value = array(); -$child = $root->first_child(); - -while ($child) { - $tag = $child->node_name(); - if (($tag == 'example') || ($tag == 'parameter')) { - if (!isset($value[$tag])) { - $value[$tag] = array(); - } - $subvalue = array(); - $gchild = $child->first_child(); - while ($gchild) { - $gtag = $gchild->node_name(); - $content = trim($gchild->get_content()); - if ($content != "") { - $subvalue[$gtag] = $content; - } - - $gchild = $gchild->next_sibling(); - } - $value[$tag][] = $subvalue; - } else if ($tag[0] == '#') { - //// skip - } else { - $content = trim($child->get_content()); - if ($content != "") { - $value[$tag] = $content; - } - } - - $child = $child->next_sibling(); -} -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name -

-
Examples - - - - - - - - - -
- - - - - - -  
-
- -
Description - -
Syntax -
-
Parameters - - - - - - - - -
 
-
Usage - -
- diff --git a/mobile/web/settings.inc.php b/mobile/web/settings.inc.php deleted file mode 100644 index fdc0d8109..000000000 --- a/mobile/web/settings.inc.php +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file