mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 02:45:36 +01:00
This commit was manufactured by cvs2svn to create tag
'processing-0075'.
This commit is contained in:
@@ -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:
|
||||
#
|
||||
# [<whitespace>]<filename><whitespace><error message><end-of-line>
|
||||
#
|
||||
# comment lines begin with '#'
|
||||
@@ -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".
|
||||
@@ -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
|
||||
@@ -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'
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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"
|
||||
@@ -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".
|
||||
@@ -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".
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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("<?xml version=\"1.0\"?>");
|
||||
stream.println("<document>");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(stream);
|
||||
if (parserAST != null) {
|
||||
((CommonAST)parserAST).xmlSerialize(writer);
|
||||
}
|
||||
writer.flush();
|
||||
stream.println("</document>");
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -1,118 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- base dir set to parent of mobile directory, i.e:
|
||||
parent <- basedir
|
||||
mobile
|
||||
build
|
||||
windows
|
||||
processing
|
||||
|
||||
processing will be checked out into the parent directory, if it doesn't exist -->
|
||||
<project name="mobile" default="dist" basedir="..\..\..">
|
||||
|
||||
<!-- init should always be the first target in a dependency list, it sets up
|
||||
properties necessary for things to work correctly. -->
|
||||
<target name="init">
|
||||
<!-- Check if processing has been checked out and set property accordingly-->
|
||||
<available property="ischeckedout" file="processing" type="dir"/>
|
||||
<!-- home directory of cygwin -->
|
||||
<property name="cygwin.dir" value="C:/Sdk/cygwin"/>
|
||||
<!-- the absolute path of the basedir, specified here with unix slashes -->
|
||||
<property name="parent.dir" value="C:/Projects/processing"/>
|
||||
<!-- the absolute path of a WTK implementation for building core files -->
|
||||
<property name="wtk.dir" value="C:/WTK22"/>
|
||||
<!-- the boot classpath to use when compiling core files -->
|
||||
<property name="wtk.bootClassPath" value="${wtk.dir}/lib/cldcapi10.jar;${wtk.dir}/lib/midpapi10.jar"/>
|
||||
<!-- the tag to use when checking out processing -->
|
||||
<property name="cvs.tag.processing" value="processing-0074"/>
|
||||
</target>
|
||||
|
||||
<!-- checks out a tagged copy of processing if it hasn't been done so already. -->
|
||||
<target name="checkout" unless="ischeckedout">
|
||||
<!-- perform the cvs update to get clean files. -->
|
||||
<exec executable="${cygwin.dir}/bin/bash.exe">
|
||||
<arg value="--login"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="cd ${parent.dir}; cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/processing co -r ${cvs.tag.processing} -P processing"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- gets unmodified tagged source files back into the processing app directory. -->
|
||||
<target name="revert" depends="init, checkout">
|
||||
<!-- perform the cvs update to get clean files. -->
|
||||
<exec executable="${cygwin.dir}/bin/bash.exe">
|
||||
<arg value="--login"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="cd ${parent.dir}/processing/app; cvs update -CP; rm .#*"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- copy app source files from mobile into corresponding directory in processing. -->
|
||||
<target name="copyappsrc" depends="checkout">
|
||||
<copy todir="processing/app" overwrite="true">
|
||||
<fileset dir="mobile/app">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="make" depends="init, copyappsrc">
|
||||
<!-- execute make.sh shell script in processing build dir. -->
|
||||
<exec executable="${cygwin.dir}/bin/bash.exe">
|
||||
<arg value="--login"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="cd ${parent.dir}/processing/build/windows; ./make.sh"/>
|
||||
</exec>
|
||||
<antcall target="copycore"/>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="init, copyappsrc">
|
||||
<!-- execute dist.sh shell script in processing build dir. -->
|
||||
<exec executable="${cygwin.dir}/bin/bash.exe">
|
||||
<arg value="--login"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="cd ${parent.dir}/processing/build/windows; ./make.sh"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="init">
|
||||
<!-- execute run.sh shell script in processing build dir. -->
|
||||
<exec executable="${cygwin.dir}/bin/bash.exe">
|
||||
<arg value="--login"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="cd ${parent.dir}/processing/build/windows; ./run.sh"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- builds the mobile core files and packages them up for inclusion with processing ide-->
|
||||
<target name="makecore" depends="init">
|
||||
<!-- compile core source files into a temporary directory -->
|
||||
<mkdir dir="mobile/build/windows/classes"/>
|
||||
<javac srcdir="mobile/core/processing/core"
|
||||
destdir="mobile/build/windows/classes"
|
||||
bootclasspath="${wtk.bootClassPath}"
|
||||
source="1.3"
|
||||
target="1.1"/>
|
||||
<!-- preverify compiled classes into another temporary directory -->
|
||||
<mkdir dir="mobile/build/windows/preverified"/>
|
||||
<exec executable="${wtk.dir}/bin/preverify.exe">
|
||||
<arg value="-classpath"/>
|
||||
<arg path="${wtk.bootClassPath}"/>
|
||||
<arg value="-target"/>
|
||||
<arg value="CLDC1.0"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="mobile/build/windows/preverified"/>
|
||||
<arg path="mobile/build/windows/classes"/>
|
||||
</exec>
|
||||
<!-- pack preverified classes into jar -->
|
||||
<jar destfile="mobile/build/windows/mobile.jar" basedir="mobile/build/windows/preverified">
|
||||
<include name="**/*.class"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<!-- copies core jar and manifest/jad template into processing ide build -->
|
||||
<target name="copycore" depends="makecore">
|
||||
<!-- copy jar and jad/manifest template into processing build -->
|
||||
<copy file="mobile/build/shared/lib/mobile.mf" todir="processing/build/windows/work/lib"/>
|
||||
<copy file="mobile/build/windows/mobile.jar" todir="processing/build/windows/work/lib"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class EllipseTest extends PMIDlet {
|
||||
void setup() {
|
||||
ellipse(30, 20, 55, 55);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class LineTest1 extends PMIDlet {
|
||||
void setup() {
|
||||
line(30, 20, 85, 75);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class Linear extends PMIDlet {
|
||||
// Linear
|
||||
// by REAS <http://www.groupc.net>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.groupc.net>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class RectTest extends PMIDlet {
|
||||
|
||||
void setup() {
|
||||
rect(30, 20, 55, 55);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class Shape_Primitives extends PMIDlet {
|
||||
void setup() {
|
||||
// Shape Primitives
|
||||
// by REAS <http://www.groupc.net>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package test;
|
||||
import processing.core.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francis Li
|
||||
*/
|
||||
public class Vertices extends PMIDlet {
|
||||
|
||||
void setup() {
|
||||
// Vertices
|
||||
// by REAS <http://www.groupc.net>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
$PAGE_TITLE = "Processing Mobile >> Download";
|
||||
|
||||
require '../header.inc.php';
|
||||
?>
|
||||
<h2>Processing Mobile pre-Alpha</h2>
|
||||
<ol>
|
||||
<li>Download and install the Wireless Toolkit (WTK) from Sun. The latest version is 2.1.<br><br>
|
||||
<a href="http://java.sun.com/products/j2mewtoolkit/">http://java.sun.com/products/j2mewtoolkit/</a><br> </li>
|
||||
<li>Download and install Processing Mobile.<br><br>
|
||||
0071 pre-ALPHA | 17 10 2004 Windows <a href="processing-0071-expert.zip">Expert</a><br> </li>
|
||||
<li>Modify <b>preferences.txt</b> to include the following line, based on the installation location of the WTK:<br>
|
||||
<br>
|
||||
wtk.path=C:\WTK21<br> </li>
|
||||
</ol>
|
||||
|
||||
<?php
|
||||
require '../footer.inc.php';
|
||||
?>
|
||||
@@ -1,8 +0,0 @@
|
||||
</div>
|
||||
<div id="footer">
|
||||
<a href="http://www.processing.org" target="_blank">Processing</a> is
|
||||
© 2004-2001 Massachusetts Institute of Technology and Interaction
|
||||
Design Institute Ivrea </p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
require 'settings.inc.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $PAGE_TITLE ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<script language="javascript">
|
||||
<!--
|
||||
|
||||
function MM_openBrWindow(theURL,winName,features) { //v2.0
|
||||
window.open(theURL,winName,features);
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<link rel="stylesheet" href="<?php echo SITE_ROOT?>css/mobile.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="head">
|
||||
<img src="<?php echo SITE_ROOT?>images/wiring.jpg" width="97" height="47">
|
||||
</div>
|
||||
<div id="navigation">
|
||||
<img src="<?php echo SITE_ROOT?>images/nav_bottomarrow.gif" width="33" height="25" align="absmiddle">
|
||||
|
||||
<?php if ($_SERVER['PHP_SELF'] == SITE_ROOT . 'index.php') { ?>
|
||||
Cover
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo SITE_ROOT ?>index.php">Cover</a>
|
||||
<?php } ?>
|
||||
|
||||
<span class="backslash">\</span>
|
||||
<?php if (strstr($_SERVER['PHP_SELF'], SITE_ROOT . 'reference/') === false) { ?>
|
||||
<a href="<?php echo SITE_ROOT ?>reference/index.php">Reference</a>
|
||||
<?php } else { ?>
|
||||
Reference
|
||||
<?php } ?>
|
||||
|
||||
<span class="backslash">\</span>
|
||||
<?php if (strstr($_SERVER['PHP_SELF'], SITE_ROOT . 'examples/') === false) { ?>
|
||||
<a href="<?php echo SITE_ROOT ?>examples/index.php">Examples</a>
|
||||
<?php } else { ?>
|
||||
Examples
|
||||
<?php } ?>
|
||||
|
||||
<span class="backslash">\</span>
|
||||
<?php if (strstr($_SERVER['PHP_SELF'], SITE_ROOT . 'download/') === false) { ?>
|
||||
<a href="<?php echo SITE_ROOT ?>download/index.php">Download</a>
|
||||
<?php } else { ?>
|
||||
Download
|
||||
<?php } ?>
|
||||
|
||||
<span class="backslash">\</span>
|
||||
<?php if (strstr($_SERVER['PHP_SELF'], SITE_ROOT . 'discourse/') === false) { ?>
|
||||
<a href="<?php echo SITE_ROOT ?>discourse/index.php">Discourse</a>
|
||||
<?php } else { ?>
|
||||
Discourse
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<?php if ($PAGE_SHOWBACKINDEX) { ?>
|
||||
<div id="backnavigation">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td align="right" width="50">
|
||||
<a href="index.php">
|
||||
<img src="<?php echo SITE_ROOT?>images/back_off.gif" width="38" height="30" border="0" align="middle">
|
||||
</a>
|
||||
</td>
|
||||
<td valign="middle">
|
||||
<a href="index.php">
|
||||
Index
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="content">
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
$PAGE_TITLE = "Processing Mobile";
|
||||
|
||||
require 'header.inc.php';
|
||||
?>
|
||||
<img align="left" src="images/wiring_cover_small.jpg" width="590" height="300">
|
||||
<div class="column">
|
||||
|
||||
</div>
|
||||
<div class="column">
|
||||
<br>
|
||||
Processing Mobile allows software written using the Processing programming
|
||||
language and development environment to run on Java Powered mobile devices.
|
||||
</div>
|
||||
<?php
|
||||
require 'footer.inc.php';
|
||||
?>
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
@@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>Array</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Composite</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
int degrees = 360;
|
||||
float[] cos_vals = new float[degrees];
|
||||
for(int i=0; i < degrees; i++) {
|
||||
cos_vals[i] = cos(TWO_PI/degrees * i);
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>[0]</b>, the second element is <b>[1]</b>, and so on. Arrays are similar to objects, so they must be created with the keyword <b>new</b>. Every array has a variable <b>length</b> which is an integer value for the total number of elements in the array.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>datatype</c>[] <c>var</c>
|
||||
<c>var</c>[<c>element</c>] = <c>value</c>
|
||||
<c>var</c>.length
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>datatype</label>
|
||||
<description>any primitive or compound datatype, including user defined classes</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>any valid variable name</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>element</label>
|
||||
<description>int: must not exceed the length of the array - 1</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>data to assign to the array element, must be the same datatype as the array</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related></related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Object</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>Object</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Composite</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants).
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>class</c> <c>instance</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>class</label>
|
||||
<description>the class to created the object from</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>instance</label>
|
||||
<description>any variable name</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
class
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Object</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,108 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>String</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Composite</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
A string is a sequence of characters. The class <b>String</b> 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'). <br /> <br />There are more string methods than those linked from this page. Additional <b>String</b> documentation is located at http://java.sun.com/j2se/1.4.2/docs/api/
|
||||
</description>
|
||||
|
||||
<syntax></syntax>
|
||||
|
||||
<parameter>
|
||||
<label></label>
|
||||
<description></description>
|
||||
</parameter>
|
||||
|
||||
<field>
|
||||
<fname></fname>
|
||||
<fdescription></fdescription>
|
||||
</field>
|
||||
|
||||
<method>
|
||||
<mname>charAt()</mname>
|
||||
<mdescription>Returns the character at the specified index</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>equals()</mname>
|
||||
<mdescription>Compares a string to a specified object</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>indexOf()</mname>
|
||||
<mdescription>Returns the index value of the first occurance of a character within the input string</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>length()</mname>
|
||||
<mdescription>Returns the number of characters in the input string</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>substring()</mname>
|
||||
<mdescription>Returns a new string that is part of the input string</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>toLowerCase()</mname>
|
||||
<mdescription>Converts all the characters to lower case</mdescription>
|
||||
</method>
|
||||
<method>
|
||||
<mname>toUpperCase()</mname>
|
||||
<mdescription>Converts all the characters to upper case</mdescription>
|
||||
</method>
|
||||
|
||||
<constructor>
|
||||
String(<c>data</c>)
|
||||
String(<c>data</c>, <c>offset</c>, <c>length</c>)
|
||||
</constructor>
|
||||
|
||||
<cparameter>
|
||||
<clabel>data</clabel>
|
||||
<cdescription>byte[] or char[]: array of bytes to be decoded into characters or array of characters to be combined into a string</cdescription>
|
||||
</cparameter>
|
||||
|
||||
<cparameter>
|
||||
<clabel>offset</clabel>
|
||||
<cdescription>int: index of the first character</cdescription>
|
||||
</cparameter>
|
||||
|
||||
<cparameter>
|
||||
<clabel>length</clabel>
|
||||
<cdescription>int: number of characters</cdescription>
|
||||
</cparameter>
|
||||
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
char
|
||||
text()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Object</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>charAt()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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'
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
charAt(<c>index</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>index</label>
|
||||
<description>int: the index of the character</description>
|
||||
</parameter>
|
||||
|
||||
<returns>char</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>equals()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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");
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>true</b> if the strings are the same and <b>false</b> if they are not.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
equals(<c>str</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>str</label>
|
||||
<description>String: any valid String</description>
|
||||
</parameter>
|
||||
|
||||
<returns>Boolean</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>indexOf()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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'
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>str</b> parameter. If the <b>str</b> parameter is not found in the string, -1 is returned.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
indexOf(<c>str</c>)
|
||||
indexOf(<c>str</c>, <c>fromIndex</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>str</label>
|
||||
<description>String: the substring to search</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>fromIndex</label>
|
||||
<description>int: the index from which to start the search</description>
|
||||
</parameter>
|
||||
|
||||
<returns>int</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>length()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String str1 = "CCCP";
|
||||
String str2 = "Rabbit";
|
||||
int l1 = str1.length();
|
||||
int l2 = str2.length();
|
||||
println(l1 + ":" + l2); // Prints '4:6'
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Returns the total number of characters included in the string as an integer number. <br />Note: You find the size of an array with the length field which works a little differently from String's <b>length()</b> method.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
charAt()
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label></label>
|
||||
<description></description>
|
||||
</parameter>
|
||||
|
||||
<returns>int</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>substring()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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'
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Returns a new string that is a part of the original string. When using the <b>endIndex</b> parameter, the string between <b>beginIndex</b> and <b>endIndex</b>-1 is returned.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
substring(<b>beginIndex</b>)
|
||||
substring(<b>beginIndex</b>, <b>endIndex</b>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>beginIndex</label>
|
||||
<description>int: position from which to begin (inclusive)</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>endIndex</label>
|
||||
<description>int: position from which to end (exclusive)</description>
|
||||
</parameter>
|
||||
|
||||
<returns>None</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>toLowerCase()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String str1 = "CCCP";
|
||||
String str2 = "Rabbit";
|
||||
str1 = str1.toLowerCase();
|
||||
str2 = str2.toLowerCase();
|
||||
println(str1 + ":" + str2); // Prints cccp:rabbit
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Converts all of the characters in the string to lowercase. For example, "ABC" will convert to "abc".
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
toLowerCase()
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label></label>
|
||||
<description></description>
|
||||
</parameter>
|
||||
|
||||
<returns>String</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
|
||||
<name>toUpperCase()</name>
|
||||
|
||||
<category>String</category>
|
||||
|
||||
<subcategory>Method</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String str1 = "Cccp";
|
||||
String str2 = "Rabbit";
|
||||
str1 = str1.toUpperCase();
|
||||
str2 = str2.toUpperCase();
|
||||
println(str1 + ":" + str2); // Prints CCCP:RABBIT
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Converts all of the characters in the string to uppercase. For example, "abc" will convert to "ABC".
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
charAt()
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>sx</label>
|
||||
<description>int: X coordinate of the pixel in source image</description>
|
||||
</parameter>
|
||||
|
||||
<returns>String</returns>
|
||||
|
||||
<related>
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Method</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>abs()</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Calcuation</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Calculates the absolute value (magnitude) of a number. The absolute value of a number is always positive.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
abs(<c>value</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>float or int</description>
|
||||
</parameter>
|
||||
|
||||
<returns>float or int (depending on the input values)</returns>
|
||||
|
||||
<related></related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>+= (add assign)</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Operators</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
int a = 50;
|
||||
int b = 23;
|
||||
a += b; // sets "a" to 73
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Combines addition with assignment. The expression <b>a += b</b> is equivalent to <b>a = a + b</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>value1</c> += <c>value2</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>int or float</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>any numberical value the same datatype as value1</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
= (assign)
|
||||
+ (add)
|
||||
-= (subtract assign)
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>+ (addition)</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Operators</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
int a = 50 + 5; // Sets a to 55
|
||||
int b = a + 5; // Sets b to 60
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String s1 = "Gorbachev";
|
||||
int i = 1987;
|
||||
String sc1 = s1 + i;
|
||||
println(sc1); // Prints Gorbachev1987
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>value1</c> + <c>value2</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>String, int, float, char, byte, boolean</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>String, int, float, char, byte, boolean</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
++ (increment)
|
||||
+= (add assign)
|
||||
- (minus)
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>append()</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Array Functions</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String sa1[] = { "OH ", "NY ", "CA "};
|
||||
String sa2[] = append(sa1, "MA ");
|
||||
print(sa2); // Prints "OH NY CA MA"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Expands an array by one element and adds data to the new position. The datatype of the <b>element</b> parameter must be the same as the datatype of the array.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
append(<c>array</c>, <c>element</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>array</label>
|
||||
<description>boolean[], byte[], char[], int[], float[], or String[]</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>element</label>
|
||||
<description>new data for the array</description>
|
||||
</parameter>
|
||||
|
||||
<returns>Array (the same datatype as the input)</returns>
|
||||
|
||||
<related>
|
||||
shorten()
|
||||
expand()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
</root>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>[] (array access)</name>
|
||||
|
||||
<category>Structure</category>
|
||||
|
||||
<subcategory></subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
The array access operator is used to specify a location within an array. The data at this location can be defined with the syntax <b>array[element] = value</b> or read with the syntax <b>value = array[element]</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>datatype</c>[]
|
||||
<c>array</c>[<c>element</c>]
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>datatype</label>
|
||||
<description>any primitive or compound datatype, including user defined classes</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>array</label>
|
||||
<description>any valid variable name</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>element</label>
|
||||
<description>int: must not exceed the length of the array - 1</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
Array
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>= (assign)</name>
|
||||
|
||||
<category>Structure</category>
|
||||
|
||||
<subcategory></subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
int a;
|
||||
a = 30; // Assigns for value 30 to the variable "a"
|
||||
a = a + 40; // Assigns the value 70 to the variable "a"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>int</b>, the value must also be an <b>int</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>var</c> = <c>value</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>any valid variable name</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>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</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
+= (add assign)
|
||||
-= (subtract assign)
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,96 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>background()</name>
|
||||
|
||||
<category>Color</category>
|
||||
|
||||
<subcategory>Setting</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>background_.gif</image>
|
||||
<code>
|
||||
background(51);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>background_2.gif</image>
|
||||
<code>
|
||||
background(255, 204, 0);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>background_4.jar</image>
|
||||
<code>
|
||||
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);
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>background_3.jpg</image>
|
||||
<code>
|
||||
PImage b;
|
||||
b = loadImage("laDefense.jpg");
|
||||
background(b);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
The <b>background()</b> function sets the color used for the background of the Processing window. The default background is light gray. In the <b>loop()</b> 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
background(<c>value1</c>)
|
||||
background(<c>value1</c>, <c>value2</c>, <c>value3</c>)
|
||||
background(<c>image</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>int or float: red or hue value (depending on the current color mode)</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>int or float: green or saturation value (depending on the current color mode)</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value3</label>
|
||||
<description>int or float: blue or brightness value (depending on the current color mode)</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>image</label>
|
||||
<description>PImage: the name of a PImage the same size as the display window</description>
|
||||
</parameter>
|
||||
|
||||
<returns>None</returns>
|
||||
|
||||
<related>
|
||||
colorMode()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>beginShape()</name>
|
||||
|
||||
<category>Shape</category>
|
||||
|
||||
<subcategory>Vertex</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>beginShape_.gif</image>
|
||||
<code>
|
||||
beginShape(POINTS);
|
||||
vertex(30, 20);
|
||||
vertex(85, 20);
|
||||
vertex(85, 75);
|
||||
vertex(30, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_2.gif</image>
|
||||
<code>
|
||||
beginShape(LINES);
|
||||
vertex(30, 20);
|
||||
vertex(85, 20);
|
||||
vertex(85, 75);
|
||||
vertex(30, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_3.gif</image>
|
||||
<code>
|
||||
beginShape(LINE_STRIP);
|
||||
vertex(30, 20);
|
||||
vertex(85, 20);
|
||||
vertex(85, 75);
|
||||
vertex(30, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_4.gif</image>
|
||||
<code>
|
||||
beginShape(LINE_LOOP);
|
||||
vertex(30, 20);
|
||||
vertex(85, 20);
|
||||
vertex(85, 75);
|
||||
vertex(30, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_5.gif</image>
|
||||
<code>
|
||||
beginShape(TRIANGLES);
|
||||
vertex(30, 75);
|
||||
vertex(40, 20);
|
||||
vertex(50, 75);
|
||||
vertex(60, 20);
|
||||
vertex(70, 75);
|
||||
vertex(80, 20);
|
||||
vertex(90, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_6.gif</image>
|
||||
<code>
|
||||
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();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_7.gif</image>
|
||||
<code>
|
||||
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();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_8.gif</image>
|
||||
<code>
|
||||
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();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>beginShape_9.gif</image>
|
||||
<code>
|
||||
beginShape(POLYGON);
|
||||
vertex(20, 20);
|
||||
vertex(40, 20);
|
||||
vertex(40, 40);
|
||||
vertex(60, 40);
|
||||
vertex(60, 60);
|
||||
vertex(20, 60);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Using the <b>beginShape()</b> and <b>endShape()</b> functions allow creating more complex forms. <b>beginShape()</b> begins recording vertices for a shape and endShape() stops recording. The <b>beginShape()</b> 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 <b>beginShape()</b> function, a series of <b>vertex()</b> commands must follow. To stop drawing the shape, call <b>endShape()</b>. The <b>vertex()</b> 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 <b>translate()</b>, <b>rotate()</b>, and <b>scale()</b> do not work within <b>beginShape()</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
beginShape(<c>MODE</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>MODE</label>
|
||||
<description>Either LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, QUADS, QUAD_STRIP, POLYGON</description>
|
||||
</parameter>
|
||||
|
||||
<returns>None</returns>
|
||||
|
||||
<related>
|
||||
endShape()
|
||||
vertex()
|
||||
curveVertex()
|
||||
bezierVertex()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,101 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>bezier()</name>
|
||||
|
||||
<category>Shape</category>
|
||||
|
||||
<subcategory>Curves</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>bezier_.gif</image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>bezier_2.gif</image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
bezier(<c>x1</c>, <c>y1</c>, <c>x2</c>, <c>y2</c>, <c>x3</c>, <c>y3</c>, <c>x4</c>, <c>y4</c>);
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>x1</label>
|
||||
<description>int or float: x-coordinate of the first anchor point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>y1</label>
|
||||
<description>int or float: y-coordinate of the first anchor point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>x2</label>
|
||||
<description>int or float: x-coordinate of the first control point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>y2</label>
|
||||
<description>int or float: y-coordinate of the first control point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>x3</label>
|
||||
<description>int or float: x-coordinate of the second control point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>y3</label>
|
||||
<description>int or float: y-coordinate of the second control point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>x4</label>
|
||||
<description>int or float: x-coordinate of the second anchor point</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>y4</label>
|
||||
<description>int or float: y-coordinate of the second anchor point</description>
|
||||
</parameter>
|
||||
|
||||
<returns>None</returns>
|
||||
|
||||
<related>
|
||||
bezierVertex()
|
||||
curve()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>bezierVertex()</name>
|
||||
|
||||
<category>Shape</category>
|
||||
|
||||
<subcategory>Vertex</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>bezierVertex_.gif</image>
|
||||
<code>
|
||||
beginShape(LINE_STRIP);
|
||||
bezierVertex(30, 20);
|
||||
bezierVertex(80, 0);
|
||||
bezierVertex(80, 75);
|
||||
bezierVertex(30, 75);
|
||||
endShape();
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Specifies vertex coordinates for Bezier curves. This function must be used between <b>beginShape()</b> and <b>endShape()</b>. These curves are defined by a series of anchor and control points. Bezier curves were developed by French engineer Pierre Bezier.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
bezierVertex(<c>x</c>, <c>y</c>)
|
||||
bezierVertex(<c>x</c>, <c>y</c>, <c>z</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>x</label>
|
||||
<description>The x-coordinate of the vertex, either a float or int</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>y</label>
|
||||
<description>The y-coordinate of the vertex, either a float or int</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>z</label>
|
||||
<description>The z-coordinate of the vertex, either a float or int</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
curveVertex()
|
||||
vertex()
|
||||
bezier()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>& (bitwise AND)</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Bitwise Operators</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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<br /><br /><pre> 11010110 // 214<br />& 01011100 // 92<br /> --------<br /> 01010100 // 84</pre><br />To see the binary representation of a number, use the <b>binary()</b> function with <b>println()</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>value</c> & <c>value2</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>int, char, byte</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>int, char, byte</description>
|
||||
</parameter>
|
||||
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
| (bitwise OR)
|
||||
binary()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>| (bitwise OR)</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Bitwise Operators</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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<br /><br /><pre> 11010110 // 214<br />& 01011100 // 92<br /> --------<br /> 11011110 // 222</pre><br />To see the binary representation of a number, use the <b>binary()</b> function with <b>println()</b>.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>value</c> | <c>value2</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>int, char, byte</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>int, char, byte</description>
|
||||
</parameter>
|
||||
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
& (bitwise AND)
|
||||
binary()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>blue()</name>
|
||||
|
||||
<category>Color</category>
|
||||
|
||||
<subcategory>Creating & Reading</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>blue_.gif</image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Extracts the blue element from a color.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
blue(<c>color</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>color</label>
|
||||
<description>any value of the color datatype</description>
|
||||
</parameter>
|
||||
|
||||
<returns>float</returns>
|
||||
|
||||
<related>
|
||||
red()
|
||||
green()
|
||||
hue()
|
||||
saturation()
|
||||
brightness()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>boolean</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Primitive</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>boolean.gif</image>
|
||||
<code>
|
||||
boolean a = false;
|
||||
if (!a) {
|
||||
rect(30, 20, 50, 50);
|
||||
}
|
||||
a = true;
|
||||
if (a) {
|
||||
line(20, 10, 90, 80);
|
||||
line(20, 80, 90, 10);
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Datatype for the Boolean values <b>true</b> and <b>false</b>. It is common to use <b>boolean</b>values 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
boolean <c>var</c>
|
||||
boolean <c>var</c> = <c>booleanvalue</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>variable name referencing the value</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>booleanvalue</label>
|
||||
<description>true or false</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
true
|
||||
false
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Datatype</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>boolean()</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Conversion</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Converts a primitive datatype, string, or array to its boolean representation. The number 0 evaluates to false and all other numbers evaluate to true.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
boolean(<c>val</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>val</label>
|
||||
<description>int, float, char, byte, String, int[], float[], char[], byte[], String[]</description>
|
||||
</parameter>
|
||||
|
||||
<returns>byte</returns>
|
||||
|
||||
<related>
|
||||
boolean
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>IDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>break</name>
|
||||
|
||||
<category>Control</category>
|
||||
|
||||
<subcategory>Conditionals</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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;
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Ends the execution of a structure such as switch(), for(), or while() and jumps to the next statement after.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>break</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label></label>
|
||||
<description></description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
switch()
|
||||
for()
|
||||
while()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Keyword</type>
|
||||
|
||||
<partof>Java</partof>
|
||||
|
||||
<level>extended</level>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>brightness()</name>
|
||||
|
||||
<category>Color</category>
|
||||
|
||||
<subcategory>Creating & Reading</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>brightness_.gif</image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Extracts the brightness value from a color.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
brightness(<c>color</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>color</label>
|
||||
<description>any value of the color datatype</description>
|
||||
</parameter>
|
||||
|
||||
<returns>float</returns>
|
||||
|
||||
<related>
|
||||
red()
|
||||
green()
|
||||
blue()
|
||||
hue()
|
||||
saturation()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>byte</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Primitive</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>char</b> 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
byte <c>var</c>
|
||||
byte <c>var</c> = <c>value</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>variable name referencing the value</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>a number between 127 to -128</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
int
|
||||
float
|
||||
boolean
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Datatype</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>byte()</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Conversion</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
byte(<c>val</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>val</label>
|
||||
<description>int, float, char, boolean, String, int[], float[], char[], boolean[], String[]</description>
|
||||
</parameter>
|
||||
|
||||
<returns>byte</returns>
|
||||
|
||||
<related>
|
||||
byte
|
||||
int()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>IDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>case</name>
|
||||
|
||||
<category>Control</category>
|
||||
|
||||
<subcategory>Conditionals</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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;
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Denotes the different labels to be evaluated with the parameter in the <b>switch()</b> structure.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
case <c>label</c>: <c>statements</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>label</label>
|
||||
<description>byte, char, or int</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>statements</label>
|
||||
<description>one or more valid statements</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
switch()
|
||||
default
|
||||
break
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Keyword</type>
|
||||
|
||||
<partof>Java</partof>
|
||||
|
||||
|
||||
<level>extended</level>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>ceil()</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Calculation</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
float x = 8.22;
|
||||
float a = ceil(x); // Set "a" to 9.0
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Calculates the closest value that is greater than or equal to the value of the parameter. For example, <b>ceil(9.03)</b> returns the value 10.0.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
ceil(<c>value</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>float</description>
|
||||
</parameter>
|
||||
|
||||
<returns>float</returns>
|
||||
|
||||
<related>
|
||||
floor()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>char</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Primitive</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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 "&"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Datatype for characters, typographic symbols such as A, d, and $. A <b>char</b> stores letters and symbols in the Unicode format, a coding system developed to support a variety of world languages. Each <b>char</b> is two bytes (16 bits) in length and is distinguished by surrounding it with single quotes. Character escapes may also stored as a <b>char</b>. 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
char <c>var</c>
|
||||
char <c>var</c> = <c>value</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>variable name referencing the value</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>any character</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
String
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Datatype</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>char()</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Conversion</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
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"
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Converts a primitive datatype, string, or array to a numeric character representation.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
char(<c>val</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>val</label>
|
||||
<description>int, float, byte, boolean, String, int[], float[], byte[], boolean[], String[]</description>
|
||||
</parameter>
|
||||
|
||||
<returns>char</returns>
|
||||
|
||||
<related>
|
||||
char
|
||||
int()
|
||||
float()
|
||||
byte()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>IDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>class</name>
|
||||
|
||||
<category>Structure</category>
|
||||
|
||||
<subcategory></subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <a href="http://java.sun.com/docs/books/tutorial/java/concepts/index.html" target="_blank">Object-Oriented Programming</a> is hosted from the Sun website.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
class <c>ClassName</c> {
|
||||
<c>statements</c>
|
||||
}
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>ClassName</label>
|
||||
<description>Any valid variable name</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>statements</label>
|
||||
<description>any valid statements</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
Object
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Keyword</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>color()</name>
|
||||
|
||||
<category>Color</category>
|
||||
|
||||
<subcategory>Creating & Reading</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>color_.gif</image>
|
||||
<code>
|
||||
color c1 = color(102, 102, 0);
|
||||
fill(c1);
|
||||
noStroke();
|
||||
rect(30, 20, 55, 55);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Creates colors which may be stored in variables of the <b>color</b> datatype. The parameters are interpreted as RGB or HSB values depending on the current <b>colorMode()</b>. The default mode is RGB values from 0 to 255 and therefore, the function call <b>color(255, 204, 0)</b> will return a bright yellow color. The <b>color()</b> 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
color(<c>gray</c>)
|
||||
color(<c>gray</c>, <c>alpha</c>)
|
||||
color(<c>value1</c>, <c>value2</c>, <c>value3</c>)
|
||||
color(<c>value1</c>, <c>value2</c>, <c>value3</c>, <c>alpha</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>gray</label>
|
||||
<description>int or float: number specifying value between white and black</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>alpha</label>
|
||||
<description>int or float: relative to current color range</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value1</label>
|
||||
<description>int or float: red or hue values relative to the current color range</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value2</label>
|
||||
<description>int or float: green or saturation values relative to the current color range</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>value3</label>
|
||||
<description>int or float: blue or brightness values relative to the current color range</description>
|
||||
</parameter>
|
||||
|
||||
|
||||
<returns>color</returns>
|
||||
|
||||
<related>
|
||||
color
|
||||
colorMode()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>colorMode()</name>
|
||||
|
||||
<category>Color</category>
|
||||
|
||||
<subcategory>Setting</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>colorMode_.jpg</image>
|
||||
<code>
|
||||
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);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<image>colorMode_2.jpg</image>
|
||||
<code>
|
||||
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);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Changes the way Processing interprets color data. By default, <b>fill()</b>, <b>stroke()</b>, and <b>background()</b> 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 <b>colorMode(RGB, 1.0)</b> 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
colorMode(<c>mode</c>);
|
||||
colorMode(<c>mode</c>, <c>range</c>);
|
||||
colorMode(<c>mode</c>, <c>range1</c>, <c>range2</c>, <c>range3</c>);
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>mode</label>
|
||||
<description>Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>range</label>
|
||||
<description>int or float: range for all color elements</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>range1</label>
|
||||
<description>int or float: range for the red or hue depending on the current color mode</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>range2</label>
|
||||
<description>int or float: range for the green or saturation depending on the current color mode</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>range3</label>
|
||||
<description>int or float: range for the blue or brightness depending on the current color mode</description>
|
||||
</parameter>
|
||||
|
||||
<returns>None</returns>
|
||||
|
||||
<related>
|
||||
background()
|
||||
fill()
|
||||
stroke()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>color</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Primitive</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>color.gif</image>
|
||||
<code>
|
||||
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);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Datatype for storing color values. Colors may be assigned with <b>get()</b> and <b>color()</b> or they may be specified directly using hexadecimal notation such as <b>#FFCC00</b>. 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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
color <c>var</c>
|
||||
color <c>var</c> = <c>colorvalue</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>var</label>
|
||||
<description>variable name referencing the value</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>colorvalue</label>
|
||||
<description>any color value</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
colorMode()
|
||||
color()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Datatype</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>, (comma)</name>
|
||||
|
||||
<category>Structure</category>
|
||||
|
||||
<subcategory></subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<applet></applet>
|
||||
<code>
|
||||
// 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]);
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Separates parameters in function calls and elements during assignment.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
value1, ..., valueN
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value1, ..., valueN</label>
|
||||
<description>any int, float, byte, boolean, color, char, String</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related></related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>// (comment)</name>
|
||||
|
||||
<category>Structure</category>
|
||||
|
||||
<subcategory></subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
// 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
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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 <b>//</b> characters. Comments are ignored by the compiler.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
// <c>comment</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>comment</label>
|
||||
<description>any sequence of characters</description>
|
||||
</parameter>
|
||||
|
||||
<returns></returns>
|
||||
|
||||
<related>
|
||||
/* */ (multiline comment)
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Operator</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>concat()</name>
|
||||
|
||||
<category>Data</category>
|
||||
|
||||
<subcategory>Array Functions</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
String sa1[] = { "OH ", "NY ", "CA "};
|
||||
String sa2[] = { "KY ", "IN ", "MA "};
|
||||
String sa3[] = concat(sa1, sa2);
|
||||
print(sa3); // Prints "OH NY CA KY IN MA "
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
concat(<c>array1</c>, <c>array2</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>array</label>
|
||||
<description>booleans[], bytes[], chars[], ints[], floats[], or Strings[]</description>
|
||||
</parameter>
|
||||
|
||||
<returns>Array (the same datatype as the input)</returns>
|
||||
|
||||
<related>
|
||||
splice()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>Core</partof>
|
||||
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>?: (conditional)</name>
|
||||
|
||||
<category>Control</category>
|
||||
|
||||
<subcategory>Conditionals</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image></image>
|
||||
<code>
|
||||
int s = 0;
|
||||
for(int i=5; i<100; i+=5) {
|
||||
s = (i < 50) ? 0 : 255;
|
||||
stroke(s);
|
||||
line(30, i, 80, i);
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
A shortcut for writing an <b>if()</b> and <b>else</b> structure. If the <b>condition</b> evaluates to <b>true</b>, <b>expression1</b> is evaluated and returned. If the <b>condition</b> evaluates to <b>false</b>, <b>expression2</b> is evaluated and returned.<br /><br />The following conditional: <br /><pre>condition : expression1 ? expression2</pre><br />is equivalent to this structure: <br /><pre>if(condition) {<br /> expression1 <br />} else { <br /> expression2 <br />}</pre>
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
<c>condition</c> ? <c>expression1</c> : <c>expression2</c>
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>condition</label>
|
||||
<description>any valid expression which evaluates to true or false</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>expression1</label>
|
||||
<description>any valid expression</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>expression2</label>
|
||||
<description>any valid expression</description>
|
||||
</parameter>
|
||||
|
||||
<returns>Variable, dependent on the datatype of the expressions</returns>
|
||||
|
||||
<related>
|
||||
if()
|
||||
else
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Structure</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
<level>Extended</level>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<root>
|
||||
<name>constrain()</name>
|
||||
|
||||
<category>Math</category>
|
||||
|
||||
<subcategory>Calculation</subcategory>
|
||||
|
||||
<usage>Web & Application</usage>
|
||||
|
||||
<example>
|
||||
<image>constrain_.jar</image>
|
||||
<code>
|
||||
void loop()
|
||||
{
|
||||
background(204);
|
||||
float mx = constrain(mouseX, 30, 70);
|
||||
rect(mx-10, 40, 20, 20);
|
||||
}
|
||||
</code>
|
||||
</example>
|
||||
|
||||
<description>
|
||||
Constrains a value to not exceed a maximum and minimum value.
|
||||
</description>
|
||||
|
||||
<syntax>
|
||||
constrain(<c>value</c>, <c>min</c>, <c>max</c>)
|
||||
</syntax>
|
||||
|
||||
<parameter>
|
||||
<label>value</label>
|
||||
<description>int or float: the value to constrain</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>min</label>
|
||||
<description>int or float: minimum limit</description>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<label>max</label>
|
||||
<description>int or float: maximum limit</description>
|
||||
</parameter>
|
||||
|
||||
<returns>float or int (depending on the input values)</returns>
|
||||
|
||||
<related>
|
||||
max()
|
||||
min()
|
||||
</related>
|
||||
|
||||
<availability>1.0</availability>
|
||||
|
||||
<type>Function</type>
|
||||
|
||||
<partof>PDE</partof>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user