mirror of
https://github.com/processing/processing4.git
synced 2026-06-09 09:03:17 +02:00
proper packaging of all processing.app classes
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
@@ -47,7 +49,7 @@ import processing.core.*;
|
||||
* files and images, etc) that comes from that.
|
||||
*/
|
||||
public class PdeBase {
|
||||
static final String VERSION = "0082 Alpha";
|
||||
static final String VERSION = "0083 Alpha";
|
||||
|
||||
/**
|
||||
* Path of filename opened on the command line,
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
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,
|
||||
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
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
@@ -31,7 +33,7 @@ public class PdeCode {
|
||||
int flavor;
|
||||
|
||||
String program;
|
||||
boolean modified;
|
||||
public boolean modified;
|
||||
//PdeHistory history; // TODO add history information
|
||||
|
||||
String preprocName; // name of .java file after preproc
|
||||
@@ -57,8 +59,8 @@ public class PdeCode {
|
||||
//program = null;
|
||||
/*
|
||||
} catch (IOException e) {
|
||||
PdeBase.showWarning("Error loading file",
|
||||
"Error while opening the file\n" +
|
||||
PdeBase.showWarning("Error loading file",
|
||||
"Error while opening the file\n" +
|
||||
file.getPath(), e);
|
||||
program = null; // just in case
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.app.syntax.*;
|
||||
import processing.app.tools.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
@@ -53,7 +58,7 @@ public class PdeEditor extends JFrame
|
||||
|
||||
// otherwise, if the window is resized with the message label
|
||||
// set to blank, it's preferredSize() will be fukered
|
||||
static final String EMPTY =
|
||||
static public final String EMPTY =
|
||||
" " +
|
||||
" " +
|
||||
" ";
|
||||
@@ -345,14 +350,14 @@ public class PdeEditor extends JFrame
|
||||
// disable line highlight and turn off the caret when disabling
|
||||
Color color = PdePreferences.getColor("editor.external.bgcolor");
|
||||
painter.setBackground(color);
|
||||
painter.lineHighlight = false;
|
||||
painter.setLineHighlightEnabled(false);
|
||||
textarea.setCaretVisible(false);
|
||||
|
||||
} else {
|
||||
Color color = PdePreferences.getColor("editor.bgcolor");
|
||||
painter.setBackground(color);
|
||||
painter.lineHighlight =
|
||||
PdePreferences.getBoolean("editor.linehighlight");
|
||||
boolean highlight = PdePreferences.getBoolean("editor.linehighlight");
|
||||
painter.setLineHighlightEnabled(highlight);
|
||||
textarea.setCaretVisible(true);
|
||||
}
|
||||
|
||||
@@ -585,7 +590,8 @@ public class PdeEditor extends JFrame
|
||||
item = new JMenuItem("Create Font...");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new PdeFontBuilder().show(sketch.dataFolder);
|
||||
//new CreateFont().show(sketch.dataFolder);
|
||||
new CreateFont(PdeEditor.this).show();
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@@ -593,9 +599,10 @@ public class PdeEditor extends JFrame
|
||||
item = new JMenuItem("Archive Sketch");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Archiver archiver = new Archiver();
|
||||
archiver.setup(PdeEditor.this);
|
||||
archiver.show();
|
||||
new Archiver(PdeEditor.this).show();
|
||||
//Archiver archiver = new Archiver();
|
||||
//archiver.setup(PdeEditor.this);
|
||||
//archiver.show();
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.font.*;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.app.syntax.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
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,
|
||||
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
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
public class PdeException extends Exception {
|
||||
public int file = -1;
|
||||
@@ -55,10 +56,10 @@ public class PdeException extends Exception {
|
||||
|
||||
|
||||
/**
|
||||
* Nix the java.lang crap out of an exception message
|
||||
* Nix the java.lang crap out of an exception message
|
||||
* because it scares the children.
|
||||
*
|
||||
* This function must be static to be used with super()
|
||||
* This function must be static to be used with super()
|
||||
* in each of the constructors above.
|
||||
*/
|
||||
static public final String massage(String msg) {
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
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,
|
||||
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
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
// Different instances of PdeMessageStream need to do different things with
|
||||
// messages. In particular, a stream instance used for parsing output from
|
||||
// the compiler compiler has to interpret its messages differently than one
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
|
||||
@@ -17,19 +17,21 @@
|
||||
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,
|
||||
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
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* this is used by PdeEditor, System.err is set to
|
||||
/**
|
||||
* this is used by PdeEditor, System.err is set to
|
||||
* new PrintStream(new PdeMessageStream())
|
||||
*
|
||||
* it's also used by PdeCompiler
|
||||
* it's also used by PdeCompiler
|
||||
*/
|
||||
class PdeMessageStream extends OutputStream {
|
||||
|
||||
@@ -50,7 +52,7 @@ class PdeMessageStream extends OutputStream {
|
||||
|
||||
public void flush() { }
|
||||
|
||||
public void write(byte b[]) {
|
||||
public void write(byte b[]) {
|
||||
// this never seems to get called
|
||||
System.out.println("leech1: " + new String(b));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.app.syntax.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.app.preproc.*;
|
||||
import processing.core.*;
|
||||
|
||||
import java.awt.FileDialog;
|
||||
@@ -54,13 +57,13 @@ public class PdeSketch {
|
||||
boolean library; // true if it's a library
|
||||
|
||||
public File folder; //sketchFolder;
|
||||
File dataFolder;
|
||||
File codeFolder;
|
||||
public File dataFolder;
|
||||
public File codeFolder;
|
||||
|
||||
static final int PDE = 0;
|
||||
static final int JAVA = 1;
|
||||
|
||||
PdeCode current;
|
||||
public PdeCode current;
|
||||
int codeCount;
|
||||
PdeCode code[];
|
||||
|
||||
@@ -1462,7 +1465,6 @@ public class PdeSketch {
|
||||
int wide = PApplet.DEFAULT_WIDTH;
|
||||
int high = PApplet.DEFAULT_HEIGHT;
|
||||
|
||||
//try {
|
||||
PatternMatcher matcher = new Perl5Matcher();
|
||||
PatternCompiler compiler = new Perl5Compiler();
|
||||
|
||||
@@ -1471,8 +1473,10 @@ public class PdeSketch {
|
||||
// this way, no warning is shown if size() isn't actually
|
||||
// used in the applet, which is the case especially for
|
||||
// beginners that are cutting/pasting from the reference.
|
||||
// modified for 83 to match size(XXX, ddd
|
||||
String sizing =
|
||||
"[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\S+)\\s*\\);";
|
||||
"[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\d+)";
|
||||
//"[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\S+)\\s*\\);";
|
||||
Pattern pattern = compiler.compile(sizing);
|
||||
|
||||
// adds a space at the beginning, in case size() is the very
|
||||
@@ -1498,25 +1502,10 @@ public class PdeSketch {
|
||||
}
|
||||
} // else no size() command found
|
||||
|
||||
/*
|
||||
// try to get / ** blah * / stuff
|
||||
// the plus gets / ***** and **** / if that's what they used
|
||||
matcher = new Perl5Matcher();
|
||||
compiler = new Perl5Compiler();
|
||||
String description = "";
|
||||
//pattern = compiler.compile("\\/\\*\\*+(.*)\\*\\/");
|
||||
pattern = compiler.compile("\\/\\*\\*+(.+)");
|
||||
//pattern = compiler.compile("\\/\\*\\*+(.*)\\*+\\/");
|
||||
System.out.println("this compiled");
|
||||
input = new PatternMatcherInput(" " + code[0].program);
|
||||
if (matcher.contains(input, pattern)) {
|
||||
MatchResult result = matcher.getMatch();
|
||||
System.out.println("contains " + result.group(0));
|
||||
String stuff = result.group(1).toString();
|
||||
String lines[] = PApplet.split(stuff, '\n');
|
||||
PApplet.printarr(lines);
|
||||
}
|
||||
*/
|
||||
// originally tried to grab this with a regexp matcher,
|
||||
// but it wouldn't span over multiple lines for the match.
|
||||
// this could prolly be forced, but since that's the case
|
||||
// better just to parse by hand.
|
||||
StringBuffer dbuffer = new StringBuffer();
|
||||
String lines[] = PApplet.split(code[0].program, '\n');
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package processing.app;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
@@ -5,7 +7,7 @@ import javax.swing.SwingUtilities;
|
||||
* SwingWorker 3), an abstract class that you subclass to
|
||||
* perform GUI-related work in a dedicated thread. For
|
||||
* instructions on and examples of using this class, see:
|
||||
*
|
||||
*
|
||||
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
||||
*
|
||||
* Note that the API changed slightly in the 3rd version:
|
||||
@@ -15,7 +17,7 @@ import javax.swing.SwingUtilities;
|
||||
public abstract class SwingWorker {
|
||||
private Object value; // see getValue(), setValue()
|
||||
|
||||
/**
|
||||
/**
|
||||
* Class to maintain reference to current worker thread
|
||||
* under separate synchronization control.
|
||||
*/
|
||||
@@ -28,23 +30,23 @@ public abstract class SwingWorker {
|
||||
|
||||
private ThreadVar threadVar;
|
||||
|
||||
/**
|
||||
* Get the value produced by the worker thread, or null if it
|
||||
/**
|
||||
* Get the value produced by the worker thread, or null if it
|
||||
* hasn't been constructed yet.
|
||||
*/
|
||||
protected synchronized Object getValue() {
|
||||
return value;
|
||||
protected synchronized Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value produced by worker thread
|
||||
/**
|
||||
* Set the value produced by worker thread
|
||||
*/
|
||||
private synchronized void setValue(Object x) {
|
||||
value = x;
|
||||
private synchronized void setValue(Object x) {
|
||||
value = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the value to be returned by the <code>get</code> method.
|
||||
/**
|
||||
* Compute the value to be returned by the <code>get</code> method.
|
||||
*/
|
||||
public abstract Object construct();
|
||||
|
||||
@@ -68,14 +70,14 @@ public abstract class SwingWorker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value created by the <code>construct</code> method.
|
||||
* Return the value created by the <code>construct</code> method.
|
||||
* Returns null if either the constructing thread or the current
|
||||
* thread was interrupted before a value was produced.
|
||||
*
|
||||
*
|
||||
* @return the value created by the <code>construct</code> method
|
||||
*/
|
||||
public Object get() {
|
||||
while (true) {
|
||||
while (true) {
|
||||
Thread t = threadVar.get();
|
||||
if (t == null) {
|
||||
return getValue();
|
||||
@@ -100,7 +102,7 @@ public abstract class SwingWorker {
|
||||
public void run() { finished(); }
|
||||
};
|
||||
|
||||
Runnable doConstruct = new Runnable() {
|
||||
Runnable doConstruct = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
setValue(construct());
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
Archiver - plugin tool for archiving sketches
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Except where noted, code is written by Ben Fry and
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
Copyright (c) 2004-05 Ben Fry and Casey Reas
|
||||
|
||||
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
|
||||
@@ -17,12 +16,14 @@
|
||||
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,
|
||||
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
|
||||
*/
|
||||
|
||||
//package processing.app.tools; // for 0071+
|
||||
package processing.app.tools;
|
||||
|
||||
import processing.app.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
@@ -41,7 +42,7 @@ public class Archiver {
|
||||
SimpleDateFormat dateFormat;
|
||||
|
||||
|
||||
public void setup(PdeEditor editor) {
|
||||
public Archiver(PdeEditor editor) {
|
||||
this.editor = editor;
|
||||
|
||||
numberFormat = NumberFormat.getInstance();
|
||||
@@ -65,15 +66,15 @@ public class Archiver {
|
||||
int index = 0;
|
||||
do {
|
||||
if (useDate) {
|
||||
String purty = dateFormat.format(new Date());
|
||||
String stamp = purty + ((char) ('a' + index));
|
||||
namely = name + "-" + stamp;
|
||||
newbie = new File(parent, namely + ".zip");
|
||||
String purty = dateFormat.format(new Date());
|
||||
String stamp = purty + ((char) ('a' + index));
|
||||
namely = name + "-" + stamp;
|
||||
newbie = new File(parent, namely + ".zip");
|
||||
|
||||
} else {
|
||||
String diggie = numberFormat.format(index + 1);
|
||||
namely = name + "-" + diggie;
|
||||
newbie = new File(parent, namely + ".zip");
|
||||
String diggie = numberFormat.format(index + 1);
|
||||
namely = name + "-" + diggie;
|
||||
newbie = new File(parent, namely + ".zip");
|
||||
}
|
||||
index++;
|
||||
} while (newbie.exists());
|
||||
@@ -98,31 +99,31 @@ public class Archiver {
|
||||
}
|
||||
|
||||
|
||||
public void buildZip(File dir, String sofar,
|
||||
ZipOutputStream zos) throws IOException {
|
||||
public void buildZip(File dir, String sofar,
|
||||
ZipOutputStream zos) throws IOException {
|
||||
String files[] = dir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") ||
|
||||
files[i].equals("..")) continue;
|
||||
if (files[i].equals(".") ||
|
||||
files[i].equals("..")) continue;
|
||||
|
||||
File sub = new File(dir, files[i]);
|
||||
String nowfar = (sofar == null) ?
|
||||
String nowfar = (sofar == null) ?
|
||||
files[i] : (sofar + "/" + files[i]);
|
||||
|
||||
if (sub.isDirectory()) {
|
||||
// directories are empty entries and have / at the end
|
||||
ZipEntry entry = new ZipEntry(nowfar + "/");
|
||||
//System.out.println(entry);
|
||||
zos.putNextEntry(entry);
|
||||
zos.closeEntry();
|
||||
buildZip(sub, nowfar, zos);
|
||||
// directories are empty entries and have / at the end
|
||||
ZipEntry entry = new ZipEntry(nowfar + "/");
|
||||
//System.out.println(entry);
|
||||
zos.putNextEntry(entry);
|
||||
zos.closeEntry();
|
||||
buildZip(sub, nowfar, zos);
|
||||
|
||||
} else {
|
||||
ZipEntry entry = new ZipEntry(nowfar);
|
||||
entry.setTime(sub.lastModified());
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(PdeBase.grabFile(sub));
|
||||
zos.closeEntry();
|
||||
ZipEntry entry = new ZipEntry(nowfar);
|
||||
entry.setTime(sub.lastModified());
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(PdeBase.grabFile(sub));
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user